Subj : Re: Using JSClass to implement ActiveXObject To : Brad From : Brendan Eich Date : Fri Jul 11 2003 05:21 pm Brad wrote: > 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... First, you should know that Mozilla supports Active X optionally, including a GeckoActiveXObject similar to MS's ActiveXObject constructor, but with a different name in order that web pages that object-detect window.ActiveXObject, and that then assume its existence implies support for many progids such as MSXML, don't try to run such IE-only code in Mozilla. > 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. Sure, those are only useful for well-known properties. > 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. You have to distinguish two objects, the first (parent, ActiveXObject) from the second (callable method) that is the value of a property in the first that you're trying to invoke. When you say obj(1, 2, 3); You can implement obj's JSClass.call hook and see it being invoked. But if you call obj.meth(4, 5); You will see only resolve and getProperty calls for 'meth' in obj, using obj's JSClass hooks. It's up to your implementation of those hooks to define the 'meth' property in obj, giving it a value that is *another* object, of a "method" JSClass that has a non-null call hook. You don't need to mess with JSObjectOps. But perhaps you don't need to do anything -- probably you can just use the Mozilla Active X support, more or less as is. David Bradley can probably say more to help. /be .