Skip to content

Commit 0f54a77

Browse files
committed
1 parent 3bce5c5 commit 0f54a77

File tree

127 files changed

+4467
-799
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+4467
-799
lines changed
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
from construct import *
22
from construct.lib import *
33

4+
bits_byte_aligned__foo = Struct(
5+
'inner' / ???,
6+
)
7+
48
bits_byte_aligned = Struct(
59
'one' / ???,
610
'byte_1' / Int8ub,
711
'two' / ???,
812
'three' / ???,
9-
'byte_2' / Int8ub,
13+
'byte_2' / FixedSized(1, GreedyBytes),
1014
'four' / ???,
11-
'byte_3' / FixedSized(1, GreedyBytes),
15+
'byte_3' / FixedSized(3, LazyBound(lambda: bits_byte_aligned__foo)),
1216
'full_byte' / ???,
1317
'byte_4' / Int8ub,
18+
'five' / ???,
19+
'bytes_term' / NullTerminated(GreedyBytes, term=b"\x45", include=True, consume=True),
20+
'six' / ???,
1421
)
1522

1623
_schema = bits_byte_aligned
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from construct import *
2+
from construct.lib import *
3+
4+
eof_exception_switch_user__one = Struct(
5+
'val' / Int16sl,
6+
)
7+
8+
eof_exception_switch_user__two = Struct(
9+
'val' / Int16ul,
10+
)
11+
12+
eof_exception_switch_user = Struct(
13+
'code' / Int16ul,
14+
'data' / Switch(this.code, {2: LazyBound(lambda: eof_exception_switch_user__two), 511: LazyBound(lambda: eof_exception_switch_user__one), }),
15+
)
16+
17+
_schema = eof_exception_switch_user
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from construct import *
2+
from construct.lib import *
3+
4+
repeat_eos_bits_b1 = Struct(
5+
'bits' / GreedyRange(???),
6+
)
7+
8+
_schema = repeat_eos_bits_b1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from construct import *
22
from construct.lib import *
33

4-
repeat_eos_bit = Struct(
4+
repeat_eos_bits_b4 = Struct(
55
'nibbles' / GreedyRange(???),
66
)
77

8-
_schema = repeat_eos_bit
8+
_schema = repeat_eos_bits_b4

compiled/construct/switch_repeat_expr.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
)
1111

1212
switch_repeat_expr = Struct(
13-
'code' / Int8ub,
14-
'size' / Int32ul,
15-
'body' / Array(1, Switch(this.code, {17: FixedSized(this.size, LazyBound(lambda: switch_repeat_expr__one)), 34: FixedSized(this.size, LazyBound(lambda: switch_repeat_expr__two)), }, default=FixedSized(this.size, GreedyBytes))),
13+
'codes' / Array(3, Int8ub),
14+
'body' / Array(3, Switch(this.codes[i], {1: FixedSized(4, LazyBound(lambda: switch_repeat_expr__one)), 2: FixedSized(4, LazyBound(lambda: switch_repeat_expr__one)), 7: FixedSized(4, LazyBound(lambda: switch_repeat_expr__two)), }, default=FixedSized(4, GreedyBytes))),
1615
)
1716

1817
_schema = switch_repeat_expr

compiled/construct/switch_repeat_expr_invalid.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
)
1111

1212
switch_repeat_expr_invalid = Struct(
13-
'code' / Int8ub,
14-
'size' / Int32ul,
15-
'body' / Array(1, Switch(this.code, {255: FixedSized(this.size, LazyBound(lambda: switch_repeat_expr_invalid__one)), 34: FixedSized(this.size, LazyBound(lambda: switch_repeat_expr_invalid__two)), }, default=FixedSized(this.size, GreedyBytes))),
13+
'codes' / Array(3, Int8ub),
14+
'body' / Array(3, Switch(this.codes[i], {1: FixedSized(4, LazyBound(lambda: switch_repeat_expr_invalid__one)), 2: FixedSized(4, LazyBound(lambda: switch_repeat_expr_invalid__two)), }, default=FixedSized(4, GreedyBytes))),
1615
)
1716

1817
_schema = switch_repeat_expr_invalid

compiled/cpp_stl_11/bits_byte_aligned.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
bits_byte_aligned_t::bits_byte_aligned_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, bits_byte_aligned_t* p__root) : kaitai::kstruct(p__io) {
66
m__parent = p__parent;
77
m__root = p__root ? p__root : this;
8+
m_byte_3 = nullptr;
9+
m__io__raw_byte_3 = nullptr;
810
_read();
911
}
1012

