Subj : JS_CallFunction To : netscape.public.mozilla.jseng From : Adrian M Date : Thu Jul 15 2004 12:29 pm Hi... I have a beginner question: I'm trying to use the spider monkey javascript engine with a small example. I'm trying to call JS_CompileFunction on a buffer containing the js code for a function. And then I'm trying to invoke the js function by calling JS_CallFunction. I check the "rval" ( value returned from js function ) and it is always "void". It should be numeric 10. What I'm doing wrong? This is the C code: #include "jsapi.h" JSObject *globalObj; int main( int argc, char * argv[] ) { JSRuntime *rt; JSContext *cx; rt = JS_NewRuntime(0x400000L); cx = JS_NewContext(rt, 8192); globalObj = JS_NewObject(cx, 0, 0, 0); JS_InitStandardClasses(cx, globalObj); char *source = "function myfunc() { return ( 10 ) }"; JSFunction *f = JS_CompileFunction( cx, globalObj, "myfunc", 0, 0, source, strlen( source ), "inlined code", lineno ); ok = JS_CallFunction( cx, globalObj, f, 0, 0, &rval ); printf( "ok=%d\n", ok ); if( JSVAL_IS_VOID( rval ) ) printf( "void...\n" ); JS_DestroyContext(cx); JS_DestroyRuntime(rt); JS_ShutDown(); } Thanks. .