2 * Browser D-Bus Bridge, JavaScriptCore version
4 * Copyright © 2008 Movial Creative Technologies Inc
5 * Contact: Movial Creative Technologies Inc, <info@movial.com>
6 * Authors: Kalle Vahlman, <kalle.vahlman@movial.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
23 /* Functions to convert between D-Bus types and JSCore types */
25 #ifndef __JSCOREBUS_CONVERT_H___
26 #define __JSCOREBUS_CONVERT_H___
28 #include <dbus/dbus.h>
29 #include <JavaScriptCore/JavaScript.h>
31 /* The number class names are in guestimated usage frequency order to speed up
32 * iteration over them.
34 #define JSCOREBUS_N_NUMBER_CLASSES 8
35 char *jscorebus_number_class_names[JSCOREBUS_N_NUMBER_CLASSES];
36 int jscorebus_number_class_types[JSCOREBUS_N_NUMBER_CLASSES];
38 /* Append JSValues to a D-Bus message iter */
39 gboolean jsvalue_array_append_to_message_iter(JSContextRef context,
40 const JSValueRef jsvalues[],
42 DBusMessageIter *iter,
43 const char *signature);
44 gboolean jsvalue_append_to_message_iter(JSContextRef context,
45 const JSValueRef jsvalue,
46 DBusMessageIter *iter,
47 const char *signature);
49 /* Call a JS function with the arguments from a message */
50 void call_function_with_message_args(JSContextRef context,
51 JSObjectRef thisObject,
53 DBusMessage *message);
55 /* To JavaScript types */
56 JSValueRef jsvalue_from_message_iter(JSContextRef context,
57 DBusMessageIter *iter);
58 JSObjectRef function_from_jsvalue(JSContextRef context,
60 JSValueRef* exception);
63 char *string_from_jsstring(JSContextRef context, JSStringRef jsstring);
64 char *string_from_jsvalue(JSContextRef context, JSValueRef jsvalue);
65 dbus_uint64_t jsvalue_to_number_value (JSContextRef context,
69 /* JSValue to D-Bus signature (autodetection) */
70 char *jsvalue_to_signature(JSContextRef context, JSValueRef jsvalue);
72 jsarray_get_signature(JSContextRef context,
74 JSPropertyNameArrayRef propNames,
77 jsdict_get_signature(JSContextRef context,
79 JSPropertyNameArrayRef propNames,
83 /* Helper functions */
84 gboolean jsvalue_typeof(JSContextRef context,
87 gboolean jsvalue_instanceof(JSContextRef context,
89 const char *constructor);
93 #endif /* __JSCOREBUS_CONVERT_H___ */