lbkit 0.5.6__tar.gz → 0.5.8__tar.gz
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.
- {lbkit-0.5.6/lbkit.egg-info → lbkit-0.5.8}/PKG-INFO +1 -1
- lbkit-0.5.8/lbkit/__init__.py +2 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/ctype_defination.py +198 -65
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/idf_interface.py +67 -5
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/template/client.c.mako +17 -2
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/template/client.h.mako +12 -4
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/template/public.c.mako +366 -5
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/template/public.h.mako +26 -1
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/template/server.c.mako +14 -3
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/template/server.h.mako +5 -2
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/misc.py +1 -1
- {lbkit-0.5.6 → lbkit-0.5.8/lbkit.egg-info}/PKG-INFO +1 -1
- lbkit-0.5.6/lbkit/__init__.py +0 -2
- {lbkit-0.5.6 → lbkit-0.5.8}/AUTHORS +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/LICENSE +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/MANIFEST.in +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/README.md +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/ci_robot/__init__.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/ci_robot/gitee.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/cli.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/__init__.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/codegen.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/renderer.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/template/interface.c.mako +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/codegen/template/interface.introspect.xml.mako +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/component/__init__.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/component/arg_parser.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/component/build.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/component/template/conanbase.mako +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/component/template/deploy.mako +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/component/test.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/errors.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/helper.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/integration/__init__.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/integration/build_manifest.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/integration/build_prepare.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/integration/build_rootfs.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/integration/config.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/integration/task.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/integration/template/conanfile.py.mako +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/lbkit.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/log.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit/tools.py +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit.egg-info/SOURCES.txt +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit.egg-info/dependency_links.txt +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit.egg-info/entry_points.txt +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit.egg-info/requires.txt +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/lbkit.egg-info/top_level.txt +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/setup.cfg +0 -0
- {lbkit-0.5.6 → lbkit-0.5.8}/setup.py +0 -0
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
"""语言相关类型定义"""
|
|
2
2
|
import sys
|
|
3
|
+
from lbkit.errors import OdfValidateException
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
class IdfValidator():
|
|
6
|
-
|
|
7
|
+
validator = {}
|
|
8
|
+
|
|
9
|
+
def set_validator(self, value):
|
|
10
|
+
self.validator = value
|
|
11
|
+
|
|
12
|
+
def odf_validate(self):
|
|
13
|
+
idf_validator = idf_validator
|
|
14
|
+
return []
|
|
15
|
+
|
|
16
|
+
def odf_schema(self, allow_ref):
|
|
17
|
+
allow_ref = allow_ref
|
|
18
|
+
idf_validator = idf_validator
|
|
7
19
|
return None
|
|
8
20
|
|
|
9
21
|
|
|
10
22
|
class BoolValidator(IdfValidator):
|
|
11
|
-
def
|
|
23
|
+
def odf_validate(self):
|
|
24
|
+
func = ["validate_odf_as_boolean(doc, node, prop, error_list)"]
|
|
25
|
+
return func
|
|
26
|
+
|
|
27
|
+
def odf_schema(self, allow_ref):
|
|
12
28
|
if allow_ref:
|
|
13
29
|
return {
|
|
14
30
|
"anyOf": [
|
|
@@ -27,8 +43,12 @@ class BoolValidator(IdfValidator):
|
|
|
27
43
|
|
|
28
44
|
|
|
29
45
|
class BoolArrayValidator(BoolValidator):
|
|
30
|
-
def
|
|
31
|
-
|
|
46
|
+
def odf_validate(self):
|
|
47
|
+
func = ["validate_odf_as_boolean_v(doc, node, prop, error_list)"]
|
|
48
|
+
return func
|
|
49
|
+
|
|
50
|
+
def odf_schema(self, allow_ref):
|
|
51
|
+
parent_schema = super().odf_schema(False)
|
|
32
52
|
if allow_ref:
|
|
33
53
|
schema = {
|
|
34
54
|
"anyOf": [
|
|
@@ -54,29 +74,57 @@ class IntegerValidator(IdfValidator):
|
|
|
54
74
|
maximum = sys.maxsize * 2
|
|
55
75
|
minimum = -(sys.maxsize + 1) * 2
|
|
56
76
|
|
|
57
|
-
def __init__(self, max, min):
|
|
77
|
+
def __init__(self, max, min, signed=False):
|
|
58
78
|
self.maximum = max
|
|
59
79
|
self.minimum = min
|
|
80
|
+
self.signed = signed
|
|
81
|
+
if not self.signed and self.minimum < 0:
|
|
82
|
+
self.minimum = 0
|
|
83
|
+
if self.maximum < self.minimum:
|
|
84
|
+
raise OdfValidateException(f"The max value {self.maximum} less than or equal to {self.minimum}")
|
|
60
85
|
super().__init__()
|
|
61
86
|
|
|
62
|
-
def
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
idf_validator为IDF模型中加载的数据验证器的对象
|
|
66
|
-
"""
|
|
67
|
-
max = idf_validator.get("max", self.maximum)
|
|
87
|
+
def set_validator(self, value):
|
|
88
|
+
super().set_validator(value)
|
|
89
|
+
max = self.validator.get("max", self.maximum)
|
|
68
90
|
if max > self.maximum:
|
|
69
91
|
max = self.maximum
|
|
70
|
-
min =
|
|
92
|
+
min = self.validator.get("min", self.minimum)
|
|
71
93
|
if min < self.minimum:
|
|
72
94
|
min = self.minimum
|
|
95
|
+
self.maximum = max
|
|
96
|
+
self.minimum = min
|
|
97
|
+
if not self.signed and self.minimum < 0:
|
|
98
|
+
self.minimum = 0
|
|
99
|
+
if self.maximum < self.minimum:
|
|
100
|
+
raise OdfValidateException(f"The max value {self.maximum} less than or equal to {self.minimum}")
|
|
101
|
+
|
|
102
|
+
def odf_validate(self):
|
|
103
|
+
func = []
|
|
104
|
+
if self.signed:
|
|
105
|
+
if self.minimum == -9223372036854775808:
|
|
106
|
+
func.append(f"validate_odf_as_signed(doc, node, prop, {self.maximum}, G_MININT64, error_list)")
|
|
107
|
+
else:
|
|
108
|
+
func.append(f"validate_odf_as_signed(doc, node, prop, {self.maximum}, {self.minimum}, error_list)")
|
|
109
|
+
else:
|
|
110
|
+
if self.maximum == 18446744073709551615:
|
|
111
|
+
func.append(f"validate_odf_as_unsigned(doc, node, prop, G_MAXUINT64, {self.minimum}, error_list)")
|
|
112
|
+
else:
|
|
113
|
+
func.append(f"validate_odf_as_unsigned(doc, node, prop, {self.maximum}, {self.minimum}, error_list)")
|
|
114
|
+
return func
|
|
115
|
+
|
|
116
|
+
def odf_schema(self, allow_ref):
|
|
117
|
+
"""
|
|
118
|
+
返回整数类型成员的ODF schema
|
|
119
|
+
idf_validator为IDF模型中加载的数据验证器的对象
|
|
120
|
+
"""
|
|
73
121
|
if allow_ref:
|
|
74
122
|
return {
|
|
75
123
|
"anyOf": [
|
|
76
124
|
{
|
|
77
125
|
"type": "integer",
|
|
78
|
-
"maximum":
|
|
79
|
-
"minimum":
|
|
126
|
+
"maximum": self.maximum,
|
|
127
|
+
"minimum": self.minimum
|
|
80
128
|
},
|
|
81
129
|
{
|
|
82
130
|
"$ref": "#/$defs/ref_value"
|
|
@@ -86,14 +134,33 @@ class IntegerValidator(IdfValidator):
|
|
|
86
134
|
else:
|
|
87
135
|
return {
|
|
88
136
|
"type": "integer",
|
|
89
|
-
"maximum":
|
|
90
|
-
"minimum":
|
|
137
|
+
"maximum": self.maximum,
|
|
138
|
+
"minimum": self.minimum
|
|
91
139
|
}
|
|
92
140
|
|
|
93
141
|
|
|
94
142
|
class IntegerArrayValidator(IntegerValidator):
|
|
95
|
-
def
|
|
96
|
-
|
|
143
|
+
def odf_validate(self):
|
|
144
|
+
func = []
|
|
145
|
+
min = self.minimum
|
|
146
|
+
max = self.maximum
|
|
147
|
+
if self.signed:
|
|
148
|
+
if self.minimum <= -0x8000_0000_0000_0000:
|
|
149
|
+
min = "G_MININT64"
|
|
150
|
+
if self.maximum >= 0x7fff_ffff_ffff_ffff:
|
|
151
|
+
max = "G_MAXINT64"
|
|
152
|
+
else:
|
|
153
|
+
if self.maximum >= 0xffff_ffff_ffff_ffff:
|
|
154
|
+
max = "G_MAXUINT64"
|
|
155
|
+
|
|
156
|
+
if self.signed:
|
|
157
|
+
func.append(f"validate_odf_as_signed_v(doc, node, prop, {max}, {min}, error_list)")
|
|
158
|
+
else:
|
|
159
|
+
func.append(f"validate_odf_as_unsigned_v(doc, node, prop, {max}, {min}, error_list)")
|
|
160
|
+
return func
|
|
161
|
+
|
|
162
|
+
def odf_schema(self, allow_ref):
|
|
163
|
+
parent_schema = super().odf_schema(False)
|
|
97
164
|
if allow_ref:
|
|
98
165
|
schema = {
|
|
99
166
|
"anyOf": [
|
|
@@ -119,35 +186,58 @@ class FloatValidator(IdfValidator):
|
|
|
119
186
|
maximum = sys.float_info.max
|
|
120
187
|
minimum = -sys.float_info.max
|
|
121
188
|
|
|
189
|
+
exclusive_max = None
|
|
190
|
+
exclusive_min = None
|
|
191
|
+
|
|
122
192
|
def __init__(self):
|
|
193
|
+
self.max_key = "maximum"
|
|
194
|
+
self.max_val = self.maximum
|
|
195
|
+
self.min_key = "minimum"
|
|
196
|
+
self.min_val = self.minimum
|
|
123
197
|
super().__init__()
|
|
124
198
|
|
|
125
|
-
def
|
|
199
|
+
def odf_validate(self):
|
|
200
|
+
func = ["validate_odf_as_double(doc, node, prop, error_list)"]
|
|
201
|
+
if self.exclusive_max is not None:
|
|
202
|
+
func.append(f"validate_odf_as_float_exclusive_max(doc, node, prop, {self.exclusive_max}, error_list)")
|
|
203
|
+
elif self.maximum != sys.float_info.max:
|
|
204
|
+
func.append(f"validate_odf_as_float_max(doc, node, prop, {self.maximum}, error_list)")
|
|
205
|
+
|
|
206
|
+
if self.exclusive_min is not None:
|
|
207
|
+
func.append(f"validate_odf_as_float_exclusive_min(doc, node, prop, {self.exclusive_min}, error_list)")
|
|
208
|
+
elif self.minimum != (-sys.float_info.max):
|
|
209
|
+
func.append(f"validate_odf_as_float_min(doc, node, prop, {self.minimum}, error_list)")
|
|
210
|
+
return func
|
|
211
|
+
|
|
212
|
+
def set_validator(self, value):
|
|
213
|
+
super().set_validator(value)
|
|
214
|
+
self.maximum = self.validator.get("max", self.maximum)
|
|
215
|
+
self.minimum = self.validator.get("min", self.minimum)
|
|
216
|
+
self.exclusive_max = self.validator.get("exclusive_max", None)
|
|
217
|
+
self.exclusive_min = self.validator.get("exclusive_min", None)
|
|
218
|
+
self.max_key = "maximum"
|
|
219
|
+
self.min_key = "minimum"
|
|
220
|
+
self.max_val = self.maximum
|
|
221
|
+
self.min_val = self.minimum
|
|
222
|
+
if self.exclusive_max is not None:
|
|
223
|
+
self.max_key = "exclusiveMaximum"
|
|
224
|
+
self.max_val = self.exclusive_max
|
|
225
|
+
if self.exclusive_min is not None:
|
|
226
|
+
self.max_key = "exclusiveMinimum"
|
|
227
|
+
self.min_val = self.exclusive_min
|
|
228
|
+
|
|
229
|
+
def odf_schema(self, allow_ref):
|
|
126
230
|
"""
|
|
127
231
|
返回整数类型成员的ODF schema
|
|
128
232
|
idf_validator为IDF模型中加载的数据验证器的对象
|
|
129
233
|
"""
|
|
130
|
-
max = idf_validator.get("max", self.maximum)
|
|
131
|
-
min = idf_validator.get("min", self.minimum)
|
|
132
|
-
exclusive_max = idf_validator.get("exclusive_max", None)
|
|
133
|
-
exclusive_min = idf_validator.get("exclusive_min", None)
|
|
134
|
-
max_key = "maximum"
|
|
135
|
-
max_val = max
|
|
136
|
-
min_key = "minimum"
|
|
137
|
-
min_val = min
|
|
138
|
-
if exclusive_max is not None:
|
|
139
|
-
max_key = "exclusiveMaximum"
|
|
140
|
-
max_val = exclusive_max
|
|
141
|
-
if exclusive_min is not None:
|
|
142
|
-
max_key = "exclusiveMinimum"
|
|
143
|
-
min_val = exclusive_min
|
|
144
234
|
if allow_ref:
|
|
145
235
|
return {
|
|
146
236
|
"anyOf": [
|
|
147
237
|
{
|
|
148
238
|
"type": "number",
|
|
149
|
-
max_key: max_val,
|
|
150
|
-
min_key: min_val
|
|
239
|
+
self.max_key: self.max_val,
|
|
240
|
+
self.min_key: self.min_val
|
|
151
241
|
},
|
|
152
242
|
{
|
|
153
243
|
"$ref": "#/$defs/ref_value"
|
|
@@ -157,14 +247,27 @@ class FloatValidator(IdfValidator):
|
|
|
157
247
|
else:
|
|
158
248
|
return {
|
|
159
249
|
"type": "number",
|
|
160
|
-
max_key: max_val,
|
|
161
|
-
min_key: min_val
|
|
250
|
+
self.max_key: self.max_val,
|
|
251
|
+
self.min_key: self.min_val
|
|
162
252
|
}
|
|
163
253
|
|
|
164
254
|
|
|
165
255
|
class FloatArrayValidator(FloatValidator):
|
|
166
|
-
def
|
|
167
|
-
|
|
256
|
+
def odf_validate(self):
|
|
257
|
+
func = ["validate_odf_as_double_v(doc, node, prop, error_list)"]
|
|
258
|
+
if self.exclusive_max is not None:
|
|
259
|
+
func.append(f"validate_odf_as_float_exclusive_max_v(doc, node, prop, {self.exclusive_max}, error_list)")
|
|
260
|
+
elif self.maximum != sys.float_info.max:
|
|
261
|
+
func.append(f"validate_odf_as_float_max_v(doc, node, prop, {self.maximum}, error_list)")
|
|
262
|
+
|
|
263
|
+
if self.exclusive_min is not None:
|
|
264
|
+
func.append(f"validate_odf_as_float_exclusive_min_v(doc, node, prop, {self.exclusive_min}, error_list)")
|
|
265
|
+
elif self.minimum != (-sys.float_info.max):
|
|
266
|
+
func.append(f"validate_odf_as_float_min_v(doc, node, prop, {self.minimum}, error_list)")
|
|
267
|
+
return func
|
|
268
|
+
|
|
269
|
+
def odf_schema(self, allow_ref):
|
|
270
|
+
parent_schema = super().odf_schema(False)
|
|
168
271
|
if allow_ref:
|
|
169
272
|
schema = {
|
|
170
273
|
"anyOf": [
|
|
@@ -191,32 +294,54 @@ class StringValidator(IdfValidator):
|
|
|
191
294
|
self.pattern = pattern
|
|
192
295
|
super().__init__()
|
|
193
296
|
|
|
194
|
-
def
|
|
195
|
-
pattern =
|
|
297
|
+
def set_validator(self, value):
|
|
298
|
+
self.pattern = self.validator.get("pattern", self.pattern)
|
|
299
|
+
super().set_validator(value)
|
|
300
|
+
|
|
301
|
+
def odf_validate(self):
|
|
302
|
+
func = []
|
|
303
|
+
if self.pattern is not None:
|
|
304
|
+
func.append(f"validate_odf_as_string(doc, node, prop, \"{self.pattern}\", error_list)")
|
|
305
|
+
else:
|
|
306
|
+
pattern = "^()|(((\\\\$)|[^$]).*)$"
|
|
307
|
+
func.append(f"validate_odf_as_string(doc, node, prop, \"{pattern}\", error_list)")
|
|
308
|
+
return func
|
|
309
|
+
|
|
310
|
+
def odf_schema(self, allow_ref):
|
|
196
311
|
if allow_ref:
|
|
197
312
|
schema = {
|
|
198
313
|
"anyOf": [
|
|
199
314
|
{
|
|
200
|
-
"type": "string"
|
|
315
|
+
"type": "string",
|
|
316
|
+
"pattern": "^()|(((\\\\$)|[^$]).*)$"
|
|
201
317
|
},
|
|
202
318
|
{
|
|
203
319
|
"$ref": "#/$defs/ref_value"
|
|
204
320
|
}
|
|
205
321
|
]
|
|
206
322
|
}
|
|
207
|
-
if pattern is not None:
|
|
208
|
-
schema["anyOf"][0]["pattern"] = pattern
|
|
323
|
+
if self.pattern is not None:
|
|
324
|
+
schema["anyOf"][0]["pattern"] = self.pattern
|
|
209
325
|
else:
|
|
210
326
|
schema = {
|
|
211
327
|
"type": "string",
|
|
212
|
-
"pattern": pattern
|
|
328
|
+
"pattern": self.pattern
|
|
213
329
|
}
|
|
214
330
|
return schema
|
|
215
331
|
|
|
216
332
|
|
|
217
333
|
class StringArrayValidator(StringValidator):
|
|
218
|
-
def
|
|
219
|
-
|
|
334
|
+
def odf_validate(self):
|
|
335
|
+
func = []
|
|
336
|
+
if self.pattern is not None:
|
|
337
|
+
func.append(f"validate_odf_as_string_v(doc, node, prop, \"{self.pattern}\", error_list)")
|
|
338
|
+
else:
|
|
339
|
+
pattern = "^()|(((\\\\$)|[^$]).*)$"
|
|
340
|
+
func.append(f"validate_odf_as_string_v(doc, node, prop, \"{pattern}\", error_list)")
|
|
341
|
+
return func
|
|
342
|
+
|
|
343
|
+
def odf_schema(self, allow_ref):
|
|
344
|
+
parent_schema = super().odf_schema(False)
|
|
220
345
|
if allow_ref:
|
|
221
346
|
schema = {
|
|
222
347
|
"anyOf": [
|
|
@@ -240,7 +365,11 @@ class RefObjValidator(IdfValidator):
|
|
|
240
365
|
def __init__(self):
|
|
241
366
|
super().__init__()
|
|
242
367
|
|
|
243
|
-
def
|
|
368
|
+
def odf_validate(self):
|
|
369
|
+
func = ["validate_odf_as_ref_obj(doc, node, prop, error_list)"]
|
|
370
|
+
return func
|
|
371
|
+
|
|
372
|
+
def odf_schema(self, allow_ref):
|
|
244
373
|
if allow_ref:
|
|
245
374
|
schema = {
|
|
246
375
|
"anyOf": [
|
|
@@ -260,7 +389,11 @@ class RefObjValidator(IdfValidator):
|
|
|
260
389
|
|
|
261
390
|
|
|
262
391
|
class RefObjArrayValidator(RefObjValidator):
|
|
263
|
-
def
|
|
392
|
+
def odf_validate(self):
|
|
393
|
+
func = ["validate_odf_as_ref_obj_v(doc, node, prop, error_list)"]
|
|
394
|
+
return func
|
|
395
|
+
|
|
396
|
+
def odf_schema(self, allow_ref):
|
|
264
397
|
if allow_ref:
|
|
265
398
|
schema = {
|
|
266
399
|
"anyOf": [
|
|
@@ -310,7 +443,7 @@ CTYPE_OBJS = {
|
|
|
310
443
|
[],
|
|
311
444
|
["<arg_out> = g_variant_new_int16(<arg_name>)"],
|
|
312
445
|
["<arg_in> = g_variant_get_int16(<arg_name>)"],
|
|
313
|
-
IntegerValidator(0x7fff, -(0x8000))
|
|
446
|
+
IntegerValidator(0x7fff, -(0x8000), True)
|
|
314
447
|
),
|
|
315
448
|
"uint16": CTypeBase(
|
|
316
449
|
["guint16 <arg_name>"],
|
|
@@ -324,7 +457,7 @@ CTYPE_OBJS = {
|
|
|
324
457
|
[],
|
|
325
458
|
["<arg_out> = g_variant_new_int32(<arg_name>)"],
|
|
326
459
|
["<arg_in> = g_variant_get_int32(<arg_name>)"],
|
|
327
|
-
IntegerValidator(0x7fff_ffff, -(0x8000_0000))
|
|
460
|
+
IntegerValidator(0x7fff_ffff, -(0x8000_0000), True)
|
|
328
461
|
),
|
|
329
462
|
"uint32": CTypeBase(
|
|
330
463
|
["guint32 <arg_name>"],
|
|
@@ -338,7 +471,7 @@ CTYPE_OBJS = {
|
|
|
338
471
|
[],
|
|
339
472
|
["<arg_out> = g_variant_new_int64(<arg_name>)"],
|
|
340
473
|
["<arg_in> = g_variant_get_int64(<arg_name>)"],
|
|
341
|
-
IntegerValidator(0x7fff_ffff_ffff_ffff, -(0x8000_0000_0000_0000))
|
|
474
|
+
IntegerValidator(0x7fff_ffff_ffff_ffff, -(0x8000_0000_0000_0000), True)
|
|
342
475
|
),
|
|
343
476
|
"uint64": CTypeBase(
|
|
344
477
|
["guint64 <arg_name>"],
|
|
@@ -359,7 +492,7 @@ CTYPE_OBJS = {
|
|
|
359
492
|
[],
|
|
360
493
|
["<arg_out> = g_variant_new_int64(<arg_name>)"],
|
|
361
494
|
["<arg_in> = g_variant_get_int64(<arg_name>)"],
|
|
362
|
-
IntegerValidator(0x7fff_ffff_ffff_ffff, -(0x8000_0000_0000_0000))
|
|
495
|
+
IntegerValidator(0x7fff_ffff_ffff_ffff, -(0x8000_0000_0000_0000), True)
|
|
363
496
|
),
|
|
364
497
|
"double": CTypeBase(
|
|
365
498
|
["gdouble <arg_name>"],
|
|
@@ -373,7 +506,7 @@ CTYPE_OBJS = {
|
|
|
373
506
|
[],
|
|
374
507
|
["<arg_out> = g_variant_new_handle(<arg_name>)"],
|
|
375
508
|
["<arg_in> = g_variant_get_handle(<arg_name>)"],
|
|
376
|
-
IntegerValidator(0x7fff_ffff_ffff_ffff, 0)
|
|
509
|
+
IntegerValidator(0x7fff_ffff_ffff_ffff, 0, True)
|
|
377
510
|
),
|
|
378
511
|
"string": CTypeBase(
|
|
379
512
|
["<const>gchar *<arg_name>"],
|
|
@@ -394,7 +527,7 @@ CTYPE_OBJS = {
|
|
|
394
527
|
["gcl_free_p((void **)&<arg_name>)"],
|
|
395
528
|
["<arg_out> = gcl_signature_encode(<arg_name>)"],
|
|
396
529
|
["<arg_in> = g_strdup(g_variant_get_string(<arg_name>, NULL))"],
|
|
397
|
-
StringValidator("^([abynqiuxtdsogv
|
|
530
|
+
StringValidator("^([abynqiuxtdsogv\\\\{\\\\}\\\\(\\\\)])+$")
|
|
398
531
|
),
|
|
399
532
|
"variant": CTypeBase(
|
|
400
533
|
["GVariant *<arg_name>"],
|
|
@@ -422,7 +555,7 @@ CTYPE_OBJS = {
|
|
|
422
555
|
["gcl_free_p((void **)&<arg_name>)"],
|
|
423
556
|
["<arg_out> = gcl_array_int16_encode(<arg_name>, n_<arg_name>)"],
|
|
424
557
|
["<arg_in> = gcl_array_int16_decode(<arg_name>, &n_<arg_in>)"],
|
|
425
|
-
IntegerArrayValidator(0x7fff, -(0x8000))
|
|
558
|
+
IntegerArrayValidator(0x7fff, -(0x8000), True)
|
|
426
559
|
),
|
|
427
560
|
"array[uint16]": CTypeBase(
|
|
428
561
|
["gsize n_<arg_name>" ,"<const>guint16 *<arg_name>"],
|
|
@@ -436,7 +569,7 @@ CTYPE_OBJS = {
|
|
|
436
569
|
["gcl_free_p((void **)&<arg_name>)"],
|
|
437
570
|
["<arg_out> = gcl_array_int32_encode(<arg_name>, n_<arg_name>)"],
|
|
438
571
|
["<arg_in> = gcl_array_int32_decode(<arg_name>, &n_<arg_in>)"],
|
|
439
|
-
IntegerArrayValidator(0x7fff_ffff, -(0x80000000))
|
|
572
|
+
IntegerArrayValidator(0x7fff_ffff, -(0x80000000), True)
|
|
440
573
|
),
|
|
441
574
|
"array[uint32]": CTypeBase(
|
|
442
575
|
["gsize n_<arg_name>" ,"<const>guint32 *<arg_name>"],
|
|
@@ -450,7 +583,7 @@ CTYPE_OBJS = {
|
|
|
450
583
|
["gcl_free_p((void **)&<arg_name>)"],
|
|
451
584
|
["<arg_out> = gcl_array_int64_encode(<arg_name>, n_<arg_name>)"],
|
|
452
585
|
["<arg_in> = gcl_array_int64_decode(<arg_name>, &n_<arg_in>)"],
|
|
453
|
-
IntegerArrayValidator(0x7fff_ffff_ffff_ffff, -(0x8000_0000_0000_0000))
|
|
586
|
+
IntegerArrayValidator(0x7fff_ffff_ffff_ffff, -(0x8000_0000_0000_0000), True)
|
|
454
587
|
),
|
|
455
588
|
"array[uint64]": CTypeBase(
|
|
456
589
|
["gsize n_<arg_name>" ,"<const>guint64 *<arg_name>"],
|
|
@@ -464,14 +597,14 @@ CTYPE_OBJS = {
|
|
|
464
597
|
["gcl_free_p((void **)&<arg_name>)"],
|
|
465
598
|
["<arg_out> = gcl_array_int64_encode(<arg_name>, n_<arg_name>)"],
|
|
466
599
|
["<arg_in> = gcl_array_int64_decode(<arg_name>, &n_<arg_in>)"],
|
|
467
|
-
IntegerArrayValidator(
|
|
600
|
+
IntegerArrayValidator(0x7fff_ffff_ffff_ffff, -(0x8000_0000_0000_0000), True)
|
|
468
601
|
),
|
|
469
602
|
"array[size]": CTypeBase(
|
|
470
603
|
["gsize n_<arg_name>" ,"<const>gsize *<arg_name>"],
|
|
471
604
|
["gcl_free_p((void **)&<arg_name>)"],
|
|
472
605
|
["<arg_out> = gcl_array_uint64_encode(<arg_name>, n_<arg_name>)"],
|
|
473
606
|
["<arg_in> = gcl_array_uint64_decode(<arg_name>, &n_<arg_in>)"],
|
|
474
|
-
IntegerArrayValidator(
|
|
607
|
+
IntegerArrayValidator(0xffff_ffff_ffff_ffff, 0)
|
|
475
608
|
),
|
|
476
609
|
"array[double]": CTypeBase(
|
|
477
610
|
["gsize n_<arg_name>" ,"<const>gdouble *<arg_name>"],
|
|
@@ -485,27 +618,27 @@ CTYPE_OBJS = {
|
|
|
485
618
|
["gcl_free_p((void **)&<arg_name>)"],
|
|
486
619
|
["<arg_out> = gcl_array_handle_encode(<arg_name>, n_<arg_name>)"],
|
|
487
620
|
["<arg_in> = gcl_array_handle_decode(<arg_name>, &n_<arg_in>)"],
|
|
488
|
-
IntegerArrayValidator(0x7fff_ffff_ffff_ffff, 0)
|
|
621
|
+
IntegerArrayValidator(0x7fff_ffff_ffff_ffff, 0, True)
|
|
489
622
|
),
|
|
490
623
|
"array[string]": CTypeBase(
|
|
491
|
-
["gchar
|
|
624
|
+
["gchar *<const>*<arg_name>"],
|
|
492
625
|
["gcl_strfreev_p(&<arg_name>)"],
|
|
493
626
|
["<arg_out> = gcl_array_string_encode(<arg_name>)"],
|
|
494
627
|
["<arg_in> = gcl_array_string_decode(<arg_name>)"],
|
|
495
628
|
StringArrayValidator("^.*$")
|
|
496
629
|
),
|
|
497
630
|
"array[object_path]": CTypeBase(
|
|
498
|
-
["gchar
|
|
631
|
+
["gchar *<const>*<arg_name>"],
|
|
499
632
|
["gcl_strfreev_p(&<arg_name>)"],
|
|
500
633
|
["<arg_out> = gcl_array_object_path_encode(<arg_name>)"],
|
|
501
634
|
["<arg_in> = gcl_array_object_path_decode(<arg_name>)"],
|
|
502
635
|
StringArrayValidator("^(/[A-Z0-9a-z_]+)*$")
|
|
503
636
|
),
|
|
504
637
|
"array[signature]": CTypeBase(
|
|
505
|
-
["gchar
|
|
638
|
+
["gchar *<const>*<arg_name>"],
|
|
506
639
|
["gcl_strfreev_p(&<arg_name>)"],
|
|
507
640
|
["<arg_out> = gcl_array_signature_encode(<arg_name>)"],
|
|
508
641
|
["<arg_in> = gcl_array_signature_decode(<arg_name>)"],
|
|
509
|
-
StringArrayValidator("^([abynqiuxtdsogv
|
|
642
|
+
StringArrayValidator("^([abynqiuxtdsogv\\\\{\\\\}\\\\(\\\\)])+$")
|
|
510
643
|
)
|
|
511
644
|
}
|
|
@@ -12,6 +12,8 @@ log = Logger("gen_interface")
|
|
|
12
12
|
class IDFException(Exception):
|
|
13
13
|
pass
|
|
14
14
|
|
|
15
|
+
class IdfInterfacePlugin(Renderer):
|
|
16
|
+
actions = []
|
|
15
17
|
|
|
16
18
|
class IdfInterfaceBase(Renderer):
|
|
17
19
|
def __init__(self) -> None:
|
|
@@ -24,6 +26,7 @@ class IdfInterfaceBase(Renderer):
|
|
|
24
26
|
self.dictionaries = {}
|
|
25
27
|
self.enumerations = {}
|
|
26
28
|
self.annotations = []
|
|
29
|
+
self.plugin: IdfInterfacePlugin = None
|
|
27
30
|
self.description = None
|
|
28
31
|
self.version = None
|
|
29
32
|
self.alias = None
|
|
@@ -135,6 +138,39 @@ class IdfCtypeRender():
|
|
|
135
138
|
if match:
|
|
136
139
|
self.ctype = f"array[enum[{match.group(1)}]]"
|
|
137
140
|
|
|
141
|
+
def odf_validate(self, allow_ref):
|
|
142
|
+
log.debug(f"Get odf validate info, name: {self.name}, ctype: {self.ctype}")
|
|
143
|
+
if "variant" == self.ctype:
|
|
144
|
+
return []
|
|
145
|
+
match = re.match(f"^array\[({CTYPE_BASE_REG})\]$", self.ctype)
|
|
146
|
+
if match:
|
|
147
|
+
if "refobj" in self.flags:
|
|
148
|
+
valiator = RefObjArrayValidator()
|
|
149
|
+
return valiator.odf_validate()
|
|
150
|
+
ctype_obj = CTYPE_OBJS.get(self.ctype)
|
|
151
|
+
return ctype_obj.validator.odf_validate()
|
|
152
|
+
match = re.match(f"^({CTYPE_BASE_REG})$", self.ctype)
|
|
153
|
+
if match:
|
|
154
|
+
if "refobj" in self.flags:
|
|
155
|
+
valiator = RefObjValidator()
|
|
156
|
+
return valiator.odf_validate()
|
|
157
|
+
ctype_obj = CTYPE_OBJS.get(self.ctype)
|
|
158
|
+
return ctype_obj.validator.odf_validate()
|
|
159
|
+
# 非基础类型
|
|
160
|
+
is_array = False
|
|
161
|
+
ctype = self.ctype
|
|
162
|
+
match = re.match(f"^array\[(.*)\]$", ctype)
|
|
163
|
+
if match:
|
|
164
|
+
is_array = True
|
|
165
|
+
ctype = match.group(1)
|
|
166
|
+
match = re.match(f"^(struct|enum|dict)\[(.*)\]$", ctype)
|
|
167
|
+
_, stru_name = get_intfname_and_ctype(match.group(2))
|
|
168
|
+
if is_array:
|
|
169
|
+
return [f"_validate_odf_as_{match.group(1)}_{stru_name}_v(doc, node, prop, error_list)"]
|
|
170
|
+
else:
|
|
171
|
+
return [f"_validate_odf_as_{match.group(1)}_{stru_name}(doc, node, prop, error_list)"]
|
|
172
|
+
|
|
173
|
+
|
|
138
174
|
def odf_schema(self, allow_ref):
|
|
139
175
|
log.debug(f"Get odf schema info, name: {self.name}, ctype: {self.ctype}")
|
|
140
176
|
if "variant" == self.ctype:
|
|
@@ -143,16 +179,16 @@ class IdfCtypeRender():
|
|
|
143
179
|
if match:
|
|
144
180
|
if "refobj" in self.flags:
|
|
145
181
|
valiator = RefObjArrayValidator()
|
|
146
|
-
return valiator.odf_schema(allow_ref
|
|
182
|
+
return valiator.odf_schema(allow_ref)
|
|
147
183
|
ctype_obj = CTYPE_OBJS.get(self.ctype)
|
|
148
|
-
return ctype_obj.validator.odf_schema(allow_ref
|
|
184
|
+
return ctype_obj.validator.odf_schema(allow_ref)
|
|
149
185
|
match = re.match(f"^({CTYPE_BASE_REG})$", self.ctype)
|
|
150
186
|
if match:
|
|
151
187
|
if "refobj" in self.flags:
|
|
152
188
|
valiator = RefObjValidator()
|
|
153
|
-
return valiator.odf_schema(allow_ref
|
|
189
|
+
return valiator.odf_schema(allow_ref)
|
|
154
190
|
ctype_obj = CTYPE_OBJS.get(self.ctype)
|
|
155
|
-
return ctype_obj.validator.odf_schema(allow_ref
|
|
191
|
+
return ctype_obj.validator.odf_schema(allow_ref)
|
|
156
192
|
# 非基础类型
|
|
157
193
|
is_array = False
|
|
158
194
|
ctype = self.ctype
|
|
@@ -231,7 +267,7 @@ class IdfCtypeRender():
|
|
|
231
267
|
if match.group(1) == "struct":
|
|
232
268
|
if is_array:
|
|
233
269
|
# 结构体数组初始化时为二级空指针,以空指针结束
|
|
234
|
-
return [f"{stru_name}
|
|
270
|
+
return [f"{stru_name} *<const>*<arg_name>"]
|
|
235
271
|
else:
|
|
236
272
|
# 结构体成员初始化时为空结构体,由反序列化时填充内容
|
|
237
273
|
return [f"<const>{stru_name} *<arg_name>"]
|
|
@@ -482,6 +518,7 @@ class IdfBase():
|
|
|
482
518
|
|
|
483
519
|
|
|
484
520
|
class IdfMethod(IdfBase):
|
|
521
|
+
is_plugin = False
|
|
485
522
|
def __init__(self, intf: IdfInterfaceBase, method_data):
|
|
486
523
|
super().__init__(intf, method_data)
|
|
487
524
|
self.parameters: IdfParameters = IdfParameters(intf, method_data.get("parameters", []))
|
|
@@ -529,6 +566,15 @@ class IdfStructure(IdfBase):
|
|
|
529
566
|
}
|
|
530
567
|
return odf
|
|
531
568
|
|
|
569
|
+
|
|
570
|
+
class IdfPluginAction(IdfMethod):
|
|
571
|
+
is_plugin = True
|
|
572
|
+
|
|
573
|
+
def __init__(self, intf: IdfInterfaceBase, method_data):
|
|
574
|
+
self.policy = method_data.get("policy", "continue_always")
|
|
575
|
+
super().__init__(intf, method_data)
|
|
576
|
+
|
|
577
|
+
|
|
532
578
|
class IdfEnumeration(IdfBase):
|
|
533
579
|
def __init__(self, intf: IdfInterfaceBase, enum_data):
|
|
534
580
|
super().__init__(intf, enum_data)
|
|
@@ -652,6 +698,7 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
652
698
|
self.dictionaries: dict[str, IdfDictionary] = {}
|
|
653
699
|
self.enumerations: dict[str, IdfEnumeration] = {}
|
|
654
700
|
self.annotations: list[IdfAnnotation] = []
|
|
701
|
+
self.plugin: IdfInterfacePlugin = IdfInterfacePlugin()
|
|
655
702
|
self.description = None
|
|
656
703
|
self.version = None
|
|
657
704
|
self.alias = None
|
|
@@ -721,6 +768,15 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
721
768
|
}
|
|
722
769
|
return odf
|
|
723
770
|
|
|
771
|
+
@property
|
|
772
|
+
def fake_methods(self):
|
|
773
|
+
methods = []
|
|
774
|
+
for method in self.methods:
|
|
775
|
+
methods.append(method)
|
|
776
|
+
for action in self.plugin.actions:
|
|
777
|
+
methods.append(action)
|
|
778
|
+
return methods
|
|
779
|
+
|
|
724
780
|
def load_elements(self):
|
|
725
781
|
# 使用schema校验数据,确保IDF文件符合格式要求,减少程序处理过程中的异常处理
|
|
726
782
|
# 验证失败时抛异常,此处不用处理,由外层处理
|
|
@@ -759,6 +815,12 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
759
815
|
for item in items:
|
|
760
816
|
obj = IdfEnumeration(self, item)
|
|
761
817
|
self.enumerations[obj.name] = obj
|
|
818
|
+
plugin = idf.get("plugin", None)
|
|
819
|
+
if plugin is not None:
|
|
820
|
+
items = plugin.get("actions", [])
|
|
821
|
+
for item in items:
|
|
822
|
+
obj = IdfPluginAction(self, item)
|
|
823
|
+
self.plugin.actions.append(obj)
|
|
762
824
|
log.debug("interface signature: " + self.signature)
|
|
763
825
|
for signal in self.signals:
|
|
764
826
|
log.debug(f"{signal.name} signature: " + signal.signature)
|
|
@@ -45,6 +45,14 @@ gint ${class_name}_get_${prop.name}(const ${class_name} *object, GVariant **valu
|
|
|
45
45
|
% endfor
|
|
46
46
|
|
|
47
47
|
% for method in intf.methods:
|
|
48
|
+
<% RSP_PARA = f'' %>\
|
|
49
|
+
<% REQ_PARA = f'' %>\
|
|
50
|
+
% if len(method.returns.parameters) > 0:
|
|
51
|
+
<% RSP_PARA = f'{intf.alias}_{method.name}_Rsp **rsp, ' %>\
|
|
52
|
+
% endif
|
|
53
|
+
% if len(method.parameters.parameters) > 0:
|
|
54
|
+
<% REQ_PARA = f'const {intf.alias}_{method.name}_Req *req, ' %>\
|
|
55
|
+
% endif
|
|
48
56
|
/*
|
|
49
57
|
* ${method.description}
|
|
50
58
|
*
|
|
@@ -56,8 +64,9 @@ gint ${class_name}_get_${prop.name}(const ${class_name} *object, GVariant **valu
|
|
|
56
64
|
* @out_${arg.name}: ${arg.description}, signature: ${arg.signature}
|
|
57
65
|
% endfor
|
|
58
66
|
*/
|
|
59
|
-
int ${class_name}_Call_${method.name}(const ${class_name} *object,
|
|
60
|
-
${
|
|
67
|
+
int ${class_name}_Call_${method.name}(const ${class_name} *object,
|
|
68
|
+
${REQ_PARA}${RSP_PARA}gint timeout,
|
|
69
|
+
GError **error)
|
|
61
70
|
{
|
|
62
71
|
if (error == NULL) {
|
|
63
72
|
log_error("Emit method ${method.name} with parameter error, error is NULL");
|
|
@@ -67,6 +76,12 @@ int ${class_name}_Call_${method.name}(const ${class_name} *object, const ${intf.
|
|
|
67
76
|
*error = g_error_new(G_DBUS_ERROR, G_DBUS_ERROR_FAILED, "Call method ${method.name} with parameter error, object is NULL");
|
|
68
77
|
return -1;
|
|
69
78
|
}
|
|
79
|
+
% if len(method.returns.parameters) == 0:
|
|
80
|
+
void **rsp = NULL;
|
|
81
|
+
% endif
|
|
82
|
+
% if len(method.parameters.parameters) == 0:
|
|
83
|
+
void *req = NULL;
|
|
84
|
+
% endif
|
|
70
85
|
return gcl_impl.call_method((GclObject *)object, (const GclMethod *)&${method_processer}->${method.name},
|
|
71
86
|
(void *)req, (void **)rsp, timeout, error);
|
|
72
87
|
}
|