lbkit 0.5.19__tar.gz → 0.5.20__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.19/lbkit.egg-info → lbkit-0.5.20}/PKG-INFO +1 -1
- lbkit-0.5.20/lbkit/__init__.py +2 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/cli.py +3 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/idf_interface.py +6 -5
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/template/client.c.mako +18 -1
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/template/server.c.mako +69 -1
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/component/test.py +7 -1
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/errors.py +2 -0
- {lbkit-0.5.19 → lbkit-0.5.20/lbkit.egg-info}/PKG-INFO +1 -1
- {lbkit-0.5.19 → lbkit-0.5.20}/test/test_codegen.py +4 -0
- lbkit-0.5.19/lbkit/__init__.py +0 -2
- {lbkit-0.5.19 → lbkit-0.5.20}/AUTHORS +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/LICENSE +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/MANIFEST.in +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/README.md +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/ci_robot/__init__.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/ci_robot/gitee.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/__init__.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/codegen.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/ctype_defination.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/renderer.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/template/client.h.mako +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/template/interface.c.mako +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/template/interface.introspect.xml.mako +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/template/public.c.mako +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/template/public.h.mako +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/codegen/template/server.h.mako +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/component/__init__.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/component/arg_parser.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/component/build.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/component/template/conanbase.mako +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/component/template/deploy.mako +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/helper.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/integration/__init__.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/integration/build_image.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/integration/build_manifest.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/integration/build_prepare.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/integration/build_rootfs.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/integration/config.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/integration/task.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/integration/template/conanfile.py.mako +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/lbkit.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/log.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/misc.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit/tools.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit.egg-info/SOURCES.txt +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit.egg-info/dependency_links.txt +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit.egg-info/entry_points.txt +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit.egg-info/requires.txt +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/lbkit.egg-info/top_level.txt +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/setup.cfg +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/setup.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/test/__init__.py +0 -0
- {lbkit-0.5.19 → lbkit-0.5.20}/test/test_helper.py +0 -0
|
@@ -619,18 +619,19 @@ class IdfProperty(IdfCtypeRender):
|
|
|
619
619
|
if self.ctype in ["boolean", "array[boolean]"]:
|
|
620
620
|
return
|
|
621
621
|
pattern = self.idf_data.get("pattern")
|
|
622
|
-
if
|
|
623
|
-
if
|
|
622
|
+
if self.ctype == "string":
|
|
623
|
+
if pattern:
|
|
624
624
|
match = re.match(pattern, self.default)
|
|
625
625
|
if not match:
|
|
626
626
|
raise OdfValidateException(f"Fail to validation default value of property {self.name} with pattern \"{pattern}\", get default: {self.default}")
|
|
627
|
-
|
|
628
|
-
|
|
627
|
+
return
|
|
628
|
+
if self.ctype == "array[string]":
|
|
629
|
+
if pattern:
|
|
629
630
|
for val in self.default:
|
|
630
631
|
match = re.match(pattern, val)
|
|
631
632
|
if not match:
|
|
632
633
|
raise OdfValidateException(f"Fail to validation default value of property {self.name} with pattern \"{pattern}\", get default: {val}")
|
|
633
|
-
|
|
634
|
+
return
|
|
634
635
|
if self.ctype == "object_path":
|
|
635
636
|
if pattern:
|
|
636
637
|
match = re.match(pattern, self.default)
|
|
@@ -104,22 +104,39 @@ int ${class_name}_Call_${method.name}(const ${class_name} *object,
|
|
|
104
104
|
|
|
105
105
|
% endfor
|
|
106
106
|
static GclObject *_${class_name}_create(const gchar *obj_name, gpointer opaque);
|
|
107
|
+
static void _${class_name}_destroy(GclObject *obj);
|
|
107
108
|
|
|
108
109
|
static GclInterface _${class_name}_interface = {
|
|
109
110
|
.create = _${class_name}_create,
|
|
111
|
+
.destroy = _${class_name}_destroy,
|
|
110
112
|
.is_remote = 1,
|
|
111
113
|
.name = "${intf.name}",
|
|
112
114
|
.properties = (GclProperty *)&${properties},
|
|
113
115
|
.interface = NULL, /* load from usr/share/dbus-1/interfaces/${intf.name}.xml by gcl_init */
|
|
114
116
|
};
|
|
115
117
|
|
|
118
|
+
/**
|
|
119
|
+
* @brief 销毁对象
|
|
120
|
+
*
|
|
121
|
+
* @param gcl_obj 待销毁的对象句柄
|
|
122
|
+
*/
|
|
123
|
+
static void _${class_name}_destroy(GclObject *gcl_obj)
|
|
124
|
+
{
|
|
125
|
+
g_assert(gcl_obj);
|
|
126
|
+
${class_name} *obj = (${class_name} *)gcl_obj;
|
|
127
|
+
g_rec_mutex_clear(obj->_base.lock);
|
|
128
|
+
g_free(obj->_base.lock);
|
|
129
|
+
${intf.alias}_clean(obj);
|
|
130
|
+
memset(obj, 0, sizeof(${class_name}));
|
|
131
|
+
}
|
|
132
|
+
|
|
116
133
|
/**
|
|
117
134
|
* @brief 分配对象
|
|
118
135
|
*
|
|
119
136
|
* @param obj_name 对象名,需要由调用者分配内存
|
|
120
137
|
* @param opaque 上层应用需要写入对象的用户数据,由上层应用使用
|
|
121
138
|
*/
|
|
122
|
-
GclObject *_${class_name}_create(const gchar *obj_name, gpointer opaque)
|
|
139
|
+
static GclObject *_${class_name}_create(const gchar *obj_name, gpointer opaque)
|
|
123
140
|
{
|
|
124
141
|
${class_name} *obj = g_new0(${class_name}, 1);
|
|
125
142
|
memcpy(obj->_base.magic, GCL_MAGIC, strlen(GCL_MAGIC) + 1);
|
|
@@ -234,11 +234,13 @@ gboolean ${class_name}_${signal.name}_Signal(const ${class_name} *object, const
|
|
|
234
234
|
|
|
235
235
|
% endfor
|
|
236
236
|
static GclObject *_${class_name}_create(const gchar *obj_name, gpointer opaque);
|
|
237
|
+
static void _${class_name}_destroy(GclObject *obj);
|
|
237
238
|
static void _load_from_odf(yaml_document_t *doc, yaml_node_t *node, GclObject *gcl_obj,
|
|
238
239
|
property_reference_loaded ref_loaded, gpointer user_data);
|
|
239
240
|
|
|
240
241
|
static GclInterface _${class_name}_interface = {
|
|
241
242
|
.create = _${intf.alias}_create,
|
|
243
|
+
.destroy = _${class_name}_destroy,
|
|
242
244
|
.validate_odf = ${intf.name.replace(".", "_")}_validate_odf,
|
|
243
245
|
.load_from_odf = _load_from_odf,
|
|
244
246
|
.is_remote = 0,
|
|
@@ -251,6 +253,7 @@ static GclInterface _${class_name}_interface = {
|
|
|
251
253
|
static void _load_odf_as_prop_${prop.name}(yaml_document_t *doc, GHashTable *prop_table,
|
|
252
254
|
${class_name} *obj, property_reference_loaded ref_loaded, gpointer user_data)
|
|
253
255
|
{
|
|
256
|
+
__attribute__((unused)) gint i = 0;
|
|
254
257
|
const gchar *flags = NULL;
|
|
255
258
|
yaml_node_t *val = g_hash_table_lookup(prop_table, "_${prop.name}_flags");
|
|
256
259
|
if (val && val->type == YAML_SCALAR_NODE) {
|
|
@@ -259,6 +262,55 @@ static void _load_odf_as_prop_${prop.name}(yaml_document_t *doc, GHashTable *pro
|
|
|
259
262
|
val = g_hash_table_lookup(prop_table, "${prop.name}");
|
|
260
263
|
## validate接口在加载odf前完成属性是否必选校验,此处如果是必选属性一定存在
|
|
261
264
|
if (!val) {
|
|
265
|
+
## 设置默认值
|
|
266
|
+
% if prop.default:
|
|
267
|
+
% if prop.ctype == "boolean":
|
|
268
|
+
% if prop.default:
|
|
269
|
+
obj->${prop.name} = TRUE;
|
|
270
|
+
% endif
|
|
271
|
+
% elif prop.ctype in ["byte", "int16", "uint16", "int32", "uint32", "int64", "uint64", "size", "ssize", "double"]:
|
|
272
|
+
% if prop.ctype == "uint64":
|
|
273
|
+
obj->${prop.name} = ${prop.default}UL;
|
|
274
|
+
% elif prop.ctype == "int64":
|
|
275
|
+
obj->${prop.name} = ${prop.default}LL;
|
|
276
|
+
% else:
|
|
277
|
+
obj->${prop.name} = ${prop.default};
|
|
278
|
+
% endif
|
|
279
|
+
% elif prop.ctype in ["object_path", "string", "signature"]:
|
|
280
|
+
obj->${prop.name} = g_strdup("${prop.default}");
|
|
281
|
+
% elif prop.ctype == "array[boolean]":
|
|
282
|
+
i = 0;
|
|
283
|
+
obj->n_${prop.name} = ${len(prop.default)};
|
|
284
|
+
obj->${prop.name} = g_new0(gboolean, obj->n_${prop.name});
|
|
285
|
+
% for val in prop.default:
|
|
286
|
+
% if val:
|
|
287
|
+
obj->${prop.name}[i++] = TRUE;
|
|
288
|
+
% else:
|
|
289
|
+
obj->${prop.name}[i++] = FALSE;
|
|
290
|
+
% endif
|
|
291
|
+
% endfor
|
|
292
|
+
% elif prop.ctype in ["array[byte]", "array[int16]", "array[uint16]", "array[int32]", "array[uint32]", "array[int64]", "array[uint64]", "array[size]", "array[ssize]", "array[double]"]:
|
|
293
|
+
<% ctype = prop.ctype[6:-1]%>
|
|
294
|
+
i = 0;
|
|
295
|
+
obj->n_${prop.name} = ${len(prop.default)};
|
|
296
|
+
obj->${prop.name} = g_new0(g${ctype}, obj->n_${prop.name});
|
|
297
|
+
% for val in prop.default:
|
|
298
|
+
% if prop.ctype == "array[uint64]":
|
|
299
|
+
obj->${prop.name}[i++] = ${val}UL;
|
|
300
|
+
% elif prop.ctype == "array[int64]":
|
|
301
|
+
obj->${prop.name}[i++] = ${val}LL;
|
|
302
|
+
% else:
|
|
303
|
+
obj->${prop.name}[i++] = ${val};
|
|
304
|
+
% endif
|
|
305
|
+
% endfor
|
|
306
|
+
% elif prop.ctype in ["array[object_path]", "array[string]", "array[signature]"]:
|
|
307
|
+
i = 0;
|
|
308
|
+
obj->${prop.name} = g_new0(gchar *, ${len(prop.default) + 1});
|
|
309
|
+
% for val in prop.default:
|
|
310
|
+
obj->${prop.name}[i++] = g_strdup("${val}");
|
|
311
|
+
% endfor
|
|
312
|
+
% endif
|
|
313
|
+
% endif
|
|
262
314
|
if (flags) {
|
|
263
315
|
## 属性不存在时传入的value为空,需要开发者在回调函数中完成异常(有flags无属性值)处理
|
|
264
316
|
ref_loaded(obj, &${properties}.${prop.name}, doc, NULL, user_data, flags);
|
|
@@ -311,13 +363,29 @@ static void _load_from_odf(yaml_document_t *doc, yaml_node_t *node, GclObject *g
|
|
|
311
363
|
% endif
|
|
312
364
|
}
|
|
313
365
|
|
|
366
|
+
/**
|
|
367
|
+
* @brief 销毁对象
|
|
368
|
+
*
|
|
369
|
+
* @param gcl_obj 待销毁的对象句柄
|
|
370
|
+
*/
|
|
371
|
+
static void _${class_name}_destroy(GclObject *gcl_obj)
|
|
372
|
+
{
|
|
373
|
+
g_assert(gcl_obj);
|
|
374
|
+
${class_name} *obj = (${class_name} *)gcl_obj;
|
|
375
|
+
g_rec_mutex_clear(obj->_base.lock);
|
|
376
|
+
g_free(obj->_base.lock);
|
|
377
|
+
${class_name}_clean(obj);
|
|
378
|
+
memset(obj, 0, sizeof(${class_name}));
|
|
379
|
+
g_free(obj);
|
|
380
|
+
}
|
|
381
|
+
|
|
314
382
|
/**
|
|
315
383
|
* @brief 分配对象
|
|
316
384
|
*
|
|
317
385
|
* @param obj_name 对象名,需要由调用者分配内存
|
|
318
386
|
* @param opaque 上层应用需要写入对象的用户数据,由上层应用使用
|
|
319
387
|
*/
|
|
320
|
-
GclObject *_${class_name}_create(const gchar *obj_name, gpointer opaque)
|
|
388
|
+
static GclObject *_${class_name}_create(const gchar *obj_name, gpointer opaque)
|
|
321
389
|
{
|
|
322
390
|
__attribute__((unused)) gint i = 0;
|
|
323
391
|
${class_name} *obj = g_new0(${class_name}, 1);
|
|
@@ -3,6 +3,7 @@ import shutil
|
|
|
3
3
|
import re
|
|
4
4
|
import os
|
|
5
5
|
import imp
|
|
6
|
+
import unittest
|
|
6
7
|
from lbkit.component.build import BuildComponent
|
|
7
8
|
from lbkit.component.arg_parser import ArgParser
|
|
8
9
|
from lbkit import errors
|
|
@@ -109,7 +110,12 @@ class TestComponent():
|
|
|
109
110
|
return 0
|
|
110
111
|
|
|
111
112
|
log.success("call test method...")
|
|
112
|
-
test.test()
|
|
113
|
+
ret = test.test()
|
|
114
|
+
if ret is not None:
|
|
115
|
+
if isinstance(ret, unittest.TestResult) and (len(ret.errors) > 0 or len(ret.failures) > 0):
|
|
116
|
+
raise errors.TestException(f"Test failed, ret: {ret}")
|
|
117
|
+
elif isinstance(ret, int) and ret != 0:
|
|
118
|
+
raise errors.TestException(f"Test failed, ret: {ret}")
|
|
113
119
|
|
|
114
120
|
test_src_folder = getattr(test, "test_src_folder", [])
|
|
115
121
|
# 设置ROOTFS_DIR环境变量,为DT测试提供相对路径
|
|
@@ -221,6 +221,8 @@ class TestCodeGenClass(unittest.TestCase):
|
|
|
221
221
|
IdfInterface(None, self.tmp_file)
|
|
222
222
|
|
|
223
223
|
def test_validate_string(self):
|
|
224
|
+
self.mk_interface_with_string_property("string", "string", None, "as")
|
|
225
|
+
IdfInterface(None, self.tmp_file)
|
|
224
226
|
self.mk_interface_with_string_property("string", "string", "^a[s]{1,2}$", "as")
|
|
225
227
|
IdfInterface(None, self.tmp_file)
|
|
226
228
|
self.mk_interface_with_string_property("string", "string", "^a[s]{1,2}$", "ass")
|
|
@@ -236,6 +238,8 @@ class TestCodeGenClass(unittest.TestCase):
|
|
|
236
238
|
IdfInterface(None, self.tmp_file)
|
|
237
239
|
|
|
238
240
|
def test_validate_array_string(self):
|
|
241
|
+
self.mk_interface_with_string_property("string", "array[string]", None, "[as, as]")
|
|
242
|
+
IdfInterface(None, self.tmp_file)
|
|
239
243
|
self.mk_interface_with_string_property("string", "array[string]", "^a[s]{1,2}$", "[as, as]")
|
|
240
244
|
IdfInterface(None, self.tmp_file)
|
|
241
245
|
self.mk_interface_with_string_property("string", "array[string]", "^a[s]{1,2}$", "[ass, ass]")
|
lbkit-0.5.19/lbkit/__init__.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|