lbkit 0.6.7__tar.gz → 0.7.0__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.
Files changed (61) hide show
  1. {lbkit-0.6.7/lbkit.egg-info → lbkit-0.7.0}/PKG-INFO +1 -1
  2. lbkit-0.7.0/lbkit/__init__.py +2 -0
  3. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/codegen/codegen.py +1 -1
  4. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/codegen/template/client.c.mako +99 -0
  5. lbkit-0.7.0/lbkit/codegen/template/client.h.mako +200 -0
  6. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/codegen/template/server.c.mako +110 -0
  7. lbkit-0.7.0/lbkit/codegen/template/server.h.mako +153 -0
  8. {lbkit-0.6.7 → lbkit-0.7.0/lbkit.egg-info}/PKG-INFO +1 -1
  9. lbkit-0.6.7/lbkit/__init__.py +0 -2
  10. lbkit-0.6.7/lbkit/codegen/template/client.h.mako +0 -120
  11. lbkit-0.6.7/lbkit/codegen/template/server.h.mako +0 -66
  12. {lbkit-0.6.7 → lbkit-0.7.0}/AUTHORS +0 -0
  13. {lbkit-0.6.7 → lbkit-0.7.0}/LICENSE +0 -0
  14. {lbkit-0.6.7 → lbkit-0.7.0}/MANIFEST.in +0 -0
  15. {lbkit-0.6.7 → lbkit-0.7.0}/README.md +0 -0
  16. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/build_conan_parallel.py +0 -0
  17. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/ci_robot/__init__.py +0 -0
  18. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/ci_robot/gitee.py +0 -0
  19. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/cli.py +0 -0
  20. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/codegen/__init__.py +0 -0
  21. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/codegen/ctype_defination.py +0 -0
  22. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/codegen/idf_interface.py +0 -0
  23. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/codegen/renderer.py +0 -0
  24. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/codegen/template/interface.c.mako +0 -0
  25. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/codegen/template/interface.introspect.xml.mako +0 -0
  26. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/codegen/template/public.c.mako +0 -0
  27. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/codegen/template/public.h.mako +0 -0
  28. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/component/__init__.py +0 -0
  29. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/component/arg_parser.py +0 -0
  30. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/component/build.py +0 -0
  31. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/component/template/conanbase.mako +0 -0
  32. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/component/template/deploy.mako +0 -0
  33. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/component/test.py +0 -0
  34. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/errors.py +0 -0
  35. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/helper.py +0 -0
  36. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/integration/__init__.py +0 -0
  37. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/integration/build_image.py +0 -0
  38. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/integration/build_manifest.py +0 -0
  39. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/integration/build_prepare.py +0 -0
  40. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/integration/build_rootfs.py +0 -0
  41. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/integration/config.py +0 -0
  42. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/integration/task.py +0 -0
  43. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/integration/template/conanfile.py.mako +0 -0
  44. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/integration/template/rootfs.py.mako +0 -0
  45. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/lbkit.py +0 -0
  46. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/log.py +0 -0
  47. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/misc.py +0 -0
  48. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/tools.py +0 -0
  49. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/utils/__init__.py +0 -0
  50. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/utils/images/__init__.py +0 -0
  51. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit/utils/images/emmc.py +0 -0
  52. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit.egg-info/SOURCES.txt +0 -0
  53. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit.egg-info/dependency_links.txt +0 -0
  54. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit.egg-info/entry_points.txt +0 -0
  55. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit.egg-info/requires.txt +0 -0
  56. {lbkit-0.6.7 → lbkit-0.7.0}/lbkit.egg-info/top_level.txt +0 -0
  57. {lbkit-0.6.7 → lbkit-0.7.0}/setup.cfg +0 -0
  58. {lbkit-0.6.7 → lbkit-0.7.0}/setup.py +0 -0
  59. {lbkit-0.6.7 → lbkit-0.7.0}/test/__init__.py +0 -0
  60. {lbkit-0.6.7 → lbkit-0.7.0}/test/test_codegen.py +0 -0
  61. {lbkit-0.6.7 → lbkit-0.7.0}/test/test_helper.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: lbkit
3
- Version: 0.6.7
3
+ Version: 0.7.0
4
4
  Summary: Tools provided by litebmc.com
5
5
  Home-page: https://www.litebmc.com
6
6
  Author: xuhj@litebmc.com
@@ -0,0 +1,2 @@
1
+
2
+ __version__ = '0.7.0'
@@ -17,7 +17,7 @@ from lbkit.misc import SmartFormatter
17
17
  lb_cwd = os.path.split(os.path.realpath(__file__))[0]
18
18
  log = Logger("codegen")
19
19
 
20
- __version__=3
20
+ __version__=4
21
21
 
22
22
  class CodeGen(object):
23
23
  def __init__(self, args):
@@ -182,6 +182,105 @@ ${class_name}_Properties *${class_name}_properties(void)
182
182
  return &${properties};
183
183
  }
184
184
 
