Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete unused FixedContentsUsingArrayByteLiteral trait #293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class CSharpCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
with AllocateIOLocalVar
with EveryReadIsExpression
with UniversalDoc
with FixedContentsUsingArrayByteLiteral
with SwitchIfOps
with NoNeedForFullClassPath {
import CSharpCompiler._
Expand Down Expand Up @@ -193,9 +192,6 @@ class CSharpCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.puts("}")
}

override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
out.puts(s"${privateMemberName(attrName)} = $normalIO.EnsureFixedContents($contents);")

override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
val srcExpr = getRawIdExpr(varSrc, rep)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class CppCompiler(
) extends LanguageCompiler(typeProvider, config)
with ObjectOrientedLanguage
with AllocateAndStoreIO
with FixedContentsUsingArrayByteLiteral
with UniversalDoc
with SwitchIfOps
with EveryReadIsExpression {
Expand Down Expand Up @@ -442,9 +441,6 @@ class CppCompiler(
outSrc.puts("}")
}

override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
outSrc.puts(s"${privateMemberName(attrName)} = $normalIO->ensure_fixed_contents($contents);")

override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
val srcExpr = getRawIdExpr(varSrc, rep)

Expand Down
19 changes: 0 additions & 19 deletions shared/src/main/scala/io/kaitai/struct/languages/GoCompiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -192,25 +192,6 @@ class GoCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.puts("}")
}

override def attrFixedContentsParse(attrName: Identifier, contents: Array[Byte]): Unit = {
out.puts(s"${privateMemberName(attrName)}, err = $normalIO.ReadBytes(${contents.length})")

out.puts(s"if err != nil {")
out.inc
out.puts("return err")
out.dec
out.puts("}")

importList.add("bytes")
importList.add("errors")
val expected = translator.resToStr(translator.doByteArrayLiteral(contents))
out.puts(s"if !bytes.Equal(${privateMemberName(attrName)}, $expected) {")
out.inc
out.puts("return errors.New(\"Unexpected fixed contents\")")
out.dec
out.puts("}")
}

override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
val srcExpr = getRawIdExpr(varSrc, rep)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class JavaCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
with UniversalFooter
with UniversalDoc
with AllocateIOLocalVar
with FixedContentsUsingArrayByteLiteral
with SwitchIfOps
with NoNeedForFullClassPath {
import JavaCompiler._
Expand Down Expand Up @@ -233,10 +232,6 @@ class JavaCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.puts("}")
}

override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit = {
out.puts(s"${privateMemberName(attrName)} = $normalIO.ensureFixedContents($contents);")
}

override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
val srcExpr = getRawIdExpr(varSrc, rep)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class JavaScriptCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
with UniversalDoc
with AllocateIOLocalVar
with EveryReadIsExpression
with SwitchIfOps
with FixedContentsUsingArrayByteLiteral {
with SwitchIfOps {
import JavaScriptCompiler._

override val translator = new JavaScriptTranslator(typeProvider, importList)
Expand Down Expand Up @@ -189,11 +188,6 @@ class JavaScriptCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.puts("}")
}

override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit = {
out.puts(s"${privateMemberName(attrName)} = " +
s"$normalIO.ensureFixedContents($contents);")
}

override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
val srcExpr = getRawIdExpr(varSrc, rep)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class LuaCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
extends LanguageCompiler(typeProvider, config)
with AllocateIOLocalVar
with EveryReadIsExpression
with FixedContentsUsingArrayByteLiteral
with ObjectOrientedLanguage
with SingleOutputFile
with UniversalDoc
Expand Down Expand Up @@ -154,9 +153,6 @@ class LuaCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.puts("end")
}

override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
out.puts(s"${privateMemberName(attrName)} = self._io:ensure_fixed_contents($contents)")

override def condIfHeader(expr: Ast.expr): Unit = {
out.puts(s"if ${expression(expr)} then")
out.inc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class NimCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
with SingleOutputFile
with EveryReadIsExpression
with UpperCamelCaseClasses
with FixedContentsUsingArrayByteLiteral
with UniversalFooter
with AllocateIOLocalVar
with SwitchIfOps
Expand Down Expand Up @@ -83,10 +82,6 @@ class NimCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)