@@ -13,11 +15,16 @@ void bits_byte_aligned_t::_read() {
1315
m_byte_1 = m__io->read_u1();
1416
m_two = m__io->read_bits_int_be(3);
1517
m_three = m__io->read_bits_int_be(1);
16-
m_byte_2 = m__io->read_u1();
18+
m_byte_2 = m__io->read_bytes(1);
1719
m_four = m__io->read_bits_int_be(14);
18-
m_byte_3 = m__io->read_bytes(1);
20+
m__raw_byte_3 = m__io->read_bytes(3);
21+
m__io__raw_byte_3 = std::unique_ptr<kaitai::kstream>(new kaitai::kstream(m__raw_byte_3));
22+
m_byte_3 = std::unique_ptr<foo_t>(new foo_t(m__io__raw_byte_3.get(), this, m__root));
1923
m_full_byte = m__io->read_bits_int_be(8);
2024
m_byte_4 = m__io->read_u1();
25+
m_five = m__io->read_bits_int_be(22);
26+
m_bytes_term = m__io->read_bytes_term(69, true, true, true);
27+
m_six = m__io->read_bits_int_be(8);
2128
}
2229

2330
bits_byte_aligned_t::~bits_byte_aligned_t() {
@@ -26,3 +33,20 @@ bits_byte_aligned_t::~bits_byte_aligned_t() {
2633

2734
void bits_byte_aligned_t::_clean_up() {
2835
}
36+
37+
bits_byte_aligned_t::foo_t::foo_t(kaitai::kstream* p__io, bits_byte_aligned_t* p__parent, bits_byte_aligned_t* p__root) : kaitai::kstruct(p__io) {
38+
m__parent = p__parent;
39+
m__root = p__root;
40+
_read();
41+
}
42+
43+
void bits_byte_aligned_t::foo_t::_read() {
44+
m_inner = m__io->read_bits_int_be(19);
45+
}
46+
47+
bits_byte_aligned_t::foo_t::~foo_t() {
48+
_clean_up();
49+
}
50+
51+
void bits_byte_aligned_t::foo_t::_clean_up() {
52+
}

compiled/cpp_stl_11/bits_byte_aligned.h

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class bits_byte_aligned_t;
1515
class bits_byte_aligned_t : public kaitai::kstruct {
1616

1717
public:
18+
class foo_t;
1819

1920
bits_byte_aligned_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = nullptr, bits_byte_aligned_t* p__root = nullptr);
2021

@@ -24,28 +25,62 @@ class bits_byte_aligned_t : public kaitai::kstruct {
2425

2526
public:
2627
~bits_byte_aligned_t();
28+
29+
class foo_t : public kaitai::kstruct {
30+
31+
public:
32+
33+
foo_t(kaitai::kstream* p__io, bits_byte_aligned_t* p__parent = nullptr, bits_byte_aligned_t* p__root = nullptr);
34+
35+
private:
36+
void _read();
37+
void _clean_up();
38+
39+
public:
40+
~foo_t();
41+
uint64_t inner() const { return m_inner; }
42+
bits_byte_aligned_t* _root() const { return m__root; }
43+
bits_byte_aligned_t* _parent() const { return m__parent; }
44+
45+
private:
46+
uint64_t m_inner;
47+
bits_byte_aligned_t* m__root;
48+
bits_byte_aligned_t* m__parent;
49+
};
50+
51+
public:
2752
uint64_t one() const { return m_one; }
2853
uint8_t byte_1() const { return m_byte_1; }
2954
uint64_t two() const { return m_two; }
3055
bool three() const { return m_three; }
31-
uint8_t byte_2() const { return m_byte_2; }
56+
std::string byte_2() const { return m_byte_2; }
3257
uint64_t four() const { return m_four; }
33-
std::string byte_3() const { return m_byte_3; }
58+
foo_t* byte_3() const { return m_byte_3.get(); }
3459
uint64_t full_byte() const { return m_full_byte; }
3560
uint8_t byte_4() const { return m_byte_4; }
61+
uint64_t five() const { return m_five; }
62+
std::string bytes_term() const { return m_bytes_term; }
63+
uint64_t six() const { return m_six; }
3664
bits_byte_aligned_t* _root() const { return m__root; }
3765
kaitai::kstruct* _parent() const { return m__parent; }
66+
std::string _raw_byte_3() const { return m__raw_byte_3; }
67+
kaitai::kstream* _io__raw_byte_3() const { return m__io__raw_byte_3.get(); }
3868

3969
private:
4070
uint64_t m_one;
4171
uint8_t m_byte_1;
4272
uint64_t m_two;
4373
bool m_three;
44-
uint8_t m_byte_2;
74+
std::string m_byte_2;
4575
uint64_t m_four;
46-
std::string m_byte_3;
76+
std::unique_ptr<foo_t> m_byte_3;
4777
uint64_t m_full_byte;
4878
uint8_t m_byte_4;
79+
uint64_t m_five;
80+
std::string m_bytes_term;
81+
uint64_t m_six;
4982
bits_byte_aligned_t* m__root;
5083
kaitai::kstruct* m__parent;
84+
std::string m__raw_byte_3;
85+
std::unique_ptr<kaitai::kstream> m__io__raw_byte_3;
5186
};
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
2+
3+
#include "eof_exception_switch_user.h"
4+
5+
eof_exception_switch_user_t::eof_exception_switch_user_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent, eof_exception_switch_user_t* p__root) : kaitai::kstruct(p__io) {
6+
m__parent = p__parent;
7+
m__root = p__root ? p__root : this;
8+
_read();
9+
}
10+
11+
void eof_exception_switch_user_t::_read() {
12+
m_code = m__io->read_u2le();
13+
n_data = true;
14+
switch (code()) {
15+
case 2: {
16+
n_data = false;
17+
m_data = std::unique_ptr<two_t>(new two_t(m__io, this, m__root));
18+
break;
19+
}
20+
case 511: {
21+
n_data = false;
22+
m_data = std::unique_ptr<one_t>(new one_t(m__io, this, m__root));
23+
break;
24+
}
25+
}
26+
}
27+
28+
eof_exception_switch_user_t::~eof_exception_switch_user_t() {
29+
_clean_up();
30+
}
31+
32+
void eof_exception_switch_user_t::_clean_up() {
33+
if (!n_data) {
34+
}
35+
}
36+
37+
eof_exception_switch_user_t::one_t::one_t(kaitai::kstream* p__io, eof_exception_switch_user_t* p__parent, eof_exception_switch_user_t* p__root) : kaitai::kstruct(p__io) {
38+
m__parent = p__parent;
39+
m__root = p__root;
40+
_read();
41+
}
42+
43+
void eof_exception_switch_user_t::one_t::_read() {
44+
m_val = m__io->read_s2le();
45+
}
46+
47+
eof_exception_switch_user_t::one_t::~one_t() {
48+
_clean_up();
49+
}
50+
51+
void eof_exception_switch_user_t::one_t::_clean_up() {
52+
}
53+
54+
eof_exception_switch_user_t::two_t::two_t(kaitai::kstream* p__io, eof_exception_switch_user_t* p__parent, eof_exception_switch_user_t* p__root) : kaitai::kstruct(p__io) {
55+
m__parent = p__parent;
56+
m__root = p__root;
57+
_read();
58+
}
59+
60+
void eof_exception_switch_user_t::two_t::_read() {
61+
m_val = m__io->read_u2le();
62+
}
63+
64+
eof_exception_switch_user_t::two_t::~two_t() {
65+
_clean_up();
66+
}
67+
68+
void eof_exception_switch_user_t::two_t::_clean_up() {
69+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#pragma once
2+
3+
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
4+
5+
class eof_exception_switch_user_t;
6+
7+
#include "kaitai/kaitaistruct.h"
8+
#include <stdint.h>
9+
#include <memory>
10+
11+
#if KAITAI_STRUCT_VERSION < 11000L
12+
#error "Incompatible Kaitai Struct C++/STL API: version 0.11 or later is required"
13+
#endif
14+
15+
class eof_exception_switch_user_t : public kaitai::kstruct {
16+
17+
public:
18+
class one_t;
19+
class two_t;
20+
21+
eof_exception_switch_user_t(kaitai::kstream* p__io, kaitai::kstruct* p__parent = nullptr, eof_exception_switch_user_t* p__root = nullptr);
22+
23+
private:
24+
void _read();
25+
void _clean_up();
26+
27+
public:
28+
~eof_exception_switch_user_t();
29+
30+
class one_t : public kaitai::kstruct {
31+
32+
public:
33+
34+
one_t(kaitai::kstream* p__io, eof_exception_switch_user_t* p__parent = nullptr, eof_exception_switch_user_t* p__root = nullptr);
35+
36+
private:
37+
void _read();
38+
void _clean_up();
39+
40+
public:
41+
~one_t();
42+
int16_t val() const { return m_val; }
43+
eof_exception_switch_user_t* _root() const { return m__root; }
44+
eof_exception_switch_user_t* _parent() const { return m__parent; }
45+
46+
private:
47+
int16_t m_val;
48+
eof_exception_switch_user_t* m__root;
49+
eof_exception_switch_user_t* m__parent;
50+
};
51+
52+
class two_t : public kaitai::kstruct {
53+
54+
public:
55+
56+
two_t(kaitai::kstream* p__io, eof_exception_switch_user_t* p__parent = nullptr, eof_exception_switch_user_t* p__root = nullptr);
57+
58+
private:
59+
void _read();
60+
void _clean_up();
61+
62+
public:
63+
~two_t();
64+
uint16_t val() const { return m_val; }
65+
eof_exception_switch_user_t* _root() const { return m__root; }
66+
eof_exception_switch_user_t* _parent() const { return m__parent; }
67+
68+
private:
69+
uint16_t m_val;
70+
eof_exception_switch_user_t* m__root;
71+
eof_exception_switch_user_t* m__parent;
72+
};
73+
74+
public:
75+
uint16_t code() const { return m_code; }
76+
kaitai::kstruct* data() const { return m_data.get(); }
77+
eof_exception_switch_user_t* _root() const { return m__root; }
78+
kaitai::kstruct* _parent() const { return m__parent; }
79+
80+
private:
81+
uint16_t m_code;
82+
std::unique_ptr<kaitai::kstruct> m_data;
83+
bool n_data;
84+
85+
public:
86+
bool _is_null_data() { data(); return n_data; };
87+
88+
private:
89+
eof_exception_switch_user_t* m__root;
90+
kaitai::kstruct* m__parent;
91+
};

0 commit comments

Comments
 (0)