Mercurial > emacs
comparison src/dbusbind.c @ 103612:25fc47c9b012
* dbusbind.c (XD_SYMBOL_TO_DBUS_TYPE): Convert macro into function
xd_symbol_to_dbus_type. With Solaris 2.11, it was said to compile
for hours, when optimzation is enabled.
(xd_signature, xd_append_arg, xd_retrieve_arg, xd_initialize)
(xd_read_message): Make them static.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Sun, 28 Jun 2009 15:21:53 +0000 |
parents | dd95cb42c0aa |
children | 50effbe728da |
comparison
equal
deleted
inserted
replaced
103611:6f6def36a946 | 103612:25fc47c9b012 |
---|---|
153 || (type == DBUS_TYPE_DOUBLE) \ | 153 || (type == DBUS_TYPE_DOUBLE) \ |
154 || (type == DBUS_TYPE_STRING) \ | 154 || (type == DBUS_TYPE_STRING) \ |
155 || (type == DBUS_TYPE_OBJECT_PATH) \ | 155 || (type == DBUS_TYPE_OBJECT_PATH) \ |
156 || (type == DBUS_TYPE_SIGNATURE)) | 156 || (type == DBUS_TYPE_SIGNATURE)) |
157 | 157 |
158 /* This was a macro. On Solaris 2.11 it was said to compile for | |
159 hours, when optimzation is enabled. So we have transferred it into | |
160 a function. */ | |
158 /* Determine the DBusType of a given Lisp symbol. OBJECT must be one | 161 /* Determine the DBusType of a given Lisp symbol. OBJECT must be one |
159 of the predefined D-Bus type symbols. */ | 162 of the predefined D-Bus type symbols. */ |
160 #define XD_SYMBOL_TO_DBUS_TYPE(object) \ | 163 static int |
161 ((EQ (object, QCdbus_type_byte)) ? DBUS_TYPE_BYTE \ | 164 xd_symbol_to_dbus_type (object) |
162 : (EQ (object, QCdbus_type_boolean)) ? DBUS_TYPE_BOOLEAN \ | 165 Lisp_Object object; |
163 : (EQ (object, QCdbus_type_int16)) ? DBUS_TYPE_INT16 \ | 166 { |
164 : (EQ (object, QCdbus_type_uint16)) ? DBUS_TYPE_UINT16 \ | 167 return |
165 : (EQ (object, QCdbus_type_int32)) ? DBUS_TYPE_INT32 \ | 168 ((EQ (object, QCdbus_type_byte)) ? DBUS_TYPE_BYTE |
166 : (EQ (object, QCdbus_type_uint32)) ? DBUS_TYPE_UINT32 \ | 169 : (EQ (object, QCdbus_type_boolean)) ? DBUS_TYPE_BOOLEAN |
167 : (EQ (object, QCdbus_type_int64)) ? DBUS_TYPE_INT64 \ | 170 : (EQ (object, QCdbus_type_int16)) ? DBUS_TYPE_INT16 |
168 : (EQ (object, QCdbus_type_uint64)) ? DBUS_TYPE_UINT64 \ | 171 : (EQ (object, QCdbus_type_uint16)) ? DBUS_TYPE_UINT16 |
169 : (EQ (object, QCdbus_type_double)) ? DBUS_TYPE_DOUBLE \ | 172 : (EQ (object, QCdbus_type_int32)) ? DBUS_TYPE_INT32 |
170 : (EQ (object, QCdbus_type_string)) ? DBUS_TYPE_STRING \ | 173 : (EQ (object, QCdbus_type_uint32)) ? DBUS_TYPE_UINT32 |
171 : (EQ (object, QCdbus_type_object_path)) ? DBUS_TYPE_OBJECT_PATH \ | 174 : (EQ (object, QCdbus_type_int64)) ? DBUS_TYPE_INT64 |
172 : (EQ (object, QCdbus_type_signature)) ? DBUS_TYPE_SIGNATURE \ | 175 : (EQ (object, QCdbus_type_uint64)) ? DBUS_TYPE_UINT64 |
173 : (EQ (object, QCdbus_type_array)) ? DBUS_TYPE_ARRAY \ | 176 : (EQ (object, QCdbus_type_double)) ? DBUS_TYPE_DOUBLE |
174 : (EQ (object, QCdbus_type_variant)) ? DBUS_TYPE_VARIANT \ | 177 : (EQ (object, QCdbus_type_string)) ? DBUS_TYPE_STRING |
175 : (EQ (object, QCdbus_type_struct)) ? DBUS_TYPE_STRUCT \ | 178 : (EQ (object, QCdbus_type_object_path)) ? DBUS_TYPE_OBJECT_PATH |
176 : (EQ (object, QCdbus_type_dict_entry)) ? DBUS_TYPE_DICT_ENTRY \ | 179 : (EQ (object, QCdbus_type_signature)) ? DBUS_TYPE_SIGNATURE |
177 : DBUS_TYPE_INVALID) | 180 : (EQ (object, QCdbus_type_array)) ? DBUS_TYPE_ARRAY |
181 : (EQ (object, QCdbus_type_variant)) ? DBUS_TYPE_VARIANT | |
182 : (EQ (object, QCdbus_type_struct)) ? DBUS_TYPE_STRUCT | |
183 : (EQ (object, QCdbus_type_dict_entry)) ? DBUS_TYPE_DICT_ENTRY | |
184 : DBUS_TYPE_INVALID); | |
185 } | |
178 | 186 |
179 /* Check whether a Lisp symbol is a predefined D-Bus type symbol. */ | 187 /* Check whether a Lisp symbol is a predefined D-Bus type symbol. */ |
180 #define XD_DBUS_TYPE_P(object) \ | 188 #define XD_DBUS_TYPE_P(object) \ |
181 (SYMBOLP (object) && ((XD_SYMBOL_TO_DBUS_TYPE (object) != DBUS_TYPE_INVALID))) | 189 (SYMBOLP (object) && ((xd_symbol_to_dbus_type (object) != DBUS_TYPE_INVALID))) |
182 | 190 |
183 /* Determine the DBusType of a given Lisp OBJECT. It is used to | 191 /* Determine the DBusType of a given Lisp OBJECT. It is used to |
184 convert Lisp objects, being arguments of `dbus-call-method' or | 192 convert Lisp objects, being arguments of `dbus-call-method' or |
185 `dbus-send-signal', into corresponding C values appended as | 193 `dbus-send-signal', into corresponding C values appended as |
186 arguments to a D-Bus message. */ | 194 arguments to a D-Bus message. */ |
188 ((EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN \ | 196 ((EQ (object, Qt) || EQ (object, Qnil)) ? DBUS_TYPE_BOOLEAN \ |
189 : (NATNUMP (object)) ? DBUS_TYPE_UINT32 \ | 197 : (NATNUMP (object)) ? DBUS_TYPE_UINT32 \ |
190 : (INTEGERP (object)) ? DBUS_TYPE_INT32 \ | 198 : (INTEGERP (object)) ? DBUS_TYPE_INT32 \ |
191 : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \ | 199 : (FLOATP (object)) ? DBUS_TYPE_DOUBLE \ |
192 : (STRINGP (object)) ? DBUS_TYPE_STRING \ | 200 : (STRINGP (object)) ? DBUS_TYPE_STRING \ |
193 : (XD_DBUS_TYPE_P (object)) ? XD_SYMBOL_TO_DBUS_TYPE (object) \ | 201 : (XD_DBUS_TYPE_P (object)) ? xd_symbol_to_dbus_type (object) \ |
194 : (CONSP (object)) \ | 202 : (CONSP (object)) \ |
195 ? ((XD_DBUS_TYPE_P (CAR_SAFE (object))) \ | 203 ? ((XD_DBUS_TYPE_P (CAR_SAFE (object))) \ |
196 ? ((XD_BASIC_DBUS_TYPE (XD_SYMBOL_TO_DBUS_TYPE (CAR_SAFE (object)))) \ | 204 ? ((XD_BASIC_DBUS_TYPE (xd_symbol_to_dbus_type (CAR_SAFE (object)))) \ |
197 ? DBUS_TYPE_ARRAY \ | 205 ? DBUS_TYPE_ARRAY \ |
198 : XD_SYMBOL_TO_DBUS_TYPE (CAR_SAFE (object))) \ | 206 : xd_symbol_to_dbus_type (CAR_SAFE (object))) \ |
199 : DBUS_TYPE_ARRAY) \ | 207 : DBUS_TYPE_ARRAY) \ |
200 : DBUS_TYPE_INVALID) | 208 : DBUS_TYPE_INVALID) |
201 | 209 |
202 /* Return a list pointer which does not have a Lisp symbol as car. */ | 210 /* Return a list pointer which does not have a Lisp symbol as car. */ |
203 #define XD_NEXT_VALUE(object) \ | 211 #define XD_NEXT_VALUE(object) \ |
208 the object is related to. It is passed as argument, because it | 216 the object is related to. It is passed as argument, because it |
209 cannot be detected in basic type objects, when they are preceded by | 217 cannot be detected in basic type objects, when they are preceded by |
210 a type symbol. PARENT_TYPE is the DBusType of a container this | 218 a type symbol. PARENT_TYPE is the DBusType of a container this |
211 signature is embedded, or DBUS_TYPE_INVALID. It is needed for the | 219 signature is embedded, or DBUS_TYPE_INVALID. It is needed for the |
212 check that DBUS_TYPE_DICT_ENTRY occurs only as array element. */ | 220 check that DBUS_TYPE_DICT_ENTRY occurs only as array element. */ |
213 void | 221 static void |
214 xd_signature (signature, dtype, parent_type, object) | 222 xd_signature (signature, dtype, parent_type, object) |
215 char *signature; | 223 char *signature; |
216 unsigned int dtype, parent_type; | 224 unsigned int dtype, parent_type; |
217 Lisp_Object object; | 225 Lisp_Object object; |
218 { | 226 { |
380 /* Append C value, extracted from Lisp OBJECT, to iteration ITER. | 388 /* Append C value, extracted from Lisp OBJECT, to iteration ITER. |
381 DTYPE must be a valid DBusType. It is used to convert Lisp | 389 DTYPE must be a valid DBusType. It is used to convert Lisp |
382 objects, being arguments of `dbus-call-method' or | 390 objects, being arguments of `dbus-call-method' or |
383 `dbus-send-signal', into corresponding C values appended as | 391 `dbus-send-signal', into corresponding C values appended as |
384 arguments to a D-Bus message. */ | 392 arguments to a D-Bus message. */ |
385 void | 393 static void |
386 xd_append_arg (dtype, object, iter) | 394 xd_append_arg (dtype, object, iter) |
387 unsigned int dtype; | 395 unsigned int dtype; |
388 Lisp_Object object; | 396 Lisp_Object object; |
389 DBusMessageIter *iter; | 397 DBusMessageIter *iter; |
390 { | 398 { |
576 | 584 |
577 /* Retrieve C value from a DBusMessageIter structure ITER, and return | 585 /* Retrieve C value from a DBusMessageIter structure ITER, and return |
578 a converted Lisp object. The type DTYPE of the argument of the | 586 a converted Lisp object. The type DTYPE of the argument of the |
579 D-Bus message must be a valid DBusType. Compound D-Bus types | 587 D-Bus message must be a valid DBusType. Compound D-Bus types |
580 result always in a Lisp list. */ | 588 result always in a Lisp list. */ |
581 Lisp_Object | 589 static Lisp_Object |
582 xd_retrieve_arg (dtype, iter) | 590 xd_retrieve_arg (dtype, iter) |
583 unsigned int dtype; | 591 unsigned int dtype; |
584 DBusMessageIter *iter; | 592 DBusMessageIter *iter; |
585 { | 593 { |
586 | 594 |
680 } | 688 } |
681 } | 689 } |
682 | 690 |
683 /* Initialize D-Bus connection. BUS is a Lisp symbol, either :system | 691 /* Initialize D-Bus connection. BUS is a Lisp symbol, either :system |
684 or :session. It tells which D-Bus to be initialized. */ | 692 or :session. It tells which D-Bus to be initialized. */ |
685 DBusConnection * | 693 static DBusConnection * |
686 xd_initialize (bus) | 694 xd_initialize (bus) |
687 Lisp_Object bus; | 695 Lisp_Object bus; |
688 { | 696 { |
689 DBusConnection *connection; | 697 DBusConnection *connection; |
690 DBusError derror; | 698 DBusError derror; |
1402 return Qt; | 1410 return Qt; |
1403 } | 1411 } |
1404 | 1412 |
1405 /* Read queued incoming message of the D-Bus BUS. BUS is a Lisp | 1413 /* Read queued incoming message of the D-Bus BUS. BUS is a Lisp |
1406 symbol, either :system or :session. */ | 1414 symbol, either :system or :session. */ |
1407 Lisp_Object | 1415 static Lisp_Object |
1408 xd_read_message (bus) | 1416 xd_read_message (bus) |
1409 Lisp_Object bus; | 1417 Lisp_Object bus; |
1410 { | 1418 { |
1411 Lisp_Object args, key, value; | 1419 Lisp_Object args, key, value; |
1412 struct gcpro gcpro1; | 1420 struct gcpro gcpro1; |