From fadee549e2cb8d0e4cd2e67188d10266d518b5c9 Mon Sep 17 00:00:00 2001 From: Mingun Date: Tue, 26 Oct 2021 22:39:38 +0500 Subject: [PATCH] Update KaitaiStruct compiler and runtime to 0.9 --- pom.xml | 6 +++--- .../struct/visualizer/VisualizerPanel.java | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index f9b056b..f7d5e1d 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ groupId kaitai_struct_visualizer_java jar - 0.8-SNAPSHOT + 0.10-SNAPSHOT http://kaitai.io @@ -32,12 +32,12 @@ io.kaitai kaitai-struct-runtime - 0.8 + 0.9 io.kaitai kaitai-struct-compiler_2.12 - 0.8 + 0.9 com.github.Mingun diff --git a/src/main/java/io/kaitai/struct/visualizer/VisualizerPanel.java b/src/main/java/io/kaitai/struct/visualizer/VisualizerPanel.java index 4b0cef6..01a618b 100644 --- a/src/main/java/io/kaitai/struct/visualizer/VisualizerPanel.java +++ b/src/main/java/io/kaitai/struct/visualizer/VisualizerPanel.java @@ -12,6 +12,7 @@ import io.kaitai.struct.ByteBufferKaitaiStream; import io.kaitai.struct.CompileLog; +import io.kaitai.struct.JavaRuntimeConfig; import io.kaitai.struct.KaitaiStream; import io.kaitai.struct.KaitaiStruct; import io.kaitai.struct.Main; @@ -39,6 +40,7 @@ import tv.porst.jhexview.SimpleDataProvider; public class VisualizerPanel extends JPanel { + /** Package to generate classes in. */ private static final String DEST_PACKAGE = "io.kaitai.struct.visualized"; /** * Regexp with 2 groups: class name and type parameters. Type parameters @@ -127,14 +129,23 @@ private static String compileKSY(String ksyFileName) { final JavaClassSpecs specs = new JavaClassSpecs(null, null, spec); final RuntimeConfig config = new RuntimeConfig( - true, // debug - required for existing _attrStart/_attrEnd/_arrStart/_arrEnd fields + false,// autoRead - do not call `_read` automatically in constructor + true, // readStoresPos - enable generation of a position info which is accessed in DebugAids later true, // opaqueTypes + null, // cppConfig null, // goPackage - DEST_PACKAGE, - "io.kaitai.struct.ByteBufferKaitaiStream", + new JavaRuntimeConfig( + DEST_PACKAGE, + // Class to be invoked in `fromFile` helper methods + "io.kaitai.struct.ByteBufferKaitaiStream", + // Exception class expected to be thrown on end-of-stream errors + "java.nio.BufferUnderflowException" + ), null, // dotNetNamespace null, // phpNamespace - null // pythonPackage + null, // pythonPackage + null, // nimModule + null // nimOpaque ); Main.importAndPrecompile(specs, config).value();