Skip to content

Commit b359866

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 54524e1 commit b359866

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 {
@@ -442,9 +441,6 @@ class CppCompiler(
442441
outSrc.puts("}")
443442
}
444443

445-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
446-
outSrc.puts(s"${privateMemberName(attrName)} = $normalIO->ensure_fixed_contents($contents);")
447-
448444
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
449445
val srcExpr = getRawIdExpr(varSrc, rep)
450446

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

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

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

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, importList)
@@ -189,11 +188,6 @@ class JavaScriptCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
189188
out.puts("}")
190189
}
191190

192-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit = {
193-
out.puts(s"${privateMemberName(attrName)} = " +
194-
s"$normalIO.ensureFixedContents($contents);")
195-
}
196-
197191
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
198192
val srcExpr = getRawIdExpr(varSrc, rep)
199193

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
@@ -154,9 +153,6 @@ class LuaCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
154153
out.puts("end")
155154
}
156155

157-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
158-
out.puts(s"${privateMemberName(attrName)} = self._io:ensure_fixed_contents($contents)")
159-
160156
override def condIfHeader(expr: Ast.expr): Unit = {
161157
out.puts(s"if ${expression(expr)} then")
162158
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
@@ -83,10 +82,6 @@ class NimCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
8382

8483
// Members declared in io.kaitai.struct.languages.components.LanguageCompiler
8584
override def alignToByte(io: String): Unit = out.puts(s"alignToByte($io)")
86-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit = {
87-
out.puts(s"this.${idToStr(attrName)} = $normalIO.ensureFixedContents($contents)")
88-
}
89-
// def attrParse(attr: AttrLikeSpec, id: Identifier, defEndian: Option[Endianness]): Unit = ???
9085
override def attrParseHybrid(leProc: () => Unit, beProc: () => Unit): Unit = {
9186
out.puts("if this.isLe:")
9287
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._
@@ -203,9 +202,6 @@ class PHPCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
203202
out.puts("}")
204203
}
205204

206-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
207-
out.puts(s"${privateMemberName(attrName)} = $normalIO->ensureFixedContents($contents);")
208-
209205
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
210206
val srcExpr = getRawIdExpr(varSrc, rep)
211207

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

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

@@ -170,10 +169,6 @@ class PerlCompiler(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->ensure_fixed_contents($contents);")
175-
}
176-
177172
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
178173
val srcExpr = getRawIdExpr(varSrc, rep)
179174

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 {
@@ -175,9 +174,6 @@ class PythonCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
175174
out.putsLines("", "\"\"\"" + docStr + refStr + "\"\"\"")
176175
}
177176

178-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
179-
out.puts(s"${privateMemberName(attrName)} = self._io.ensure_fixed_contents($contents)")
180-
181177
override def attrParseHybrid(leProc: () => Unit, beProc: () => Unit): Unit = {
182178
out.puts("if self._is_le:")
183179
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._
@@ -202,9 +201,6 @@ class RubyCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
202201
out.puts("end")
203202
}
204203

205-
override def attrFixedContentsParse(attrName: Identifier, contents: String): Unit =
206-
out.puts(s"${privateMemberName(attrName)} = $normalIO.ensure_fixed_contents($contents)")
207-
208204
override def attrProcess(proc: ProcessExpr, varSrc: Identifier, varDest: Identifier, rep: RepeatSpec): Unit = {
209205
val srcExpr = getRawIdExpr(varSrc, rep)
210206

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)