lbkit 0.7.0__tar.gz → 0.7.2__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 (59) hide show
  1. {lbkit-0.7.0/lbkit.egg-info → lbkit-0.7.2}/PKG-INFO +1 -1
  2. lbkit-0.7.2/lbkit/__init__.py +2 -0
  3. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/template/client.c.mako +47 -25
  4. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/template/client.h.mako +29 -25
  5. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/template/public.c.mako +18 -18
  6. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/template/public.h.mako +15 -11
  7. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/template/server.c.mako +46 -36
  8. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/template/server.h.mako +24 -24
  9. {lbkit-0.7.0 → lbkit-0.7.2/lbkit.egg-info}/PKG-INFO +1 -1
  10. lbkit-0.7.0/lbkit/__init__.py +0 -2
  11. {lbkit-0.7.0 → lbkit-0.7.2}/AUTHORS +0 -0
  12. {lbkit-0.7.0 → lbkit-0.7.2}/LICENSE +0 -0
  13. {lbkit-0.7.0 → lbkit-0.7.2}/MANIFEST.in +0 -0
  14. {lbkit-0.7.0 → lbkit-0.7.2}/README.md +0 -0
  15. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/build_conan_parallel.py +0 -0
  16. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/ci_robot/__init__.py +0 -0
  17. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/ci_robot/gitee.py +0 -0
  18. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/cli.py +0 -0
  19. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/__init__.py +0 -0
  20. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/codegen.py +0 -0
  21. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/ctype_defination.py +0 -0
  22. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/idf_interface.py +0 -0
  23. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/renderer.py +0 -0
  24. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/template/interface.c.mako +0 -0
  25. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/codegen/template/interface.introspect.xml.mako +0 -0
  26. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/component/__init__.py +0 -0
  27. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/component/arg_parser.py +0 -0
  28. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/component/build.py +0 -0
  29. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/component/template/conanbase.mako +0 -0
  30. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/component/template/deploy.mako +0 -0
  31. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/component/test.py +0 -0
  32. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/errors.py +0 -0
  33. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/helper.py +0 -0
  34. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/integration/__init__.py +0 -0
  35. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/integration/build_image.py +0 -0
  36. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/integration/build_manifest.py +0 -0
  37. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/integration/build_prepare.py +0 -0
  38. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/integration/build_rootfs.py +0 -0
  39. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/integration/config.py +0 -0
  40. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/integration/task.py +0 -0
  41. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/integration/template/conanfile.py.mako +0 -0
  42. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/integration/template/rootfs.py.mako +0 -0
  43. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/lbkit.py +0 -0
  44. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/log.py +0 -0
  45. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/misc.py +0 -0
  46. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/tools.py +0 -0
  47. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/utils/__init__.py +0 -0
  48. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/utils/images/__init__.py +0 -0
  49. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit/utils/images/emmc.py +0 -0
  50. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit.egg-info/SOURCES.txt +0 -0
  51. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit.egg-info/dependency_links.txt +0 -0
  52. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit.egg-info/entry_points.txt +0 -0
  53. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit.egg-info/requires.txt +0 -0
  54. {lbkit-0.7.0 → lbkit-0.7.2}/lbkit.egg-info/top_level.txt +0 -0
  55. {lbkit-0.7.0 → lbkit-0.7.2}/setup.cfg +0 -0
  56. {lbkit-0.7.0 → lbkit-0.7.2}/setup.py +0 -0
  57. {lbkit-0.7.0 → lbkit-0.7.2}/test/__init__.py +0 -0
  58. {lbkit-0.7.0 → lbkit-0.7.2}/test/test_codegen.py +0 -0
  59. {lbkit-0.7.0 → lbkit-0.7.2}/test/test_helper.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: lbkit
3
- Version: 0.7.0
3
+ Version: 0.7.2
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.2'
@@ -14,10 +14,10 @@ static const ${intf.alias}_Signals *${signal_processer} = NULL;
14
14
  ## 私有属性或者只读属性
15
15
  % if not prop.private and prop.access != "read":
16
16
  % if prop.deprecated:
