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

First working C implementation #253

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ project/boot/
# Unpacking complete binaries for testing purposes
/runnable
js/npm
output/kaitai-struct-compiler-0.10-SNAPSHOT/lib
.bsp
20 changes: 20 additions & 0 deletions shared/src/main/scala/io/kaitai/struct/CClassCompiler.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.kaitai.struct

import scala.collection.mutable.ListBuffer
import io.kaitai.struct.datatype.DataType.{CalcIntType, KaitaiStreamType, UserTypeInstream}
import io.kaitai.struct.datatype.{BigEndian, CalcEndian, Endianness, FixedEndian, InheritedEndian, LittleEndian}
import io.kaitai.struct.exprlang.Ast
import io.kaitai.struct.exprlang.Ast.expr
import io.kaitai.struct.exprlang.Ast.identifier
import io.kaitai.struct.exprlang.Ast.expr.{BoolOp, BinOp, UnaryOp, IfExp, Compare, Call, Attribute, CastToType, Subscript, Name}
import io.kaitai.struct.format._
import io.kaitai.struct.languages.CCompiler
import io.kaitai.struct.languages.components.ExtraAttrs

class CClassCompiler(
classSpecs: ClassSpecs,
override val topClass: ClassSpec,
config: RuntimeConfig
) extends ClassCompiler(classSpecs, topClass, config, CCompiler) {

}
4 changes: 3 additions & 1 deletion shared/src/main/scala/io/kaitai/struct/Main.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.kaitai.struct

import io.kaitai.struct.format.{ClassSpec, ClassSpecs, GenericStructClassSpec, MetaSpec}
import io.kaitai.struct.languages.{GoCompiler, NimCompiler, RustCompiler}
import io.kaitai.struct.languages.{CCompiler, GoCompiler, NimCompiler, RustCompiler}
import io.kaitai.struct.languages.components.LanguageCompilerStatic
import io.kaitai.struct.precompile._
import io.kaitai.struct.problems.CompilationProblem
Expand Down Expand Up @@ -92,6 +92,8 @@ object Main {
val config = updateConfigFromMeta(conf, spec.meta)

val cc = lang match {
case CCompiler =>
new CClassCompiler(specs, spec, conf)
case GraphvizClassCompiler =>
new GraphvizClassCompiler(specs, spec)
case GoCompiler =>
Expand Down
Loading