I'm not the most familar with the SpiderMonkey docs, but I think they have class handling functions, anyway to expose a function I do the following : (These links can help get you in the right direction too : http://www.mozilla.org/js/spidermonkey/ http://www.mozilla.org/js/spidermonkey/apidoc/gen/api-JS_DefineFunction.html )Create the function definition (in C or C++):JSBool MyFunction(JSContext *cx, JSObject *obj, uintN /* argc*/, jsval*argv, jsval * /*rval*/){//Do some stuff here ... //example to get two string values passed to you from Javascript : CAtlString arg1=CAtlString(JS_GetStringBytes(JS_ValueToString(cx,argv[0]))); CAtlString arg2 = CAtlString(JS_GetStringBytes(JS_ValueToString(cx,argv[1])));}argc I believe is the number of args, argv is the data passed in, and rvalueis if you want to return a value to javascript.you then pass the function to Javascript with the following :JS_DefineFunction(cx,pJobj,"MyFunctionName",MyFunction,2,0);cx and pJobj are the context and Global object you can get from thensIScriptContext, next is the name the function will appear as injavascript. then your function pointer, # of args the function takes, Ibelieve the last param is always zero,Hope that helps you going the ri ght direction--RIchard"Olaf" <[EMAIL PROTECTED]> wrote in messagenews:[EMAIL PROTECTED]> Do you have a small code snippet showing how this is done? I would like> to expose a struct or class, but functions would be a start.>
_______________________________________________ dev-embedding mailing list [email protected] https://lists.mozilla.org/listinfo/dev-embedding
