Skip to content

Commit 1a45283

Browse files
committed
Delete unused FixedContentsUsingArrayByteLiteral trait
Its usage was removed in 3fcc700 Need to delete method `ensureFixedContents` from runtime libraries as no longer used
1 parent 15959f0 commit 1a45283

14 files changed

+1
-93
lines changed

shared/src/main/scala/io/kaitai/struct/languages/CSharpCompiler.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class CSharpCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
1717
with AllocateIOLocalVar
1818
with EveryReadIsExpression
1919
with UniversalDoc
20-
with FixedContentsUsingArrayByteLiteral
2120
with SwitchIfOps
2221
with NoNeedForFullClassPath {
2322
import CSharpCompiler._
@@ -193,9 +192,6 @@ class CSharpCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
193192
out.puts("}")
194193
}
195194

196-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
197-
out.puts(s"${privateMemberName(attrName)} = $normalIO.EnsureFixedContents($contents);")
198-
199195
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
200196
val srcExpr = getRawIdExpr(varSrc, rep)
201197

shared/src/main/scala/io/kaitai/struct/languages/CppCompiler.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class CppCompiler(
1616
) extends LanguageCompiler(typeProvider, config)
1717
with ObjectOrientedLanguage
1818
with AllocateAndStoreIO
19-
with FixedContentsUsingArrayByteLiteral
2019
with UniversalDoc
2120
with SwitchIfOps
2221
with EveryReadIsExpression {
@@ -452,9 +451,6 @@ class CppCompiler(
452451
outSrc.puts("}")
453452
}
454453

455-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
456-
outSrc.puts(s"${privateMemberName(attrName)} = $normalIO->ensure_fixed_contents($contents);")
457-
458454
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
459455
val srcExpr = getRawIdExpr(varSrc, rep)
460456

shared/src/main/scala/io/kaitai/struct/languages/GoCompiler.scala

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -190,25 +190,6 @@ class GoCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
190190
out.puts("}")
191191
}
192192

193-
override def attrFixedContentsParse(attrName: Identifier, contents: Array[Byte]): Unit = {
194-
out.puts(s"${privateMemberName(attrName)}, err = $normalIO.ReadBytes(${contents.length})")
195-
196-
out.puts(s"if err != nil {")
197-
out.inc
198-
out.puts("return err")
199-
out.dec
200-
out.puts("}")
201-
202-
importList.add("bytes")
203-
importList.add("errors")
204-
val expected = translator.resToStr(translator.doByteArrayLiteral(contents))
205-
out.puts(s"if !bytes.Equal(${privateMemberName(attrName)}, $expected) {")
206-
out.inc
207-
out.puts("return errors.New(\"Unexpected fixed contents\")")
208-
out.dec
209-
out.puts("}")
210-
}
211-
212193
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
213194
val srcExpr = getRawIdExpr(varSrc, rep)
214195

shared/src/main/scala/io/kaitai/struct/languages/JavaCompiler.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class JavaCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
1818
with UniversalFooter
1919
with UniversalDoc
2020
with AllocateIOLocalVar
21-
with FixedContentsUsingArrayByteLiteral
2221
with SwitchIfOps
2322
with NoNeedForFullClassPath {
2423
import JavaCompiler._
@@ -233,10 +232,6 @@ class JavaCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
233232
out.puts("}")
234233
}
235234

236-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit = {
237-
out.puts(s"${privateMemberName(attrName)} = $normalIO.ensureFixedContents($contents);")
238-
}
239-
240235
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
241236
val srcExpr = getRawIdExpr(varSrc, rep)
242237

shared/src/main/scala/io/kaitai/struct/languages/JavaScriptCompiler.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ class JavaScriptCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
1717
with UniversalDoc
1818
with AllocateIOLocalVar
1919
with EveryReadIsExpression
20-
with SwitchIfOps
21-
with FixedContentsUsingArrayByteLiteral {
20+
with SwitchIfOps {
2221
import JavaScriptCompiler._
2322

2423
override val translator = new JavaScriptTranslator(typeProvider)
@@ -185,11 +184,6 @@ class JavaScriptCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
185184
out.puts("}")
186185
}
187186

188-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit = {
189-
out.puts(s"${privateMemberName(attrName)} = " +
190-
s"$normalIO.ensureFixedContents($contents);")
191-
}
192-
193187
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
194188
val srcExpr = getRawIdExpr(varSrc, rep)
195189

shared/src/main/scala/io/kaitai/struct/languages/LuaCompiler.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class LuaCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
1212
extends LanguageCompiler(typeProvider, config)
1313
with AllocateIOLocalVar
1414
with EveryReadIsExpression
15-
with FixedContentsUsingArrayByteLiteral
1615
with ObjectOrientedLanguage
1716
with SingleOutputFile
1817
with UniversalDoc
@@ -150,9 +149,6 @@ class LuaCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
150149
out.puts("end")
151150
}
152151

