summaryrefslogtreecommitdiff
path: root/src/bin/eldbus
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2013-04-23 11:40:05 -0300
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2013-04-23 12:36:29 -0300
commit4e3804041f8e865e007b2a6a0d45a05f39500c3b (patch)
treea493b9c8f8a610d2667651f3ba81819ed16fbe8c /src/bin/eldbus
parent4cf68bf728b5a858ce1c0efac25ded1a49ba8d9d (diff)
Rename edbus->eldbus
git grep -l edbus2 | while read f; do sed -i 's/edbus2/eldbus/g' "$f"; done find . -name '*edbus2*' -exec rename edbus2 eldbus {} \; git grep -l "EDBUS" | while read f; do sed -i 's/EDBUS/ELDBUS/g' "$f"; done git grep -l "EDBus" | while read f; do sed -i 's/EDBus/Eldbus/g' "$f"; done git grep -l "edbus (v2)" | while read f; do sed -i 's/edbus (v2)/eldbus/g' "$f"; done git grep -l "Edbus" | while read f; do sed -i 's/Edbus/Eldbus/g' "$f"; done git grep -l "edbus" | while read f; do sed -i 's/edbus/eldbus/g' "$f"; done find . -name '*edbus*' -exec rename edbus eldbus {} \; find . -name '*EDBus*' -exec rename EDBus Eldbus {} \;
Diffstat (limited to 'src/bin/eldbus')
-rw-r--r--src/bin/eldbus/client.c81
-rw-r--r--src/bin/eldbus/codegen.h112
-rw-r--r--src/bin/eldbus/dbus.c141
-rw-r--r--src/bin/eldbus/parser.c491
-rw-r--r--src/bin/eldbus/source_client.c629
-rw-r--r--src/bin/eldbus/utils.c165
6 files changed, 1619 insertions, 0 deletions
diff --git a/src/bin/eldbus/client.c b/src/bin/eldbus/client.c
new file mode 100644
index 0000000000..feca0841de
--- /dev/null
+++ b/src/bin/eldbus/client.c
@@ -0,0 +1,81 @@
1#include "codegen.h"
2
3static const Ecore_Getopt optdesc = {
4 "eldbus_codegen",
5 "%prog [options] <file.xml>",
6 "1.0",
7 "(C) 2012 - The Enlightenment Project",
8 "BSD",
9 "Generate DBUS code, making write DBus client applications easy\n",
10 0,
11 {
12 ECORE_GETOPT_STORE_STR('p', "prefix", "The prefix for the generated code."),
13 ECORE_GETOPT_STORE_STR('i', "interface", "To generate code of only one interface of xml."),
14 ECORE_GETOPT_STORE_STR('o', "output file name", "The name of output files, only used if a interface is selected."),
15 ECORE_GETOPT_LICENSE('L', "license"),
16 ECORE_GETOPT_COPYRIGHT('C', "copyright"),
17 ECORE_GETOPT_VERSION('V', "version"),
18 ECORE_GETOPT_HELP('h', "help"),
19 ECORE_GETOPT_SENTINEL
20 }
21};
22
23int
24main(int argc, char **argv)
25{
26 char *xml_buf = NULL;
27 DBus_Object *obj = NULL;
28 char *prefix = NULL, *interface = NULL, *output = NULL;
29 Eina_Bool quit_option = EINA_FALSE;
30 int arg_index;
31 Ecore_Getopt_Value values[] = {
32 ECORE_GETOPT_VALUE_STR(prefix),
33 ECORE_GETOPT_VALUE_STR(interface),
34 ECORE_GETOPT_VALUE_STR(output),
35 ECORE_GETOPT_VALUE_BOOL(quit_option),
36 ECORE_GETOPT_VALUE_BOOL(quit_option),
37 ECORE_GETOPT_VALUE_BOOL(quit_option),
38 ECORE_GETOPT_VALUE_BOOL(quit_option),
39 ECORE_GETOPT_VALUE_NONE
40 };
41
42 eina_init();
43
44 arg_index = ecore_getopt_parse(&optdesc, values, argc, argv);
45 if (arg_index == -1)
46 {
47 printf("Error: parsing arguments.\n");
48 return -1;
49 }
50 if (quit_option)
51 return 0;
52 if (argc <= arg_index)
53 {
54 printf("Error: Missing file name.\n");
55 return -1;
56 }
57
58 if (!file_read(argv[arg_index], &xml_buf))
59 {
60 printf("Error reading file.\n");
61 goto end;
62 }
63
64 if (!eina_simple_xml_parse(xml_buf, strlen(xml_buf), EINA_TRUE,
65 parser, &obj))
66 {
67 printf("Error: could not parse XML\n");
68 goto end;
69 }
70
71 source_client_generate(obj, prefix, interface, output);
72 util_h_write();
73
74end:
75 if (obj)
76 object_free(obj);
77
78 free(xml_buf);
79 eina_shutdown();
80 return 0;
81}
diff --git a/src/bin/eldbus/codegen.h b/src/bin/eldbus/codegen.h
new file mode 100644
index 0000000000..ffcaf993ef
--- /dev/null
+++ b/src/bin/eldbus/codegen.h
@@ -0,0 +1,112 @@
1#include <Eina.h>
2#include <Ecore.h>
3#include <Ecore_Getopt.h>
4#include <ctype.h>
5
6#define ACCESS_READ 1 << 0
7#define ACCESS_WRITE 1 << 1
8
9typedef struct _DBus_Object
10{
11 char *name;
12 char *c_name;
13 Eina_Inlist *ifaces;
14} DBus_Object;
15
16typedef struct _DBus_Interface
17{
18 EINA_INLIST;
19 char *name;
20 char *c_name;
21 Eina_Inlist *methods;
22 Eina_Inlist *signals;
23 Eina_Inlist *properties;
24 DBus_Object *obj;
25} DBus_Interface;
26
27typedef struct _DBus_Signal
28{
29 EINA_INLIST;
30 char *name;
31 char *c_name;
32 char *cb_name;
33 char *struct_name;
34 char *free_function;
35 Eina_Inlist *args;
36 unsigned int arg_without_name;
37 DBus_Interface *iface;
38 Eina_Bool complex;
39 char *signal_event;
40} DBus_Signal;
41
42typedef struct _DBus_Arg
43{
44 EINA_INLIST;
45 char *type;
46 char direction;
47 char *name;
48 char *c_name;
49} DBus_Arg;
50
51typedef enum
52{
53 NO_REPLY = 0,
54 INVALID
55} DBus_Annotation_Type;
56
57typedef struct _DBus_Annotation
58{
59 DBus_Annotation_Type type;
60 char *value;
61} DBus_Annotation;
62
63typedef struct _DBus_Method
64{
65 EINA_INLIST;
66 char *name;
67 char *c_name;
68 char *cb_name;
69 char *function_cb;
70 Eina_Inlist *args;
71 unsigned int arg_without_name;
72 DBus_Interface *iface;
73 Eina_Bool in_complex:1;
74 Eina_Bool out_complex:1;
75 Eina_Bool no_reply:1;
76} DBus_Method;
77
78typedef struct _DBus_Property
79{
80 EINA_INLIST;
81 char *name;
82 char *c_name;
83 char *cb_name;
84 char *type;
85 char access;
86 DBus_Interface *iface;
87 Eina_Bool complex;
88} DBus_Property;
89
90Eina_Bool parser(void *data, Eina_Simple_XML_Type type, const char *content, unsigned offset, unsigned length);
91
92void object_free(DBus_Object *obj);
93DBus_Interface *interface_new(DBus_Object *obj);
94void interface_free(DBus_Interface *iface);
95DBus_Signal *signal_new(DBus_Interface *iface);
96void signal_free(DBus_Signal *signal);
97void arg_free(DBus_Arg *arg);
98void method_free(DBus_Method *method);
99DBus_Method *method_new(DBus_Interface *iface);
100DBus_Property *property_new(DBus_Interface *iface);
101void property_free(DBus_Property *property);
102
103void source_client_generate(DBus_Object *path, const char *prefix, const char *interface_name, const char *output);
104
105//utils
106Eina_Bool file_read(const char *file_name, char **buffer);
107Eina_Bool file_write(const char *file_name, const char *buffer);
108Eina_Bool util_h_write(void);
109char *replace_string(const char *string, const char *substr, const char *replacement);
110char *dbus_name_to_c(const char *dbus);
111char *string_build(const char *fmt, ...);
112char *get_pieces(const char *string, char break_in, int amount);
diff --git a/src/bin/eldbus/dbus.c b/src/bin/eldbus/dbus.c
new file mode 100644
index 0000000000..ac9e828f57
--- /dev/null
+++ b/src/bin/eldbus/dbus.c
@@ -0,0 +1,141 @@
1#include "codegen.h"
2
3void
4property_free(DBus_Property *property)
5{
6 property->iface->properties = eina_inlist_remove(property->iface->properties,
7 EINA_INLIST_GET(property));
8 free(property->c_name);
9 free(property->cb_name);
10 free(property->name);
11 free(property->type);
12 free(property);
13}
14
15DBus_Property *
16property_new(DBus_Interface *iface)
17{
18 DBus_Property *prop = calloc(1, sizeof(DBus_Property));
19 EINA_SAFETY_ON_NULL_RETURN_VAL(prop, NULL);
20 iface->properties = eina_inlist_append(iface->properties,
21 EINA_INLIST_GET(prop));
22 prop->iface = iface;
23 return prop;
24}
25
26DBus_Method *
27method_new(DBus_Interface *iface)
28{
29 DBus_Method *method = calloc(1, sizeof(DBus_Method));
30 EINA_SAFETY_ON_NULL_RETURN_VAL(method, NULL);
31 iface->methods = eina_inlist_append(iface->methods, EINA_INLIST_GET(method));
32 method->iface = iface;
33 return method;
34}
35
36void
37method_free(DBus_Method *method)
38{
39 DBus_Arg *arg;
40 Eina_Inlist *inlist;
41
42 EINA_INLIST_FOREACH_SAFE(method->args, inlist, arg)
43 arg_free(arg);
44 method->iface->methods = eina_inlist_remove(method->iface->methods,
45 EINA_INLIST_GET(method));
46 free(method->c_name);
47 free(method->cb_name);
48 free(method->function_cb);
49 free(method->name);
50 free(method);
51}
52
53void
54arg_free(DBus_Arg *arg)
55{
56 free(arg->c_name);
57 free(arg->name);
58 free(arg->type);
59 free(arg);
60}
61
62DBus_Signal *
63signal_new(DBus_Interface *iface)
64{
65 DBus_Signal *sig = calloc(1, sizeof(DBus_Signal));
66 EINA_SAFETY_ON_NULL_RETURN_VAL(sig, NULL);
67 iface->signals = eina_inlist_append(iface->signals, EINA_INLIST_GET(sig));
68 sig->iface = iface;
69 return sig;
70}
71
72void
73signal_free(DBus_Signal *sig)
74{
75 DBus_Arg *arg;
76 Eina_Inlist *inlist;
77
78 EINA_INLIST_FOREACH_SAFE(sig->args, inlist, arg)
79 arg_free(arg);
80 sig->iface->signals = eina_inlist_remove(sig->iface->signals,
81 EINA_INLIST_GET(sig));
82 free(sig->c_name);
83 free(sig->struct_name);
84 free(sig->free_function);
85 free(sig->cb_name);
86 free(sig->name);
87 free(sig->signal_event);
88 free(sig);
89}
90
91DBus_Interface *
92interface_new(DBus_Object *obj)
93{
94 DBus_Interface *iface = calloc(1, sizeof(DBus_Interface));
95 EINA_SAFETY_ON_NULL_RETURN_VAL(iface, NULL);
96 obj->ifaces = eina_inlist_append(obj->ifaces, EINA_INLIST_GET(iface));
97 iface->obj = obj;
98 return iface;
99}
100
101void
102interface_free(DBus_Interface *iface)
103{
104 while (iface->signals)
105 {
106 DBus_Signal *sig = EINA_INLIST_CONTAINER_GET(iface->signals,
107 DBus_Signal);
108 signal_free(sig);
109 }
110 while (iface->methods)
111 {
112 DBus_Method *method = EINA_INLIST_CONTAINER_GET(iface->methods,
113 DBus_Method);
114 method_free(method);
115 }
116 while (iface->properties)
117 {
118 DBus_Property *property = EINA_INLIST_CONTAINER_GET(iface->properties,
119 DBus_Property);
120 property_free(property);
121 }
122 iface->obj->ifaces = eina_inlist_remove(iface->obj->ifaces,
123 EINA_INLIST_GET(iface));
124 free(iface->c_name);
125 free(iface->name);
126 free(iface);
127}
128
129void
130object_free(DBus_Object *obj)
131{
132 while (obj->ifaces)
133 {
134 DBus_Interface *iface = EINA_INLIST_CONTAINER_GET(obj->ifaces,
135 DBus_Interface);
136 interface_free(iface);
137 }
138 free(obj->c_name);
139 free(obj->name);
140 free(obj);
141}
diff --git a/src/bin/eldbus/parser.c b/src/bin/eldbus/parser.c
new file mode 100644
index 0000000000..96a8f9e354
--- /dev/null
+++ b/src/bin/eldbus/parser.c
@@ -0,0 +1,491 @@
1#include "codegen.h"
2
3#define OBJECT_TAG "node"
4#define OBJECT_TAG_LENGHT strlen(OBJECT_TAG)
5#define INTERFACE_TAG "interface"
6#define INTERFACE_TAG_LENGHT strlen(INTERFACE_TAG)
7#define SIGNAL_TAG "signal"
8#define SIGNAL_TAG_LENGHT strlen(SIGNAL_TAG)
9#define METHOD_TAG "method"
10#define METHOD_TAG_LENGHT strlen(METHOD_TAG)
11#define PROPERTY_TAG "property"
12#define PROPERTY_TAG_LENGHT strlen(PROPERTY_TAG)
13#define ARG_TAG "arg"
14#define ARG_TAG_LENGHT strlen(ARG_TAG)
15#define ANNOTATION_TAG "annotation"
16#define ANNOTATION_TAG_LENGHT strlen(ANNOTATION_TAG)
17
18//attributes
19#define NAME_ATTR "name"
20#define TYPE_ATTR "type"
21#define DIRECTION_ATTR "direction"
22#define ACCESS_ATTR "access"
23#define VALUE_ATTR "value"
24
25#define ACCESS_ATTR_VALUE_WRITE "write"
26#define ACCESS_ATTR_VALUE_READ "read"
27
28#define DBUS_INTERFACE "org.freedesktop.DBus."
29
30static DBus_Interface *iface;
31static DBus_Signal *d_signal;
32static DBus_Method *method;
33static DBus_Property *property;
34
35static Eina_Bool attributes_parse(const char *content, unsigned length, Eina_Simple_XML_Attribute_Cb func, const void *data);
36
37static Eina_Bool
38obj_attributes_parser(void *data, const char *key, const char *value)
39{
40 DBus_Object *obj = data;
41
42 if (!strcmp(key, NAME_ATTR))
43 obj->name = strdup(value);
44
45 return EINA_TRUE;
46}
47
48static Eina_Bool
49iface_attributes_parser(void *data EINA_UNUSED, const char *key, const char *value)
50{
51 if (!strcmp(key, NAME_ATTR))
52 iface->name = strdup(value);
53
54 return EINA_TRUE;
55}
56
57static Eina_Bool
58signal_attributes_parser(void *data EINA_UNUSED, const char *key, const char *value)
59{
60 if (!strcmp(key, NAME_ATTR))
61 d_signal->name = strdup(value);
62
63 return EINA_TRUE;
64}
65
66static Eina_Bool
67arg_attributes_parser(void *data EINA_UNUSED, const char *key, const char *value)
68{
69 DBus_Arg *arg = data;
70 if (!strcmp(key, NAME_ATTR))
71 arg->name = strdup(value);
72 else if (!strcmp(key, TYPE_ATTR))
73 arg->type = strdup(value);
74 else if (!strcmp(key, DIRECTION_ATTR))
75 arg->direction = value[0];
76
77 return EINA_TRUE;
78}
79
80static Eina_Bool
81method_attributes_parser(void *data EINA_UNUSED, const char *key, const char *value)
82{
83 if (!strcmp(key, NAME_ATTR))
84 method->name = strdup(value);
85
86 return EINA_TRUE;
87}
88
89static Eina_Bool
90property_attributes_parser(void *data EINA_UNUSED, const char *key, const char *value)
91{
92 if (!strcmp(key, NAME_ATTR))
93 property->name = strdup(value);
94 else if (!strcmp(key, TYPE_ATTR))
95 {
96 property->type = strdup(value);
97 if (value[1] || value[0] == 'v')
98 property->complex = EINA_TRUE;
99 }
100 else if (!strcmp(key, ACCESS_ATTR))
101 {
102 if (!strcmp(value, ACCESS_ATTR_VALUE_READ))
103 property->access = ACCESS_READ;
104 else if (!strcmp(value, ACCESS_ATTR_VALUE_WRITE))
105 property->access = ACCESS_WRITE;
106 else
107 property->access = (ACCESS_WRITE | ACCESS_READ);
108 }
109
110 return EINA_TRUE;
111}
112
113static Eina_Bool
114open_object(const char *content, unsigned length, Eina_Bool is_open_empty, DBus_Object **ptr_obj)
115{
116 Eina_Bool r;
117 DBus_Object *obj = *ptr_obj;
118
119 if (is_open_empty) return EINA_TRUE;
120
121 if (obj)
122 {
123 printf("Only one object is supported per file.");
124 return EINA_FALSE;
125 }
126 obj = calloc(1, sizeof(DBus_Object));
127 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EINA_FALSE);
128
129 r = attributes_parse(content, length, obj_attributes_parser, obj);
130 if (!obj->name) obj->name = strdup("/");
131
132 obj->c_name = dbus_name_to_c(obj->name);
133
134 *ptr_obj = obj;
135 return r;
136}
137
138static void
139interface_close(void)
140{
141 //its not necessary generate code to FreeDesktop interfaces
142 if (!strncmp(iface->name, DBUS_INTERFACE, strlen(DBUS_INTERFACE)))
143 interface_free(iface);
144 iface = NULL;
145}
146
147static Eina_Bool
148open_interface(const char *content, unsigned length, Eina_Bool is_open_empty, DBus_Object *obj)
149{
150 Eina_Bool r;
151 char *tmp_name;
152
153 iface = interface_new(obj);
154 EINA_SAFETY_ON_NULL_RETURN_VAL(iface, EINA_FALSE);
155
156 r = attributes_parse(content, length, iface_attributes_parser, NULL);
157 if (!iface->name)
158 {
159 interface_free(iface);
160 printf("Error interface without name.\n");
161 return EINA_FALSE;
162 }
163
164 tmp_name = get_pieces(iface->name, '.', 2);
165 iface->c_name = dbus_name_to_c(tmp_name);
166 free(tmp_name);
167
168 if (is_open_empty)
169 interface_close();
170
171 return r;
172}
173
174static void
175signal_close(void)
176{
177 DBus_Arg *arg;
178 EINA_INLIST_FOREACH(d_signal->args, arg)
179 {
180 if ((arg->type[1]) || (arg->type[0] == 'v'))
181 {
182 d_signal->complex = EINA_TRUE;
183 break;
184 }
185 }
186 d_signal = NULL;
187}
188
189static Eina_Bool
190open_signal(const char *content, unsigned length, Eina_Bool is_open_empty)
191{
192 Eina_Bool r;
193 char *tmp;
194 int i;
195 Eina_Strbuf *buf = eina_strbuf_new();
196
197 d_signal = signal_new(iface);
198 EINA_SAFETY_ON_NULL_RETURN_VAL(d_signal, EINA_FALSE);
199
200 r = attributes_parse(content, length, signal_attributes_parser, NULL);
201 if (!d_signal->name)
202 {
203 signal_free(d_signal);
204 d_signal = NULL;
205 printf("Error signal without name.\n");
206 return EINA_FALSE;
207 }
208
209 tmp = dbus_name_to_c(d_signal->name);
210 d_signal->c_name = string_build("%s_%s", iface->c_name, tmp);
211 free(tmp);
212 d_signal->cb_name = string_build("on_%s", d_signal->c_name);
213 d_signal->free_function = string_build("%s_data_free", d_signal->c_name);
214 d_signal->struct_name = string_build("%s_%s_Data", iface->c_name, d_signal->name);
215 d_signal->struct_name[0] = toupper(d_signal->struct_name[0]);
216 for (i = 0; d_signal->struct_name[i]; i++)
217 {
218 if (d_signal->struct_name[i] == '_' && d_signal->struct_name[i+1])
219 d_signal->struct_name[i+1] = toupper(d_signal->struct_name[i+1]);
220 }
221 for (i = 0; iface->c_name[i]; i++)
222 eina_strbuf_append_char(buf, toupper(iface->c_name[i]));
223 eina_strbuf_append_char(buf, '_');
224 for (i = 0; d_signal->name[i]; i++)
225 {
226 if (i && isupper(d_signal->name[i]) && !isupper(d_signal->name[i-1]))
227 eina_strbuf_append_char(buf, '_');
228 eina_strbuf_append_char(buf, toupper(d_signal->name[i]));
229 }
230 eina_strbuf_append(buf, "_EVENT");
231 d_signal->signal_event = eina_strbuf_string_steal(buf);
232 eina_strbuf_free(buf);
233
234 if (is_open_empty)
235 signal_close();
236
237 return r;
238}
239
240#define ANNOTATION_NO_REPLY "org.freedesktop.DBus.Method.NoReply"
241
242static Eina_Bool
243annotation_attributes_parser(void *data, const char *key, const char *value)
244{
245 DBus_Annotation *annotation = data;
246 if (!strcmp(key, NAME_ATTR))
247 {
248 if (!strcmp(value, ANNOTATION_NO_REPLY))
249 annotation->type = NO_REPLY;
250 }
251 else if (!strcmp(key, VALUE_ATTR))
252 {
253 unsigned i;
254 annotation->value = strdup(value);
255 for (i = 0; annotation->value[i]; i++)
256 annotation->value[i] = tolower(annotation->value[i]);
257 }
258
259 return EINA_TRUE;
260}
261
262static Eina_Bool
263open_annotation(const char *content, unsigned length)
264{
265 DBus_Annotation annotation;
266 Eina_Bool r;
267
268 annotation.type = INVALID;
269 r = attributes_parse(content, length, annotation_attributes_parser, &annotation);
270
271 if (annotation.type == NO_REPLY)
272 {
273 Eina_Bool value = EINA_FALSE;
274 if (!strcmp(annotation.value, "true"))
275 value = EINA_TRUE;
276 free(annotation.value);
277
278 if (method)
279 method->no_reply = value;
280 }
281
282 return r;
283}
284
285static Eina_Bool
286open_arg(const char *content, unsigned length)
287{
288 Eina_Bool r;
289 unsigned int *without_name;
290 DBus_Arg *arg = calloc(1, sizeof(DBus_Arg));
291 EINA_SAFETY_ON_NULL_RETURN_VAL(arg, EINA_FALSE);
292
293 r = attributes_parse(content, length, arg_attributes_parser, arg);
294 if (d_signal)
295 {
296 d_signal->args = eina_inlist_append(d_signal->args, EINA_INLIST_GET(arg));
297 without_name = &d_signal->arg_without_name;
298 }
299 else if (method)
300 {
301 method->args = eina_inlist_append(method->args, EINA_INLIST_GET(arg));
302 without_name = &method->arg_without_name;
303 }
304 else
305 {
306 printf("Error find an argument without any valid parent.\n");
307 return EINA_FALSE;
308 }
309
310 if (!arg->name)
311 {
312 arg->c_name = string_build("arg%d", *without_name);
313 (*without_name)++;
314 }
315 else
316 arg->c_name = dbus_name_to_c(arg->name);
317
318 return r;
319}
320
321static void
322method_close(void)
323{
324 DBus_Arg *arg;
325 EINA_INLIST_FOREACH(method->args, arg)
326 {
327 if ((arg->type[1]) || (arg->type[0] == 'v'))
328 {
329 if (arg->direction == 'o')
330 method->out_complex = EINA_TRUE;
331 else
332 method->in_complex = EINA_TRUE;
333 }
334 }
335 if (method->no_reply)
336 {
337 free(method->cb_name);
338 method->cb_name = strdup("NULL");
339 }
340 method = NULL;
341}
342
343static Eina_Bool
344open_method(const char *content, unsigned lenght, Eina_Bool is_open_empty)
345{
346 Eina_Bool r;
347 char *tmp;
348 int i;
349
350 method = method_new(iface);
351 EINA_SAFETY_ON_NULL_RETURN_VAL(method, EINA_FALSE);
352
353 r = attributes_parse(content, lenght, method_attributes_parser, NULL);
354 if (!method->name)
355 {
356 method_free(method);
357 method = NULL;
358 printf("Error method without name.\n");
359 return EINA_FALSE;
360 }
361
362 tmp = dbus_name_to_c(method->name);
363 method->c_name = string_build("%s_%s", iface->c_name, tmp);
364 free(tmp);
365 method->cb_name = string_build("cb_%s", method->c_name);
366 method->function_cb = string_build("%s_Cb", method->c_name);
367 method->function_cb[0] = toupper(method->function_cb[0]);
368 for (i = 0; method->function_cb[i]; i++)
369 {
370 if (method->function_cb[i] == '_' && method->function_cb[i+1])
371 method->function_cb[i+1] = toupper(method->function_cb[i+1]);
372 }
373
374 if (is_open_empty)
375 method_close();
376
377 return r;
378}
379
380static Eina_Bool
381open_property(const char *content, unsigned length)
382{
383 Eina_Bool r;
384 char *tmp;
385
386 property = property_new(iface);
387 EINA_SAFETY_ON_NULL_RETURN_VAL(property, EINA_FALSE);
388
389 r = attributes_parse(content, length, property_attributes_parser, NULL);
390 if (!property->name)
391 {
392 property_free(property);
393 property = NULL;
394 printf("Error property without name.\n");
395 return EINA_FALSE;
396 }
397
398 tmp = dbus_name_to_c(property->name);
399 property->c_name = string_build("%s_%s", iface->c_name, tmp);
400 free(tmp);
401 property->cb_name = string_build("cb_%s", property->c_name);
402
403 return r;
404}
405
406static Eina_Bool
407open_tag(const char *content, unsigned length, Eina_Bool is_open_empty, DBus_Object **obj)
408{
409 unsigned int i;
410 if (!strncmp(content, OBJECT_TAG, OBJECT_TAG_LENGHT))
411 return open_object(content, length, is_open_empty, obj);
412 else if (!strncmp(content, INTERFACE_TAG, INTERFACE_TAG_LENGHT) && *obj)
413 return open_interface(content, length, is_open_empty, *obj);
414 else if (!strncmp(content, SIGNAL_TAG, SIGNAL_TAG_LENGHT) && iface)
415 return open_signal(content, length, is_open_empty);
416 else if (!strncmp(content, ARG_TAG, ARG_TAG_LENGHT) && iface)
417 return open_arg(content, length);
418 else if (!strncmp(content, ANNOTATION_TAG, ANNOTATION_TAG_LENGHT) && iface)
419 return open_annotation(content, length);
420 else if (!strncmp(content, METHOD_TAG, METHOD_TAG_LENGHT) && iface)
421 return open_method(content, length, is_open_empty);
422 else if (!strncmp(content, PROPERTY_TAG, PROPERTY_TAG_LENGHT) && iface)
423 return open_property(content, length);
424 else if (!strncmp(content, ANNOTATION_TAG, ANNOTATION_TAG_LENGHT) && iface)
425 return EINA_TRUE;
426
427 printf("Warning: Tag not handled:\n");
428 for (i = 0; i < length; i++)
429 printf("%c", content[i]);
430 printf("\n\n");
431
432 return EINA_TRUE;
433}
434
435static Eina_Bool
436close_tag(const char *content)
437{
438 if (!strncmp(content, INTERFACE_TAG, INTERFACE_TAG_LENGHT))
439 interface_close();
440 if (!strncmp(content, SIGNAL_TAG, SIGNAL_TAG_LENGHT))
441 signal_close();
442 else if (!strncmp(content, METHOD_TAG, METHOD_TAG_LENGHT))
443 method_close();
444 else if (!strncmp(content, PROPERTY_TAG, PROPERTY_TAG_LENGHT))
445 property = NULL;
446
447 return EINA_TRUE;
448}
449
450Eina_Bool
451parser(void *data, Eina_Simple_XML_Type type, const char *content, unsigned offset EINA_UNUSED, unsigned length)
452{
453 Eina_Bool r = EINA_TRUE;
454 DBus_Object **obj = data;
455
456 switch (type)
457 {
458 case EINA_SIMPLE_XML_OPEN:
459 case EINA_SIMPLE_XML_OPEN_EMPTY:
460 {
461 r = open_tag(content, length, type == EINA_SIMPLE_XML_OPEN_EMPTY,
462 obj);
463 break;
464 }
465 case EINA_SIMPLE_XML_CLOSE:
466 {
467 r = close_tag(content);
468 break;
469 }
470 default:
471 break;
472 }
473 return r;
474}
475
476static Eina_Bool
477attributes_parse(const char *content, unsigned length, Eina_Simple_XML_Attribute_Cb func, const void *data)
478{
479 const char *attrs = eina_simple_xml_tag_attributes_find(content, length);
480 unsigned attrslen = 0;
481 if (attrs)
482 {
483 attrslen = length - (attrs - content);
484 if (!eina_simple_xml_attributes_parse(attrs, attrslen, func, data))
485 {
486 printf("Parser error - attrs=%s | content=%s\n", attrs, content);
487 return EINA_FALSE;
488 }
489 }
490 return EINA_TRUE;
491}
diff --git a/src/bin/eldbus/source_client.c b/src/bin/eldbus/source_client.c
new file mode 100644
index 0000000000..3d0bf437f4
--- /dev/null
+++ b/src/bin/eldbus/source_client.c
@@ -0,0 +1,629 @@
1#include "codegen.h"
2
3static const char *code_prefix = NULL;
4static char buffer[4028];
5
6static const char *
7prefix_append(const char *text)
8{
9 if (code_prefix)
10 {
11 sprintf(buffer, "%s_%s", code_prefix, text);
12 return buffer;
13 }
14 return text;
15}
16
17static const char *
18dbus_type2c_type2(const char *dbus_type, Eina_Bool with_const)
19{
20 switch (dbus_type[0])
21 {
22 case 's'://string
23 case 'o'://object path
24 case 'g'://signature
25 {
26 if (with_const)
27 return "const char *";
28 else
29 return "char *";
30 }
31 case 'h'://file descriptor
32 case 'i'://int
33 return "int ";
34 case 'y'://byte
35 return "unsigned char ";
36 case 'b'://bool
37 return "Eina_Bool ";
38 case 'n'://int16
39 return "short int ";
40 case 'q'://uint16
41 return "unsigned short int ";
42 case 'u'://uint32
43 return "unsigned int ";
44 case 'x'://int64
45 return "int64_t ";
46 case 't'://uint64
47 return "uint64_t ";
48 case 'd'://double
49 return "double ";
50 case 'a'://array
51 case 'v'://variant
52 case '{'://dict
53 case '('://struct
54 return "Eldbus_Message_Iter *";
55 default:
56 {
57 printf("Error type not handled: %c\n", dbus_type[0]);
58 return NULL;
59 }
60 }
61}
62
63static const char *
64dbus_type2c_type(const char *dbus_type)
65{
66 return dbus_type2c_type2(dbus_type, EINA_TRUE);
67}
68
69static void
70source_client_complex_method_call_generate(const DBus_Method *method, Eina_Strbuf *c_code, Eina_Strbuf *h)
71{
72 DBus_Arg *arg;
73 Eina_Strbuf *full_signature = eina_strbuf_new();
74
75 EINA_INLIST_FOREACH(method->args, arg)
76 {
77 if (arg->direction == 'o')
78 continue;
79 eina_strbuf_append(full_signature, arg->type);
80 }
81
82 if (method->no_reply)
83 {
84 eina_strbuf_append_printf(h, "void %s_call(Eldbus_Proxy *proxy, Eina_Value *args);\n", prefix_append(method->c_name));
85
86 eina_strbuf_append_printf(c_code, "\nvoid \n%s_call(Eldbus_Proxy *proxy, Eina_Value *args)\n{\n", prefix_append(method->c_name));
87 eina_strbuf_append_printf(c_code, " EINA_SAFETY_ON_NULL_RETURN(proxy);\n");
88 eina_strbuf_append_printf(c_code, " Eldbus_Message *msg = eldbus_proxy_method_call_new(proxy, \"%s\");\n", method->name);
89 eina_strbuf_append_printf(c_code, " if (!eldbus_message_from_eina_value(\"%s\", msg, args))\n", eina_strbuf_string_get(full_signature));
90 eina_strbuf_append_printf(c_code, " {\n");
91 eina_strbuf_append_printf(c_code, " ERR(\"Error: Filling message from eina value.\");\n");
92 eina_strbuf_append_printf(c_code, " return;\n");
93 eina_strbuf_append_printf(c_code, " }\n");
94 eina_strbuf_append_printf(c_code, " eldbus_proxy_send(proxy, msg, %s, NULL, NULL, -1);\n", method->cb_name);
95 eina_strbuf_append_printf(c_code, "}\n");
96 goto end;
97 }
98
99 eina_strbuf_append_printf(h, "Eldbus_Pending *%s_call", prefix_append(method->c_name));
100 eina_strbuf_append_printf(h, "(Eldbus_Proxy *proxy, %s cb, const void *data, Eina_Value *args);\n", prefix_append(method->function_cb));
101
102 eina_strbuf_append_printf(c_code, "\nEldbus_Pending *\n%s_call(", prefix_append(method->c_name));
103 eina_strbuf_append_printf(c_code, "Eldbus_Proxy *proxy, %s cb, const void *data, Eina_Value *args)\n{\n", prefix_append(method->function_cb));
104 eina_strbuf_append_printf(c_code, " Eldbus_Message *msg;\n");
105 eina_strbuf_append_printf(c_code, " Eldbus_Pending *p;\n");
106 eina_strbuf_append_printf(c_code, " EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);\n");
107 eina_strbuf_append_printf(c_code, " msg = eldbus_proxy_method_call_new(proxy, \"%s\");\n", method->name);
108 eina_strbuf_append_printf(c_code, " if (!eldbus_message_from_eina_value(\"%s\", msg, args))\n", eina_strbuf_string_get(full_signature));
109 eina_strbuf_append_printf(c_code, " {\n");
110 eina_strbuf_append_printf(c_code, " ERR(\"Error: Filling message from eina value.\");\n");
111 eina_strbuf_append_printf(c_code, " return NULL;\n");
112 eina_strbuf_append_printf(c_code, " }\n");
113 eina_strbuf_append_printf(c_code, " p = eldbus_proxy_send(proxy, msg, %s, cb, -1);\n", method->cb_name);
114 eina_strbuf_append_printf(c_code, " if (data)\n");
115 eina_strbuf_append_printf(c_code, " eldbus_pending_data_set(p, \"__user_data\", data);\n");
116 eina_strbuf_append_printf(c_code, " eldbus_pending_data_set(p, \"__proxy\", proxy);\n");
117 eina_strbuf_append_printf(c_code, " return p;\n");
118 eina_strbuf_append_printf(c_code, "}\n");
119
120end:
121 eina_strbuf_free(full_signature);
122}
123
124static void
125source_client_simple_method_call_no_reply_generate(const DBus_Method *method, Eina_Strbuf *c_code, Eina_Strbuf *h)
126{
127 DBus_Arg *arg;
128 Eina_Strbuf *full_signature = eina_strbuf_new();
129 Eina_Strbuf *args_call = eina_strbuf_new();
130
131 eina_strbuf_append_printf(h, "void %s_call(Eldbus_Proxy *proxy", prefix_append(method->c_name));
132 eina_strbuf_append_printf(c_code, "\nvoid\n%s_call(Eldbus_Proxy *proxy", prefix_append(method->c_name));
133
134 EINA_INLIST_FOREACH(method->args, arg)
135 {
136 if (arg->direction == 'o')
137 continue;
138 eina_strbuf_append(full_signature, arg->type);
139 eina_strbuf_append_printf(h, ", %s%s", dbus_type2c_type(arg->type), arg->c_name);
140 eina_strbuf_append_printf(c_code, ", %s%s", dbus_type2c_type(arg->type), arg->c_name);
141 eina_strbuf_append_printf(args_call, ", %s", arg->c_name);
142 }
143 eina_strbuf_append_printf(h, ");\n");
144 eina_strbuf_append_printf(c_code, ")\n{\n");
145
146 eina_strbuf_append_printf(c_code, " Eldbus_Message *msg;\n");
147 eina_strbuf_append_printf(c_code, " EINA_SAFETY_ON_NULL_RETURN(proxy);\n");
148 eina_strbuf_append_printf(c_code, " msg = eldbus_proxy_method_call_new(proxy, \"%s\");\n", method->name);
149 eina_strbuf_append_printf(c_code, " if (!eldbus_message_arguments_append(msg, \"%s\"%s))\n", eina_strbuf_string_get(full_signature), eina_strbuf_string_get(args_call));
150 eina_strbuf_append_printf(c_code, " {\n");
151 eina_strbuf_append_printf(c_code, " ERR(\"Error: Filling message.\");\n");
152 eina_strbuf_append_printf(c_code, " return;\n");
153 eina_strbuf_append_printf(c_code, " }\n");
154 eina_strbuf_append_printf(c_code, " eldbus_proxy_send(proxy, msg, NULL, NULL, -1);\n");
155 eina_strbuf_append_printf(c_code, "}\n");
156
157 eina_strbuf_free(full_signature);
158 eina_strbuf_free(args_call);
159}
160
161static void
162source_client_simple_method_call_generate(const DBus_Method *method, Eina_Strbuf *c_code, Eina_Strbuf *h)
163{
164 DBus_Arg *arg;
165 Eina_Strbuf *full_signature = eina_strbuf_new();
166 Eina_Strbuf *args_call = eina_strbuf_new();
167
168 eina_strbuf_append_printf(h, "Eldbus_Pending *%s_call", prefix_append(method->c_name));
169 eina_strbuf_append_printf(h, "(Eldbus_Proxy *proxy, %s cb, const void *data", prefix_append(method->function_cb));
170 eina_strbuf_append_printf(c_code, "\nEldbus_Pending *\n%s_call", prefix_append(method->c_name));
171 eina_strbuf_append_printf(c_code, "(Eldbus_Proxy *proxy, %s cb, const void *data", prefix_append(method->function_cb));
172
173 EINA_INLIST_FOREACH(method->args, arg)
174 {
175 if (arg->direction == 'o')
176 continue;
177 eina_strbuf_append(full_signature, arg->type);
178 eina_strbuf_append_printf(h, ", %s%s", dbus_type2c_type(arg->type), arg->c_name);
179 eina_strbuf_append_printf(c_code, ", %s%s", dbus_type2c_type(arg->type), arg->c_name);
180 eina_strbuf_append_printf(args_call, ", %s", arg->c_name);
181 }
182 eina_strbuf_append_printf(h, ");\n");
183 eina_strbuf_append_printf(c_code,")\n{\n");
184
185 eina_strbuf_append_printf(c_code, " Eldbus_Message *msg;\n");
186 eina_strbuf_append_printf(c_code, " Eldbus_Pending *p;\n");
187 eina_strbuf_append_printf(c_code, " EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);\n");
188 eina_strbuf_append_printf(c_code, " msg = eldbus_proxy_method_call_new(proxy, \"%s\");\n", method->name);
189 eina_strbuf_append_printf(c_code, " if (!eldbus_message_arguments_append(msg, \"%s\"%s))\n", eina_strbuf_string_get(full_signature), eina_strbuf_string_get(args_call));
190 eina_strbuf_append_printf(c_code, " {\n");
191 eina_strbuf_append_printf(c_code, " ERR(\"Error: Filling message.\");\n");
192 eina_strbuf_append_printf(c_code, " return NULL;\n");
193 eina_strbuf_append_printf(c_code, " }\n");
194 eina_strbuf_append_printf(c_code, " p = eldbus_proxy_send(proxy, msg, %s, cb, -1);\n", method->cb_name);
195 eina_strbuf_append_printf(c_code, " if (data)\n");
196 eina_strbuf_append_printf(c_code, " eldbus_pending_data_set(p, \"__user_data\", data);\n");
197 eina_strbuf_append_printf(c_code, " eldbus_pending_data_set(p, \"__proxy\", proxy);\n");
198 eina_strbuf_append_printf(c_code, " return p;\n");
199 eina_strbuf_append_printf(c_code, "}\n");
200
201 eina_strbuf_free(full_signature);
202 eina_strbuf_free(args_call);
203}
204
205static void
206source_client_complex_method_callback_generate(const DBus_Method *method, Eina_Strbuf *c_code, Eina_Strbuf *h)
207{
208 eina_strbuf_append_printf(h, "typedef void (*%s)(Eldbus_Proxy *proxy, void *data, Eldbus_Pending *pending, Eldbus_Error_Info *error, Eina_Value *args);\n", prefix_append(method->function_cb));
209
210 eina_strbuf_append_printf(c_code, "\nstatic void\n%s(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)\n{\n", method->cb_name);
211 eina_strbuf_append_printf(c_code, " void *user_data = eldbus_pending_data_del(pending, \"__user_data\");\n");
212 eina_strbuf_append_printf(c_code, " %s cb = data;\n", prefix_append(method->function_cb));
213 eina_strbuf_append_printf(c_code, " const char *error, *error_msg;\n");
214 eina_strbuf_append_printf(c_code, " Eina_Value *value;\n");
215 eina_strbuf_append_printf(c_code, " Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, \"__proxy\");\n");
216 eina_strbuf_append_printf(c_code, " if (eldbus_message_error_get(msg, &error, &error_msg))\n");
217 eina_strbuf_append_printf(c_code, " {\n");
218 eina_strbuf_append_printf(c_code, " Eldbus_Error_Info error_info = {error, error_msg};\n");
219 eina_strbuf_append_printf(c_code, " cb(proxy, user_data, pending, &error_info, NULL);\n");
220 eina_strbuf_append_printf(c_code, " return;\n");
221 eina_strbuf_append_printf(c_code, " }\n");
222 eina_strbuf_append_printf(c_code, " value = eldbus_message_to_eina_value(msg);\n");
223 eina_strbuf_append_printf(c_code, " cb(proxy, user_data, pending, NULL, value);\n");
224 eina_strbuf_append_printf(c_code, " eina_value_free(value);\n");
225 eina_strbuf_append_printf(c_code, " return;\n");
226 eina_strbuf_append_printf(c_code, "}\n");
227}
228
229static void
230source_client_simple_method_callback_generate(const DBus_Method *method, Eina_Strbuf *c_code, Eina_Strbuf *h)
231{
232 Eina_Strbuf *full_signature = eina_strbuf_new();
233 DBus_Arg *arg;
234 Eina_Strbuf *end_cb = eina_strbuf_new();
235 Eina_Strbuf *arguments_get = eina_strbuf_new();
236
237 eina_strbuf_append_printf(h, "typedef void (*%s)(Eldbus_Proxy *proxy, void *data, Eldbus_Pending *pending, Eldbus_Error_Info *error", prefix_append(method->function_cb));
238
239 eina_strbuf_append_printf(c_code, "\nstatic void\n%s(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)\n{\n", method->cb_name);
240 eina_strbuf_append_printf(c_code, " void *user_data = eldbus_pending_data_del(pending, \"__user_data\");\n");
241 eina_strbuf_append_printf(c_code, " %s cb = data;\n", prefix_append(method->function_cb));
242 eina_strbuf_append_printf(c_code, " const char *error, *error_msg;\n");
243 eina_strbuf_append_printf(c_code, " Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, \"__proxy\");\n");
244
245 EINA_INLIST_FOREACH(method->args, arg)
246 {
247 if (arg->direction != 'o')
248 continue;
249 eina_strbuf_append(full_signature, arg->type);
250 eina_strbuf_append_printf(h, ", %s%s", dbus_type2c_type(arg->type), arg->c_name);
251 eina_strbuf_append_printf(c_code, " %s%s;\n", dbus_type2c_type(arg->type), arg->c_name);
252 eina_strbuf_append_printf(end_cb, ", %s", arg->c_name);
253 eina_strbuf_append_printf(arguments_get, ", &%s", arg->c_name);
254 }
255 eina_strbuf_append_printf(h, ");\n");
256
257 eina_strbuf_append_printf(c_code, " if (eldbus_message_error_get(msg, &error, &error_msg))\n");
258 eina_strbuf_append_printf(c_code, " {\n");
259 eina_strbuf_append_printf(c_code, " Eldbus_Error_Info error_info = {error, error_msg};\n");
260 eina_strbuf_append_printf(c_code, " cb(proxy, user_data, pending, &error_info%s);\n", eina_strbuf_string_get(end_cb));
261 eina_strbuf_append_printf(c_code, " return;\n");
262 eina_strbuf_append_printf(c_code, " }\n");
263
264 eina_strbuf_append_printf(c_code, " if (!eldbus_message_arguments_get(msg, \"%s\"%s))\n", eina_strbuf_string_get(full_signature), eina_strbuf_string_get(arguments_get));
265 eina_strbuf_append_printf(c_code, " {\n");
266 eina_strbuf_append_printf(c_code, " Eldbus_Error_Info error_info = {\"\", \"\"};\n");
267 eina_strbuf_append_printf(c_code, " ERR(\"Error: Getting arguments from message.\");\n");
268 eina_strbuf_append_printf(c_code, " cb(proxy, user_data, pending, &error_info%s);\n", eina_strbuf_string_get(end_cb));
269 eina_strbuf_append_printf(c_code, " return;\n");
270 eina_strbuf_append_printf(c_code, " }\n");
271 eina_strbuf_append_printf(c_code, " cb(proxy, user_data, pending, NULL%s);\n", eina_strbuf_string_get(end_cb));
272 eina_strbuf_append_printf(c_code, " return;\n");
273 eina_strbuf_append_printf(c_code, "}\n");
274
275 eina_strbuf_free(full_signature);
276 eina_strbuf_free(end_cb);
277 eina_strbuf_free(arguments_get);
278}
279
280static void
281source_client_method_generate(const DBus_Method *method, Eina_Strbuf *c_code, Eina_Strbuf *h)
282{
283 if (!method->no_reply)
284 {
285 if (method->out_complex)
286 source_client_complex_method_callback_generate(method, c_code, h);
287 else
288 source_client_simple_method_callback_generate(method, c_code, h);
289 }
290
291 if (method->in_complex)
292 source_client_complex_method_call_generate(method, c_code, h);
293 else
294 {
295 if (method->no_reply)
296 source_client_simple_method_call_no_reply_generate(method, c_code, h);
297 else
298 source_client_simple_method_call_generate(method, c_code, h);
299 }
300}
301
302static void
303source_client_signal_generate(const DBus_Signal *sig, Eina_Strbuf *c_code, Eina_Strbuf * h, Eina_Strbuf *c_init_function, Eina_Strbuf *c_header)
304{
305 DBus_Arg *arg;
306 Eina_Strbuf *full_signature = eina_strbuf_new();
307 Eina_Strbuf *parameters = eina_strbuf_new();
308 Eina_Strbuf *string_copy = eina_strbuf_new();
309 Eina_Strbuf *string_free = eina_strbuf_new();
310
311 eina_strbuf_append_printf(c_init_function, " eldbus_proxy_signal_handler_add(proxy, \"%s\", %s, proxy);\n", sig->name, sig->cb_name);
312 eina_strbuf_append_printf(c_header, "int %s;\n", sig->signal_event);
313 eina_strbuf_append_printf(h, "extern int %s;\n", sig->signal_event);
314 eina_strbuf_append_printf(c_init_function, " if (!%s)\n", sig->signal_event);
315 eina_strbuf_append_printf(c_init_function, " %s = ecore_event_type_new();\n", sig->signal_event);
316
317 eina_strbuf_append_printf(h, "typedef struct _%s\n", sig->struct_name);
318 eina_strbuf_append_printf(h, "{\n");
319 eina_strbuf_append_printf(h, " Eldbus_Proxy *proxy;\n");
320
321 if (sig->complex)
322 {
323 eina_strbuf_append_printf(h, " Eina_Value *value;\n");
324 goto jump_simple_stuff;
325 }
326
327 EINA_INLIST_FOREACH(sig->args, arg)
328 {
329 eina_strbuf_append(full_signature, arg->type);
330 eina_strbuf_append_printf(parameters, ", &s_data->%s", arg->c_name);
331 eina_strbuf_append_printf(h, " %s%s;\n", dbus_type2c_type2(arg->type, EINA_FALSE), arg->c_name);
332
333 if (!strcmp(arg->type, "s") || !strcmp(arg->type, "o"))
334 {
335 eina_strbuf_append_printf(string_copy, " s_data->%s = strdup(s_data->%s);\n", arg->c_name, arg->c_name);
336 eina_strbuf_append_printf(string_free, " free(s_data->%s);\n", arg->c_name);
337 }
338 }
339
340jump_simple_stuff:
341 eina_strbuf_append_printf(h, "} %s;\n", sig->struct_name);
342
343 //free function
344 eina_strbuf_append_printf(c_code, "\nstatic void\n%s(void *user_data, void *func_data)\n{\n", sig->free_function);
345 eina_strbuf_append_printf(c_code, " %s *s_data = user_data;\n", sig->struct_name);
346 if (sig->complex)
347 eina_strbuf_append(c_code, " eina_value_free(s_data->proxy);\n");
348 else
349 eina_strbuf_append(c_code, eina_strbuf_string_get(string_free));
350 eina_strbuf_append_printf(c_code, " free(s_data);\n");
351 eina_strbuf_append_printf(c_code, "}\n");
352
353 //cb function
354 eina_strbuf_append_printf(c_code, "\nstatic void\n%s(void *data, const Eldbus_Message *msg)\n{\n", sig->cb_name);
355 eina_strbuf_append_printf(c_code, " Eldbus_Proxy *proxy = data;\n");
356 eina_strbuf_append_printf(c_code, " %s *s_data = calloc(1, sizeof(%s));\n", sig->struct_name, sig->struct_name);
357 eina_strbuf_append_printf(c_code, " s_data->proxy = proxy;\n");
358 if (sig->complex)
359 {
360 eina_strbuf_append_printf(c_code, " s_data->value = eldbus_message_to_eina_value(msg);\n");
361 goto end_signal;
362 }
363 eina_strbuf_append_printf(c_code, " if (!eldbus_message_arguments_get(msg, \"%s\"%s))\n", eina_strbuf_string_get(full_signature), eina_strbuf_string_get(parameters));
364 eina_strbuf_append_printf(c_code, " {\n");
365 eina_strbuf_append_printf(c_code, " ERR(\"Error: Getting arguments from message.\");\n");
366 eina_strbuf_append_printf(c_code, " return;\n");
367 eina_strbuf_append_printf(c_code, " }\n");
368 eina_strbuf_append(c_code, eina_strbuf_string_get(string_copy));
369
370end_signal:
371 eina_strbuf_append_printf(c_code, " ecore_event_add(%s, s_data, %s, NULL);\n", sig->signal_event, sig->free_function);
372 eina_strbuf_append_printf(c_code, "}\n");
373
374 eina_strbuf_free(full_signature);
375 eina_strbuf_free(parameters);
376 eina_strbuf_free(string_copy);
377 eina_strbuf_free(string_free);
378}
379
380static const char *
381prop_cb_get(const DBus_Property *prop)
382{
383 if (prop->complex)
384 return "Eldbus_Codegen_Property_Complex_Get_Cb";
385 switch (prop->type[0])
386 {
387 case 's':
388 case 'o':
389 return "Eldbus_Codegen_Property_String_Get_Cb";
390 case 'i':
391 case 'h':
392 return "Eldbus_Codegen_Property_Int32_Get_Cb";
393 case 'y':
394 return "Eldbus_Codegen_Property_Byte_Get_Cb";
395 case 'b':
396 return "Eldbus_Codegen_Property_Bool_Get_Cb";
397 case 'n':
398 return "Eldbus_Codegen_Property_Int16_Get_Cb";
399 case 'q':
400 return "Eldbus_Codegen_Property_Uint16_Get_Cb";
401 case 'u':
402 return "Eldbus_Codegen_Property_Uint32_Get_Cb";
403 case 'd':
404 return "Eldbus_Codegen_Property_Double_Get_Cb";
405 case 'x':
406 return "Eldbus_Codegen_Property_Int64_Get_Cb";
407 case 't':
408 return "Eldbus_Codegen_Property_Uint64_Get_Cb";
409 default:
410 return "Unexpected_type";
411 }
412}
413
414static const char *
415null_or_zero(const char *type)
416{
417 if (type[0] == 's' || type[0] == 'o' || type[0] == 'v' || type[1])
418 return "NULL";
419 return "0";
420}
421
422static void
423source_client_property_generate_get(const DBus_Property *prop, Eina_Strbuf *c_code, Eina_Strbuf *h)
424{
425 //callback
426 eina_strbuf_append_printf(c_code, "\nstatic void\n%s(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)\n{\n", prop->cb_name);
427 eina_strbuf_append_printf(c_code, " void *user_data = eldbus_pending_data_del(pending, \"__user_data\");\n");
428 eina_strbuf_append_printf(c_code, " const char *error, *error_msg;\n");
429 eina_strbuf_append_printf(c_code, " %s cb = data;\n", prop_cb_get(prop));
430 eina_strbuf_append_printf(c_code, " Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, \"__proxy\");\n");
431 eina_strbuf_append_printf(c_code, " Eldbus_Message_Iter *variant;\n");
432 if (prop->complex)
433 eina_strbuf_append_printf(c_code, " Eina_Value *v, stack_value;\n");
434 else
435 eina_strbuf_append_printf(c_code, " %sv;\n", dbus_type2c_type(prop->type));
436 eina_strbuf_append_printf(c_code, " if (eldbus_message_error_get(msg, &error, &error_msg))\n");
437 eina_strbuf_append_printf(c_code, " {\n");
438 eina_strbuf_append_printf(c_code, " Eldbus_Error_Info error_info = {error, error_msg};\n");
439 eina_strbuf_append_printf(c_code, " cb(user_data, pending, \"%s\", proxy, &error_info, %s);\n", prop->name, null_or_zero(prop->type));
440 eina_strbuf_append_printf(c_code, " return;\n");
441 eina_strbuf_append_printf(c_code, " }\n");
442
443 eina_strbuf_append_printf(c_code, " if (!eldbus_message_arguments_get(msg, \"v\", &variant))\n");
444 eina_strbuf_append_printf(c_code, " {\n");
445 eina_strbuf_append_printf(c_code, " Eldbus_Error_Info error_info = {\"\", \"\"};\n");
446 eina_strbuf_append_printf(c_code, " cb(user_data, pending, \"%s\", proxy, &error_info, %s);\n", prop->name, null_or_zero(prop->type));
447 eina_strbuf_append_printf(c_code, " return;\n");
448 eina_strbuf_append_printf(c_code, " }\n");
449
450 if (prop->complex)
451 {
452 eina_strbuf_append_printf(c_code, " v = eldbus_message_iter_struct_like_to_eina_value(variant);\n");
453 eina_strbuf_append_printf(c_code, " eina_value_struct_value_get(v, \"arg0\", &stack_value);\n");
454 eina_strbuf_append_printf(c_code, " cb(user_data, pending, \"%s\", proxy, NULL, &stack_value);\n", prop->name);
455 eina_strbuf_append_printf(c_code, " eina_value_flush(&stack_value);\n");
456 eina_strbuf_append_printf(c_code, " eina_value_free(v);\n");
457 }
458 else
459 {
460 eina_strbuf_append_printf(c_code, " if (!eldbus_message_iter_arguments_get(variant, \"%s\", &v))\n", prop->type);
461 eina_strbuf_append_printf(c_code, " {\n");
462 eina_strbuf_append_printf(c_code, " Eldbus_Error_Info error_info = {\"\", \"\"};\n");
463 eina_strbuf_append_printf(c_code, " cb(user_data, pending, \"%s\", proxy, &error_info, %s);\n", prop->name, null_or_zero(prop->type));
464 eina_strbuf_append_printf(c_code, " return;\n");
465 eina_strbuf_append_printf(c_code, " }\n");
466 eina_strbuf_append_printf(c_code, " cb(user_data, pending, \"%s\", proxy, NULL, v);\n", prop->name);
467 }
468 eina_strbuf_append_printf(c_code, "}\n");
469
470 //call
471 eina_strbuf_append_printf(h, "Eldbus_Pending *%s_propget(Eldbus_Proxy *proxy, %s cb, const void *data);\n", prefix_append(prop->c_name), prop_cb_get(prop));
472
473 eina_strbuf_append_printf(c_code, "\nEldbus_Pending *\n%s_propget(Eldbus_Proxy *proxy, %s cb, const void *data)\n{\n", prefix_append(prop->c_name), prop_cb_get(prop));
474 eina_strbuf_append_printf(c_code, " Eldbus_Pending *p;\n");
475 eina_strbuf_append_printf(c_code, " EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);\n");
476 eina_strbuf_append_printf(c_code, " p = eldbus_proxy_property_get(proxy, \"%s\", %s, cb);\n", prop->name, prop->cb_name);
477 eina_strbuf_append_printf(c_code, " if (data)\n");
478 eina_strbuf_append_printf(c_code, " eldbus_pending_data_set(p, \"__user_data\", data);\n");
479 eina_strbuf_append_printf(c_code, " eldbus_pending_data_set(p, \"__proxy\", proxy);\n");
480 eina_strbuf_append_printf(c_code, " return p;\n");
481 eina_strbuf_append_printf(c_code, "}\n");
482}
483
484static void
485source_client_property_generate_set(const DBus_Property *prop, Eina_Strbuf *c_code, Eina_Strbuf *h)
486{
487 //callback
488 eina_strbuf_append_printf(c_code, "\nstatic void\n%s_set(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)\n{\n", prop->cb_name);
489 eina_strbuf_append_printf(c_code, " const char *error, *error_msg;\n");
490 eina_strbuf_append_printf(c_code, " void *user_data = eldbus_pending_data_del(pending, \"__user_data\");\n");
491 eina_strbuf_append_printf(c_code, " Eldbus_Proxy *proxy = eldbus_pending_data_del(pending, \"__proxy\");\n");
492 eina_strbuf_append_printf(c_code, " Eldbus_Codegen_Property_Set_Cb cb = data;\n");
493 eina_strbuf_append_printf(c_code, " if (eldbus_message_error_get(msg, &error, &error_msg))");
494 eina_strbuf_append_printf(c_code, " {\n");
495 eina_strbuf_append_printf(c_code, " Eldbus_Error_Info error_info = {error, error_msg};\n\n");
496 eina_strbuf_append_printf(c_code, " cb(user_data, \"%s\", proxy, pending, &error_info);\n", prop->name);
497 eina_strbuf_append_printf(c_code, " return;\n");
498 eina_strbuf_append_printf(c_code, " }\n");
499 eina_strbuf_append_printf(c_code, " cb(user_data, \"%s\", proxy, pending, NULL);\n", prop->name);
500 eina_strbuf_append_printf(c_code, "}\n");
501
502 //call
503 eina_strbuf_append_printf(h, "Eldbus_Pending *%s_propset(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Set_Cb cb, const void *data, const void *value);\n", prefix_append(prop->c_name));
504
505 eina_strbuf_append_printf(c_code, "\nEldbus_Pending *\n%s_propset(Eldbus_Proxy *proxy, Eldbus_Codegen_Property_Set_Cb cb, const void *data, const void *value)\n{\n", prop->c_name);
506 eina_strbuf_append_printf(c_code, " Eldbus_Pending *p;\n");
507 eina_strbuf_append_printf(c_code, " EINA_SAFETY_ON_NULL_RETURN_VAL(proxy, NULL);\n");
508 eina_strbuf_append_printf(c_code, " EINA_SAFETY_ON_NULL_RETURN_VAL(value, NULL);\n");
509 eina_strbuf_append_printf(c_code, " p = eldbus_proxy_property_set(proxy, \"%s\", \"%s\", value, %s_set, data);\n", prop->name, prop->type, prop->cb_name);
510 eina_strbuf_append_printf(c_code, " eldbus_pending_data_set(p, \"__user_data\", data);\n");
511 eina_strbuf_append_printf(c_code, " eldbus_pending_data_set(p, \"__proxy\", proxy);\n");
512 eina_strbuf_append_printf(c_code, " return p;\n");
513 eina_strbuf_append_printf(c_code, "}\n");
514}
515
516static void
517source_client_property_generate(const DBus_Property *prop, Eina_Strbuf *c_code, Eina_Strbuf *h)
518{
519 if ((prop->access & ACCESS_READ) == ACCESS_READ)
520 source_client_property_generate_get(prop, c_code, h);
521 if ((prop->access & ACCESS_WRITE) == ACCESS_WRITE)
522 source_client_property_generate_set(prop, c_code, h);
523}
524
525void
526source_client_generate(DBus_Object *path, const char *prefix, const char *interface_name, const char *output_name)
527{
528 DBus_Interface *iface;
529 Eina_Bool found = EINA_FALSE;
530 code_prefix = prefix;
531 EINA_INLIST_FOREACH(path->ifaces, iface)
532 {
533 Eina_Strbuf *h, *c_init_function, *c_header, *c_code;
534 DBus_Method *method;
535 DBus_Signal *sig;
536 DBus_Property *prop;
537 char *file_name, *aux;
538 int i;
539
540 if (interface_name && strcmp(interface_name, iface->name))
541 continue;
542 found = EINA_TRUE;
543 h = eina_strbuf_new();//.h file
544 c_init_function = eina_strbuf_new();
545 c_header = eina_strbuf_new();
546 c_code = eina_strbuf_new();
547
548 aux = string_build("ELDBUS_%s_H", iface->c_name);
549 for (i = 0; aux[i]; i++)
550 aux[i] = toupper(aux[i]);
551 eina_strbuf_append_printf(h, "#ifndef %s\n", aux);
552 eina_strbuf_append_printf(h, "#define %s\n\n", aux);
553 free(aux);
554
555 eina_strbuf_append_printf(h, "#include <Eina.h>\n");
556 eina_strbuf_append_printf(h, "#include <Ecore.h>\n");
557 eina_strbuf_append_printf(h, "#include <Eldbus.h>\n");
558 eina_strbuf_append_printf(h, "#include \"eldbus_utils.h\"\n\n");
559 eina_strbuf_append_printf(h, "Eldbus_Proxy *%s_proxy_get(Eldbus_Connection *conn, const char *bus, const char *path);\n", prefix_append(iface->c_name));
560 eina_strbuf_append_printf(h, "void %s_proxy_unref(Eldbus_Proxy *proxy);\n", prefix_append(iface->c_name));
561 eina_strbuf_append_printf(h, "void %s_log_domain_set(int id);\n", prefix_append(iface->c_name));
562
563 if (interface_name && output_name)
564 eina_strbuf_append_printf(c_header, "#include \"%s.h\"\n\n", output_name);
565 else
566 eina_strbuf_append_printf(c_header, "#include \"eldbus_%s.h\"\n\n", iface->c_name);
567
568 eina_strbuf_append_printf(c_header, "static int _log_main = -1;\n");
569 eina_strbuf_append_printf(c_header, "#undef ERR\n");
570 eina_strbuf_append_printf(c_header, "#define ERR(...) EINA_LOG_DOM_ERR(_log_main, __VA_ARGS__);\n");
571
572 eina_strbuf_append_printf(c_init_function, "void\n%s_log_domain_set(int id)\n{\n", prefix_append(iface->c_name));
573 eina_strbuf_append_printf(c_init_function, " _log_main = id;\n");
574 eina_strbuf_append_printf(c_init_function, "}\n");
575
576 eina_strbuf_append_printf(c_init_function, "\nvoid\n%s_proxy_unref(Eldbus_Proxy *proxy)\n{\n", prefix_append(iface->c_name));
577 eina_strbuf_append_printf(c_init_function, " Eldbus_Object *obj = eldbus_proxy_object_get(proxy);\n");
578 eina_strbuf_append_printf(c_init_function, " eldbus_proxy_unref(proxy);\n");
579 eina_strbuf_append_printf(c_init_function, " eldbus_object_unref(obj);\n");
580 eina_strbuf_append_printf(c_init_function, "}\n");
581
582 eina_strbuf_append_printf(c_init_function, "\nEldbus_Proxy *\n%s_proxy_get(Eldbus_Connection *conn, const char *bus, const char *path)\n{\n", prefix_append(iface->c_name));
583 eina_strbuf_append_printf(c_init_function, " Eldbus_Object *obj;\n");
584 eina_strbuf_append_printf(c_init_function, " Eldbus_Proxy *proxy;\n");
585 eina_strbuf_append_printf(c_init_function, " EINA_SAFETY_ON_NULL_RETURN_VAL(conn, NULL);\n");
586 eina_strbuf_append_printf(c_init_function, " EINA_SAFETY_ON_NULL_RETURN_VAL(bus, NULL);\n");
587 eina_strbuf_append_printf(c_init_function, " if (!path) path = \"%s\";\n", path->name);
588 eina_strbuf_append_printf(c_init_function, " obj = eldbus_object_get(conn, bus, path);\n");
589 eina_strbuf_append_printf(c_init_function, " proxy = eldbus_proxy_get(obj, \"%s\");\n", iface->name);
590
591 EINA_INLIST_FOREACH(iface->methods, method)
592 source_client_method_generate(method, c_code, h);
593
594 EINA_INLIST_FOREACH(iface->signals, sig)
595 source_client_signal_generate(sig, c_code, h, c_init_function, c_header);
596
597 EINA_INLIST_FOREACH(iface->properties, prop)
598 source_client_property_generate(prop, c_code, h);
599
600 eina_strbuf_append_printf(c_init_function, " return proxy;\n");
601 eina_strbuf_append_printf(c_init_function, "}\n");
602
603 eina_strbuf_append(h, "\n#endif");
604
605 if (interface_name && output_name)
606 file_name = string_build("%s.h", output_name);
607 else
608 file_name = string_build("eldbus_%s.h", iface->c_name);
609 file_write(file_name, eina_strbuf_string_get(h));
610 eina_strbuf_free(h);
611 free(file_name);
612
613 eina_strbuf_append(c_header, eina_strbuf_string_get(c_code));
614 eina_strbuf_free(c_code);
615 eina_strbuf_append(c_header, "\n");
616 eina_strbuf_append(c_header, eina_strbuf_string_get(c_init_function));
617 eina_strbuf_free(c_init_function);
618 if (interface_name && output_name)
619 file_name = string_build("%s.c", output_name);
620 else
621 file_name = string_build("eldbus_%s.c", iface->c_name);
622 file_write(file_name, eina_strbuf_string_get(c_header));
623 eina_strbuf_free(c_header);
624 free(file_name);
625 }
626
627 if (interface_name && !found)
628 printf("Error: Interface %s not found.\n", interface_name);
629}
diff --git a/src/bin/eldbus/utils.c b/src/bin/eldbus/utils.c
new file mode 100644
index 0000000000..a020445e1d
--- /dev/null
+++ b/src/bin/eldbus/utils.c
@@ -0,0 +1,165 @@
1#include "codegen.h"
2#include <ctype.h>
3
4Eina_Bool
5file_read(const char *file_name, char **buffer)
6{
7 FILE *xml_handler;
8 int data; /* fgetc needs int to detect EOF correctly */
9 Eina_Strbuf *buf;
10
11 xml_handler = fopen(file_name, "rt");
12 if (!xml_handler)
13 {
14 printf("Error to read file: %s\n", file_name);
15 return EINA_FALSE;
16 }
17 buf = eina_strbuf_new();
18
19 while ((data = fgetc(xml_handler)) != EOF)
20 eina_strbuf_append_char(buf, (char)data);
21
22 fclose(xml_handler);
23 *buffer = eina_strbuf_string_steal(buf);
24 eina_strbuf_free(buf);
25
26 return EINA_TRUE;
27}
28
29Eina_Bool
30file_write(const char *file_name, const char *buffer)
31{
32 FILE *file_handler;
33
34 file_handler = fopen(file_name, "wt");
35 if (!file_handler)
36 {
37 printf("Error to write file: %s\n", file_name);
38 return EINA_FALSE;
39 }
40
41 fwrite(buffer, strlen(buffer), 1, file_handler);
42 fclose(file_handler);
43
44 return EINA_TRUE;
45}
46
47char *
48dbus_name_to_c(const char *dbus)
49{
50 char *str_cpy = strdup(dbus), *pch, *ret;
51 Eina_Strbuf *buffer = eina_strbuf_new();
52 unsigned i;
53
54 pch = strtok(str_cpy, "/.");
55 if (!pch)
56 {
57 ret = strdup("root");
58 goto end;
59 }
60 eina_strbuf_append(buffer, pch);
61
62 while ((pch = strtok(NULL, "/.")))
63 eina_strbuf_append_printf(buffer, "_%s",pch);
64
65 ret = eina_strbuf_string_steal(buffer);
66 for (i = 0; ret[i]; i++)
67 {
68 if (i > 0 && ret[i-1] != '_' && ret[i] > '@' && ret[i] < '[')//upper case
69 eina_strbuf_append_printf(buffer, "_%c", tolower(ret[i]));
70 else
71 eina_strbuf_append_char(buffer, tolower(ret[i]));
72 }
73 free(ret);
74 ret = eina_strbuf_string_steal(buffer);
75end:
76 free(str_cpy);
77 eina_strbuf_free(buffer);
78 return ret;
79}
80
81char *
82replace_string(const char *string, const char *substr, const char *replacement)
83{
84 char *str_cpy = strdup(string);
85 char *pch;
86 char *ret;
87 Eina_Strbuf *buffer = eina_strbuf_new();
88
89 pch = strtok(str_cpy, substr);
90 eina_strbuf_append(buffer, pch);
91
92 while ((pch = strtok(NULL, substr)))
93 eina_strbuf_append_printf(buffer, "%s%s", replacement, pch);
94
95 ret = eina_strbuf_string_steal(buffer);
96 free(str_cpy);
97 eina_strbuf_free(buffer);
98 return ret;
99}
100
101char *
102get_pieces(const char *string, char break_in, int amount)
103{
104 int i;
105 int found = 0;
106
107 for (i = strlen(string) - 1; i && amount > found; i--)
108 if (string[i] == break_in)
109 found++;
110
111 if (found)
112 return strdup(string+i+2);
113 else
114 return strdup(string);
115}
116
117char *
118string_build(const char *fmt, ...)
119{
120 va_list ap;
121 Eina_Strbuf *buffer = eina_strbuf_new();
122 char *ret;
123
124 va_start(ap, fmt);
125 eina_strbuf_prepend_vprintf(buffer, fmt, ap);
126 va_end(ap);
127
128 ret = eina_strbuf_string_steal(buffer);
129 eina_strbuf_free(buffer);
130
131 return ret;
132}
133
134#define UTIL_H "\
135#ifndef ELDBUS_UTILS_H\n\
136#define ELDBUS_UTILS_H 1\n\
137\n\
138typedef struct _Eldbus_Error_Info\n\
139{\n\
140 const char *error;\n\
141 const char *message;\n\
142} Eldbus_Error_Info;\n\
143\n\
144typedef void (*Eldbus_Codegen_Property_Set_Cb)(void *data, const char *propname, Eldbus_Proxy *proxy, Eldbus_Pending *p, Eldbus_Error_Info *error_info);\n\
145\n\
146typedef void (*Eldbus_Codegen_Property_String_Get_Cb)(void *data, Eldbus_Pending *p, const char *propname, Eldbus_Proxy *proxy, Eldbus_Error_Info *error_info, const char *value);\n\
147typedef void (*Eldbus_Codegen_Property_Int32_Get_Cb)(void *data, Eldbus_Pending *p, const char *propname, Eldbus_Proxy *proxy, Eldbus_Error_Info *error_info, int value);\n\
148typedef void (*Eldbus_Codegen_Property_Byte_Get_Cb)(void *data, Eldbus_Pending *p, const char *propname, Eldbus_Proxy *proxy, Eldbus_Error_Info *error_info, unsigned char value);\n\
149typedef void (*Eldbus_Codegen_Property_Bool_Get_Cb)(void *data, Eldbus_Pending *p, const char *propname, Eldbus_Proxy *proxy, Eldbus_Error_Info *error_info, Eina_Bool value);\n\
150typedef void (*Eldbus_Codegen_Property_Int16_Get_Cb)(void *data, Eldbus_Pending *p, const char *propname, Eldbus_Proxy *proxy, Eldbus_Error_Info *error_info, short int value);\n\
151typedef void (*Eldbus_Codegen_Property_Uint16_Get_Cb)(void *data, Eldbus_Pending *p, const char *propname, Eldbus_Proxy *proxy, Eldbus_Error_Info *error_info, unsigned short int value);\n\
152typedef void (*Eldbus_Codegen_Property_Uint32_Get_Cb)(void *data, Eldbus_Pending *p, const char *propname, Eldbus_Proxy *proxy, Eldbus_Error_Info *error_info, unsigned int value);\n\
153typedef void (*Eldbus_Codegen_Property_Double_Get_Cb)(void *data, Eldbus_Pending *p, const char *propname, Eldbus_Proxy *proxy, Eldbus_Error_Info *error_info, double value);\n\
154typedef void (*Eldbus_Codegen_Property_Int64_Get_Cb)(void *data, Eldbus_Pending *p, const char *propname, Eldbus_Proxy *proxy, Eldbus_Error_Info *error_info, int64_t value);\n\
155typedef void (*Eldbus_Codegen_Property_Uint64_Get_Cb)(void *data, Eldbus_Pending *p, const char *propname, Eldbus_Proxy *proxy, Eldbus_Error_Info *error_info, uint64_t value);\n\
156typedef void (*Eldbus_Codegen_Property_Complex_Get_Cb)(void *data, Eldbus_Pending *p, const char *propname, Eldbus_Proxy *proxy, Eldbus_Error_Info *error_info, Eina_Value *value);\n\
157\n\
158#endif\
159"
160
161Eina_Bool
162util_h_write(void)
163{
164 return file_write("eldbus_utils.h", UTIL_H);
165}