lbkit 0.8.9__tar.gz → 0.9.1__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.8.9/lbkit.egg-info → lbkit-0.9.1}/PKG-INFO +1 -1
- lbkit-0.9.1/lbkit/__init__.py +2 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/codegen.py +7 -8
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/idf_interface.py +52 -35
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/template/client.c.mako +8 -11
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/template/client.h.mako +1 -18
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/template/public.c.mako +21 -82
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/template/public.h.mako +7 -23
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/template/server.c.mako +19 -21
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/template/server.h.mako +1 -12
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/component/build.py +1 -1
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/component/template/deploy.mako +0 -2
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/component/test.py +73 -2
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/image_maker/make_qemu_image.py +2 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/utils/images/emmc.py +4 -4
- {lbkit-0.8.9 → lbkit-0.9.1/lbkit.egg-info}/PKG-INFO +1 -1
- {lbkit-0.8.9 → lbkit-0.9.1}/test/test_codegen.py +16 -16
- lbkit-0.8.9/lbkit/__init__.py +0 -2
- {lbkit-0.8.9 → lbkit-0.9.1}/AUTHORS +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/LICENSE +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/MANIFEST.in +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/README.md +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/build_conan_parallel.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/ci_robot/__init__.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/ci_robot/gitee.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/cli.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/__init__.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/ctype_defination.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/renderer.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/template/interface.c.mako +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/codegen/template/interface.introspect.xml.mako +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/component/__init__.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/component/arg_parser.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/component/template/conanbase.mako +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/errors.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/helper.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/lbkit.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/log.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/misc.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/__init__.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/config.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/executor.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/image_maker/__init__.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/image_maker/make_image.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/image_maker/make_rockchip_image.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/task.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/task_build_image.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/task_build_manifest.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/task_build_prepare.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/task_build_rootfs.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/task_download.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/template/conanfile.py.mako +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tasks/template/rootfs.py.mako +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/tools.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/ukr/__init__.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/ukr/build.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/utils/__init__.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/utils/env_detector.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit/utils/images/__init__.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit.egg-info/SOURCES.txt +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit.egg-info/dependency_links.txt +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit.egg-info/entry_points.txt +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit.egg-info/requires.txt +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/lbkit.egg-info/top_level.txt +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/setup.cfg +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/setup.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/test/__init__.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/test/test_config.py +0 -0
- {lbkit-0.8.9 → lbkit-0.9.1}/test/test_helper.py +0 -0
|
@@ -64,12 +64,10 @@ class Version():
|
|
|
64
64
|
# 历史自动生成版本号,计划用于用于生成代码稳定性测试
|
|
65
65
|
# TODO: 支持生成代码稳定性测试,确保生成的代码一致性
|
|
66
66
|
history_versions = {
|
|
67
|
-
"5.0": CodeGenHistory("lb_base/[>=0.8.1 <0.9.0]", "简化接口类名定义;简化枚举变量在接口间传递时的字符串定义", "0"),
|
|
68
|
-
"5.1": CodeGenHistory("lb_base/[>=0.8.3 <0.9.0]", "方法和信号添加保留字段用于功能扩展,同时设置请求和响应为空标志位", "8002"),
|
|
69
|
-
"5.2": CodeGenHistory("lb_base/[>=0.8.4 <0.9.0]", "支持校验数值边界、字符串正则以及数组匹配等规则", "8004"),
|
|
70
67
|
"5.3": CodeGenHistory("lb_base/[>=0.8.5 <0.9.0]", "支持32位操作系统", "8004"),
|
|
68
|
+
"5.4": CodeGenHistory("lb_base/[>=0.9.0 <0.10.0]", "LBInterface增加alias", "9000"),
|
|
71
69
|
}
|
|
72
|
-
__version__=Version("5.
|
|
70
|
+
__version__=Version("5.4")
|
|
73
71
|
|
|
74
72
|
|
|
75
73
|
def version_check(ver_str: str):
|
|
@@ -119,13 +117,13 @@ class CodeGen(object):
|
|
|
119
117
|
os.makedirs(os.path.join(directory, ct), exist_ok=True)
|
|
120
118
|
out_file = os.path.join(directory, ct, interface.name + ".xml")
|
|
121
119
|
interface.render_dbus_xml("interface.introspect.xml.mako", out_file)
|
|
122
|
-
out_file = os.path.join(directory, ct, interface.
|
|
120
|
+
out_file = os.path.join(directory, ct, interface.alias + ".h")
|
|
123
121
|
interface.render_c_source(ct + ".h.mako", out_file)
|
|
124
|
-
out_file = os.path.join(directory, ct, interface.
|
|
122
|
+
out_file = os.path.join(directory, ct, interface.alias + ".c")
|
|
125
123
|
interface.render_c_source(ct + ".c.mako", out_file)
|
|
126
124
|
if "server" == ct:
|
|
127
125
|
# 生成接口schema文件
|
|
128
|
-
odf_file = os.path.join(directory, "server", "schema", f"{interface.
|
|
126
|
+
odf_file = os.path.join(directory, "server", "schema", f"{interface.alias}.json")
|
|
129
127
|
os.makedirs(os.path.dirname(odf_file), exist_ok=True)
|
|
130
128
|
odf_data = interface.odf_schema
|
|
131
129
|
with open(odf_file, "w", encoding="utf-8") as fp:
|
|
@@ -133,7 +131,8 @@ class CodeGen(object):
|
|
|
133
131
|
json_file = os.path.join(directory, "package.yml")
|
|
134
132
|
data = {
|
|
135
133
|
"version": interface.version,
|
|
136
|
-
"name": interface.name
|
|
134
|
+
"name": interface.name,
|
|
135
|
+
"alias": interface.alias
|
|
137
136
|
}
|
|
138
137
|
with open(json_file, "w", encoding="utf-8") as fp:
|
|
139
138
|
yaml.dump(data, fp, encoding='utf-8', allow_unicode=True)
|
|
@@ -7,11 +7,12 @@ from functools import cached_property
|
|
|
7
7
|
from lbkit.log import Logger
|
|
8
8
|
from lbkit.codegen.renderer import Renderer
|
|
9
9
|
from lbkit.codegen.ctype_defination import CTYPE_OBJS, RefObjArrayValidator, RefObjValidator
|
|
10
|
-
from lbkit.misc import load_yml_with_json_schema_validate
|
|
10
|
+
from lbkit.misc import load_yml_with_json_schema_validate, get_json_schema_file
|
|
11
11
|
from lbkit.errors import OdfValidateException, LiteBmcException
|
|
12
12
|
from lbkit.helper import SigInvalidException, validate_glib_signature
|
|
13
13
|
|
|
14
14
|
log = Logger("gen_interface")
|
|
15
|
+
alias = None
|
|
15
16
|
|
|
16
17
|
class IDFException(Exception):
|
|
17
18
|
pass
|
|
@@ -37,6 +38,8 @@ class IdfInterfaceBase(Renderer):
|
|
|
37
38
|
self.description = None
|
|
38
39
|
self.version = None
|
|
39
40
|
self.alias = None
|
|
41
|
+
self.name = None
|
|
42
|
+
self.object_path = None
|
|
40
43
|
self.codegen_version = None
|
|
41
44
|
|
|
42
45
|
class IdfAnnotation():
|
|
@@ -120,9 +123,13 @@ CTYPE_SIGNATURE_MAP = {
|
|
|
120
123
|
None: "s"
|
|
121
124
|
}
|
|
122
125
|
|
|
123
|
-
def get_intfname_and_ctype(ctype):
|
|
126
|
+
def get_intfname_and_ctype(class_alias: str, ctype: str):
|
|
124
127
|
match = re.findall(r"([\w][\w\d]*)", ctype)
|
|
125
|
-
|
|
128
|
+
intf = ".".join(match[:-1])
|
|
129
|
+
ctype = match[-1]
|
|
130
|
+
if intf == "self":
|
|
131
|
+
return class_alias, class_alias + "_" + ctype
|
|
132
|
+
return intf, intf + "_" + ctype
|
|
126
133
|
|
|
127
134
|
def ctype_to_variant_signature(intf: IdfInterfaceBase, ctype: str):
|
|
128
135
|
sig_prefix = ""
|
|
@@ -135,8 +142,8 @@ def ctype_to_variant_signature(intf: IdfInterfaceBase, ctype: str):
|
|
|
135
142
|
return sig_prefix + CTYPE_SIGNATURE_MAP.get(ctype)
|
|
136
143
|
match = re.match(f"^(struct|enum|dict)\[(.*)\]$", ctype)
|
|
137
144
|
|
|
138
|
-
match_intf, match_ctype = get_intfname_and_ctype(match.group(2))
|
|
139
|
-
if match_intf !=
|
|
145
|
+
match_intf, match_ctype = get_intfname_and_ctype(intf.alias, match.group(2))
|
|
146
|
+
if match_intf != intf.alias:
|
|
140
147
|
intf = intf.dependency_idf_interface[match_intf]
|
|
141
148
|
if match.group(1) == "struct":
|
|
142
149
|
stru = intf.structures.get(match_ctype)
|
|
@@ -151,7 +158,7 @@ def ctype_to_variant_signature(intf: IdfInterfaceBase, ctype: str):
|
|
|
151
158
|
raise IDFException(f"Unknown structure {match_ctype} get")
|
|
152
159
|
return sig_prefix + dictionary.signature
|
|
153
160
|
|
|
154
|
-
def ctype_to_dependency_interface(ctype: str):
|
|
161
|
+
def ctype_to_dependency_interface(class_alias: str, ctype: str):
|
|
155
162
|
match = re.match(f"^array\[(.*)\]$", ctype)
|
|
156
163
|
if match is not None:
|
|
157
164
|
ctype = match.group(1)
|
|
@@ -160,8 +167,8 @@ def ctype_to_dependency_interface(ctype: str):
|
|
|
160
167
|
return []
|
|
161
168
|
match = re.match(f"^(struct|enum|dict)\[(.*)\]$", ctype)
|
|
162
169
|
|
|
163
|
-
match_intf, _ = get_intfname_and_ctype(match.group(2))
|
|
164
|
-
if match_intf ==
|
|
170
|
+
match_intf, _ = get_intfname_and_ctype(class_alias, match.group(2))
|
|
171
|
+
if match_intf == class_alias:
|
|
165
172
|
return []
|
|
166
173
|
return [match_intf]
|
|
167
174
|
|
|
@@ -214,7 +221,7 @@ class IdfCtypeRender():
|
|
|
214
221
|
is_array = True
|
|
215
222
|
ctype = match.group(1)
|
|
216
223
|
match = re.match(f"^(struct|enum|dict)\[(.*)\]$", ctype)
|
|
217
|
-
_, stru_name = get_intfname_and_ctype(match.group(2))
|
|
224
|
+
_, stru_name = get_intfname_and_ctype(self.intf.alias, match.group(2))
|
|
218
225
|
if is_array:
|
|
219
226
|
return [f"{stru_name}_validate_odf_v(doc, node, prop, error_list)"]
|
|
220
227
|
else:
|
|
@@ -304,8 +311,8 @@ class IdfCtypeRender():
|
|
|
304
311
|
is_array = True
|
|
305
312
|
ctype = match.group(1)
|
|
306
313
|
match = re.match(f"^(struct|enum|dict)\[(.*)\]$", ctype)
|
|
307
|
-
intf_name, stru_name = get_intfname_and_ctype(match.group(2))
|
|
308
|
-
if intf_name ==
|
|
314
|
+
intf_name, stru_name = get_intfname_and_ctype(self.intf.alias, match.group(2))
|
|
315
|
+
if intf_name == self.intf.alias:
|
|
309
316
|
intf = self.intf
|
|
310
317
|
else:
|
|
311
318
|
intf = self.intf.dependency_idf_interface[intf_name]
|
|
@@ -374,7 +381,7 @@ class IdfCtypeRender():
|
|
|
374
381
|
is_array = True
|
|
375
382
|
ctype = match.group(1)
|
|
376
383
|
match = re.match(f"^(struct|enum|dict)\[(.*)\]$", ctype)
|
|
377
|
-
_, stru_name = get_intfname_and_ctype(match.group(2))
|
|
384
|
+
_, stru_name = get_intfname_and_ctype(self.intf.alias, match.group(2))
|
|
378
385
|
if match.group(1) == "struct":
|
|
379
386
|
if is_array:
|
|
380
387
|
# 结构体数组初始化时为二级空指针,以空指针结束
|
|
@@ -414,7 +421,7 @@ class IdfCtypeRender():
|
|
|
414
421
|
is_array = True
|
|
415
422
|
ctype = match.group(1)
|
|
416
423
|
match = re.match(f"^(struct|enum|dict)\[(.*)\]$", ctype)
|
|
417
|
-
_, stru_name = get_intfname_and_ctype(match.group(2))
|
|
424
|
+
_, stru_name = get_intfname_and_ctype(self.intf.alias, match.group(2))
|
|
418
425
|
if match.group(1) == "struct":
|
|
419
426
|
if is_array:
|
|
420
427
|
# 结构体数组初始化时为二级空指针,以空指针结束
|
|
@@ -454,7 +461,7 @@ class IdfCtypeRender():
|
|
|
454
461
|
is_array = True
|
|
455
462
|
ctype = match.group(1)
|
|
456
463
|
match = re.match(f"^(struct|enum|dict)\[(.*)\]$", ctype)
|
|
457
|
-
_, stru_name = get_intfname_and_ctype(match.group(2))
|
|
464
|
+
_, stru_name = get_intfname_and_ctype(self.intf.alias, match.group(2))
|
|
458
465
|
if match.group(1) == "enum":
|
|
459
466
|
if is_array:
|
|
460
467
|
return [f"lb_free_p((void **)&<arg_name>)"]
|
|
@@ -483,7 +490,7 @@ class IdfCtypeRender():
|
|
|
483
490
|
is_array = True
|
|
484
491
|
ctype = match.group(1)
|
|
485
492
|
match = re.match(f"^(struct|enum|dict)\[(.*)\]$", ctype)
|
|
486
|
-
_, stru_name = get_intfname_and_ctype(match.group(2))
|
|
493
|
+
_, stru_name = get_intfname_and_ctype(self.intf.alias, match.group(2))
|
|
487
494
|
if match.group(1) == "enum":
|
|
488
495
|
if is_array:
|
|
489
496
|
# 入参为二级指针
|
|
@@ -516,7 +523,7 @@ class IdfCtypeRender():
|
|
|
516
523
|
is_array = True
|
|
517
524
|
ctype = match.group(1)
|
|
518
525
|
match = re.match(f"^(struct|enum|dict)\[(.*)\]$", ctype)
|
|
519
|
-
_, stru_name = get_intfname_and_ctype(match.group(2))
|
|
526
|
+
_, stru_name = get_intfname_and_ctype(self.intf.alias, match.group(2))
|
|
520
527
|
if match.group(1) == "enum":
|
|
521
528
|
if is_array:
|
|
522
529
|
# 入参为二级指针
|
|
@@ -596,7 +603,7 @@ class IdfCtypeRender():
|
|
|
596
603
|
is_array = True
|
|
597
604
|
ctype = match.group(1)
|
|
598
605
|
match = re.match(f"^(struct|enum|dict)\[(.*)\]$", ctype)
|
|
599
|
-
_, stru_name = get_intfname_and_ctype(match.group(2))
|
|
606
|
+
_, stru_name = get_intfname_and_ctype(self.intf.alias, match.group(2))
|
|
600
607
|
if match.group(1) == "enum":
|
|
601
608
|
if is_array:
|
|
602
609
|
# 入参为二级指针
|
|
@@ -835,7 +842,7 @@ class IdfProperty(IdfCtypeRender):
|
|
|
835
842
|
|
|
836
843
|
@cached_property
|
|
837
844
|
def dependency_interface(self):
|
|
838
|
-
return ctype_to_dependency_interface(self.ctype)
|
|
845
|
+
return ctype_to_dependency_interface(self.intf.alias, self.ctype)
|
|
839
846
|
|
|
840
847
|
|
|
841
848
|
class IdfParameter(IdfCtypeRender):
|
|
@@ -853,7 +860,7 @@ class IdfParameter(IdfCtypeRender):
|
|
|
853
860
|
|
|
854
861
|
@cached_property
|
|
855
862
|
def dependency_interface(self):
|
|
856
|
-
return ctype_to_dependency_interface(self.ctype)
|
|
863
|
+
return ctype_to_dependency_interface(self.intf.alias, self.ctype)
|
|
857
864
|
|
|
858
865
|
|
|
859
866
|
class IdfParameters():
|
|
@@ -994,10 +1001,7 @@ class IdfEnumeration(IdfBase):
|
|
|
994
1001
|
def odf_schema(self):
|
|
995
1002
|
values = []
|
|
996
1003
|
for prop in self.values.parameters:
|
|
997
|
-
|
|
998
|
-
val = self.intf.name + "." + self.name + "." + prop.name
|
|
999
|
-
else:
|
|
1000
|
-
val = prop.name
|
|
1004
|
+
val = prop.name
|
|
1001
1005
|
values.append(val)
|
|
1002
1006
|
|
|
1003
1007
|
odf = {
|
|
@@ -1104,7 +1108,6 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
1104
1108
|
super().__init__()
|
|
1105
1109
|
self.lookup = lookup
|
|
1106
1110
|
self.file = idf_file
|
|
1107
|
-
self.name = os.path.basename(idf_file)[:-5]
|
|
1108
1111
|
self.properties: list[IdfProperty] = []
|
|
1109
1112
|
self.methods: list[IdfMethod] = []
|
|
1110
1113
|
self.signals: list[IdfSignal] = []
|
|
@@ -1127,7 +1130,7 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
1127
1130
|
deps: dict[str, IdfInterface] = {}
|
|
1128
1131
|
intfs = self.dependency_interface
|
|
1129
1132
|
for intf in intfs:
|
|
1130
|
-
intf_path = intf
|
|
1133
|
+
intf_path = intf + ".yaml"
|
|
1131
1134
|
cwd = os.getcwd()
|
|
1132
1135
|
realpath = None
|
|
1133
1136
|
while cwd != "/":
|
|
@@ -1205,13 +1208,13 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
1205
1208
|
odf["$defs"] = {
|
|
1206
1209
|
"ref_value": {
|
|
1207
1210
|
"type": "string",
|
|
1208
|
-
"description": "Property reference syntax. The format must be `\\$\\{([<]*|:)<
|
|
1209
|
-
"pattern": "^\\$\\{([<]*|:)
|
|
1211
|
+
"description": "Property reference syntax. The format must be `\\$\\{([<]*|:)<object>.<property name>\\}`, for example: Test_Obj.Prop",
|
|
1212
|
+
"pattern": "^\\$\\{([<]*|:)\\.?[a-zA-Z][a-z0-9A-Z]+_[a-zA-Z0-9][a-z0-9A-Z_]*\\.[a-zA-Z][A-Za-z0-9_-]*\\}$"
|
|
1210
1213
|
},
|
|
1211
1214
|
"ref_obj": {
|
|
1212
1215
|
"type": "string",
|
|
1213
|
-
"description": "Property reference syntax. The format must be `\\$\\{([<]*|:)<
|
|
1214
|
-
"pattern": "^\\$\\{([<]*|:)
|
|
1216
|
+
"description": "Property reference syntax. The format must be `\\$\\{([<]*|:)<object>.<property name>\\}`, for example: Test_Obj",
|
|
1217
|
+
"pattern": "^\\$\\{([<]*|:)\\.?[a-zA-Z][a-z0-9A-Z]+_[a-zA-Z0-9][a-z0-9A-Z_]*\\}$"
|
|
1215
1218
|
},
|
|
1216
1219
|
"ref_obj_array": {
|
|
1217
1220
|
"type": "array",
|
|
@@ -1220,13 +1223,13 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
1220
1223
|
"anyOf": [
|
|
1221
1224
|
{
|
|
1222
1225
|
"type": "string",
|
|
1223
|
-
"description": "Object reference syntax. The format must be `\\$\\{([<]*|:)<
|
|
1224
|
-
"pattern": "^\\$\\{([<]*|:)
|
|
1226
|
+
"description": "Object reference syntax. The format must be `\\$\\{([<]*|:)<object>\\}`, for example: Test_Obj",
|
|
1227
|
+
"pattern": "^\\$\\{([<]*|:)\\.?[a-zA-Z][a-z0-9A-Z]+_[a-zA-Z0-9][a-z0-9A-Z_]*\\}$"
|
|
1225
1228
|
},
|
|
1226
1229
|
{
|
|
1227
1230
|
"type": "string",
|
|
1228
1231
|
"description": "Plain string format, if the string start with `$` must add `\\` before `$` to escape; If the string is empty it must be surrounded by `\"`",
|
|
1229
|
-
"pattern": "
|
|
1232
|
+
"pattern": "^/?[A-Z0-9a-z_]+(/[A-Z0-9a-z_]+)*$"
|
|
1230
1233
|
}
|
|
1231
1234
|
]
|
|
1232
1235
|
}
|
|
@@ -1246,12 +1249,23 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
1246
1249
|
def load_elements(self):
|
|
1247
1250
|
# 使用schema校验数据,确保IDF文件符合格式要求,减少程序处理过程中的异常处理
|
|
1248
1251
|
# 验证失败时抛异常,此处不用处理,由外层处理
|
|
1249
|
-
idf = load_yml_with_json_schema_validate(self.file, "/usr/share/litebmc/schema/idf.
|
|
1252
|
+
idf = load_yml_with_json_schema_validate(self.file, "/usr/share/litebmc/schema/idf.v2.json")
|
|
1253
|
+
schema = get_json_schema_file(self.file, "/usr/share/litebmc/schema/idf.v2.json")
|
|
1254
|
+
if schema.endswith("idf.v1.json"):
|
|
1255
|
+
self.name = os.path.basename(self.file)[:-5]
|
|
1256
|
+
self.alias = idf.get("alias")
|
|
1257
|
+
self.object_path = ""
|
|
1258
|
+
else:
|
|
1259
|
+
self.alias = os.path.basename(self.file)[:-5]
|
|
1260
|
+
self.name = idf.get("interface")
|
|
1261
|
+
# 别名
|
|
1262
|
+
self.object_path = idf.get("object_path", "")
|
|
1263
|
+
|
|
1250
1264
|
log.debug(f"validate {self.file} successfully")
|
|
1251
1265
|
self.version = idf.get("version")
|
|
1252
1266
|
self.description = idf.get("description", "")
|
|
1253
|
-
|
|
1254
|
-
|
|
1267
|
+
global alias
|
|
1268
|
+
alias = self.alias
|
|
1255
1269
|
# 注释
|
|
1256
1270
|
flags = idf.get("flags", "").split(",")
|
|
1257
1271
|
for k, v in ANNOTATION_MAP.items():
|
|
@@ -1271,6 +1285,7 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
1271
1285
|
items = idf.get("structures", [])
|
|
1272
1286
|
for item in items:
|
|
1273
1287
|
obj = IdfStructure(self, item)
|
|
1288
|
+
obj.name = alias + "_" + obj.name
|
|
1274
1289
|
self.structures[obj.name] = obj
|
|
1275
1290
|
items = idf.get("errors", [])
|
|
1276
1291
|
for item in items:
|
|
@@ -1280,10 +1295,12 @@ class IdfInterface(IdfInterfaceBase):
|
|
|
1280
1295
|
items = idf.get("dictionaries", [])
|
|
1281
1296
|
for item in items:
|
|
1282
1297
|
obj = IdfDictionary(self, item)
|
|
1298
|
+
obj.name = alias + "_" + obj.name
|
|
1283
1299
|
self.dictionaries[obj.name] = obj
|
|
1284
1300
|
items = idf.get("enumerations", [])
|
|
1285
1301
|
for item in items:
|
|
1286
1302
|
obj = IdfEnumeration(self, item)
|
|
1303
|
+
obj.name = alias + "_" + obj.name
|
|
1287
1304
|
self.enumerations[obj.name] = obj
|
|
1288
1305
|
plugin = idf.get("plugin", None)
|
|
1289
1306
|
self.plugin = IdfInterfacePlugin()
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
<%
|
|
2
|
+
from inflection import underscore
|
|
3
|
+
%>\
|
|
1
4
|
#include "lb_base.h"
|
|
2
|
-
#include "${intf.
|
|
5
|
+
#include "${intf.alias}.h"
|
|
3
6
|
|
|
4
7
|
<% class_name = intf.alias + "_Cli"
|
|
5
8
|
properties = "_" + class_name + "_properties"
|
|
@@ -113,6 +116,10 @@ static LBInterface _${class_name}_interface = {
|
|
|
113
116
|
.name = "${intf.name}",
|
|
114
117
|
.properties = (LBProperty *)&${properties},
|
|
115
118
|
.interface = NULL, /* load from usr/share/dbus-1/interfaces/${intf.name}.xml by lb_init */
|
|
119
|
+
#ifdef LB_CODEGEN_BE_5_4
|
|
120
|
+
.alias = "${class_name}",
|
|
121
|
+
.object_template = "${intf.object_path}",
|
|
122
|
+
#endif
|
|
116
123
|
};
|
|
117
124
|
|
|
118
125
|
static LBBase *_get_real_object(LBO *obj)
|
|
@@ -160,18 +167,10 @@ static LBO *_${class_name}_create(const gchar *name, gpointer opaque)
|
|
|
160
167
|
|
|
161
168
|
% for signal in intf.signals:
|
|
162
169
|
% if signal.deprecated:
|
|
163
|
-
% if codegen_version.be("5.1"):
|
|
164
170
|
__deprecated guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Callback handler,
|
|
165
|
-
% else:
|
|
166
|
-
__deprecated guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Signal handler,
|
|
167
|
-
% endif
|
|
168
171
|
const gchar *bus_name, const gchar *object_path, const gchar *arg0, gpointer user_data)
|
|
169
172
|
% else:
|
|
170
|
-
% if codegen_version.be("5.1"):
|
|
171
173
|
guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Callback handler,
|
|
172
|
-
% else:
|
|
173
|
-
guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Signal handler,
|
|
174
|
-
% endif
|
|
175
174
|
const gchar *bus_name, const gchar *object_path, const gchar *arg0, gpointer user_data)
|
|
176
175
|
% endif
|
|
177
176
|
{
|
|
@@ -200,7 +199,6 @@ ${class_name}_Properties *${class_name}_properties(void)
|
|
|
200
199
|
return &${properties};
|
|
201
200
|
}
|
|
202
201
|
|
|
203
|
-
% if codegen_version.be("4.0"):
|
|
204
202
|
${class_name} ${class_name}_get(const gchar *well_known, const gchar *name)
|
|
205
203
|
{
|
|
206
204
|
return lb_impl._cli_get(&_${class_name}_interface, well_known, name);
|
|
@@ -314,7 +312,6 @@ void ${class_name}_${prop.name}_hook(${class_name}_after_changed_hook after, gpo
|
|
|
314
312
|
}
|
|
315
313
|
|
|
316
314
|
% endfor
|
|
317
|
-
% endif
|
|
318
315
|
static void __constructor(150) ${class_name}_register(void)
|
|
319
316
|
{
|
|
320
317
|
// 从公共库中复制信号处理函数
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
#include <glib-2.0/glib.h>
|
|
6
6
|
#include <glib-2.0/gio/gio.h>
|
|
7
7
|
#include "lb_base.h"
|
|
8
|
-
#include "public/${intf.
|
|
8
|
+
#include "public/${intf.alias}.h"
|
|
9
9
|
|
|
10
10
|
#ifdef __cplusplus
|
|
11
11
|
extern "C" {
|
|
@@ -88,15 +88,9 @@ int ${class_name}_Call_${method.name}(${class_name} obj,
|
|
|
88
88
|
% endfor
|
|
89
89
|
% endif
|
|
90
90
|
*/
|
|
91
|
-
% if codegen_version.be("5.1"):
|
|
92
91
|
typedef void (*${class_name}_${signal.name}_Callback)(${class_name} obj, const gchar *destination,
|
|
93
92
|
const ${intf.alias}_${signal.name}_Msg *req, gpointer user_data, const LBSignalExtData *ext_data);
|
|
94
|
-
% else:
|
|
95
|
-
typedef void (*${class_name}_${signal.name}_Signal)(${class_name} obj, const gchar *destination,
|
|
96
|
-
const ${intf.alias}_${signal.name}_Msg *req, gpointer user_data);
|
|
97
|
-
% endif
|
|
98
93
|
/**/
|
|
99
|
-
% if codegen_version.be("5.1"):
|
|
100
94
|
% if signal.deprecated:
|
|
101
95
|
__deprecated guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Callback handler,
|
|
102
96
|
const gchar *bus_name, const gchar *object_path, const gchar *arg0, gpointer user_data);
|
|
@@ -104,15 +98,6 @@ __deprecated guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal
|
|
|
104
98
|
guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Callback handler,
|
|
105
99
|
const gchar *bus_name, const gchar *object_path, const gchar *arg0, gpointer user_data);
|
|
106
100
|
% endif
|
|
107
|
-
% else:
|
|
108
|
-
% if signal.deprecated:
|
|
109
|
-
__deprecated guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Signal handler,
|
|
110
|
-
const gchar *bus_name, const gchar *object_path, const gchar *arg0, gpointer user_data);
|
|
111
|
-
% else:
|
|
112
|
-
guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Signal handler,
|
|
113
|
-
const gchar *bus_name, const gchar *object_path, const gchar *arg0, gpointer user_data);
|
|
114
|
-
% endif
|
|
115
|
-
% endif
|
|
116
101
|
% if signal.deprecated:
|
|
117
102
|
__deprecated void ${class_name}_Unsubscribe_${signal.name}(guint *id);
|
|
118
103
|
% else:
|
|
@@ -125,7 +110,6 @@ ${class_name}_Properties *${class_name}_properties(void);
|
|
|
125
110
|
LBInterface *${class_name}_interface(void);
|
|
126
111
|
#define ${hump2underline(class_name).upper()} ${class_name}_interface()
|
|
127
112
|
|
|
128
|
-
% if codegen_version.be("4.0"):
|
|
129
113
|
/* notes: 对象变更加回调函数 */
|
|
130
114
|
typedef void (*${class_name}_on_changed_hook)(${class_name} obj, gpointer user_data);
|
|
131
115
|
/* notes: 属性变更后回调,远程对象或本地对象变更后都会调用 */
|
|
@@ -205,7 +189,6 @@ static inline void _cleanup_${class_name}_list(GSList **ptr)
|
|
|
205
189
|
|
|
206
190
|
#define cleanup_${class_name} __attribute__((cleanup(_cleanup_${class_name}_)))
|
|
207
191
|
#define cleanup_${class_name}_list __attribute__((cleanup(_cleanup_${class_name}_list)))
|
|
208
|
-
% endif
|
|
209
192
|
#ifdef __cplusplus
|
|
210
193
|
}
|
|
211
194
|
#endif
|