开泰结构参数类型
Kaitai Struct Parameter Type
我正在尝试将参数传递给 ksy 文件。该参数是另一个 ksy 文件类型。原因是我需要访问作为参数传递的 ksy 文件中的所有字段。
那可能吗?
如果是,能否请您提供语法代码片段,以便我可以模仿它。
如果不是,还有什么解决方案?
谢谢。
加盟免责声明:我是 Kaitai Struct maintainer (see my GitHub profile).
首先,我建议始终使用开发版的Kaitai Struct WebIDE(https://ide.kaitai.io/devel/), not the stable one. The stable IDE deployed at https://ide.kaitai.io/ has KS compiler of version 0.8, which is indeed the latest stable version, but already 2 years old at the moment. But the project is under active development, new bug fixes and improvements are coming every week, so the stable Web IDE is pretty much outdated. And thanks to the recent infrastructure enhancement,现在开发版IDE每次更新编译器时都会重建,因此您甚至可以使用最新的功能。
但是,您将无法模拟您在 Web IDE 中描述的特定情况,因为它目前无法处理顶级参数类型(没有您可以传递的挂钩你自己的价值观作为论据)。但它应该在本地环境中工作。您可以在 Web IDE to the target language you want to use (the manual shows how to do it) 中编译 commontype.ksy
和 pty.ksy
规范。将它们放在一起的代码可能如下所示 (Java):
Commontype ct = new Commontype(new ByteBufferKaitaiStream(new byte[] { 80, 75 }));
Pty r = new Pty(
new ByteBufferKaitaiStream(new byte[] { 80 }), // IO stream
ct // commonword
);
注意Pty
构造函数的实际参数顺序可能不同,例如在 Python 中,首先是自定义参数 (commonword
),然后是 IO 对象。检查以您的特定语言生成的代码。
我正在尝试将参数传递给 ksy 文件。该参数是另一个 ksy 文件类型。原因是我需要访问作为参数传递的 ksy 文件中的所有字段。 那可能吗? 如果是,能否请您提供语法代码片段,以便我可以模仿它。 如果不是,还有什么解决方案?
谢谢。
加盟免责声明:我是 Kaitai Struct maintainer (see my GitHub profile).
首先,我建议始终使用开发版的Kaitai Struct WebIDE(https://ide.kaitai.io/devel/), not the stable one. The stable IDE deployed at https://ide.kaitai.io/ has KS compiler of version 0.8, which is indeed the latest stable version, but already 2 years old at the moment. But the project is under active development, new bug fixes and improvements are coming every week, so the stable Web IDE is pretty much outdated. And thanks to the recent infrastructure enhancement,现在开发版IDE每次更新编译器时都会重建,因此您甚至可以使用最新的功能。
但是,您将无法模拟您在 Web IDE 中描述的特定情况,因为它目前无法处理顶级参数类型(没有您可以传递的挂钩你自己的价值观作为论据)。但它应该在本地环境中工作。您可以在 Web IDE to the target language you want to use (the manual shows how to do it) 中编译 commontype.ksy
和 pty.ksy
规范。将它们放在一起的代码可能如下所示 (Java):
Commontype ct = new Commontype(new ByteBufferKaitaiStream(new byte[] { 80, 75 }));
Pty r = new Pty(
new ByteBufferKaitaiStream(new byte[] { 80 }), // IO stream
ct // commonword
);
注意Pty
构造函数的实际参数顺序可能不同,例如在 Python 中,首先是自定义参数 (commonword
),然后是 IO 对象。检查以您的特定语言生成的代码。