summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosé Roberto de Souza <zehortigoza@profusion.mobi>2013-01-03 14:06:02 +0000
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2013-01-03 14:06:02 +0000
commitdaec0f2e74ff74bd7b9323f2e090d7d0c6e180c7 (patch)
tree698675638cd4ba6483216b50c82b917f0bfcd568 /src
parent62676bebb7ebdc3817aa069c7f87daab9aea6b9a (diff)
edbus codegen: Properly handle autoclosed tags
Patch by: José Roberto de Souza <zehortigoza@profusion.mobi> SVN revision: 82074
Diffstat (limited to 'src')
-rw-r--r--src/bin/edbus/parser.c109
1 files changed, 59 insertions, 50 deletions
diff --git a/src/bin/edbus/parser.c b/src/bin/edbus/parser.c
index 36b1810d1c..7ddd1a50d7 100644
--- a/src/bin/edbus/parser.c
+++ b/src/bin/edbus/parser.c
@@ -135,6 +135,15 @@ open_object(const char *content, unsigned length, Eina_Bool is_open_empty, DBus_
135 return r; 135 return r;
136} 136}
137 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
138static Eina_Bool 147static Eina_Bool
139open_interface(const char *content, unsigned length, Eina_Bool is_open_empty, DBus_Object *obj) 148open_interface(const char *content, unsigned length, Eina_Bool is_open_empty, DBus_Object *obj)
140{ 149{
@@ -156,9 +165,27 @@ open_interface(const char *content, unsigned length, Eina_Bool is_open_empty, DB
156 iface->c_name = dbus_name_to_c(tmp_name); 165 iface->c_name = dbus_name_to_c(tmp_name);
157 free(tmp_name); 166 free(tmp_name);
158 167
168 if (is_open_empty)
169 interface_close();
170
159 return r; 171 return r;
160} 172}
161 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
162static Eina_Bool 189static Eina_Bool
163open_signal(const char *content, unsigned length, Eina_Bool is_open_empty) 190open_signal(const char *content, unsigned length, Eina_Bool is_open_empty)
164{ 191{
@@ -204,6 +231,9 @@ open_signal(const char *content, unsigned length, Eina_Bool is_open_empty)
204 d_signal->signal_event = eina_strbuf_string_steal(buf); 231 d_signal->signal_event = eina_strbuf_string_steal(buf);
205 eina_strbuf_free(buf); 232 eina_strbuf_free(buf);
206 233
234 if (is_open_empty)
235 signal_close();
236
207 return r; 237 return r;
208} 238}
209 239
@@ -288,8 +318,30 @@ open_arg(const char *content, unsigned length)
288 return r; 318 return r;
289} 319}
290 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
291static Eina_Bool 343static Eina_Bool
292open_method(const char *content, unsigned lenght) 344open_method(const char *content, unsigned lenght, Eina_Bool is_open_empty)
293{ 345{
294 Eina_Bool r; 346 Eina_Bool r;
295 char *tmp; 347 char *tmp;
@@ -319,11 +371,14 @@ open_method(const char *content, unsigned lenght)
319 method->function_cb[i+1] = toupper(method->function_cb[i+1]); 371 method->function_cb[i+1] = toupper(method->function_cb[i+1]);
320 } 372 }
321 373
374 if (is_open_empty)
375 method_close();
376
322 return r; 377 return r;
323} 378}
324 379
325static Eina_Bool 380static Eina_Bool
326open_property(const char *content, unsigned length, Eina_Bool is_open_empty) 381open_property(const char *content, unsigned length)
327{ 382{
328 Eina_Bool r; 383 Eina_Bool r;
329 char *tmp; 384 char *tmp;
@@ -363,9 +418,9 @@ open_tag(const char *content, unsigned length, Eina_Bool is_open_empty, DBus_Obj
363 else if (!strncmp(content, ANNOTATION_TAG, ANNOTATION_TAG_LENGHT) && iface) 418 else if (!strncmp(content, ANNOTATION_TAG, ANNOTATION_TAG_LENGHT) && iface)
364 return open_annotation(content, length); 419 return open_annotation(content, length);
365 else if (!strncmp(content, METHOD_TAG, METHOD_TAG_LENGHT) && iface) 420 else if (!strncmp(content, METHOD_TAG, METHOD_TAG_LENGHT) && iface)
366 return open_method(content, length); 421 return open_method(content, length, is_open_empty);
367 else if (!strncmp(content, PROPERTY_TAG, PROPERTY_TAG_LENGHT) && iface) 422 else if (!strncmp(content, PROPERTY_TAG, PROPERTY_TAG_LENGHT) && iface)
368 return open_property(content, length, is_open_empty); 423 return open_property(content, length);
369 else if (!strncmp(content, ANNOTATION_TAG, ANNOTATION_TAG_LENGHT) && iface) 424 else if (!strncmp(content, ANNOTATION_TAG, ANNOTATION_TAG_LENGHT) && iface)
370 return EINA_TRUE; 425 return EINA_TRUE;
371 426
@@ -377,52 +432,6 @@ open_tag(const char *content, unsigned length, Eina_Bool is_open_empty, DBus_Obj
377 return EINA_TRUE; 432 return EINA_TRUE;
378} 433}
379 434
380static void
381interface_close(void)
382{
383 //its not necessary generate code to FreeDesktop interfaces
384 if (!strncmp(iface->name, DBUS_INTERFACE, strlen(DBUS_INTERFACE)))
385 interface_free(iface);
386 iface = NULL;
387}
388
389static void
390signal_close(void)
391{
392 DBus_Arg *arg;
393 EINA_INLIST_FOREACH(d_signal->args, arg)
394 {
395 if ((arg->type[1]) || (arg->type[0] == 'v'))
396 {
397 d_signal->complex = EINA_TRUE;
398 break;
399 }
400 }
401 d_signal = NULL;
402}
403
404static void
405method_close(void)
406{
407 DBus_Arg *arg;
408 EINA_INLIST_FOREACH(method->args, arg)
409 {
410 if ((arg->type[1]) || (arg->type[0] == 'v'))
411 {
412 if (arg->direction == 'o')
413 method->out_complex = EINA_TRUE;
414 else
415 method->in_complex = EINA_TRUE;
416 }
417 }
418 if (method->no_reply)
419 {
420 free(method->cb_name);
421 method->cb_name = strdup("NULL");
422 }
423 method = NULL;
424}
425
426static Eina_Bool 435static Eina_Bool
427close_tag(const char *content, unsigned length) 436close_tag(const char *content, unsigned length)
428{ 437{