resources/RooUsage.txt
[app.Builder.js] / src / c / jscore_object_call_as_function.c
1 #include <JavaScriptCore/JavaScript.h>
2 #include <glib.h>
3 #include <glib-object.h>
4 /**
5  a wrapper around call as function, as Value[] arrays do not work in Vala...
6
7 */
8
9
10 JSValueRef jscore_object_call_as_function(
11         JSContextRef ctx,
12         JSObjectRef object, 
13         JSObjectRef thisObject,
14           gchar * val,
15         JSValueRef* exception
16         
17 ) {
18         JSValueRef  ex = 0;
19         JSValueRef res;
20     JSValueRef *jsargs;
21     
22     
23     JSStringRef jsstr = JSStringCreateWithUTF8CString (val);
24         JSValueRef valstr = JSValueMakeString (ctx, jsstr);
25         //JSStringRelease (jsstr); //??
26     
27     jsargs = (JSValueRef *) g_newa (JSValueRef, 1);
28     jsargs[0] =  valstr;
29     
30     res =  JSObjectCallAsFunction(
31                         ctx, 
32                         object, 
33                         0, 
34                         1, 
35                         jsargs, 
36                         &ex
37         );
38         // free the args..
39         
40     return res;
41
42   
43 }
44