185
+ % if codegen_version >= 4:
186
+ const ${class_name} *${class_name}_get(const gchar *name)
187
+ {
188
+ return lb_impl._get(&_${class_name}_interface, name);
189
+ }
190
+
191
+ const ${class_name} *${class_name}_new(const gchar *well_known, const gchar *obj_name)
192
+ {
193
+ LBO *obj = lb_impl._cli_new(&_${class_name}_interface, well_known, obj_name);
194
+ return (const ${class_name} *)obj;
195
+ }
196
+
197
+ /* 减对象引用计数 */
198
+ void ${class_name}_unref(const ${class_name} **obj)
199
+ {
200
+ lb_impl._unref((LBO **)obj);
201
+ }
202
+
203
+ /* 加对象引用计数 */
204
+ const ${class_name} *${class_name}_ref(const ${class_name} *obj)
205
+ {
206
+ return (const ${class_name} *)lb_impl._ref((LBO *)obj);
207
+ }
208
+
209
+ /* 绑定数据 */
210
+ void ${class_name}_bind(const ${class_name} *lb_obj, gpointer data, GDestroyNotify destroy_func)
211
+ {
212
+ lb_impl._bind((LBO *)lb_obj, data, destroy_func);
213
+ }
214
+
215
+ /* 获取绑定数据 */
216
+ gpointer ${class_name}_data(const ${class_name} *lb_obj)
217
+ {
218
+ return lb_impl._data((LBO *)lb_obj);
219
+ }
220
+
221
+ /* @notes 属性对象属性值变更(后)事件 */
222
+ gint ${class_name}_on_prop_changed(const ${class_name} *lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gpointer user_data, GDestroyNotify destroy)
223
+ {
224
+ return lb_impl._on_prop_changed((LBO *)lb_obj, prop, (lbo_after_changed_hook)pc, user_data, destroy);
225
+ }
226
+
227
+ /* 取消监听,成功取消监听时会调用监听时设置的destroy回调清除注册时的user_data */
228
+ void ${class_name}_on_prop_changed_cancel(const ${class_name} *lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gconstpointer user_data)
229
+ {
230
+ lb_impl._on_prop_changed_cancel((LBO *)lb_obj, prop, (lbo_after_changed_hook)pc, user_data);
231
+ }
232
+
233
+ /* 对象变更事件 */
234
+ void ${class_name}_on_changed(${class_name}_on_changed_hook cb, gpointer user_data, GDestroyNotify destroy)
235
+ {
236
+ lb_impl._on_changed(&_${class_name}_interface, (LbObjectHook)cb, user_data, destroy);
237
+ }
238
+
239
+ /* 注册对象释放回调 */
240
+ void ${class_name}_before_destroy(const ${class_name} *lb_obj, GHookFunc cb, gpointer user_data)
241
+ {
242
+ lb_impl._before_destroy((LBO *)lb_obj, cb, user_data);
243
+ }
244
+
245
+ /* 查询第n个对象 */
246
+ const ${class_name} *${class_name}_nth(int nth)
247
+ {
248
+ return (const ${class_name} *)lb_impl._nth(&_${class_name}_interface, nth);
249
+ }
250
+
251
+ /* 查询对象名称 */
252
+ const gchar *${class_name}_name(const ${class_name} *obj)
253
+ {
254
+ return lbo_name((LBO *)obj);
255
+ }
256
+
257
+ /* 对象加锁 */
258
+ void ${class_name}_lock(const ${class_name} *obj)
259
+ {
260
+ lbo_lock((LBO *)obj);
261
+ }
262
+
263
+ /* 对象解锁 */
264
+ void ${class_name}_unlock(const ${class_name} *obj)
265
+ {
266
+ lbo_unlock((LBO *)obj);
267
+ }
268
+
269
+ /* 对象列表查询接口 */
270
+ GSList *${class_name}_list(void)
271
+ {
272
+ return lb_impl._list(&_${class_name}_interface);
273
+ }
274
+
275
+ % for prop in intf.properties:
276
+ /* 监听属性${prop.name}变更 */
277
+ void ${class_name}_${prop.name}_hook(const ${class_name}_property_hook *hook)
278
+ {
279
+ lb_impl._prop_hook(&${properties}.${prop.name}, (const LBPropertyHook *)hook);
280
+ }
281
+
282
+ % endfor
283
+ % endif
185
284
  static void __attribute__((constructor(150))) ${class_name}_register(void)
