struct-frame 0.0.23__py3-none-any.whl → 0.0.24__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of struct-frame might be problematic. Click here for more details.
- struct_frame/__init__.py +2 -1
- struct_frame/boilerplate/c/struct_frame.h +5 -0
- struct_frame/boilerplate/c/struct_frame_cpp.h +3 -4
- struct_frame/boilerplate/py/struct_frame_parser.py +118 -0
- struct_frame/boilerplate/ts/struct_frame_gen.ts +2 -2
- struct_frame/generate.py +22 -2
- struct_frame/py_gen.py +160 -0
- struct_frame/ts_gen.py +15 -12
- {struct_frame-0.0.23.dist-info → struct_frame-0.0.24.dist-info}/METADATA +2 -1
- struct_frame-0.0.24.dist-info/RECORD +21 -0
- struct_frame-0.0.23.dist-info/RECORD +0 -19
- {struct_frame-0.0.23.dist-info → struct_frame-0.0.24.dist-info}/WHEEL +0 -0
- {struct_frame-0.0.23.dist-info → struct_frame-0.0.24.dist-info}/licenses/LICENSE +0 -0
struct_frame/__init__.py
CHANGED
|
@@ -2,8 +2,9 @@ from .base import version, NamingStyleC, CamelToSnakeCase, pascalCase
|
|
|
2
2
|
|
|
3
3
|
from .c_gen import FileCGen
|
|
4
4
|
from .ts_gen import FileTsGen
|
|
5
|
+
from .py_gen import FilePyGen
|
|
5
6
|
|
|
6
7
|
from .generate import main
|
|
7
8
|
|
|
8
|
-
__all__ = ["main", "FileCGen", "FileTsGen", "version",
|
|
9
|
+
__all__ = ["main", "FileCGen", "FileTsGen", "FilePyGen", "version",
|
|
9
10
|
"NamingStyleC", "CamelToSnakeCase", "pascalCase"]
|
|
@@ -88,11 +88,16 @@ static inline bool msg_finish(struct_buffer *buffer) {
|
|
|
88
88
|
name msg = *(name *)(buffer->data); \
|
|
89
89
|
return msg; \
|
|
90
90
|
} \
|
|
91
|
+
static inline name funcname##_get(uint8_t *buffer) { \
|
|
92
|
+
name msg = *(name *)(buffer); \
|
|
93
|
+
return msg; \
|
|
94
|
+
} \
|
|
91
95
|
static inline name funcname##_get_from_buffer_result(buffer_parser_result_t result) { \
|
|
92
96
|
name msg = *(name *)(result.msg_loc); \
|
|
93
97
|
return msg; \
|
|
94
98
|
} \
|
|
95
99
|
static inline name *funcname##_get_ref(struct_buffer *buffer) { return (name *)(buffer->data); } \
|
|
100
|
+
static inline name *funcname##_get_ref(uint8_t *buffer) { return (name *)(buffer); } \
|
|
96
101
|
static inline name *funcname##_get_ref_from_buffer_result(buffer_parser_result_t result) { \
|
|
97
102
|
return (name *)(result.msg_loc); \
|
|
98
103
|
}
|
|
@@ -9,8 +9,6 @@ class StructFrameDevice : public struct_buffer {
|
|
|
9
9
|
: struct_buffer{config, nullptr, 0, 0, false, 0, LOOKING_FOR_START_BYTE, 0, {false, 0, 0}},
|
|
10
10
|
parser_result_{config, false, 0, 0, false, {0, 0}} {}
|
|
11
11
|
|
|
12
|
-
void Init() { PutArray(struct_buffer::data, struct_buffer::max_size, 0); }
|
|
13
|
-
|
|
14
12
|
void RunRx() {
|
|
15
13
|
uint8_t *buffer;
|
|
16
14
|
size_t buffer_size;
|
|
@@ -28,6 +26,9 @@ class StructFrameDevice : public struct_buffer {
|
|
|
28
26
|
|
|
29
27
|
void RunTx() { PutArray(struct_buffer::data, struct_buffer::max_size, struct_buffer::size); }
|
|
30
28
|
|
|
29
|
+
protected:
|
|
30
|
+
void Init() { PutArray(struct_buffer::data, struct_buffer::max_size, 0); }
|
|
31
|
+
|
|
31
32
|
// Put Array must accept the full buffer of data and returns a pointer to either a new buffer or the same buffer
|
|
32
33
|
// that is free
|
|
33
34
|
virtual void PutArray(uint8_t *&buffer, size_t &max_length, size_t length) = 0;
|
|
@@ -36,7 +37,5 @@ class StructFrameDevice : public struct_buffer {
|
|
|
36
37
|
virtual void GetArray(uint8_t *&buffer, size_t &length) = 0;
|
|
37
38
|
|
|
38
39
|
virtual void HandleResult() = 0;
|
|
39
|
-
|
|
40
|
-
private:
|
|
41
40
|
buffer_parser_result_t parser_result_;
|
|
42
41
|
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def fletcher_checksum_calculation(buffer, start=0, end=None):
|
|
6
|
+
if end == None:
|
|
7
|
+
end = buffer.length
|
|
8
|
+
|
|
9
|
+
byte1 = 0
|
|
10
|
+
byte2 = 2
|
|
11
|
+
|
|
12
|
+
for x in range(start, end):
|
|
13
|
+
byte1 += buffer[x]
|
|
14
|
+
byte2 += byte1
|
|
15
|
+
|
|
16
|
+
return [byte1, byte2]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BasicPacket:
|
|
20
|
+
start_byte = None
|
|
21
|
+
header_length = 0
|
|
22
|
+
footer_length = 0
|
|
23
|
+
|
|
24
|
+
desired_packet_length = 0
|
|
25
|
+
packet = []
|
|
26
|
+
|
|
27
|
+
def __init__(self, start_byte, header_length, footer_length):
|
|
28
|
+
self.start_byte = start_byte
|
|
29
|
+
self.header_length = header_length
|
|
30
|
+
self.footer_length = footer_length
|
|
31
|
+
|
|
32
|
+
def add_header_byte(self, byte, clear):
|
|
33
|
+
if clear:
|
|
34
|
+
self.packet.clear()
|
|
35
|
+
self.packet.push(byte)
|
|
36
|
+
return len(self.packet) == self.header_length
|
|
37
|
+
|
|
38
|
+
def add_packet_byte(self, byte):
|
|
39
|
+
self.packet.push(byte)
|
|
40
|
+
return len(self.packet) == self.desired_packet_length
|
|
41
|
+
|
|
42
|
+
def get_msg_id(self):
|
|
43
|
+
return self.packet[1]
|
|
44
|
+
|
|
45
|
+
def get_full_packet_length(self, msg_length):
|
|
46
|
+
self.desired_packet_length = self.header_length + self.footer_length + msg_length
|
|
47
|
+
return self.desired_packet_length
|
|
48
|
+
|
|
49
|
+
def validate_packet(self):
|
|
50
|
+
checksum = fletcher_checksum_calculation(
|
|
51
|
+
self.packet, self.header_length, self.desired_packet_length - self.footer_length)
|
|
52
|
+
return checksum[0] == self.packet[-2] and checksum[1] == self.packet[-1]
|
|
53
|
+
|
|
54
|
+
def get_msg_buffer(self):
|
|
55
|
+
return self.packet[self.header_length:self.desired_packet_length - self.footer_length]
|
|
56
|
+
|
|
57
|
+
def encode(self, data, msg_id):
|
|
58
|
+
output = []
|
|
59
|
+
output.push(self.start_byte)
|
|
60
|
+
output.push(msg_id)
|
|
61
|
+
output.push(data)
|
|
62
|
+
checksum = fletcher_checksum_calculation(data)
|
|
63
|
+
|
|
64
|
+
output.push(checksum[0])
|
|
65
|
+
output.push(checksum[1])
|
|
66
|
+
return output
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class ParserState(Enum):
|
|
70
|
+
LOOKING_FOR_START_BYTE = 0
|
|
71
|
+
GETTING_HEADER = 1
|
|
72
|
+
GETTING_PACKET = 2
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class FrameParser:
|
|
76
|
+
state = ParserState.LOOKING_FOR_START_BYTE
|
|
77
|
+
buffer = []
|
|
78
|
+
parser = None
|
|
79
|
+
msg_definitions = None
|
|
80
|
+
msg_id_loc = None
|
|
81
|
+
msg_type = None
|
|
82
|
+
|
|
83
|
+
def __init__(self, parsers, msg_definitions):
|
|
84
|
+
self.parsers = parsers
|
|
85
|
+
self.msg_definitions = msg_definitions
|
|
86
|
+
|
|
87
|
+
def parse_char(self, c):
|
|
88
|
+
if state == ParserState.LOOKING_FOR_START_BYTE:
|
|
89
|
+
self.parser = self.parsers[c]
|
|
90
|
+
if self.parser:
|
|
91
|
+
if self.parser.add_header_byte(c, True):
|
|
92
|
+
state = ParserState.GETTING_PACKET
|
|
93
|
+
else:
|
|
94
|
+
state = ParserState.GETTING_HEADER
|
|
95
|
+
|
|
96
|
+
elif state == ParserState.GETTING_HEADER:
|
|
97
|
+
if self.parser.add_header_byte(c):
|
|
98
|
+
msg_id = self.parser.get_msg_id()
|
|
99
|
+
self.msg_type = self.msg_definitions[msg_id]
|
|
100
|
+
if self.msg_type:
|
|
101
|
+
self.parser.get_full_packet_length(self.msg_type.msg_size)
|
|
102
|
+
state = ParserState.GETTING_PACKET
|
|
103
|
+
else:
|
|
104
|
+
state = ParserState.LOOKING_FOR_START_BYTE
|
|
105
|
+
|
|
106
|
+
elif state == ParserState.GETTING_PACKET:
|
|
107
|
+
if self.parser.add_packet_byte(c):
|
|
108
|
+
state = ParserState.LOOKING_FOR_START_BYTE
|
|
109
|
+
if self.parser.validatePackage:
|
|
110
|
+
return self.msg_type.create_unpack(self.parser.get_msg_buffer())
|
|
111
|
+
|
|
112
|
+
return False
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def TestFunction():
|
|
116
|
+
parsers = {BasicPacket.start_byte, BasicPacket()}
|
|
117
|
+
frameParser = FrameParser(parsers)
|
|
118
|
+
frameParser.parse_char
|
struct_frame/generate.py
CHANGED
|
@@ -6,6 +6,7 @@ import os
|
|
|
6
6
|
import shutil
|
|
7
7
|
from struct_frame import FileCGen
|
|
8
8
|
from struct_frame import FileTsGen
|
|
9
|
+
from struct_frame import FilePyGen
|
|
9
10
|
from proto_schema_parser.parser import Parser
|
|
10
11
|
from proto_schema_parser import ast
|
|
11
12
|
|
|
@@ -258,8 +259,10 @@ parser.add_argument('filename')
|
|
|
258
259
|
parser.add_argument('--debug', action='store_true')
|
|
259
260
|
parser.add_argument('--build_c', action='store_true')
|
|
260
261
|
parser.add_argument('--build_ts', action='store_true')
|
|
262
|
+
parser.add_argument('--build_py', action='store_true')
|
|
261
263
|
parser.add_argument('--c_path', nargs=1, type=str, default=['c/'])
|
|
262
264
|
parser.add_argument('--ts_path', nargs=1, type=str, default=['ts/'])
|
|
265
|
+
parser.add_argument('--py_path', nargs=1, type=str, default=['py/'])
|
|
263
266
|
|
|
264
267
|
|
|
265
268
|
def parseFile(filename):
|
|
@@ -334,11 +337,20 @@ def generateTsFileStrings(path):
|
|
|
334
337
|
return out
|
|
335
338
|
|
|
336
339
|
|
|
340
|
+
def generatePyFileStrings(path):
|
|
341
|
+
out = {}
|
|
342
|
+
for key, value in packages.items():
|
|
343
|
+
name = os.path.join(path, value.name + ".sf.py")
|
|
344
|
+
data = ''.join(FilePyGen.generate(value))
|
|
345
|
+
out[name] = data
|
|
346
|
+
return out
|
|
347
|
+
|
|
348
|
+
|
|
337
349
|
def main():
|
|
338
350
|
args = parser.parse_args()
|
|
339
351
|
parseFile(args.filename)
|
|
340
352
|
|
|
341
|
-
if (not args.build_c and not args.build_ts):
|
|
353
|
+
if (not args.build_c and not args.build_ts and not args.build_py):
|
|
342
354
|
print("Select at least one build argument")
|
|
343
355
|
return
|
|
344
356
|
|
|
@@ -348,12 +360,16 @@ def main():
|
|
|
348
360
|
print(
|
|
349
361
|
f'Recursion Error. Messages most likely have a cyclical dependancy. Check Message: {recErrCurrentMessage} and Field: {recErrCurrentField}')
|
|
350
362
|
|
|
363
|
+
files = {}
|
|
351
364
|
if (args.build_c):
|
|
352
|
-
files
|
|
365
|
+
files.update(generateCFileStrings(args.c_path[0]))
|
|
353
366
|
|
|
354
367
|
if (args.build_ts):
|
|
355
368
|
files.update(generateTsFileStrings(args.ts_path[0]))
|
|
356
369
|
|
|
370
|
+
if (args.build_py):
|
|
371
|
+
files.update(generatePyFileStrings(args.py_path[0]))
|
|
372
|
+
|
|
357
373
|
for filename, filedata in files.items():
|
|
358
374
|
dirname = os.path.dirname(filename)
|
|
359
375
|
if dirname and not os.path.exists(dirname):
|
|
@@ -372,6 +388,10 @@ def main():
|
|
|
372
388
|
shutil.copytree(os.path.join(dir_path, "boilerplate/ts"),
|
|
373
389
|
args.ts_path[0], dirs_exist_ok=True)
|
|
374
390
|
|
|
391
|
+
if (args.build_py):
|
|
392
|
+
shutil.copytree(os.path.join(dir_path, "boilerplate/py"),
|
|
393
|
+
args.py_path[0], dirs_exist_ok=True)
|
|
394
|
+
|
|
375
395
|
if args.debug:
|
|
376
396
|
printPackages()
|
|
377
397
|
print("Struct Frame successfully completed")
|
struct_frame/py_gen.py
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# kate: replace-tabs on; indent-width 4;
|
|
3
|
+
|
|
4
|
+
from struct_frame import version, NamingStyleC, CamelToSnakeCase, pascalCase
|
|
5
|
+
import time
|
|
6
|
+
|
|
7
|
+
StyleC = NamingStyleC()
|
|
8
|
+
|
|
9
|
+
py_types = {"uint8": "uint8",
|
|
10
|
+
"int8": "int8",
|
|
11
|
+
"uint16": "uint16",
|
|
12
|
+
"int16": "int16",
|
|
13
|
+
"uint32": "uint32",
|
|
14
|
+
"int32": "int32",
|
|
15
|
+
"bool": "bool8",
|
|
16
|
+
"float": "float32",
|
|
17
|
+
"double": "float64",
|
|
18
|
+
"uint64": 'uint64',
|
|
19
|
+
"int64": 'int64',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class EnumPyGen():
|
|
24
|
+
@staticmethod
|
|
25
|
+
def generate(field):
|
|
26
|
+
leading_comment = field.comments
|
|
27
|
+
|
|
28
|
+
result = ''
|
|
29
|
+
if leading_comment:
|
|
30
|
+
for c in leading_comment:
|
|
31
|
+
result = '#%s\n' % c
|
|
32
|
+
|
|
33
|
+
enumName = '%s%s' % (pascalCase(field.package), field.name)
|
|
34
|
+
result += 'class %s(Enum):\n' % (enumName)
|
|
35
|
+
|
|
36
|
+
enum_length = len(field.data)
|
|
37
|
+
enum_values = []
|
|
38
|
+
for index, (d) in enumerate(field.data):
|
|
39
|
+
leading_comment = field.data[d][1]
|
|
40
|
+
|
|
41
|
+
if leading_comment:
|
|
42
|
+
for c in leading_comment:
|
|
43
|
+
enum_values.append("#" + c)
|
|
44
|
+
|
|
45
|
+
enum_value = " %s_%s = %d" % (CamelToSnakeCase(
|
|
46
|
+
field.name).upper(), StyleC.enum_entry(d), field.data[d][0])
|
|
47
|
+
|
|
48
|
+
enum_values.append(enum_value)
|
|
49
|
+
|
|
50
|
+
result += '\n'.join(enum_values)
|
|
51
|
+
return result
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class FieldPyGen():
|
|
55
|
+
@staticmethod
|
|
56
|
+
def generate(field):
|
|
57
|
+
result = ''
|
|
58
|
+
|
|
59
|
+
var_name = field.name
|
|
60
|
+
type_name = field.fieldType
|
|
61
|
+
if type_name in py_types:
|
|
62
|
+
type_name = py_types[type_name]
|
|
63
|
+
else:
|
|
64
|
+
type_name = '%s%s' % (pascalCase(field.package), type_name)
|
|
65
|
+
if field.isEnum:
|
|
66
|
+
type_name = 'uint8 #%s' % type_name
|
|
67
|
+
|
|
68
|
+
result += ' %s: %s' % (var_name, type_name)
|
|
69
|
+
|
|
70
|
+
leading_comment = field.comments
|
|
71
|
+
if leading_comment:
|
|
72
|
+
for c in leading_comment:
|
|
73
|
+
result = "#" + c + "\n" + result
|
|
74
|
+
|
|
75
|
+
return result
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class MessagePyGen():
|
|
79
|
+
@staticmethod
|
|
80
|
+
def generate(msg):
|
|
81
|
+
leading_comment = msg.comments
|
|
82
|
+
|
|
83
|
+
result = ''
|
|
84
|
+
if leading_comment:
|
|
85
|
+
for c in msg.comments:
|
|
86
|
+
result = '#%s\n' % c
|
|
87
|
+
|
|
88
|
+
structName = '%s%s' % (pascalCase(msg.package), msg.name)
|
|
89
|
+
result += 'class %s(Structured):\n' % structName
|
|
90
|
+
result += ' msg_size = %s\n' % msg.size
|
|
91
|
+
if msg.id:
|
|
92
|
+
result += ' msg_id = %s\n' % msg.id
|
|
93
|
+
|
|
94
|
+
size = 1
|
|
95
|
+
if not msg.fields:
|
|
96
|
+
# Empty structs are not allowed in C standard.
|
|
97
|
+
# Therefore add a dummy field if an empty message occurs.
|
|
98
|
+
result += ' dummy_field: pad'
|
|
99
|
+
else:
|
|
100
|
+
size = msg.size
|
|
101
|
+
|
|
102
|
+
result += '\n'.join([FieldPyGen.generate(f)
|
|
103
|
+
for key, f in msg.fields.items()])
|
|
104
|
+
|
|
105
|
+
# defineName = '%s_%s' % (CamelToSnakeCase(
|
|
106
|
+
# msg.package).upper(), CamelToSnakeCase(msg.name).upper())
|
|
107
|
+
# result += '#define %s_MAX_SIZE %d\n' % (defineName, size)
|
|
108
|
+
#
|
|
109
|
+
# if msg.id:
|
|
110
|
+
# result += '#define %s_MSG_ID %d\n' % (defineName, msg.id)
|
|
111
|
+
#
|
|
112
|
+
# funcName = defineName.lower()
|
|
113
|
+
# if msg.id:
|
|
114
|
+
# result += 'MESSAGE_HELPER(%s, %s, %d, %d);\n\n' % (funcName, structName,
|
|
115
|
+
# size, msg.id)
|
|
116
|
+
#
|
|
117
|
+
return result + '\n'
|
|
118
|
+
|
|
119
|
+
@staticmethod
|
|
120
|
+
def get_initializer(msg, null_init):
|
|
121
|
+
if not msg.fields:
|
|
122
|
+
return '{0}'
|
|
123
|
+
|
|
124
|
+
parts = []
|
|
125
|
+
for field in msg.fields:
|
|
126
|
+
parts.append(field.get_initializer(null_init))
|
|
127
|
+
return '{' + ', '.join(parts) + '}'
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class FilePyGen():
|
|
131
|
+
@staticmethod
|
|
132
|
+
def generate(package):
|
|
133
|
+
yield '# Automatically generated struct frame header \n'
|
|
134
|
+
yield '# Generated by %s at %s. \n\n' % (version, time.asctime())
|
|
135
|
+
|
|
136
|
+
yield 'from structured import *\n'
|
|
137
|
+
yield 'from enum import Enum\n\n'
|
|
138
|
+
|
|
139
|
+
if package.enums:
|
|
140
|
+
yield '# Enum definitions\n'
|
|
141
|
+
for key, enum in package.enums.items():
|
|
142
|
+
yield EnumPyGen.generate(enum) + '\n\n'
|
|
143
|
+
|
|
144
|
+
if package.messages:
|
|
145
|
+
yield '# Struct definitions \n'
|
|
146
|
+
# Need to sort messages to make sure dependecies are properly met
|
|
147
|
+
|
|
148
|
+
for key, msg in package.sortedMessages().items():
|
|
149
|
+
yield MessagePyGen.generate(msg) + '\n'
|
|
150
|
+
yield '\n'
|
|
151
|
+
|
|
152
|
+
if package.messages:
|
|
153
|
+
|
|
154
|
+
yield '%s_definitions = {\n' % package.name
|
|
155
|
+
for key, msg in package.sortedMessages().items():
|
|
156
|
+
if msg.id:
|
|
157
|
+
structName = '%s%s' % (pascalCase(msg.package), msg.name)
|
|
158
|
+
yield ' %s: %s,\n' % (msg.id, structName)
|
|
159
|
+
|
|
160
|
+
yield '}\n'
|
struct_frame/ts_gen.py
CHANGED
|
@@ -101,9 +101,10 @@ class MessageTsGen():
|
|
|
101
101
|
for c in msg.comments:
|
|
102
102
|
result = '%s\n' % c
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
package_msg_name = '%s_%s' % (packageName, msg.name)
|
|
105
|
+
|
|
105
106
|
result += 'export const %s = new typed_struct.Struct(\'%s\') ' % (
|
|
106
|
-
|
|
107
|
+
package_msg_name, package_msg_name)
|
|
107
108
|
|
|
108
109
|
result += '\n'
|
|
109
110
|
|
|
@@ -119,25 +120,26 @@ class MessageTsGen():
|
|
|
119
120
|
for key, f in msg.fields.items()])
|
|
120
121
|
result += '\n .compile();\n\n'
|
|
121
122
|
|
|
122
|
-
result += 'export const %s_max_size = %d;\n' % (
|
|
123
|
+
result += 'export const %s_max_size = %d;\n' % (package_msg_name, size)
|
|
123
124
|
|
|
124
125
|
if msg.id:
|
|
125
|
-
result += 'export const %s_msgid = %d\n' % (
|
|
126
|
+
result += 'export const %s_msgid = %d\n' % (
|
|
127
|
+
package_msg_name, msg.id)
|
|
126
128
|
|
|
127
129
|
result += 'export function %s_encode(buffer: struct_frame_buffer, msg: any) {\n' % (
|
|
128
|
-
|
|
129
|
-
result += ' msg_encode(buffer, msg, %s_msgid)\n}\n' % (
|
|
130
|
+
package_msg_name)
|
|
131
|
+
result += ' msg_encode(buffer, msg, %s_msgid)\n}\n' % (package_msg_name)
|
|
130
132
|
|
|
131
133
|
result += 'export function %s_reserve(buffer: struct_frame_buffer) {\n' % (
|
|
132
|
-
|
|
134
|
+
package_msg_name)
|
|
133
135
|
result += ' const msg_buffer = msg_reserve(buffer, %s_msgid, %s_max_size);\n' % (
|
|
134
|
-
|
|
136
|
+
package_msg_name, package_msg_name)
|
|
135
137
|
result += ' if (msg_buffer){\n'
|
|
136
138
|
result += ' return new %s(msg_buffer)\n }\n return;\n}\n' % (
|
|
137
|
-
|
|
139
|
+
package_msg_name)
|
|
138
140
|
|
|
139
141
|
result += 'export function %s_finish(buffer: struct_frame_buffer) {\n' % (
|
|
140
|
-
|
|
142
|
+
package_msg_name)
|
|
141
143
|
result += ' msg_finish(buffer);\n}\n'
|
|
142
144
|
return result + '\n'
|
|
143
145
|
|
|
@@ -182,8 +184,9 @@ class FileTsGen():
|
|
|
182
184
|
if package.messages:
|
|
183
185
|
yield 'export function get_message_length(msg_id : number){\n switch (msg_id)\n {\n'
|
|
184
186
|
for key, msg in package.sortedMessages().items():
|
|
185
|
-
|
|
186
|
-
|
|
187
|
+
|
|
188
|
+
package_msg_name = '%s_%s' % (package.name, msg.name)
|
|
189
|
+
yield ' case %s_msgid: return %s_max_size;\n' % (package_msg_name, package_msg_name)
|
|
187
190
|
|
|
188
191
|
yield ' default: break;\n } return 0;\n}'
|
|
189
192
|
yield '\n'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: struct-frame
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.24
|
|
4
4
|
Summary: A framework for serializing data with headers
|
|
5
5
|
Project-URL: Homepage, https://github.com/mylonics/struct-frame
|
|
6
6
|
Project-URL: Issues, https://github.com/mylonics/struct-frame/issues
|
|
@@ -11,6 +11,7 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Requires-Python: >=3.8
|
|
13
13
|
Requires-Dist: proto-schema-parser>=1.4.5
|
|
14
|
+
Requires-Dist: structured-classes>=3.1.0
|
|
14
15
|
Description-Content-Type: text/markdown
|
|
15
16
|
|
|
16
17
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
struct_frame/__init__.py,sha256=6v6MeHXVPlCn-sXE23fbGHqz8VA_xqCab8yeJ61-Njo,327
|
|
2
|
+
struct_frame/__main__.py,sha256=tIybnBeFHvwiwVhodVOSnxhne5AX_80mtXBx4rneSB4,143
|
|
3
|
+
struct_frame/base.py,sha256=1Z_0vMkwz0X8r2hIVLv5yuhwwD929LwNMzVKBqFxxac,2012
|
|
4
|
+
struct_frame/c_gen.py,sha256=dQw52Zgec38O471KaHuYkRyehcxfjmSOpvhppExgB1c,5969
|
|
5
|
+
struct_frame/generate.py,sha256=vAPTCLikB_DIy_mopLRWovZqDlOe8Y61Z6gcQi9AMdI,12598
|
|
6
|
+
struct_frame/py_gen.py,sha256=6sdZEPBUteNUh2lv2OWLdJlj2Q_r-WipQX7kF6BHAvo,4811
|
|
7
|
+
struct_frame/ts_gen.py,sha256=qdJgAMxL2lV_WmGZErjHpgukYHNNpKpECarXdfmngEI,6266
|
|
8
|
+
struct_frame/boilerplate/c/struct_frame.h,sha256=sVJtzKsA5H6irH_dTdbVmiL0A74cG8AhzO37xSlANzo,5074
|
|
9
|
+
struct_frame/boilerplate/c/struct_frame_cpp.h,sha256=S6KEgeW78TGVeGGRuTseTXwkMNtzFT-n7faRg3A6nfo,1387
|
|
10
|
+
struct_frame/boilerplate/c/struct_frame_gen.h,sha256=rsuYGesEv1rWzSU1z6ybG-1e95RuVR7_IiR1mGLhYpQ,14
|
|
11
|
+
struct_frame/boilerplate/c/struct_frame_parser.h,sha256=5WP-0fH8BbqTeRUdzAye0Qh6gPBNHwVUocB3-gn5MOE,3005
|
|
12
|
+
struct_frame/boilerplate/c/struct_frame_types.h,sha256=5aJUQ_cbVPM9drdRfo1gmN46-PiAtICAZYrpVjmHaJA,1684
|
|
13
|
+
struct_frame/boilerplate/py/struct_frame_parser.py,sha256=txqaYNs5KFgnOsxRIbF3FGMwwtx0-6ynEDjOTy8LcU0,3607
|
|
14
|
+
struct_frame/boilerplate/ts/struct_frame.ts,sha256=botKdIKVP7Bi6BJdXfIZaGAmoATnuj54LxZxc4DAWqM,2252
|
|
15
|
+
struct_frame/boilerplate/ts/struct_frame_gen.ts,sha256=KAZitCUBeE8k0LSYLfOvR1GfG9JWDJUEDtmAOvOUAX0,168
|
|
16
|
+
struct_frame/boilerplate/ts/struct_frame_parser.ts,sha256=6eTbafomqTsX3Fvfn82rxNQMxu4PwTaPug38xw4wrhE,3523
|
|
17
|
+
struct_frame/boilerplate/ts/struct_frame_types.ts,sha256=aBtxVI2lUJKGPTtJAOpbStpS2sXSKvd4XWCIsOnaMk8,2130
|
|
18
|
+
struct_frame-0.0.24.dist-info/METADATA,sha256=IfG-TS9rPWYr5ovqto2FXPP1VYo5u_j-OLahTg7M5rU,745
|
|
19
|
+
struct_frame-0.0.24.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
20
|
+
struct_frame-0.0.24.dist-info/licenses/LICENSE,sha256=UjbLtGfcHCIqJg9UzEVGoNW8fyX4Ah9ZbsuAmJ_vhmk,1094
|
|
21
|
+
struct_frame-0.0.24.dist-info/RECORD,,
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
struct_frame/__init__.py,sha256=HnmRU0-0so_x2zmRtex4weF1XPd11SE73iBHn0hcKE4,283
|
|
2
|
-
struct_frame/__main__.py,sha256=tIybnBeFHvwiwVhodVOSnxhne5AX_80mtXBx4rneSB4,143
|
|
3
|
-
struct_frame/base.py,sha256=1Z_0vMkwz0X8r2hIVLv5yuhwwD929LwNMzVKBqFxxac,2012
|
|
4
|
-
struct_frame/c_gen.py,sha256=dQw52Zgec38O471KaHuYkRyehcxfjmSOpvhppExgB1c,5969
|
|
5
|
-
struct_frame/generate.py,sha256=UkZEZtKfTEmC0lEeInL7F4amCYFx1-bXPg23382rV-Y,11903
|
|
6
|
-
struct_frame/ts_gen.py,sha256=9arnjhgQZqT4F2aTKyFQrHNpn7u-fqX3B-g_17sxIFE,6137
|
|
7
|
-
struct_frame/boilerplate/c/struct_frame.h,sha256=vou8iXsV_4dQBlZRuMNOr1RnuXD1bUJUR4A3dH_uvwM,4564
|
|
8
|
-
struct_frame/boilerplate/c/struct_frame_cpp.h,sha256=gZRNmrQqmzoGkfwlGKh14dfbndkeVhnro11SNPngJng,1387
|
|
9
|
-
struct_frame/boilerplate/c/struct_frame_gen.h,sha256=rsuYGesEv1rWzSU1z6ybG-1e95RuVR7_IiR1mGLhYpQ,14
|
|
10
|
-
struct_frame/boilerplate/c/struct_frame_parser.h,sha256=5WP-0fH8BbqTeRUdzAye0Qh6gPBNHwVUocB3-gn5MOE,3005
|
|
11
|
-
struct_frame/boilerplate/c/struct_frame_types.h,sha256=5aJUQ_cbVPM9drdRfo1gmN46-PiAtICAZYrpVjmHaJA,1684
|
|
12
|
-
struct_frame/boilerplate/ts/struct_frame.ts,sha256=botKdIKVP7Bi6BJdXfIZaGAmoATnuj54LxZxc4DAWqM,2252
|
|
13
|
-
struct_frame/boilerplate/ts/struct_frame_gen.ts,sha256=pz6QTIWDTIY0rMCFiGNgp3DcfO7cKsmXrx3rj3zgN_U,164
|
|
14
|
-
struct_frame/boilerplate/ts/struct_frame_parser.ts,sha256=6eTbafomqTsX3Fvfn82rxNQMxu4PwTaPug38xw4wrhE,3523
|
|
15
|
-
struct_frame/boilerplate/ts/struct_frame_types.ts,sha256=aBtxVI2lUJKGPTtJAOpbStpS2sXSKvd4XWCIsOnaMk8,2130
|
|
16
|
-
struct_frame-0.0.23.dist-info/METADATA,sha256=hR99Tvri4v-oJ6nFuhoOo8MfsIm91zcCIeCbYO_gk14,704
|
|
17
|
-
struct_frame-0.0.23.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
-
struct_frame-0.0.23.dist-info/licenses/LICENSE,sha256=UjbLtGfcHCIqJg9UzEVGoNW8fyX4Ah9ZbsuAmJ_vhmk,1094
|
|
19
|
-
struct_frame-0.0.23.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|