153-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
154-
out.puts(s"${privateMemberName(attrName)} = self._io:ensure_fixed_contents($contents)")
155-
156152
override def condIfHeader(expr: Ast.expr): Unit = {
157153
out.puts(s"if ${expression(expr)} then")
158154
out.inc

shared/src/main/scala/io/kaitai/struct/languages/NimCompiler.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class NimCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
1313
with SingleOutputFile
1414
with EveryReadIsExpression
1515
with UpperCamelCaseClasses
16-
with FixedContentsUsingArrayByteLiteral
1716
with UniversalFooter
1817
with AllocateIOLocalVar
1918
with SwitchIfOps
@@ -86,10 +85,6 @@ class NimCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
8685
importList.add(file)
8786
}
8887
override def alignToByte(io: String): Unit = out.puts(s"alignToByte($io)")
89-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit = {
90-
out.puts(s"this.${idToStr(attrName)} = $normalIO.ensureFixedContents($contents)")
91-
}
92-
// def attrParse(attr: AttrLikeSpec, id: Identifier, defEndian: Option[Endianness]): Unit = ???
9388
override def attrParseHybrid(leProc: () => Unit, beProc: () => Unit): Unit = {
9489
out.puts("if this.isLe:")
9590
out.inc

shared/src/main/scala/io/kaitai/struct/languages/PHPCompiler.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class PHPCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
1616
with AllocateIOLocalVar
1717
with UniversalFooter
1818
with UniversalDoc
19-
with FixedContentsUsingArrayByteLiteral
2019
with EveryReadIsExpression {
2120

2221
import PHPCompiler._
@@ -191,9 +190,6 @@ class PHPCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
191190
out.puts("}")
192191
}
193192

194-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
195-
out.puts(s"${privateMemberName(attrName)} = $normalIO->ensureFixedContents($contents);")
196-
197193
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
198194
val srcExpr = getRawIdExpr(varSrc, rep)
199195

shared/src/main/scala/io/kaitai/struct/languages/PerlCompiler.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class PerlCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
1515
with UniversalFooter
1616
with UpperCamelCaseClasses
1717
with AllocateIOLocalVar
18-
with FixedContentsUsingArrayByteLiteral
1918
with SwitchIfOps
2019
with EveryReadIsExpression {
2120

@@ -163,10 +162,6 @@ class PerlCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
163162
out.puts("}")
164163
}
165164

166-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit = {
167-
out.puts(s"${privateMemberName(attrName)} = $normalIO->ensure_fixed_contents($contents);")
168-
}
169-
170165
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
171166
val srcExpr = getRawIdExpr(varSrc, rep)
172167

shared/src/main/scala/io/kaitai/struct/languages/PythonCompiler.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class PythonCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
1717
with UniversalFooter
1818
with EveryReadIsExpression
1919
with AllocateIOLocalVar
20-
with FixedContentsUsingArrayByteLiteral
2120
with UniversalDoc
2221
with SwitchIfOps
2322
with NoNeedForFullClassPath {
@@ -179,9 +178,6 @@ class PythonCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
179178
out.putsLines("", "\"\"\"" + docStr + refStr + "\"\"\"")
180179
}
181180

182-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
183-
out.puts(s"${privateMemberName(attrName)} = self._io.ensure_fixed_contents($contents)")
184-
185181
override def attrParseHybrid(leProc: () => Unit, beProc: () => Unit): Unit = {
186182
out.puts("if self._is_le:")
187183
out.inc

shared/src/main/scala/io/kaitai/struct/languages/RubyCompiler.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class RubyCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
1818
with UpperCamelCaseClasses
1919
with AllocateIOLocalVar
2020
with EveryReadIsExpression
21-
with FixedContentsUsingArrayByteLiteral
2221
with NoNeedForFullClassPath {
2322

2423
import RubyCompiler._
@@ -174,9 +173,6 @@ class RubyCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
174173
out.puts("end")
175174
}
176175

177-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
178-
out.puts(s"${privateMemberName(attrName)} = $normalIO.ensure_fixed_contents($contents)")
179-
180176
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
181177
val srcExpr = getRawIdExpr(varSrc, rep)
182178

shared/src/main/scala/io/kaitai/struct/languages/RustCompiler.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class RustCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
1616
with AllocateIOLocalVar
1717
with UniversalFooter
1818
with UniversalDoc
19-
with FixedContentsUsingArrayByteLiteral
2019
with EveryReadIsExpression {
2120

2221
import RustCompiler._
@@ -170,9 +169,6 @@ class RustCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
170169
out.puts("}")
171170
}
172171

173-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
174-
out.puts(s"${privateMemberName(attrName)} = $normalIO.ensureFixedContents($contents);")
175-
176172
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
177173
val srcExpr = getRawIdExpr(varSrc, rep)
178174

shared/src/main/scala/io/kaitai/struct/languages/components/FixedContentsUsingArrayByteLiteral.scala

Lines changed: 0 additions & 21 deletions
This file was deleted.

shared/src/main/scala/io/kaitai/struct/languages/components/LanguageCompiler.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ abstract class LanguageCompiler(
123123
def attrInit(attr: AttrLikeSpec): Unit = {}
124124
def attrDestructor(attr: AttrLikeSpec, id: Identifier): Unit = {}
125125

126-
// TODO: delete
127-
def attrFixedContentsParse(attrName: Identifier, contents: Array[Byte]): Unit
128-
129126
def condIfSetNull(instName: Identifier): Unit = {}
130127
def condIfSetNonNull(instName: Identifier): Unit = {}
131128
def condIfHeader(expr: Ast.expr): Unit

0 commit comments

Comments
 (0)