Subj : Using JSClass to implement ActiveXObject To : netscape.public.mozilla.jseng From : "Brad" Date : Thu Jul 10 2003 11:42 pm I'm using SpiderMonkey on Win32 and have created a JSClass (via JS_InitClass) to replicate the behavior of ActiveXObject. As far as I can tell this is not part of the script engine, but perhaps this code is available somewhere already written and public domain, please let me know. If not, I'll continue with my post... ActiveXObject drives the IDispatch interface which has 'discovered' properties and methods so it isn't practical, or really possible to define them ahead of time using the JSFunctionSpec and JSPropertySpec structures. Looking at the JSClass structure I can see a number of property hooks, but I need a callback that uses something like the JSNative prototype which includes argv since the methods can have variable numbers of arguments. Ultimately I would like the user to be able to write script like this: obj = new ActiveXObject( "App.ObjectType" ); obj.ArbitraryMethod( parm1, parm2, parm3... ); obj.ArbitraryMethod2( parm1, parm2... ); obj.ArbitraryProperty = parm1; Unfortunately I haven't been able to figure out how to do this. If I add a GetProperty callback to the JSClass, the statement obj.ArbitraryProperty will work, but the engine will report "function obj.ArbitraryMethod is not defined" on the ArbitraryMethod calls, plus I'm not passed an argc/argv parameter set for additional parms. I have had some luck defining a JSFunctionSpec called InvokeMethod. When implemented, the code ends up looking like this, it works but is not really an authentic replication of the ActiveXObject: obj = new ActiveXObject("App.ObjectType"); obj.InvokeMethod( "ArbitraryMethod", parm1, parm2, parm3...) obj.InvokeMethod( "ArbitraryMethod2", parm1, parm2...) obj.InvokeMethod( "ArbitraryProperty", parm1 ); Finally, as a secondary issue, I've found that if I have PropertyOps defined on the JSClass it will override any JSFunctionSpecs I've defined. The engine will again report that "function obj.InvokeMethod is not defined". When I replace the GetPropertyOps with the stub versions the script then executes fine and calls InvokeMethod. Is this expected? I'm always returning JS_TRUE from my PropertyOps callbacks. Most of the posts on this subject lead me to believe that I need to use the JsObjectOps order to get the functionality I desire, but I can't find a lot of information on using that data structure. It seems like I'm just missing something simple here. Any help is appreciated. -Brad .