186
285
  {
187
286
  // 从公共库中复制信号处理函数
@@ -0,0 +1,200 @@
1
+ <% from lbkit.tools import hump2underline %>\
2
+ #ifndef __${"_".join(intf.name.upper().split(".", -1))}_CLI_H__
3
+ #define __${"_".join(intf.name.upper().split(".", -1))}_CLI_H__
4
+
5
+ #include <glib-2.0/glib.h>
6
+ #include <glib-2.0/gio/gio.h>
7
+ #include "lb_base.h"
8
+ #include "public/${intf.name}.h"
9
+
10
+ #ifdef __cplusplus
11
+ extern "C" {
12
+ #endif
13
+ <% class_name = intf.alias + "_Cli"%>
14
+ typedef ${intf.alias} ${class_name};
15
+ typedef ${intf.alias}_Properties ${class_name}_Properties;
16
+
17
+ % for prop in intf.properties:
18
+ % if not prop.private:
19
+ /*
20
+ * property: ${prop.name}
21
+ % if len(prop.description.strip()) > 0:
22
+ *
23
+ % for line in prop.description.split("\n"):
24
+ % if len(line.strip()) > 0:
25
+ * ${line.strip()}
26
+ % endif
27
+ % endfor
28
+ % endif
29
+ */
30
+ ## 私有属性或者只读属性不允许写
31
+ % if not prop.private and prop.access != "read":
32
+ % if prop.deprecated:
33
+ __attribute__((__deprecated__)) gint ${class_name}_set_${prop.name}(const ${class_name} *object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")}, GError **error);
34
+ % else:
35
+ gint ${class_name}_set_${prop.name}(const ${class_name} *object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")}, GError **error);
36
+ % endif
37
+ % endif
38
+ % if not prop.private and prop.access != "write":
39
+ % if prop.deprecated:
40
+ __attribute__((__deprecated__)) gint ${class_name}_get_${prop.name}(const ${class_name} *object, ${", ".join(prop.out_declare()).replace("<arg_name>", "value").replace("<const>", "")}, GError **error);
41
+ % else:
42
+ gint ${class_name}_get_${prop.name}(const ${class_name} *object, ${", ".join(prop.out_declare()).replace("<arg_name>", "value").replace("<const>", "")}, GError **error);
43
+ % endif
44
+ % endif
45
+ % endif
46
+ % endfor
47
+
48
+ % for method in intf.methods:
49
+ <% RSP_PARA = f'' %>\
50
+ <% REQ_PARA = f'' %>\
51
+ % if len(method.returns.parameters) > 0:
52
+ <% RSP_PARA = f'{intf.alias}_{method.name}_Rsp **rsp, ' %>\
53
+ % endif
54
+ % if len(method.parameters.parameters) > 0:
55
+ <% REQ_PARA = f'const {intf.alias}_{method.name}_Req *req, ' %>\
56
+ % endif
57
+ /*
58
+ * method: ${method.name}
59
+ % if len(method.description.strip()) > 0:
60
+ *
61
+ % for line in method.description.split("\n"):
62
+ % if len(line.strip()) > 0:
63
+ * ${line.strip()}
64
+ % endif
65
+ % endfor
66
+ % endif
67
+ */
68
+ % if method.deprecated:
69
+ __attribute__((__deprecated__)) int ${class_name}_Call_${method.name}(const ${class_name} *object,
70
+ ${REQ_PARA}${RSP_PARA}gint timeout,
71
+ GError **error);
72
+ % else:
73
+ int ${class_name}_Call_${method.name}(const ${class_name} *object,
74
+ ${REQ_PARA}${RSP_PARA}gint timeout,
75
+ GError **error);
76
+ % endif
77
+ % endfor
78
+
79
+ % for signal in intf.signals:
80
+ /*
81
+ * signal: ${signal.name}
82
+ % if len(signal.description.strip()) > 0:
83
+ *
84
+ % for line in signal.description.split("\n"):
85
+ % if len(line.strip()) > 0:
86
+ * ${line.strip()}
87
+ % endif
88
+ % endfor
89
+ % endif
90
+ */
91
+ typedef void (*${class_name}_${signal.name}_Signal)(const ${class_name} *object, const gchar *destination,
92
+ const ${intf.alias}_${signal.name}_Msg *req, gpointer user_data);
93
+ /**/
94
+ % if signal.deprecated:
95
+ __attribute__((__deprecated__)) guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Signal handler,
96
+ const gchar *bus_name, const gchar *object_path, const gchar *arg0, gpointer user_data);
97
+ % else:
98
+ guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Signal handler,
99
+ const gchar *bus_name, const gchar *object_path, const gchar *arg0, gpointer user_data);
100
+ % endif
101
+ % if signal.deprecated:
102
+ __attribute__((__deprecated__)) void ${class_name}_Unsubscribe_${signal.name}(guint *id);
103
+ % else:
104
+ void ${class_name}_Unsubscribe_${signal.name}(guint *id);
105
+ % endif
106
+
107
+ % endfor
108
+
109
+ ${class_name}_Properties *${class_name}_properties(void);
110
+ LBInterface *${class_name}_interface(void);
111
+ #define ${hump2underline(class_name).upper()} ${class_name}_interface()
112
+
113
+ % if codegen_version >= 4:
114
+ /* notes: 对象变更加回调函数 */
115
+ typedef void (*${class_name}_on_changed_hook)(const ${class_name} *lb_obj, gpointer user_data);
116
+ /* notes: 属性变更后回调,远程对象或本地对象变更后都会调用 */
117
+ typedef void (*${class_name}_after_changed_hook)(const ${class_name} *object, const LBProperty *prop, GVariant *value, gpointer user_data);
118
+ /* notes: 属性变更前回调,返回-1表示阻止值变更,一般用于值合法性校验,只在被远程操作时才会生效,本地变更值不会回调 */
119
+ typedef gint (*${class_name}_before_change_hook)(const ${class_name} *object, const LBProperty *prop, GVariant *value, gpointer user_data, GError **error);
120
+
121
+ /* 属性值变更回调钩子 */
122
+ typedef struct {
123
+ ${class_name}_after_changed_hook after; /* 属性变更(写入对象数据区后)后回调函数 */
124
+ ${class_name}_before_change_hook before; /* 属性变更前回调函数,返回0后继续调用,返回非0时中止,所有before都成功时执行属性变更 */
125
+ gpointer user_data;
126
+ } ${class_name}_property_hook;
127
+ /* 查询对象 */
128
+ const ${class_name} *${class_name}_get(const gchar *name);
129
+ /* 创建对象 */
130
+ const ${class_name} *${class_name}_new(const gchar *well_known, const gchar *obj_name);
131
+ /* 减对象引用计数 */
132
+ void ${class_name}_unref(const ${class_name} **obj);
133
+ /* 加对象引用计数 */
134
+ const ${class_name} *${class_name}_ref(const ${class_name} *obj);
135
+ /* 绑定数据 */
136
+ void ${class_name}_bind(const ${class_name} *lb_obj, gpointer data, GDestroyNotify destroy_func);
137
+ /* 获取绑定数据 */
138
+ gpointer ${class_name}_data(const ${class_name} *lb_obj);
139
+ /* @notes 属性对象属性值变更(后)事件 */
140
+ gint ${class_name}_on_prop_changed(const ${class_name} *lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gpointer user_data, GDestroyNotify destroy);
141
+ /* 取消监听,成功取消监听时会调用监听时设置的destroy回调清除注册时的user_data */
142
+ void ${class_name}_on_prop_changed_cancel(const ${class_name} *lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gconstpointer user_data);
143
+ /* 对象变更事件 */
144
+ void ${class_name}_on_changed(${class_name}_on_changed_hook cb, gpointer user_data, GDestroyNotify destroy);
145
+ /* 注册对象释放回调 */
146
+ void ${class_name}_before_destroy(const ${class_name} *lb_obj, GHookFunc cb, gpointer user_data);
147
+ /*
148
+ * 查询第n个对象
149
+ * @notes: 支持正逆向查询第n个对象,返回的对象需要使用lbo_unref减引用计数
150
+ * 正向查找传入非负n,以0开始计数,表示查找最早创建的第n个对象;
151
+ * 逆向查找传入负数n,以-1开始计数,依次为-2、-3等,表示查找最后创建的第n个对象。
152
+ */
153
+ const ${class_name} *${class_name}_nth(int nth);
154
+ /* 查询对象名称 */
155
+ const gchar *${class_name}_name(const ${class_name} *obj);
156
+ /* 对象加锁 */
157
+ void ${class_name}_lock(const ${class_name} *obj);
158
+ /* 对象解锁 */
159
+ void ${class_name}_unlock(const ${class_name} *obj);
160
+ /* 对象列表查询接口 */
161
+ GSList *${class_name}_list(void);
162
+ /* 监听属性 */
163
+ % for prop in intf.properties:
164
+ void ${class_name}_${prop.name}_hook(const ${class_name}_property_hook *hook);
165
+ % endfor
166
+
167
+ static inline void ${class_name}_unref_p(const ${class_name} *obj)
168
+ {
169
+ ${class_name}_unref(&obj);
170
+ }
171
+
172
+ static inline void _cleanup_${class_name}_(const ${class_name} **ptr)
173
+ {
174
+ if (ptr && *ptr) {
175
+ ${class_name}_unref(ptr);
176
+ }
177
+ }
178
+
179
+ static inline void ${class_name}_list_free(GSList **list)
180
+ {
181
+ g_assert(list);
182
+ g_slist_free_full(*list, (GDestroyNotify)${class_name}_unref_p);
183
+ *list = NULL;
184
+ }
185
+
186
+ static inline void _cleanup_${class_name}_list(GSList **ptr)
187
+ {
188
+ if (ptr && *ptr) {
189
+ ${class_name}_list_free(ptr);
190
+ }
191
+ }
192
+
193
+ #define cleanup_${class_name} __attribute__((cleanup(_cleanup_${class_name}_)))
194
+ #define cleanup_${class_name}_list __attribute__((cleanup(_cleanup_${class_name}_list)))
195
+ % endif
196
+ #ifdef __cplusplus
197
+ }
198
+ #endif
199
+
200
+ #endif /* __${"_".join(intf.name.upper().split(".", -1))}_CLI_H__ */
@@ -458,6 +458,116 @@ ${class_name}_Properties *${class_name}_properties(void)
458
458
  return &${properties};
459
459
  }