// Members declared in io.kaitai.struct.languages.components.LanguageCompiler
override def alignToByte(io: String): Unit = out.puts(s"alignToByte($io)")
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit = {
out.puts(s"this.${idToStr(attrName)} = $normalIO.ensureFixedContents($contents)")
}
// def attrParse(attr: AttrLikeSpec, id: Identifier, defEndian: Option[Endianness]): Unit = ???
override def attrParseHybrid(leProc: () => Unit, beProc: () => Unit): Unit = {
out.puts("if this.isLe:")
out.inc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class PHPCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
with AllocateIOLocalVar
with UniversalFooter
with UniversalDoc
with FixedContentsUsingArrayByteLiteral
with EveryReadIsExpression {

import PHPCompiler._
Expand Down Expand Up @@ -203,9 +202,6 @@ class PHPCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.puts("}")
}

override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
out.puts(s"${privateMemberName(attrName)} = $normalIO->ensureFixedContents($contents);")

override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
val srcExpr = getRawIdExpr(varSrc, rep)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class PerlCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
with UniversalFooter
with UpperCamelCaseClasses
with AllocateIOLocalVar
with FixedContentsUsingArrayByteLiteral
with SwitchIfOps
with EveryReadIsExpression {

Expand Down Expand Up @@ -170,10 +169,6 @@ class PerlCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.puts("}")
}

override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit = {
out.puts(s"${privateMemberName(attrName)} = $normalIO->ensure_fixed_contents($contents);")
}

override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
val srcExpr = getRawIdExpr(varSrc, rep)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class PythonCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
with UniversalFooter
with EveryReadIsExpression
with AllocateIOLocalVar
with FixedContentsUsingArrayByteLiteral
with UniversalDoc
with SwitchIfOps
with NoNeedForFullClassPath {
Expand Down Expand Up @@ -175,9 +174,6 @@ class PythonCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.putsLines("", "\"\"\"" + docStr + refStr + "\"\"\"")
}

override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
out.puts(s"${privateMemberName(attrName)} = self._io.ensure_fixed_contents($contents)")

override def attrParseHybrid(leProc: () => Unit, beProc: () => Unit): Unit = {
out.puts("if self._is_le:")
out.inc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class RubyCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
with UpperCamelCaseClasses
with AllocateIOLocalVar
with EveryReadIsExpression
with FixedContentsUsingArrayByteLiteral
with NoNeedForFullClassPath {

import RubyCompiler._
Expand Down Expand Up @@ -202,9 +201,6 @@ class RubyCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
out.puts("end")
}

override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
out.puts(s"${privateMemberName(attrName)} = $normalIO.ensure_fixed_contents($contents)")

override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
val srcExpr = getRawIdExpr(varSrc, rep)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class RustCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
extends LanguageCompiler(typeProvider, config)
with AllocateIOLocalVar
with EveryReadIsExpression
with FixedContentsUsingArrayByteLiteral
with ObjectOrientedLanguage
with SingleOutputFile
with UpperCamelCaseClasses
Expand Down Expand Up @@ -846,10 +845,6 @@ class RustCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
expr2
}

override def attrFixedContentsParse(attrName: Identifier,
contents: String): Unit =
out.puts(s"// attrFixedContentsParse($attrName, $contents)")

override def publicMemberName(id: Identifier): String =
s"// publicMemberName($id)"

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ abstract class LanguageCompiler(
def attrInit(attr: AttrLikeSpec): Unit = {}
def attrDestructor(attr: AttrLikeSpec, id: Identifier): Unit = {}

// TODO: delete
def attrFixedContentsParse(attrName: Identifier, contents: Array[Byte]): Unit

def condIfSetNull(instName: Identifier): Unit = {}
def condIfSetNonNull(instName: Identifier): Unit = {}
def condIfHeader(expr: Ast.expr): Unit
Expand Down
Loading