summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--m4/ac_valist.m439
-rw-r--r--src/lib/edbus/edbus_message.c88
-rw-r--r--src/lib/edbus/edbus_private.h6
4 files changed, 61 insertions, 74 deletions
diff --git a/configure.ac b/configure.ac
index e3e1e1261b..27ba2b06e1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -291,8 +291,6 @@ AC_LANG(C)
291AC_PROG_CC_C99 291AC_PROG_CC_C99
292AM_PROG_CC_C_O 292AM_PROG_CC_C_O
293 293
294AC_C_VA_LIST_AS_ARRAY
295
296if test "x${ac_cv_prog_cc_c99}" = "xno" ; then 294if test "x${ac_cv_prog_cc_c99}" = "xno" ; then
297 AC_MSG_ERROR([ecore requires a c99-capable compiler]) 295 AC_MSG_ERROR([ecore requires a c99-capable compiler])
298fi 296fi
diff --git a/m4/ac_valist.m4 b/m4/ac_valist.m4
deleted file mode 100644
index 8016a060b7..0000000000
--- a/m4/ac_valist.m4
+++ /dev/null
@@ -1,39 +0,0 @@
1dnl Copyright (C) 2013 ProFUSION embedded systems
2dnl This code is public domain and can be freely used or copied.
3
4dnl Macro for checking if va_list is an array
5
6dnl Usage: AC_C_VA_LIST_AS_ARRAY
7dnl call AC_DEFINE for HAVE_VA_LIST_AS_ARRAY if for this architecture
8dnl va_list is defined as an array
9
10AC_DEFUN([AC_C_VA_LIST_AS_ARRAY],
11[
12AC_MSG_CHECKING([whether va_list is defined as an array])
13AC_COMPILE_IFELSE(
14 [AC_LANG_PROGRAM(
15 [[
16#include <stdlib.h>
17#include <stdarg.h>
18
19#define BUILD_ASSERT(cond) \
20 do { (void) sizeof(char [1 - 2*!(cond)]); } while(0)
21 ]],
22 [[
23va_list ap;
24BUILD_ASSERT(__builtin_types_compatible_p(typeof(ap),
25 typeof(&(ap)[0])));
26return 0;
27 ]])],
28 [have_va_list_as_array="no"],
29 [have_va_list_as_array="yes"])
30
31AC_MSG_RESULT([${have_va_list_as_array}])
32
33if test "x${have_va_list_as_array}" = "xyes" ; then
34 AC_DEFINE([HAVE_VA_LIST_AS_ARRAY], [1], [Define to 1 if va_list is an array])
35fi
36
37])
38
39dnl End of ac_valist.m4
diff --git a/src/lib/edbus/edbus_message.c b/src/lib/edbus/edbus_message.c
index 2b58ca678e..d6694e94ba 100644
--- a/src/lib/edbus/edbus_message.c
+++ b/src/lib/edbus/edbus_message.c
@@ -273,8 +273,8 @@ edbus_message_arguments_vget(const EDBus_Message *msg, const char *signature, va
273 return _edbus_message_arguments_vget((EDBus_Message *)msg, signature, ap); 273 return _edbus_message_arguments_vget((EDBus_Message *)msg, signature, ap);
274} 274}
275 275
276EAPI Eina_Bool 276static Eina_Bool
277edbus_message_iter_arguments_vappend(EDBus_Message_Iter *iter, const char *signature, va_list ap) 277_edbus_message_iter_arguments_vappend(EDBus_Message_Iter *iter, const char *signature, va_list *aq)
278{ 278{
279 DBusSignatureIter signature_iter; 279 DBusSignatureIter signature_iter;
280 Eina_Bool r = EINA_TRUE; 280 Eina_Bool r = EINA_TRUE;
@@ -288,14 +288,13 @@ edbus_message_iter_arguments_vappend(EDBus_Message_Iter *iter, const char *signa
288 while ((type = dbus_signature_iter_get_signature(&signature_iter))) 288 while ((type = dbus_signature_iter_get_signature(&signature_iter)))
289 { 289 {
290 if (type[0] != DBUS_TYPE_VARIANT && !type[1]) 290 if (type[0] != DBUS_TYPE_VARIANT && !type[1])
291 r = append_basic(type[0], MAKE_PTR_FROM_VA_LIST(ap), 291 r = append_basic(type[0], aq, &iter->dbus_iterator);
292 &iter->dbus_iterator);
293 else 292 else
294 { 293 {
295 EDBus_Message_Iter **user_itr; 294 EDBus_Message_Iter **user_itr;
296 EDBus_Message_Iter *sub; 295 EDBus_Message_Iter *sub;
297 296
298 user_itr = va_arg(ap, EDBus_Message_Iter **); 297 user_itr = va_arg(*aq, EDBus_Message_Iter **);
299 sub = _message_iterator_new(EINA_TRUE); 298 sub = _message_iterator_new(EINA_TRUE);
300 if (!sub) 299 if (!sub)
301 { 300 {
@@ -340,6 +339,20 @@ next:
340 } 339 }
341 340
342 return r; 341 return r;
342
343}
344
345EAPI Eina_Bool
346edbus_message_iter_arguments_vappend(EDBus_Message_Iter *iter, const char *signature, va_list ap)
347{
348 va_list aq;
349 Eina_Bool ret;
350
351 va_copy(aq, ap);
352 ret = _edbus_message_iter_arguments_vappend(iter, signature, &aq);
353 va_end(aq);
354
355 return ret;
343} 356}
344 357
345EAPI Eina_Bool 358EAPI Eina_Bool
@@ -422,7 +435,7 @@ append_basic(char type, va_list *vl, DBusMessageIter *iter)
422} 435}
423 436
424static Eina_Bool 437static Eina_Bool
425_edbus_message_arguments_vappend(EDBus_Message *msg, const char *signature, va_list ap) 438_edbus_message_arguments_vappend(EDBus_Message *msg, const char *signature, va_list *aq)
426{ 439{
427 DBusSignatureIter signature_iter; 440 DBusSignatureIter signature_iter;
428 EDBus_Message_Iter *iter; 441 EDBus_Message_Iter *iter;
@@ -440,8 +453,7 @@ _edbus_message_arguments_vappend(EDBus_Message *msg, const char *signature, va_l
440 while ((type = dbus_signature_iter_get_current_type(&signature_iter))) 453 while ((type = dbus_signature_iter_get_current_type(&signature_iter)))
441 { 454 {
442 if (dbus_type_is_basic(type)) 455 if (dbus_type_is_basic(type))
443 r = append_basic(type, MAKE_PTR_FROM_VA_LIST(ap), 456 r = append_basic(type, aq, &iter->dbus_iterator);
444 &iter->dbus_iterator);
445 else 457 else
446 { 458 {
447 ERR("sig = %s | edbus_message_arguments_append() and \ 459 ERR("sig = %s | edbus_message_arguments_append() and \
@@ -468,7 +480,7 @@ edbus_message_arguments_append(EDBus_Message *msg, const char *signature, ...)
468 EINA_SAFETY_ON_NULL_RETURN_VAL(signature, EINA_FALSE); 480 EINA_SAFETY_ON_NULL_RETURN_VAL(signature, EINA_FALSE);
469 481
470 va_start(ap, signature); 482 va_start(ap, signature);
471 ret = _edbus_message_arguments_vappend(msg, signature, ap); 483 ret = _edbus_message_arguments_vappend(msg, signature, &ap);
472 va_end(ap); 484 va_end(ap);
473 return ret; 485 return ret;
474} 486}
@@ -476,9 +488,17 @@ edbus_message_arguments_append(EDBus_Message *msg, const char *signature, ...)
476EAPI Eina_Bool 488EAPI Eina_Bool
477edbus_message_arguments_vappend(EDBus_Message *msg, const char *signature, va_list ap) 489edbus_message_arguments_vappend(EDBus_Message *msg, const char *signature, va_list ap)
478{ 490{
491 va_list aq;
492 Eina_Bool ret;
493
479 EDBUS_MESSAGE_CHECK_RETVAL(msg, EINA_FALSE); 494 EDBUS_MESSAGE_CHECK_RETVAL(msg, EINA_FALSE);
480 EINA_SAFETY_ON_NULL_RETURN_VAL(signature, EINA_FALSE); 495 EINA_SAFETY_ON_NULL_RETURN_VAL(signature, EINA_FALSE);
481 return _edbus_message_arguments_vappend(msg, signature, ap); 496
497 va_copy(aq, ap);
498 ret = _edbus_message_arguments_vappend(msg, signature, &aq);
499 va_end(aq);
500
501 return ret;
482} 502}
483 503
484EAPI EDBus_Message_Iter * 504EAPI EDBus_Message_Iter *
@@ -701,21 +721,8 @@ edbus_message_iter_get_and_next(EDBus_Message_Iter *iter, char signature, ...)
701 return EINA_TRUE; 721 return EINA_TRUE;
702} 722}
703 723
704EAPI Eina_Bool 724static Eina_Bool
705edbus_message_iter_arguments_get(EDBus_Message_Iter *iter, const char *signature, ...) 725_edbus_message_iter_arguments_vget(EDBus_Message_Iter *iter, const char *signature, va_list *aq)
706{
707 va_list ap;
708 Eina_Bool ret;
709
710 va_start(ap, signature);
711 ret = edbus_message_iter_arguments_vget(iter, signature, ap);
712 va_end(ap);
713
714 return ret;
715}
716
717EAPI Eina_Bool
718edbus_message_iter_arguments_vget(EDBus_Message_Iter *iter, const char *signature, va_list ap)
719{ 726{
720 int iter_type; 727 int iter_type;
721 DBusSignatureIter sig_iter; 728 DBusSignatureIter sig_iter;
@@ -739,10 +746,10 @@ edbus_message_iter_arguments_vget(EDBus_Message_Iter *iter, const char *signatur
739 } 746 }
740 747
741 if (dbus_type_is_basic(iter_type)) 748 if (dbus_type_is_basic(iter_type))
742 get_basic(iter_type, &iter->dbus_iterator, MAKE_PTR_FROM_VA_LIST(ap)); 749 get_basic(iter_type, &iter->dbus_iterator, aq);
743 else 750 else
744 { 751 {
745 EDBus_Message_Iter **user_itr = va_arg(ap, EDBus_Message_Iter **); 752 EDBus_Message_Iter **user_itr = va_arg(*aq, EDBus_Message_Iter **);
746 EDBus_Message_Iter *sub_itr; 753 EDBus_Message_Iter *sub_itr;
747 754
748 sub_itr = _message_iterator_new(EINA_FALSE); 755 sub_itr = _message_iterator_new(EINA_FALSE);
@@ -760,6 +767,33 @@ edbus_message_iter_arguments_vget(EDBus_Message_Iter *iter, const char *signatur
760 } 767 }
761 768
762 return dbus_signature_iter_get_current_type(&sig_iter) == DBUS_TYPE_INVALID; 769 return dbus_signature_iter_get_current_type(&sig_iter) == DBUS_TYPE_INVALID;
770
771}
772
773EAPI Eina_Bool
774edbus_message_iter_arguments_get(EDBus_Message_Iter *iter, const char *signature, ...)
775{
776 va_list ap;
777 Eina_Bool ret;
778
779 va_start(ap, signature);
780 ret = _edbus_message_iter_arguments_vget(iter, signature, &ap);
781 va_end(ap);
782
783 return ret;
784}
785
786EAPI Eina_Bool
787edbus_message_iter_arguments_vget(EDBus_Message_Iter *iter, const char *signature, va_list ap)
788{
789 va_list aq;
790 Eina_Bool ret;
791
792 va_copy(aq, ap);
793 ret = _edbus_message_iter_arguments_vget(iter, signature, &aq);
794 va_end(aq);
795
796 return ret;
763} 797}
764 798
765EAPI void 799EAPI void
diff --git a/src/lib/edbus/edbus_private.h b/src/lib/edbus/edbus_private.h
index 6b2f7785f1..1a69c9f813 100644
--- a/src/lib/edbus/edbus_private.h
+++ b/src/lib/edbus/edbus_private.h
@@ -82,10 +82,4 @@ EDBus_Signal_Handler *_edbus_signal_handler_add(EDBus_Connection *conn, const c
82 82
83EDBus_Message *edbus_message_signal_new(const char *path, const char *interface, const char *name) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT; 83EDBus_Message *edbus_message_signal_new(const char *path, const char *interface, const char *name) EINA_ARG_NONNULL(1, 2, 3) EINA_WARN_UNUSED_RESULT;
84 84
85#ifdef HAVE_VA_LIST_AS_ARRAY
86#define MAKE_PTR_FROM_VA_LIST(arg) ((va_list *)(arg))
87#else
88#define MAKE_PTR_FROM_VA_LIST(arg) (&(arg))
89#endif
90
91#endif 85#endif