460
460
 
461
+ % if codegen_version >= 4:
462
+ const ${class_name} *${class_name}_get(const gchar *name)
463
+ {
464
+ return lb_impl._get(&_${class_name}_interface, name);
465
+ }
466
+
467
+ const ${class_name} *${class_name}_new(const gchar *name, gboolean *exist)
468
+ {
469
+ LBO *obj = lb_impl._new(&_${class_name}_interface, name, exist);
470
+ return (const ${class_name} *)obj;
471
+ }
472
+
473
+ void ${class_name}_unref(const ${class_name} **obj)
474
+ {
475
+ lb_impl._unref((LBO **)obj);
476
+ }
477
+
478
+ /* 加对象引用计数 */
479
+ const ${class_name} *${class_name}_ref(const ${class_name} *obj)
480
+ {
481
+ return (const ${class_name} *)lb_impl._ref((LBO *)obj);
482
+ }
483
+
484
+ /* 设置在位状态 */
485
+ void ${class_name}_present_set(const ${class_name} *obj, gboolean present)
486
+ {
487
+ lb_impl._present_set((LBO *)obj, present);
488
+ }
489
+
490
+ /* 获取在位状态 */
491
+ gboolean ${class_name}_present(const ${class_name} *obj)
492
+ {
493
+ return lb_impl._present((LBO *)obj);
494
+ }
495
+
496
+ /* 绑定数据 */
497
+ void ${class_name}_bind(const ${class_name} *lb_obj, gpointer data, GDestroyNotify destroy_func)
498
+ {
499
+ lb_impl._bind((LBO *)lb_obj, data, destroy_func);
500
+ }
501
+
502
+ /* 获取绑定数据 */
503
+ gpointer ${class_name}_data(const ${class_name} *lb_obj)
504
+ {
505
+ return lb_impl._data((LBO *)lb_obj);
506
+ }
507
+
508
+ /* @notes 属性对象属性值变更(后)事件 */
509
+ gint ${class_name}_on_prop_changed(const ${class_name} *lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gpointer user_data, GDestroyNotify destroy)
510
+ {
511
+ return lb_impl._on_prop_changed((LBO *)lb_obj, prop, (lbo_after_changed_hook)pc, user_data, destroy);
512
+ }
513
+
514
+ /* 取消监听,成功取消监听时会调用监听时设置的destroy回调清除注册时的user_data */
515
+ void ${class_name}_on_prop_changed_cancel(const ${class_name} *lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gconstpointer user_data)
516
+ {
517
+ lb_impl._on_prop_changed_cancel((LBO *)lb_obj, prop, (lbo_after_changed_hook)pc, user_data);
518
+ }
519
+
520
+ /* 对象变更事件 */
521
+ void ${class_name}_on_changed(${class_name}_on_changed_hook cb, gpointer user_data, GDestroyNotify destroy)
522
+ {
523
+ lb_impl._on_changed(&_${class_name}_interface, (LbObjectHook)cb, user_data, destroy);
524
+ }
525
+
526
+ /* 注册对象释放回调 */
527
+ void ${class_name}_before_destroy(const ${class_name} *lb_obj, GHookFunc cb, gpointer user_data)
528
+ {
529
+ lb_impl._before_destroy((LBO *)lb_obj, cb, user_data);
530
+ }
531
+
532
+ /* 查询第n个对象 */
533
+ const ${class_name} *${class_name}_nth(int nth)
534
+ {
535
+ return (const ${class_name} *)lb_impl._nth(&_${class_name}_interface, nth);
536
+ }
537
+
538
+ /* 查询对象名称 */
539
+ const gchar *${class_name}_name(const ${class_name} *obj)
540
+ {
541
+ return lbo_name((LBO *)obj);
542
+ }
543
+
544
+ /* 对象加锁 */
545
+ void ${class_name}_lock(const ${class_name} *obj)
546
+ {
547
+ lbo_lock((LBO *)obj);
548
+ }
549
+
550
+ /* 对象解锁 */
551
+ void ${class_name}_unlock(const ${class_name} *obj)
552
+ {
553
+ lbo_unlock((LBO *)obj);
554
+ }
555
+
556
+ /* 对象列表查询接口 */
557
+ GSList *${class_name}_list(void)
558
+ {
559
+ return lb_impl._list(&_${class_name}_interface);
560
+ }
561
+
562
+ % for prop in intf.properties:
563
+ /* 监听属性${prop.name}变更 */
564
+ void ${class_name}_${prop.name}_hook(const ${class_name}_property_hook *hook)
565
+ {
566
+ lb_impl._prop_hook(&${properties}.${prop.name}, (const LBPropertyHook *)hook);
567
+ }
568
+
569
+ % endfor
570
+ % endif
461
571
  static void __attribute__((constructor(150))) ${class_name}_register(void)