17
- __attribute__((__deprecated__)) gint ${class_name}_set_${prop.name}(const ${class_name} *object,
17
+ __attribute__((__deprecated__)) gint ${class_name}_set_${prop.name}(${class_name} object,
18
18
  ${", ".join(prop.declare()).replace("<arg_name>", prop.name).replace("<const>", "const ")}, GError **error)
19
19
  % else:
20
- gint ${class_name}_set_${prop.name}(const ${class_name} *object,
20
+ gint ${class_name}_set_${prop.name}(${class_name} object,
21
21
  ${", ".join(prop.declare()).replace("<arg_name>", prop.name).replace("<const>", "const ")}, GError **error)
22
22
  % endif
23
23
  {
@@ -32,10 +32,10 @@ gint ${class_name}_set_${prop.name}(const ${class_name} *object,
32
32
  ## 私有或只写属性不允许读
33
33
  % if not prop.private and prop.access != "write":
34
34
  % if prop.deprecated:
35
- __attribute__((__deprecated__)) gint ${class_name}_get_${prop.name}(const ${class_name} *object,
35
+ __attribute__((__deprecated__)) gint ${class_name}_get_${prop.name}(${class_name} object,
36
36
  ${", ".join(prop.out_declare()).replace("<arg_name>", "value").replace("<const>", "")}, GError **error)
37
37
  % else:
38
- gint ${class_name}_get_${prop.name}(const ${class_name} *object, ${", ".join(prop.out_declare()).replace("<arg_name>", "value").replace("<const>", "")}, GError **error)
38
+ gint ${class_name}_get_${prop.name}(${class_name} object, ${", ".join(prop.out_declare()).replace("<arg_name>", "value").replace("<const>", "")}, GError **error)
39
39
  % endif
40
40
  {
41
41
  % if "gsize n_" in prop.declare()[0]:
@@ -80,7 +80,7 @@ gint ${class_name}_get_${prop.name}(const ${class_name} *object, ${", ".join(pro
80
80
  % if len(method.parameters.parameters) > 0:
81
81
  <% REQ_PARA = f'const {intf.alias}_{method.name}_Req *req, ' %>\
82
82
  % endif
83
- int ${class_name}_Call_${method.name}(const ${class_name} *object,
83
+ int ${class_name}_Call_${method.name}(${class_name} object,
84
84
  ${REQ_PARA}${RSP_PARA}gint timeout,
85
85
  GError **error)
86
86
  {
@@ -115,6 +115,16 @@ static LBInterface _${class_name}_interface = {
115
115
  .interface = NULL, /* load from usr/share/dbus-1/interfaces/${intf.name}.xml by lb_init */
116
116
  };
117
117
 
118
+ static LBBase *_get_real_object(LBO *object)
119
+ {
120
+ LBBase *real = (LBBase *)strstr((const char *)object, LB_MAGIC);
121
+ if ((gconstpointer)real != (gconstpointer)object) {
122
+ log_error("Get real object fail, Perhaps the memory has been freed, call abort() now");
123
+ abort();
124
+ }
125
+ return real;
126
+ }
127
+
118
128
  /**
119
129
  * @brief 销毁对象
120
130
  *
@@ -123,11 +133,11 @@ static LBInterface _${class_name}_interface = {
123
133
  static void _${class_name}_destroy(LBO *lb_obj)
124
134
  {
125
135
  g_assert(lb_obj);
126
- ${class_name} *obj = (${class_name} *)lb_obj;
136
+ struct _${intf.alias} *obj = (struct _${intf.alias} *)_get_real_object(lb_obj);
127
137
  g_rec_mutex_clear(obj->_base.lock);
128
138
  g_free(obj->_base.lock);
129
139
  ${intf.alias}_clean(obj);
130
- memset(obj, 0, sizeof(${class_name}));
140
+ memset(obj, 0, sizeof(struct _${intf.alias}));
131
141
  }
132
142
 
133
143
  /**
@@ -138,7 +148,7 @@ static void _${class_name}_destroy(LBO *lb_obj)
138
148
  */
139
149
  static LBO *_${class_name}_create(const gchar *obj_name, gpointer opaque)
140
150
  {
141
- ${class_name} *obj = g_new0(${class_name}, 1);
151
+ struct _${intf.alias} *obj = g_new0(struct _${intf.alias}, 1);
142
152
  memcpy(obj->_base.magic, LB_MAGIC, strlen(LB_MAGIC) + 1);
143
153
  obj->_base.lock = g_new0(GRecMutex, 1);
144
154
  g_rec_mutex_init(obj->_base.lock);
@@ -183,49 +193,61 @@ ${class_name}_Properties *${class_name}_properties(void)
183
193
  }
184
194
 
185
195
  % if codegen_version >= 4:
186
- const ${class_name} *${class_name}_get(const gchar *name)
196
+ ${class_name} ${class_name}_get(const gchar *well_known, const gchar *name)
187
197
  {
188
- return lb_impl._get(&_${class_name}_interface, name);
198
+ return lb_impl._cli_get(&_${class_name}_interface, well_known, name);
189
199
  }
190
200
 
191
- const ${class_name} *${class_name}_new(const gchar *well_known, const gchar *obj_name)
201
+ ${class_name} ${class_name}_new(const gchar *well_known, const gchar *obj_name)
192
202
  {
193
203
  LBO *obj = lb_impl._cli_new(&_${class_name}_interface, well_known, obj_name);
194
- return (const ${class_name} *)obj;
204
+ return (${class_name} )obj;
195
205
  }
196
206
 
197
207
  /* 减对象引用计数 */
198
- void ${class_name}_unref(const ${class_name} **obj)
208
+ void ${class_name}_unref(${class_name} *obj)
199
209
  {
200
210
  lb_impl._unref((LBO **)obj);
201
211
  }
202
212
 
203
213
  /* 加对象引用计数 */
204
- const ${class_name} *${class_name}_ref(const ${class_name} *obj)
214
+ ${class_name} ${class_name}_ref(${class_name} obj)
215
+ {
216
+ return (${class_name} )lb_impl._ref((LBO *)obj);
217
+ }
218
+
219
+ /* 设置在位状态 */
220
+ void ${class_name}_present_set(${class_name} obj, gboolean present)
221
+ {
222
+ lb_impl._present_set((LBO *)obj, present);
223
+ }
224
+
225
+ /* 获取在位状态 */
226
+ gboolean ${class_name}_present(${class_name} obj)
205
227
  {
206
- return (const ${class_name} *)lb_impl._ref((LBO *)obj);
228
+ return lb_impl._present((LBO *)obj);
207
229
  }
208
230
 
209
231
  /* 绑定数据 */
210
- void ${class_name}_bind(const ${class_name} *lb_obj, gpointer data, GDestroyNotify destroy_func)
232
+ void ${class_name}_bind(${class_name} lb_obj, gpointer data, GDestroyNotify destroy_func)
211
233
  {
212
234
  lb_impl._bind((LBO *)lb_obj, data, destroy_func);
213
235
  }
214
236
 
215
237
  /* 获取绑定数据 */
216
- gpointer ${class_name}_data(const ${class_name} *lb_obj)
238
+ gpointer ${class_name}_data(${class_name} lb_obj)
217
239
  {
218
240
  return lb_impl._data((LBO *)lb_obj);
219
241
  }
220
242
 
221
243
  /* @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)
244
+ gint ${class_name}_on_prop_changed(${class_name} lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gpointer user_data, GDestroyNotify destroy)
223
245
  {
224
246
  return lb_impl._on_prop_changed((LBO *)lb_obj, prop, (lbo_after_changed_hook)pc, user_data, destroy);
225
247
  }
226
248
 
227
249
  /* 取消监听,成功取消监听时会调用监听时设置的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)
250
+ void ${class_name}_on_prop_changed_cancel(${class_name} lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gconstpointer user_data)
229
251
  {
230
252
  lb_impl._on_prop_changed_cancel((LBO *)lb_obj, prop, (lbo_after_changed_hook)pc, user_data);
231
253
  }
@@ -237,31 +259,31 @@ void ${class_name}_on_changed(${class_name}_on_changed_hook cb, gpointer user_da
237
259
  }
238
260
 
239
261
  /* 注册对象释放回调 */
240
- void ${class_name}_before_destroy(const ${class_name} *lb_obj, GHookFunc cb, gpointer user_data)
262
+ void ${class_name}_before_destroy(${class_name} lb_obj, GHookFunc cb, gpointer user_data)
241
263
  {
242
264
  lb_impl._before_destroy((LBO *)lb_obj, cb, user_data);
243
265
  }
244
266
 
245
267
  /* 查询第n个对象 */
246
- const ${class_name} *${class_name}_nth(int nth)
268
+ ${class_name} ${class_name}_nth(int nth)
247
269
  {
248
- return (const ${class_name} *)lb_impl._nth(&_${class_name}_interface, nth);
270
+ return (${class_name} )lb_impl._nth(&_${class_name}_interface, nth);
249
271
  }
250
272
 
251
273
  /* 查询对象名称 */
252
- const gchar *${class_name}_name(const ${class_name} *obj)
274
+ const gchar *${class_name}_name(${class_name} obj)
253
275
  {
254
276
  return lbo_name((LBO *)obj);
255
277
  }
256
278
 
257
279
  /* 对象加锁 */
258
- void ${class_name}_lock(const ${class_name} *obj)
280
+ void ${class_name}_lock(${class_name} obj)
259
281
  {
260
282
  lbo_lock((LBO *)obj);
261
283
  }
262
284
 
263
285
  /* 对象解锁 */
264
- void ${class_name}_unlock(const ${class_name} *obj)
286
+ void ${class_name}_unlock(${class_name} obj)
265
287
  {
266
288
  lbo_unlock((LBO *)obj);
267
289
  }
@@ -30,16 +30,16 @@ typedef ${intf.alias}_Properties ${class_name}_Properties;
30
30
  ## 私有属性或者只读属性不允许写
31
31
  % if not prop.private and prop.access != "read":
32
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);
33
+ __attribute__((__deprecated__)) gint ${class_name}_set_${prop.name}(${class_name} object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")}, GError **error);
34
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);
35
+ gint ${class_name}_set_${prop.name}(${class_name} object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")}, GError **error);
36
36
  % endif
37
37
  % endif
38
38
  % if not prop.private and prop.access != "write":
39
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);
40
+ __attribute__((__deprecated__)) gint ${class_name}_get_${prop.name}(${class_name} object, ${", ".join(prop.out_declare()).replace("<arg_name>", "value").replace("<const>", "")}, GError **error);
41
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);
42
+ gint ${class_name}_get_${prop.name}(${class_name} object, ${", ".join(prop.out_declare()).replace("<arg_name>", "value").replace("<const>", "")}, GError **error);
43
43
  % endif
44
44
  % endif
45
45
  % endif
@@ -66,11 +66,11 @@ gint ${class_name}_get_${prop.name}(const ${class_name} *object, ${", ".join(pro
66
66
  % endif
67
67
  */
68
68
  % if method.deprecated:
69
- __attribute__((__deprecated__)) int ${class_name}_Call_${method.name}(const ${class_name} *object,
69
+ __attribute__((__deprecated__)) int ${class_name}_Call_${method.name}(${class_name} object,
70
70
  ${REQ_PARA}${RSP_PARA}gint timeout,
71
71
  GError **error);
72
72
  % else:
73
- int ${class_name}_Call_${method.name}(const ${class_name} *object,
73
+ int ${class_name}_Call_${method.name}(${class_name} object,
74
74
  ${REQ_PARA}${RSP_PARA}gint timeout,
75
75
  GError **error);
76
76
  % endif
@@ -88,7 +88,7 @@ int ${class_name}_Call_${method.name}(const ${class_name} *object,
88
88
  % endfor
89
89
  % endif
90
90
  */
91
- typedef void (*${class_name}_${signal.name}_Signal)(const ${class_name} *object, const gchar *destination,
91
+ typedef void (*${class_name}_${signal.name}_Signal)(${class_name} object, const gchar *destination,
92
92
  const ${intf.alias}_${signal.name}_Msg *req, gpointer user_data);
93
93
  /**/
94
94
  % if signal.deprecated:
@@ -112,11 +112,11 @@ LBInterface *${class_name}_interface(void);
112
112
 
113
113
  % if codegen_version >= 4:
114
114
  /* notes: 对象变更加回调函数 */
115
- typedef void (*${class_name}_on_changed_hook)(const ${class_name} *lb_obj, gpointer user_data);
115
+ typedef void (*${class_name}_on_changed_hook)(${class_name} lb_obj, gpointer user_data);
116
116
  /* notes: 属性变更后回调,远程对象或本地对象变更后都会调用 */
117
- typedef void (*${class_name}_after_changed_hook)(const ${class_name} *object, const LBProperty *prop, GVariant *value, gpointer user_data);
117
+ typedef void (*${class_name}_after_changed_hook)(${class_name} object, const LBProperty *prop, GVariant *value, gpointer user_data);
118
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);
119
+ typedef gint (*${class_name}_before_change_hook)(${class_name} object, const LBProperty *prop, GVariant *value, gpointer user_data, GError **error);
120
120
 
121
121
  /* 属性值变更回调钩子 */
122
122
  typedef struct {
@@ -125,38 +125,42 @@ typedef struct {
125
125
  gpointer user_data;
126
126
  } ${class_name}_property_hook;
127
127
  /* 查询对象 */
128
- const ${class_name} *${class_name}_get(const gchar *name);
128
+ ${class_name} ${class_name}_get(const gchar *well_known, const gchar *name);
129
129
  /* 创建对象 */
130
- const ${class_name} *${class_name}_new(const gchar *well_known, const gchar *obj_name);
130
+ ${class_name} ${class_name}_new(const gchar *well_known, const gchar *obj_name);
131
131
  /* 减对象引用计数 */
132
- void ${class_name}_unref(const ${class_name} **obj);
132
+ void ${class_name}_unref(${class_name} *obj);
133
133
  /* 加对象引用计数 */
134
- const ${class_name} *${class_name}_ref(const ${class_name} *obj);
134
+ ${class_name} ${class_name}_ref(${class_name} obj);
135
+ /* 设置在位状态 */
136
+ void ${class_name}_present_set(${class_name} obj, gboolean present);
137
+ /* 获取在位状态 */
138
+ gboolean ${class_name}_present(${class_name} obj);
135
139
  /* 绑定数据 */
136
- void ${class_name}_bind(const ${class_name} *lb_obj, gpointer data, GDestroyNotify destroy_func);
140
+ void ${class_name}_bind(${class_name} lb_obj, gpointer data, GDestroyNotify destroy_func);
137
141
  /* 获取绑定数据 */
138
- gpointer ${class_name}_data(const ${class_name} *lb_obj);
142
+ gpointer ${class_name}_data(${class_name} lb_obj);
139
143
  /* @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);
144
+ gint ${class_name}_on_prop_changed(${class_name} lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gpointer user_data, GDestroyNotify destroy);
141
145
  /* 取消监听,成功取消监听时会调用监听时设置的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);
146
+ void ${class_name}_on_prop_changed_cancel(${class_name} lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gconstpointer user_data);
143
147
  /* 对象变更事件 */
144
148
  void ${class_name}_on_changed(${class_name}_on_changed_hook cb, gpointer user_data, GDestroyNotify destroy);
145
149
  /* 注册对象释放回调 */
146
- void ${class_name}_before_destroy(const ${class_name} *lb_obj, GHookFunc cb, gpointer user_data);
150
+ void ${class_name}_before_destroy(${class_name} lb_obj, GHookFunc cb, gpointer user_data);
147
151
  /*
148
152
  * 查询第n个对象
149
153
  * @notes: 支持正逆向查询第n个对象,返回的对象需要使用lbo_unref减引用计数
150
154
  * 正向查找传入非负n,以0开始计数,表示查找最早创建的第n个对象;
151
155
  * 逆向查找传入负数n,以-1开始计数,依次为-2、-3等,表示查找最后创建的第n个对象。
152
156
  */
153
- const ${class_name} *${class_name}_nth(int nth);
157
+ ${class_name} ${class_name}_nth(int nth);
154
158
  /* 查询对象名称 */
155
- const gchar *${class_name}_name(const ${class_name} *obj);
159
+ const gchar *${class_name}_name(${class_name} obj);
156
160
  /* 对象加锁 */
157
- void ${class_name}_lock(const ${class_name} *obj);
161
+ void ${class_name}_lock(${class_name} obj);
158
162
  /* 对象解锁 */
159
- void ${class_name}_unlock(const ${class_name} *obj);
163
+ void ${class_name}_unlock(${class_name} obj);
160
164
  /* 对象列表查询接口 */
161
165
  GSList *${class_name}_list(void);
162
166
  /* 监听属性 */
@@ -164,12 +168,12 @@ GSList *${class_name}_list(void);
164
168
  void ${class_name}_${prop.name}_hook(const ${class_name}_property_hook *hook);
165
169
  % endfor
166
170
 
167
- static inline void ${class_name}_unref_p(const ${class_name} *obj)
171
+ static inline void ${class_name}_unref_p(${class_name} obj)
168
172
  {
169
173
  ${class_name}_unref(&obj);
170
174
  }
171
175
 
172
- static inline void _cleanup_${class_name}_(const ${class_name} **ptr)
176
+ static inline void _cleanup_${class_name}_(${class_name} *ptr)
173
177
  {
174
178
  if (ptr && *ptr) {
175
179
  ${class_name}_unref(ptr);
@@ -83,13 +83,13 @@ static gboolean __attribute__((unused)) _validate_odf_as_dict_${name}_v(yaml_doc
83
83
  % endfor
84
84
  % for name, stru in intf.structures.items():
85
85
  /* ${name}结构体类型序列化(struct转GVariant)函数 */
86
- GVariant *${name}_encode(const ${name} *value)
86
+ GVariant *${name}_encode(const struct _${name} *value)
87
87
  {
88
88
  % if stru.values.has_variant_value:
89
89
  g_assert(value);
90
90
 
91
91
  % else:
92
- static ${name} default_val;
92
+ static struct _${name} default_val;
93
93
  if (value == NULL) {
94
94
  value = &default_val;
95
95
  }
@@ -111,11 +111,11 @@ GVariant *${name}_encode(const ${name} *value)
111
111
  * ${name}结构体类型反序列化(GVariant转struct)函数,返回以NULL结束的指针数组
112
112
  * Note: return an EMPTY ${name} object when `in` is NULL
113
113
  */
114
- ${name} *${name}_decode(GVariant *in)
114
+ struct _${name} *${name}_decode(GVariant *in)
115
115
  {
116
116
  GVariantIter iter;
117
117
  __attribute__((unused)) GVariant *tmp = NULL;
118
- ${name} *output = g_new0(${name}, 1);
118
+ struct _${name} *output = g_new0(struct _${name}, 1);
119
119
  if (!in) {
120
120
  return output;
121
121
  }
@@ -133,7 +133,7 @@ ${name} *${name}_decode(GVariant *in)
133
133
  }
134
134
 
135
135
  /* ${name}结构体指针释放 */
136
- void ${name}_free(${name} **value)
136
+ void ${name}_free(struct _${name} **value)
137
137
  {
138
138
  if (!value || !(*value)) {
139
139
  return;
@@ -145,7 +145,7 @@ void ${name}_free(${name} **value)
145
145
  }
146
146
 
147
147
  /* ${name}结构体指针释放 */
148
- void ${name}_clean(${name} *value)
148
+ void ${name}_clean(struct _${name} *value)
149
149
  {
150
150
  if (!value) {
151
151
  return;
@@ -159,7 +159,7 @@ void ${name}_clean(${name} *value)
159
159
  }
160
160
 
161
161
  /* ${name}结构体组件类型序列化(struct转GVariant)函数,values以NULL结束的数组 */
162
- GVariant *${name}_encode_v(${name} * const *values)
162
+ GVariant *${name}_encode_v(struct _${name} * const *values)
163
163
  {
164
164
  GVariantBuilder builder;
165
165
  GVariant *tmp = NULL;
@@ -173,7 +173,7 @@ GVariant *${name}_encode_v(${name} * const *values)
173
173
  }
174
174
 
175
175
  /* ${name}结构体数组类型反序列化(GVariant转struct)函数,返回以NULL结束的指针数组 */
176
- ${name} **${name}_decode_v(GVariant *in)
176
+ struct _${name} **${name}_decode_v(GVariant *in)
177
177
  {
178
178
  if (!in) {
179
179
  return NULL;
@@ -187,7 +187,7 @@ ${name} **${name}_decode_v(GVariant *in)
187
187
  if (n == 0) {
188
188
  return NULL;
189
189
  }
190
- ${name} **output = g_new0(${name} *, n + 1);
190
+ struct _${name} **output = g_new0(struct _${name} *, n + 1);
191
191
  for (gsize i = 0; i < n; i++) {
192
192
  tmp = g_variant_iter_next_value(&iter);
193
193
  output[i] = ${name}_decode(tmp);
@@ -197,7 +197,7 @@ ${name} **${name}_decode_v(GVariant *in)
197
197
  }
198
198
 
199
199
  /* ${name}结构体指针数组释放 */
200
- void ${name}_free_v(${name} ***value)
200
+ void ${name}_free_v(struct _${name} ***value)
201
201
  {
202
202
  if(!value || !(*value)) {
203
203
  return;
@@ -356,7 +356,7 @@ gboolean _validate_odf_as_enum_${name}(yaml_document_t *doc, yaml_node_t *node,
356
356
  if (!valid) {
357
357
  return FALSE;
358
358
  }
359
- const gchar *value = node->data.scalar.value;
359
+ const gchar *value = (const gchar *)node->data.scalar.value;
360
360
  for (int i = 0; i <= ${len(enum.values.parameters)}; i++) {
361
361
  if (g_strcmp0(value, ${name}_as_string(i)) == 0) {
362
362
  return TRUE;
@@ -843,8 +843,10 @@ static GDBusPropertyInfo ${class_name}_property_${prop.name} =
843
843
 
844
844
  % endif
845
845
  % endfor
846
+ ## 只有自动生成工具版本号大于等于3的才会生成get和set方法
847
+ % if codegen_version >= 3:
846
848
  % if len(intf.properties):
847
- LBBase *_get_real_object(const ${class_name} *object)
849
+ static LBBase *_get_real_object(${class_name} object)
848
850
  {
849
851
  LBBase *real = (LBBase *)strstr((const char *)object, LB_MAGIC);
850
852
  if ((gconstpointer)real != (gconstpointer)object) {
@@ -854,13 +856,11 @@ LBBase *_get_real_object(const ${class_name} *object)
854
856
  return real;
855
857
  }
856
858
  % endif
857
- ## 只有自动生成工具版本号大于等于3的才会生成get和set方法
858
- % if codegen_version >= 3:
859
859
  % for prop in intf.properties:
860
860
  static void ${class_name}_set_${prop.name}_variant(LBO *object, GVariant *value)
861
861
  {
862
862
  g_assert(value && object);
863
- ${class_name} *real_obj = (${class_name} *)_get_real_object(object);
863
+ struct _${class_name} *real_obj = (struct _${class_name} *)_get_real_object(object);
864
864
  % for line in prop.free_func():
865
865
  ${line.replace("<arg_name>", "real_obj->" + prop.name)};
866
866
  % endfor
@@ -873,7 +873,7 @@ static GVariant *${class_name}_get_${prop.name}_variant(LBO *object)
873
873
  {
874
874
  g_assert(object);
875
875
  GVariant *out = NULL;
876
- ${class_name} *real_obj = (${class_name} *)_get_real_object(object);
876
+ struct _${class_name} *real_obj = (struct _${class_name} *)_get_real_object(object);
877
877
  % for line in prop.encode_func():
878
878
  ${line.replace("<arg_out>", "out").replace("n_<arg_name>", "real_obj->n_" + prop.name).replace("<arg_name>", "real_obj->" + prop.name)};
879
879
  % endfor
@@ -894,7 +894,7 @@ static ${class_name}_Properties _${class_name}_properties =
894
894
  % else:
895
895
  .info = NULL, /* load from /usr/share/dbus-1/interfaces/${intf.name} by lb_init */
896
896
  % endif
897
- .offset = offsetof(${class_name}, ${prop.name}),
897
+ .offset = offsetof(struct _${class_name}, ${prop.name}),
898
898
  % if codegen_version >= 3:
899
899
  .flags = ${prop.desc_flags},
900
900
  .set = ${class_name}_set_${prop.name}_variant,
@@ -1138,7 +1138,7 @@ void ${class_name}_${action.name}_unregister(${class_name}_${action.name}_action
1138
1138
  <% REQ_PARA = f', const {class_name}_{action.name}_Req *req' %>\
1139
1139
  <% REQ_NAME = f', req' %>\
1140
1140
  % endif
1141
- int ${class_name}_${action.name}_run(const ${class_name} *object${REQ_PARA}${RSP_PARA})
1141
+ int ${class_name}_${action.name}_run(${class_name} object${REQ_PARA}${RSP_PARA})
1142
1142
  {
1143
1143
  gint result = 0;
1144
1144
  g_mutex_lock(&_${class_name}_${action.name}_lock);
@@ -38,7 +38,11 @@ typedef enum {
38
38
  % endfor
39
39
  % endif
40
40
  */
41
+ % if name != class_name:
41
42
  typedef struct _${name} ${name};
43
+ % else:
44
+ typedef const struct _${name} * ${name};
45
+ % endif
42
46
  % endfor
43
47
  % for name, enum in intf.enumerations.items():
44
48
  /*
@@ -151,18 +155,18 @@ ${name} *${name}_new(void);
151
155
  % for name, stru in intf.structures.items():
152
156
  /* ${name} structure object */
153
157
  /* START: 结构体${name}及其数组类型的序列化、反序列化、释放函数 */
154
- GVariant *${name}_encode(const ${name} *value);
155
- ${name} *${name}_decode(GVariant *in);
158
+ GVariant *${name}_encode(const struct _${name} *value);
159
+ struct _${name} *${name}_decode(GVariant *in);
156
160
  // Clean up the memory of structure and it's all members, `*value` will to NULL
157
- void ${name}_free(${name} **value);
161
+ void ${name}_free(struct _${name} **value);
158
162
  // Clean up the memory of members managed by structure ${name}
159
- void ${name}_clean(${name} *value);
163
+ void ${name}_clean(struct _${name} *value);
160
164
 
161
- ${name} **${name}_decode_v(GVariant *in);
162
- GVariant *${name}_encode_v(${name} * const *value);
165
+ struct _${name} **${name}_decode_v(GVariant *in);
166
+ GVariant *${name}_encode_v(struct _${name} * const *value);
163
167
  // Clean up the memory of structure array and it's all members, `*value` will to NULL
164
- void ${name}_free_v(${name} ***value);
165
- /* END: 结构体${name}及其数组类型的序列化、反序列化、释放函数 */
168
+ void ${name}_free_v(struct _${name} ***value);
169
+ /* END: 结构体struct _${name}及其数组类型的序列化、反序列化、释放函数 */
166
170
 
167
171
  % endfor
168
172
  ## 定义枚举编解码函数
@@ -210,7 +214,7 @@ typedef struct {
210
214
  } ${class_name}_${method.name}_Rsp;
211
215
 
212
216
  % if not method.is_plugin:
213
- typedef int (*${class_name}_${method.name}_Method)(const ${class_name} *object,
217
+ typedef int (*${class_name}_${method.name}_Method)(${class_name} object,
214
218
  const ${class_name}_${method.name}_Req *req,
215
219
  ${class_name}_${method.name}_Rsp **rsp,
216
220
  GError **error, gpointer ext_data);
@@ -252,13 +256,13 @@ typedef struct {
252
256
  % if len(action.parameters.parameters) > 0:
253
257
  <% REQ_PARA = f', const {class_name}_{action.name}_Req *req' %>\
254
258
  % endif
255
- typedef int (*${class_name}_${action.name}_action)(const ${class_name} *object${REQ_PARA}${RSP_PARA}, gpointer user_data);
259
+ typedef int (*${class_name}_${action.name}_action)(${class_name} object${REQ_PARA}${RSP_PARA}, gpointer user_data);
256
260
 
257
261
  /* Register a new plugin action, can't register repeated with same action and user_data */
258
262
  int ${class_name}_${action.name}_register(const gchar *req_signature, const gchar *rsp_signature,
259
263
  ${class_name}_${action.name}_action action, gpointer user_data);
260
264
  void ${class_name}_${action.name}_unregister(${class_name}_${action.name}_action action);
261
- int ${class_name}_${action.name}_run(const ${class_name} *object${REQ_PARA}${RSP_PARA});
265
+ int ${class_name}_${action.name}_run(${class_name} object${REQ_PARA}${RSP_PARA});
262
266
 
263
267
  % endfor
264
268
  % endif
@@ -11,8 +11,8 @@ signal_processer = "_" + class_name + "_signals"
11
11
  % for name, stru in intf.structures.items():
12
12
  /* ${name} structure object */
13
13
  /* START: 结构体${name}及其数组类型的ODF加载函数 */
14
- ${name} *_load_odf_as_${name}(yaml_document_t *doc, yaml_node_t *node);
15
- ${name} **_load_odf_as_${name}_v(yaml_document_t *doc, yaml_node_t *node);
14
+ struct _${name} *_load_odf_as_${name}(yaml_document_t *doc, yaml_node_t *node);
15
+ struct _${name} **_load_odf_as_${name}_v(yaml_document_t *doc, yaml_node_t *node);
16
16
 
17
17
  % endfor
18
18
  ## 定义枚举ODF加载函数
@@ -33,7 +33,7 @@ ${name} **_load_odf_as_${name}_v(yaml_document_t *doc, yaml_node_t *node);
33
33
  % for name, stru in intf.structures.items():
34
34
  /* ${name} structure object */
35
35
  /* START: 结构体${name}及其数组类型的ODF加载函数 */
36
- ${name} *_load_odf_as_${name}(yaml_document_t *doc, yaml_node_t *node)
36
+ struct _${name} *_load_odf_as_${name}(yaml_document_t *doc, yaml_node_t *node)
37
37
  {
38
38
  <% cnt = 0 %>\
39
39
  % for prop in stru.values.parameters:
@@ -42,10 +42,10 @@ ${name} *_load_odf_as_${name}(yaml_document_t *doc, yaml_node_t *node)
42
42
  % endif
43
43
  % endfor
44
44
  % if cnt == 0:
45
- return g_new0(${name}, 1);
45
+ return g_new0(struct _${name}, 1);
46
46
  % else:
47
47
  __attribute__((unused)) yaml_node_t *val;
48
- ${name} *output = g_new0(${name}, 1);
48
+ struct _${name} *output = g_new0(struct _${name}, 1);
49
49
  GHashTable *prop_table = load_yaml_mapping_to_hash_table(doc, node);
50
50
  % for prop in stru.values.parameters:
51
51
  % if prop.odf_load_func() is not None:
@@ -61,18 +61,18 @@ ${name} *_load_odf_as_${name}(yaml_document_t *doc, yaml_node_t *node)
61
61
  % endif
62
62
  }
63
63
 
64
- ${name} **_load_odf_as_${name}_v(yaml_document_t *doc, yaml_node_t *node)
64
+ struct _${name} **_load_odf_as_${name}_v(yaml_document_t *doc, yaml_node_t *node)
65
65
  {
66
66
  yaml_node_t *val;
67
67
  gint i = 0;
68
68
  if (node->type != YAML_SEQUENCE_NODE) {
69
69
  log_warn("Load array ${name} failed because node type error, need type 1(sequence), get type %d", node->type);
70
- return g_new0(${name} *, 1);
70
+ return g_new0(struct _${name} *, 1);
71
71
  }
72
72
  yaml_node_item_t *top = node->data.sequence.items.top;
73
73
  yaml_node_item_t *start = node->data.sequence.items.start;
74
74
  gsize cnt = ((gsize)top - (gsize)start) / sizeof(yaml_node_item_t);
75
- ${name} **output = g_new0(${name} *, cnt + 1);
75
+ struct _${name} **output = g_new0(struct _${name} *, cnt + 1);
76
76
 
77
77
  for (yaml_node_item_t *item = start; item < top; item++) {
78
78
  val = yaml_document_get_node(doc, *item);
@@ -92,7 +92,7 @@ ${name} _load_odf_as_${name}(yaml_document_t *doc, yaml_node_t *node)
92
92
  }
93
93
 
94
94
  for (int i = 0; i <= ${len(enum.values.parameters)}; i++) {
95
- if (g_strcmp0(node->data.scalar.value, ${name}_as_string(i)) == 0) {
95
+ if (g_strcmp0((const gchar *)node->data.scalar.value, ${name}_as_string(i)) == 0) {
96
96
  return (${name})i;
97
97
  }
98
98
  }
@@ -188,10 +188,10 @@ static const ${class_name}_Signals *${signal_processer} = NULL;
188
188
 
189
189
  % for prop in intf.properties:
190
190
  % if prop.deprecated:
191
- __attribute__((__deprecated__)) void ${class_name}_set_${prop.name}(const ${class_name} *object,
191
+ __attribute__((__deprecated__)) void ${class_name}_set_${prop.name}(${class_name} object,
192
192
  ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")})
193
193
  % else:
194
- void ${class_name}_set_${prop.name}(const ${class_name} *object,
194
+ void ${class_name}_set_${prop.name}(${class_name} object,
195
195
  ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")})
196
196
  % endif
197
197
  {
@@ -210,10 +210,10 @@ void ${class_name}_set_${prop.name}(const ${class_name} *object,
210
210
  <% REQ_PARA = f'const {class_name}_{signal.name}_Msg *msg, ' %>\
211
211
  % endif
212
212
  % if signal.deprecated:
213
- __attribute__((__deprecated__)) gboolean ${class_name}_${signal.name}_Signal(const ${class_name} *object,
213
+ __attribute__((__deprecated__)) gboolean ${class_name}_${signal.name}_Signal(${class_name} object,
214
214
  const gchar *destination, ${REQ_PARA}GError **error)
215
215
  % else:
216
- gboolean ${class_name}_${signal.name}_Signal(const ${class_name} *object, const gchar *destination,
216
+ gboolean ${class_name}_${signal.name}_Signal(${class_name} object, const gchar *destination,
217
217
  ${REQ_PARA}GError **error)
218
218
  % endif
219
219
  {
@@ -251,7 +251,7 @@ static LBInterface _${class_name}_interface = {
251
251
 
252
252
  % for prop in intf.properties:
253
253
  static void _load_odf_as_prop_${prop.name}(yaml_document_t *doc, GHashTable *prop_table,
254
- ${class_name} *obj, lbo_property_reference_loaded_handler ref_loaded, gpointer user_data)
254
+ struct _${class_name} *obj, lbo_property_reference_loaded_handler ref_loaded, gpointer user_data)
255
255
  {
256
256
  __attribute__((unused)) gint i = 0;
257
257
  const gchar *flags = NULL;
@@ -352,7 +352,7 @@ static void _load_from_odf(yaml_document_t *doc, yaml_node_t *node, LBO *lb_obj,
352
352
  % if cnt == 0:
353
353
  return;
354
354
  % else:
355
- ${class_name} *obj = (${class_name} *)lb_obj;
355
+ struct _${class_name} *obj = (struct _${class_name} *)lb_obj;
356
356
  ${class_name}_clean(obj);
357
357
  GHashTable *prop_table = load_yaml_mapping_to_hash_table(doc, node);
358
358
  % for prop in intf.properties:
@@ -363,6 +363,16 @@ static void _load_from_odf(yaml_document_t *doc, yaml_node_t *node, LBO *lb_obj,
363
363
  % endif
364
364
  }
365
365
 
366
+ static LBBase *_get_real_object(LBO *object)
367
+ {
368
+ LBBase *real = (LBBase *)strstr((const char *)object, LB_MAGIC);
369
+ if ((gconstpointer)real != (gconstpointer)object) {
370
+ log_error("Get real object fail, Perhaps the memory has been freed, call abort() now");
371
+ abort();
372
+ }
373
+ return real;
374
+ }
375
+
366
376
  /**
367
377
  * @brief 销毁对象
368
378
  *
@@ -371,11 +381,11 @@ static void _load_from_odf(yaml_document_t *doc, yaml_node_t *node, LBO *lb_obj,
371
381
  static void _${class_name}_destroy(LBO *lb_obj)
372
382
  {
373
383
  g_assert(lb_obj);
374
- ${class_name} *obj = (${class_name} *)lb_obj;
384
+ struct _${class_name} *obj = (struct _${class_name} *)_get_real_object(lb_obj);
375
385
  g_rec_mutex_clear(obj->_base.lock);
376
386
  g_free(obj->_base.lock);
377
387
  ${class_name}_clean(obj);
378
- memset(obj, 0, sizeof(${class_name}));
388
+ memset(obj, 0, sizeof(struct _${class_name}));
379
389
  g_free(obj);
380
390
  }
381
391
 
@@ -388,7 +398,7 @@ static void _${class_name}_destroy(LBO *lb_obj)
388
398
  static LBO *_${class_name}_create(const gchar *obj_name, gpointer opaque)
389
399
  {
390
400
  __attribute__((unused)) gint i = 0;
391
- ${class_name} *obj = g_new0(${class_name}, 1);
401
+ struct _${class_name} *obj = g_new0(struct _${class_name}, 1);
392
402
  memcpy(obj->_base.magic, LB_MAGIC, strlen(LB_MAGIC) + 1);
393
403
  obj->_base.lock = g_new0(GRecMutex, 1);
394
404
  g_rec_mutex_init(obj->_base.lock);
@@ -459,60 +469,60 @@ ${class_name}_Properties *${class_name}_properties(void)
459
469
  }
460
470
 
461
471
  % if codegen_version >= 4:
462
- const ${class_name} *${class_name}_get(const gchar *name)
472
+ ${class_name} ${class_name}_get(const gchar *name)
463
473
  {
464
474
  return lb_impl._get(&_${class_name}_interface, name);
465
475
  }
466
476
 
467
- const ${class_name} *${class_name}_new(const gchar *name, gboolean *exist)
477
+ ${class_name} ${class_name}_new(const gchar *name, gboolean *exist)
468
478
  {
469
479
  LBO *obj = lb_impl._new(&_${class_name}_interface, name, exist);
470
- return (const ${class_name} *)obj;
480
+ return (${class_name} )obj;
471
481
  }
472
482
 
473
- void ${class_name}_unref(const ${class_name} **obj)
483
+ void ${class_name}_unref(${class_name} *obj)
474
484
  {
475
485
  lb_impl._unref((LBO **)obj);
476
486
  }
477
487
 
478
488
  /* 加对象引用计数 */
479
- const ${class_name} *${class_name}_ref(const ${class_name} *obj)
489
+ ${class_name} ${class_name}_ref(${class_name} obj)
480
490
  {
481
- return (const ${class_name} *)lb_impl._ref((LBO *)obj);
491
+ return (${class_name} )lb_impl._ref((LBO *)obj);
482
492
  }
483
493
 
484
494
  /* 设置在位状态 */
485
- void ${class_name}_present_set(const ${class_name} *obj, gboolean present)
495
+ void ${class_name}_present_set(${class_name} obj, gboolean present)
486
496
  {
487
497
  lb_impl._present_set((LBO *)obj, present);
488
498
  }
489
499
 
490
500
  /* 获取在位状态 */
491
- gboolean ${class_name}_present(const ${class_name} *obj)
501
+ gboolean ${class_name}_present(${class_name} obj)
492
502
  {
493
503
  return lb_impl._present((LBO *)obj);
494
504
  }
495
505
 
496
506
  /* 绑定数据 */
497
- void ${class_name}_bind(const ${class_name} *lb_obj, gpointer data, GDestroyNotify destroy_func)
507
+ void ${class_name}_bind(${class_name} lb_obj, gpointer data, GDestroyNotify destroy_func)
498
508
  {
499
509
  lb_impl._bind((LBO *)lb_obj, data, destroy_func);
500
510
  }
501
511
 
502
512
  /* 获取绑定数据 */
503
- gpointer ${class_name}_data(const ${class_name} *lb_obj)
513
+ gpointer ${class_name}_data(${class_name} lb_obj)
504
514
  {
505
515
  return lb_impl._data((LBO *)lb_obj);
506
516
  }
507
517
 
508
518
  /* @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)
519
+ gint ${class_name}_on_prop_changed(${class_name} lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gpointer user_data, GDestroyNotify destroy)
510
520
  {
511
521
  return lb_impl._on_prop_changed((LBO *)lb_obj, prop, (lbo_after_changed_hook)pc, user_data, destroy);
512
522
  }
513
523
 
514
524
  /* 取消监听,成功取消监听时会调用监听时设置的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)
525
+ void ${class_name}_on_prop_changed_cancel(${class_name} lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gconstpointer user_data)
516
526
  {
517
527
  lb_impl._on_prop_changed_cancel((LBO *)lb_obj, prop, (lbo_after_changed_hook)pc, user_data);
518
528
  }
@@ -524,31 +534,31 @@ void ${class_name}_on_changed(${class_name}_on_changed_hook cb, gpointer user_da
524
534
  }
525
535
 
526
536
  /* 注册对象释放回调 */
527
- void ${class_name}_before_destroy(const ${class_name} *lb_obj, GHookFunc cb, gpointer user_data)
537
+ void ${class_name}_before_destroy(${class_name} lb_obj, GHookFunc cb, gpointer user_data)
528
538
  {
529
539
  lb_impl._before_destroy((LBO *)lb_obj, cb, user_data);
530
540
  }
531
541
 
532
542
  /* 查询第n个对象 */
533
- const ${class_name} *${class_name}_nth(int nth)
543
+ ${class_name} ${class_name}_nth(int nth)
534
544
  {
535
- return (const ${class_name} *)lb_impl._nth(&_${class_name}_interface, nth);
545
+ return (${class_name} )lb_impl._nth(&_${class_name}_interface, nth);
536
546
  }
537
547
 
538
548
  /* 查询对象名称 */
539
- const gchar *${class_name}_name(const ${class_name} *obj)
549
+ const gchar *${class_name}_name(${class_name} obj)
540
550
  {
541
551
  return lbo_name((LBO *)obj);
542
552
  }
543
553
 
544
554
  /* 对象加锁 */
545
- void ${class_name}_lock(const ${class_name} *obj)
555
+ void ${class_name}_lock(${class_name} obj)
546
556
  {
547
557
  lbo_lock((LBO *)obj);
548
558
  }
549
559
 
550
560
  /* 对象解锁 */
551
- void ${class_name}_unlock(const ${class_name} *obj)
561
+ void ${class_name}_unlock(${class_name} obj)
552
562
  {
553
563
  lbo_unlock((LBO *)obj);
554
564
  }
@@ -25,9 +25,9 @@ extern "C" {
25
25
  % endif
26
26
  */
27
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 ")});
28
+ __attribute__((__deprecated__)) void ${class_name}_set_${prop.name}(${class_name} object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")});
29
29
  % else:
30
- void ${class_name}_set_${prop.name}(const ${class_name} *object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")});
30
+ void ${class_name}_set_${prop.name}(${class_name} object, ${", ".join(prop.declare()).replace("<arg_name>", "value").replace("<const>", "const ")});
31
31
  % endif
32
32
  % endfor
33
33
 
@@ -44,10 +44,10 @@ void ${class_name}_set_${prop.name}(const ${class_name} *object, ${", ".join(pro
44
44
  % endif
45
45
  */
46
46
  % if len(signal.properties.parameters) > 0:
47
- gboolean ${class_name}_${signal.name}_Signal(const ${class_name} *object, const gchar *destination,
47
+ gboolean ${class_name}_${signal.name}_Signal(${class_name} object, const gchar *destination,
48
48
  const ${class_name}_${signal.name}_Msg *msg, GError **error);
49
49
  % else:
50
- gboolean ${class_name}_${signal.name}_Signal(const ${class_name} *object, const gchar *destination, GError **error);
50
+ gboolean ${class_name}_${signal.name}_Signal(${class_name} object, const gchar *destination, GError **error);
51
51
  % endif
52
52
  % endfor
53
53
 
@@ -58,11 +58,11 @@ ${class_name}_Properties *${class_name}_properties(void);
58
58
 
59
59
  % if codegen_version >= 4:
60
60
  /* notes: 对象变更加回调函数 */
61
- typedef void (*${class_name}_on_changed_hook)(const ${class_name} *lb_obj, gpointer user_data);
61
+ typedef void (*${class_name}_on_changed_hook)(${class_name} lb_obj, gpointer user_data);
62
62
  /* notes: 属性变更后回调,远程对象或本地对象变更后都会调用 */
63
- typedef void (*${class_name}_after_changed_hook)(const ${class_name} *object, const LBProperty *prop, GVariant *value, gpointer user_data);
63
+ typedef void (*${class_name}_after_changed_hook)(${class_name} object, const LBProperty *prop, GVariant *value, gpointer user_data);
64
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);
65
+ typedef gint (*${class_name}_before_change_hook)(${class_name} object, const LBProperty *prop, GVariant *value, gpointer user_data, GError **error);
66
66
 
67
67
  /* 属性值变更回调钩子 */
68
68
  typedef struct {
@@ -71,41 +71,41 @@ typedef struct {
71
71
  gpointer user_data;
72
72
  } ${class_name}_property_hook;
73
73
  /* 查询对象 */
74
- const ${class_name} *${class_name}_get(const gchar *name);
74
+ ${class_name} ${class_name}_get(const gchar *name);
75
75
  /* 创建对象 */
76
- const ${class_name} *${class_name}_new(const gchar *name, gboolean *exist);
77
- void ${class_name}_unref(const ${class_name} **obj);
76
+ ${class_name} ${class_name}_new(const gchar *name, gboolean *exist);
77
+ void ${class_name}_unref(${class_name} *obj);
78
78
  /* 加对象引用计数 */
79
- const ${class_name} *${class_name}_ref(const ${class_name} *obj);
79
+ ${class_name} ${class_name}_ref(${class_name} obj);
80
80
  /* 设置在位状态 */
81
- void ${class_name}_present_set(const ${class_name} *obj, gboolean present);
81
+ void ${class_name}_present_set(${class_name} obj, gboolean present);
82
82
  /* 获取在位状态 */
83
- gboolean ${class_name}_present(const ${class_name} *obj);
83
+ gboolean ${class_name}_present(${class_name} obj);
84
84
  /* 绑定数据 */
85
- void ${class_name}_bind(const ${class_name} *lb_obj, gpointer data, GDestroyNotify destroy_func);
85
+ void ${class_name}_bind(${class_name} lb_obj, gpointer data, GDestroyNotify destroy_func);
86
86
  /* 获取绑定数据 */
87
- gpointer ${class_name}_data(const ${class_name} *lb_obj);
87
+ gpointer ${class_name}_data(${class_name} lb_obj);
88
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);
89
+ gint ${class_name}_on_prop_changed(${class_name} lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gpointer user_data, GDestroyNotify destroy);
90
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);
91
+ void ${class_name}_on_prop_changed_cancel(${class_name} lb_obj, const gchar *prop, ${class_name}_after_changed_hook pc, gconstpointer user_data);
92
92
  /* 对象添加删除事件 */
93
93
  void ${class_name}_on_changed(${class_name}_on_changed_hook cb, gpointer user_data, GDestroyNotify destroy);
94
94
  /* 注册对象释放回调 */
95
- void ${class_name}_before_destroy(const ${class_name} *lb_obj, GHookFunc cb, gpointer user_data);
95
+ void ${class_name}_before_destroy(${class_name} lb_obj, GHookFunc cb, gpointer user_data);
96
96
  /*
97
97
  * 查询第n个对象
98
98
  * @notes: 支持正逆向查询第n个对象,返回的对象需要使用lbo_unref减引用计数
99
99
  * 正向查找传入非负n,以0开始计数,表示查找最早创建的第n个对象;
100
100
  * 逆向查找传入负数n,以-1开始计数,依次为-2、-3等,表示查找最后创建的第n个对象。
101
101
  */
102
- const ${class_name} *${class_name}_nth(int nth);
102
+ ${class_name} ${class_name}_nth(int nth);
103
103
  /* 查询对象名称 */
104
- const gchar *${class_name}_name(const ${class_name} *obj);
104
+ const gchar *${class_name}_name(${class_name} obj);
105
105
  /* 对象加锁 */
106
- void ${class_name}_lock(const ${class_name} *obj);
106
+ void ${class_name}_lock(${class_name} obj);
107
107
  /* 对象解锁 */
108
- void ${class_name}_unlock(const ${class_name} *obj);
108
+ void ${class_name}_unlock(${class_name} obj);
109
109
  /* 对象列表查询接口
110
110
  * @notes: 返回的单链需要lbo_unref减每个单链数据的引用计数
111
111
  * 或者调用${class_name}_list_free释放
@@ -117,12 +117,12 @@ GSList *${class_name}_list(void);
117
117
  void ${class_name}_${prop.name}_hook(const ${class_name}_property_hook *hook);
118
118
  % endfor
119
119
 
120
- static inline void ${class_name}_unref_p(const ${class_name} *obj)
120
+ static inline void ${class_name}_unref_p(${class_name} obj)
121
121
  {
122
122
  ${class_name}_unref(&obj);
123
123
  }
124
124
 
125
- static inline void _cleanup_${class_name}_(const ${class_name} **ptr)
125
+ static inline void _cleanup_${class_name}_(${class_name} *ptr)
126
126
  {
127
127
  if (ptr && *ptr) {
128
128
  ${class_name}_unref(ptr);
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: lbkit
3
- Version: 0.7.0
3
+ Version: 0.7.2
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.7.0'
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