Skip to content

Commit 7ac0461

Browse files
committed
Remove unused parameters from condRepeatExprHeader and document condRepeatExprHeader and condRepeatExprFooter
1 parent 7e0dfc2 commit 7ac0461

File tree

14 files changed

+36
-30
lines changed

14 files changed

+36
-30
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ class CSharpCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
300300
out.puts("}")
301301
}
302302

303-
override def condRepeatExprHeader(id: Identifier, io: String, dataType: DataType, repeatExpr: expr): Unit = {
304-
out.puts(s"for (var i = 0, _end = ${expression(repeatExpr)}; i < _end; ++i)")
303+
override def condRepeatExprHeader(countExpr: expr): Unit = {
304+
out.puts(s"for (var i = 0, _end = ${expression(countExpr)}; i < _end; ++i)")
305305
out.puts("{")
306306
out.inc
307307
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,8 @@ class CppCompiler(
591591
outSrc.puts("}")
592592
}
593593

594-
override def condRepeatExprHeader(id: Identifier, io: String, dataType: DataType, repeatExpr: Ast.expr): Unit = {
595-
outSrc.puts(s"for (int i = 0, _end = ${expression(repeatExpr)}; i < _end; ++i) {")
594+
override def condRepeatExprHeader(countExpr: Ast.expr): Unit = {
595+
outSrc.puts(s"for (int i = 0, _end = ${expression(countExpr)}; i < _end; ++i) {")
596596
outSrc.inc
597597
}
598598

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ class GoCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
320320
out.puts(s"$name = append($name, $expr)")
321321
}
322322

323-
override def condRepeatExprHeader(id: Identifier, io: String, dataType: DataType, repeatExpr: Ast.expr): Unit = {
324-
out.puts(s"for i, _end := 0, int(${expression(repeatExpr)}); i < _end; i++ {")
323+
override def condRepeatExprHeader(countExpr: Ast.expr): Unit = {
324+
out.puts(s"for i, _end := 0, int(${expression(countExpr)}); i < _end; i++ {")
325325
out.inc
326326
// FIXME: Go throws a fatal compile error when the `i` variable is not used (unused variables
327327
// can only use the blank identifier `_`, see https://go.dev/doc/effective_go#blank), so we have

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ class JavaCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
377377
out.puts("}")
378378
}
379379

380-
override def condRepeatExprHeader(id: Identifier, io: String, dataType: DataType, repeatExpr: expr): Unit = {
381-
out.puts(s"for (int i = 0, _end = ${expression(repeatExpr)}; i < _end; ++i) {")
380+
override def condRepeatExprHeader(countExpr: expr): Unit = {
381+
out.puts(s"for (int i = 0, _end = ${expression(countExpr)}; i < _end; ++i) {")
382382
out.inc
383383

384384
importList.add("java.util.ArrayList")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ class JavaScriptCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
319319
out.puts("}")
320320
}
321321

322-
override def condRepeatExprHeader(id: Identifier, io: String, dataType: DataType, repeatExpr: expr): Unit = {
323-
out.puts(s"for (var i = 0, _end = ${expression(repeatExpr)}; i < _end; ++i) {")
322+
override def condRepeatExprHeader(countExpr: expr): Unit = {
323+
out.puts(s"for (var i = 0, _end = ${expression(countExpr)}; i < _end; ++i) {")
324324
out.inc
325325
}
326326

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ class LuaCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
181181
out.puts("end")
182182
}
183183

184-
override def condRepeatExprHeader(id: Identifier, io: String, dataType: DataType, repeatExpr: Ast.expr): Unit = {
185-
out.puts(s"for i = 0, ${expression(repeatExpr)} - 1 do")
184+
override def condRepeatExprHeader(countExpr: Ast.expr): Unit = {
185+
out.puts(s"for i = 0, ${expression(countExpr)} - 1 do")
186186
out.inc
187187
}
188188
override def condRepeatExprFooter: Unit = {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ class NimCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
167167
out.dec
168168
out.dec
169169
}
170-
override def condRepeatExprHeader(id: Identifier, io: String, dataType: DataType, repeatExpr: Ast.expr): Unit = {
171-
out.puts(s"for i in 0 ..< int(${expression(repeatExpr)}):")
170+
override def condRepeatExprHeader(countExpr: Ast.expr): Unit = {
171+
out.puts(s"for i in 0 ..< int(${expression(countExpr)}):")
172172
out.inc
173173
}
174174
override def condRepeatUntilHeader(itemType: DataType): Unit = {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ class PHPCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
297297
super.condRepeatEosFooter
298298
}
299299

300-
override def condRepeatExprHeader(id: Identifier, io: String, dataType: DataType, repeatExpr: Ast.expr): Unit = {
301-
out.puts(s"$$n = ${expression(repeatExpr)};")
300+
override def condRepeatExprHeader(countExpr: Ast.expr): Unit = {
301+
out.puts(s"$$n = ${expression(countExpr)};")
302302
out.puts("for ($i = 0; $i < $n; $i++) {")
303303
out.inc
304304
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ class PerlCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
254254
override def handleAssignmentRepeatEos(id: Identifier, expr: String): Unit =
255255
out.puts(s"push @{${privateMemberName(id)}}, $expr;")
256256

257-
override def condRepeatExprHeader(id: Identifier, io: String, dataType: DataType, repeatExpr: expr): Unit = {
258-
out.puts(s"for (my $$i = 0, $$_end = ${expression(repeatExpr)}; $$i < $$_end; ++$$i) {")
257+
override def condRepeatExprHeader(countExpr: expr): Unit = {
258+
out.puts(s"for (my $$i = 0, $$_end = ${expression(countExpr)}; $$i < $$_end; ++$$i) {")
259259
out.inc
260260
}
261261

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ class PythonCompiler(typeProvider: ClassTypeProvider, config: RuntimeConfig)
313313
universalFooter
314314
}
315315

316-
override def condRepeatExprHeader(id: Identifier, io: String, dataType: DataType, repeatExpr: expr): Unit = {
317-
out.puts(s"for i in range(${expression(repeatExpr)}):")
316+
override def condRepeatExprHeader(countExpr: expr): Unit = {
317+
out.puts(s"for i in range(${expression(countExpr)}):")
318318
out.inc
319319
}
320320
override def handleAssignmentRepeatExpr(id: Identifier, expr: String): Unit =

0 commit comments

Comments
 (0)