462
572
  {
463
573
  // 从公共库中复制信号处理函数
@@ -0,0 +1,153 @@
1
+ <% from lbkit.tools import hump2underline %>\
2
+ #ifndef __${"_".join(intf.name.upper().split(".", -1))}_SRV_H__
3
+ #define __${"_".join(intf.name.upper().split(".", -1))}_SRV_H__
4
+
5
+ #include <glib-2.0/glib.h>
6
+ #include <glib-2.0/gio/gio.h>
7
+ #include "lb_base.h"
8
+ #include "public/${intf.name}.h"
9
+
10
+ #ifdef __cplusplus
11
+ extern "C" {
12
+ #endif
13
+ <% class_name = intf.alias %>\
14
+
15
+ % for prop in intf.properties:
16
+ /*
17
+ * property: ${prop.name}
18
+ % if len(prop.description.strip()) > 0:
19
+ *
20
+ % for line in prop.description.split("\n"):
21
+ % if len(line.strip()) > 0:
22
+ * ${line.strip()}
23
+ % endif
24
+ % endfor
25
+ % endif
26
+ */
27
+ % if prop.deprecated:
28
+ __attribute__((__deprecated__)) void ${class_name}_set_${prop.name}(const ${class_name} *object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")});
29
+ % else:
30
+ void ${class_name}_set_${prop.name}(const ${class_name} *object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")});
31
+ % endif
32
+ % endfor
33
+
34
+ % for signal in intf.signals:
35
+ /*
36
+ * signal: ${signal.name}
37
+ % if len(signal.description.strip()) > 0:
38
+ *
39
+ % for line in signal.description.split("\n"):
40
+ % if len(line.strip()) > 0:
41
+ * ${line.strip()}
42
+ % endif
43
+ % endfor
44
+ % endif
45
+ */
46
+ % if len(signal.properties.parameters) > 0:
47
+ gboolean ${class_name}_${signal.name}_Signal(const ${class_name} *object, const gchar *destination,
48
+ const ${class_name}_${signal.name}_Msg *msg, GError **error);
49
+ % else:
50
+ gboolean ${class_name}_${signal.name}_Signal(const ${class_name} *object, const gchar *destination, GError **error);
51
+ % endif
52
+ % endfor
53
+
54
+ LBInterface *${class_name}_interface(void);
55
+ ${class_name}_Properties *${class_name}_properties(void);
56
+
57
+ #define ${hump2underline(class_name).upper()} ${class_name}_interface()
58
+
59
+ % if codegen_version >= 4:
60
+ /* notes: 对象变更加回调函数 */
61
+ typedef void (*${class_name}_on_changed_hook)(const ${class_name} *lb_obj, gpointer user_data);
62
+ /* notes: 属性变更后回调,远程对象或本地对象变更后都会调用 */
63
+ typedef void (*${class_name}_after_changed_hook)(const ${class_name} *object, const LBProperty *prop, GVariant *value, gpointer user_data);
64
+ /* notes: 属性变更前回调,返回-1表示阻止值变更,一般用于值合法性校验,只在被远程操作时才会生效,本地变更值不会回调 */
65
+ typedef gint (*${class_name}_before_change_hook)(const ${class_name} *object, const LBProperty *prop, GVariant *value, gpointer user_data, GError **error);
66
+
67
+ /* 属性值变更回调钩子 */
68
+ typedef struct {
69
+ ${class_name}_after_changed_hook after; /* 属性变更(写入对象数据区后)后回调函数 */
70
+ ${class_name}_before_change_hook before; /* 属性变更前回调函数,返回0后继续调用,返回非0时中止,所有before都成功时执行属性变更 */
71
+ gpointer user_data;
72
+ } ${class_name}_property_hook;
73
+ /* 查询对象 */
74
+ const ${class_name} *${class_name}_get(const gchar *name);
75
+ /* 创建对象 */
76
+ const ${class_name} *${class_name}_new(const gchar *name, gboolean *exist);
77
+ void ${class_name}_unref(const ${class_name} **obj);
78
+ /* 加对象引用计数 */
79
+ const ${class_name} *${class_name}_ref(const ${class_name} *obj);
80
+ /* 设置在位状态 */
81
+ void ${class_name}_present_set(const ${class_name} *obj, gboolean present);
82
+ /* 获取在位状态 */
83
+ gboolean ${class_name}_present(const ${class_name} *obj);
84
+ /* 绑定数据 */
85
+ void ${class_name}_bind(const ${class_name} *lb_obj, gpointer data, GDestroyNotify destroy_func);
86
+ /* 获取绑定数据 */
87
+ gpointer ${class_name}_data(const ${class_name} *lb_obj);
88
+ /* @notes 属性对象属性值变更(后)事件 */
89
+ gint ${class_name}_on_prop_changed(const ${class_name} *lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gpointer user_data, GDestroyNotify destroy);
90
+ /* 取消监听,成功取消监听时会调用监听时设置的destroy回调清除注册时的user_data */
91
+ void ${class_name}_on_prop_changed_cancel(const ${class_name} *lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gconstpointer user_data);
92
+ /* 对象添加删除事件 */
93
+ void ${class_name}_on_changed(${class_name}_on_changed_hook cb, gpointer user_data, GDestroyNotify destroy);
94
+ /* 注册对象释放回调 */
95
+ void ${class_name}_before_destroy(const ${class_name} *lb_obj, GHookFunc cb, gpointer user_data);
96
+ /*
97
+ * 查询第n个对象
98
+ * @notes: 支持正逆向查询第n个对象,返回的对象需要使用lbo_unref减引用计数
99
+ * 正向查找传入非负n,以0开始计数,表示查找最早创建的第n个对象;
100
+ * 逆向查找传入负数n,以-1开始计数,依次为-2、-3等,表示查找最后创建的第n个对象。
101
+ */
102
+ const ${class_name} *${class_name}_nth(int nth);
103
+ /* 查询对象名称 */
104
+ const gchar *${class_name}_name(const ${class_name} *obj);
105
+ /* 对象加锁 */
106
+ void ${class_name}_lock(const ${class_name} *obj);
107
+ /* 对象解锁 */
108
+ void ${class_name}_unlock(const ${class_name} *obj);
109
+ /* 对象列表查询接口
110
+ * @notes: 返回的单链需要lbo_unref减每个单链数据的引用计数
111
+ * 或者调用${class_name}_list_free释放
112
+ * 或者申明GSList时使用cleanup_${class_name}_list在作用域结束时自动释放
113
+ */
114
+ GSList *${class_name}_list(void);
115
+ /* 监听属性 */
116
+ % for prop in intf.properties:
117
+ void ${class_name}_${prop.name}_hook(const ${class_name}_property_hook *hook);
118
+ % endfor
119
+
120
+ static inline void ${class_name}_unref_p(const ${class_name} *obj)
121
+ {
122
+ ${class_name}_unref(&obj);
123
+ }
124
+
125
+ static inline void _cleanup_${class_name}_(const ${class_name} **ptr)
126
+ {
127
+ if (ptr && *ptr) {
128
+ ${class_name}_unref(ptr);
129
+ }
130
+ }
131
+
132
+ static inline void ${class_name}_list_free(GSList **list)
133
+ {
134
+ g_assert(list);
135
+ g_slist_free_full(*list, (GDestroyNotify)${class_name}_unref_p);
136
+ *list = NULL;
137
+ }
138
+
139
+ static inline void _cleanup_${class_name}_list(GSList **ptr)
140
+ {
141
+ if (ptr && *ptr) {
142
+ ${class_name}_list_free(ptr);
143
+ }
144
+ }
145
+
146
+ #define cleanup_${class_name} __attribute__((cleanup(_cleanup_${class_name}_)))
147
+ #define cleanup_${class_name}_list __attribute__((cleanup(_cleanup_${class_name}_list)))
148
+ % endif
149
+ #ifdef __cplusplus
150
+ }
151
+ #endif
152
+
153
+ #endif /* __${"_".join(intf.name.upper().split(".", -1))}_H__ */
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: lbkit
3
- Version: 0.6.7
3
+ Version: 0.7.0
4
4
  Summary: Tools provided by litebmc.com
5
5
  Home-page: https://www.litebmc.com
6
6
  Author: xuhj@litebmc.com
@@ -1,2 +0,0 @@
1
-
2
- __version__ = '0.6.7'
@@ -1,120 +0,0 @@
1
- #ifndef __${"_".join(intf.name.upper().split(".", -1))}_CLI_H__
2
- #define __${"_".join(intf.name.upper().split(".", -1))}_CLI_H__
3
-
4
- #include <glib-2.0/glib.h>
5
- #include <glib-2.0/gio/gio.h>
6
- #include "lb_base.h"
7
- #include "public/${intf.name}.h"
8
-
9
- #ifdef __cplusplus
10
- extern "C" {
11
- #endif
12
- <% class_name = intf.alias + "_Cli"%>
13
- typedef ${intf.alias} ${class_name};
14
- typedef ${intf.alias}_Properties ${class_name}_Properties;
15
-
16
- % for prop in intf.properties:
17
- % if not prop.private:
18
- /*
19
- * property: ${prop.name}
20
- % if len(prop.description.strip()) > 0:
21
- *
22
- % for line in prop.description.split("\n"):
23
- % if len(line.strip()) > 0:
24
- * ${line.strip()}
25
- % endif
26
- % endfor
27
- % endif
28
- */
29
- ## 私有属性或者只读属性不允许写
30
- % if not prop.private and prop.access != "read":
31
- % if prop.deprecated:
32
- __attribute__((__deprecated__)) gint ${class_name}_set_${prop.name}(const ${class_name} *object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")}, GError **error);
33
- % else:
34
- gint ${class_name}_set_${prop.name}(const ${class_name} *object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")}, GError **error);
35
- % endif
36
- % endif
37
- % if not prop.private and prop.access != "write":
38
- % if prop.deprecated:
39
- __attribute__((__deprecated__)) gint ${class_name}_get_${prop.name}(const ${class_name} *object, ${", ".join(prop.out_declare()).replace("<arg_name>", "value").replace("<const>", "")}, GError **error);
40
- % else:
41
- gint ${class_name}_get_${prop.name}(const ${class_name} *object, ${", ".join(prop.out_declare()).replace("<arg_name>", "value").replace("<const>", "")}, GError **error);
42
- % endif
43
- % endif
44
- % endif
45
- % endfor
46
-
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
56
- /*
57
- * method: ${method.name}
58
- % if len(method.description.strip()) > 0:
59
- *
60
- % for line in method.description.split("\n"):
61
- % if len(line.strip()) > 0:
62
- * ${line.strip()}
63
- % endif
64
- % endfor
65
- % endif
66
- */
67
- % if method.deprecated:
68
- __attribute__((__deprecated__)) int ${class_name}_Call_${method.name}(const ${class_name} *object,
69
- ${REQ_PARA}${RSP_PARA}gint timeout,
70
- GError **error);
71
- % else:
72
- int ${class_name}_Call_${method.name}(const ${class_name} *object,
73
- ${REQ_PARA}${RSP_PARA}gint timeout,
74
- GError **error);
75
- % endif
76
- % endfor
77
-
78
- % for signal in intf.signals:
79
- /*
80
- * signal: ${signal.name}
81
- % if len(signal.description.strip()) > 0:
82
- *
83
- % for line in signal.description.split("\n"):
84
- % if len(line.strip()) > 0:
85
- * ${line.strip()}
86
- % endif
87
- % endfor
88
- % endif
89
- */
90
- typedef void (*${class_name}_${signal.name}_Signal)(const ${class_name} *object, const gchar *destination,
91
- const ${intf.alias}_${signal.name}_Msg *req, gpointer user_data);
92
- /**/
93
- % if signal.deprecated:
94
- __attribute__((__deprecated__)) guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Signal handler,
95
- const gchar *bus_name, const gchar *object_path, const gchar *arg0, gpointer user_data);
96
- % else:
97
- guint ${class_name}_Subscribe_${signal.name}(${class_name}_${signal.name}_Signal handler,
98
- const gchar *bus_name, const gchar *object_path, const gchar *arg0, gpointer user_data);
99
- % endif
100
- % if signal.deprecated:
101
- __attribute__((__deprecated__)) void ${class_name}_Unsubscribe_${signal.name}(guint *id);
102
- % else:
103
- void ${class_name}_Unsubscribe_${signal.name}(guint *id);
104
- % endif
105
-
106
- % endfor
107
- #define ${class_name.upper()}_NAME "${intf.name}"
108
- % for prop in intf.properties:
109
- #define ${class_name.upper()}_${prop.name}_NAME "${prop.name}"
110
- % endfor
111
-
112
- ${class_name}_Properties *${class_name}_properties(void);
113
- LBInterface *${class_name}_interface(void);
114
- #define ${class_name.upper()}_INTERFACE ${class_name}_interface()
115
-
116
- #ifdef __cplusplus
117
- }
118
- #endif
119
-
120
- #endif /* __${"_".join(intf.name.upper().split(".", -1))}_CLI_H__ */
@@ -1,66 +0,0 @@
1
- #ifndef __${"_".join(intf.name.upper().split(".", -1))}_SRV_H__
2
- #define __${"_".join(intf.name.upper().split(".", -1))}_SRV_H__
3
-
4
- #include <glib-2.0/glib.h>
5
- #include <glib-2.0/gio/gio.h>
6
- #include "lb_base.h"
7
- #include "public/${intf.name}.h"
8
-
9
- #ifdef __cplusplus
10
- extern "C" {
11
- #endif
12
- <% class_name = intf.alias %>\
13
-
14
- % for prop in intf.properties:
15
- /*
16
- * property: ${prop.name}
17
- % if len(prop.description.strip()) > 0:
18
- *
19
- % for line in prop.description.split("\n"):
20
- % if len(line.strip()) > 0:
21
- * ${line.strip()}
22
- % endif
23
- % endfor
24
- % endif
25
- */
26
- % if prop.deprecated:
27
- __attribute__((__deprecated__)) void ${class_name}_set_${prop.name}(const ${class_name} *object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")});
28
- % else:
29
- void ${class_name}_set_${prop.name}(const ${class_name} *object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")});
30
- % endif
31
- % endfor
32
-
33
- % for signal in intf.signals:
34
- /*
35
- * signal: ${signal.name}
36
- % if len(signal.description.strip()) > 0:
37
- *
38
- % for line in signal.description.split("\n"):
39
- % if len(line.strip()) > 0:
40
- * ${line.strip()}
41
- % endif
42
- % endfor
43
- % endif
44
- */
45
- % if len(signal.properties.parameters) > 0:
46
- gboolean ${class_name}_${signal.name}_Signal(const ${class_name} *object, const gchar *destination,
47
- const ${class_name}_${signal.name}_Msg *msg, GError **error);
48
- % else:
49
- gboolean ${class_name}_${signal.name}_Signal(const ${class_name} *object, const gchar *destination, GError **error);
50
- % endif
51
- % endfor
52
-
53
- #define ${class_name.upper()}_NAME "${intf.name}"
54
- % for prop in intf.properties:
55
- #define ${class_name.upper()}_${prop.name}_NAME "${prop.name}"
56
- % endfor
57
-
58
- LBInterface *${class_name}_interface(void);
59
- #define ${class_name.upper()}_INTERFACE ${class_name}_interface()
60
- ${class_name}_Properties *${class_name}_properties(void);
61
-
62
- #ifdef __cplusplus
63
- }
64
- #endif
65
-
66
- #endif /* __${"_".join(intf.name.upper().split(".", -1))}_H__ */
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