Subj : Re: [SpiderMonkey] Confused about class property To : netscape.public.mozilla.jseng From : Peter Paulus Date : Tue Oct 04 2005 05:26 pm Not just to start a monologue, I've disassembled the javascript: var x = ColorSpace.lab; into: 00000: 0 defvar "x" main: 00003: 0 bindname "x" 00006: 0 name "ColorSpace" 00009: 0 getprop "lab" 00012: 0 setname "x" 00015: 0 pop So I guess it must be the interpreter that turns ColorSpace into a Function object, rather than an 'ColorSpace' object. Are there flags on my JSClass struct or otherwise to manipulate this behavior? With kind regards, Peter Paulus Peter Paulus wrote: > Hello all, > > In my host class 'ColorSpace' I've added, a.o., a class property 'lab' > with flags: JSPROP_READONLY | JSPROP_PERMANENT | JSPROP_GETTER | > JSPROP_SHARED and a getter: getClassProperty(). > > This property mimics a value where in other languages one would use an > enumeration. > > My testscript contains: > var x = ColorSpace.lab; > > When getClassProperty() is invoked the tinyid is correct. But the > JSobject* obj parameter supplied, contains a Function object, instead of > an object of class "ColorSpace". > > The 'this' object retrieved from the stackframe is my global object. > > I have been fiddling with the flags of JSClass and JSPropertySpec, but I > can't seem to find how to set them correctly. Most of the time > js_InvokeInternal() is invoked and crashes. > > I do realize that there is a possibility to say in javascript: > > if (ColorSpace.convert) > { > ... > } > else > { > ... > } > > In order to check if a method exists. Can I take any actions as to > resolve the ambiguity between getting a 'class' property and checking > for the existence of a method. > > Thank you in advance. > > With kind regards, > Peter Paulus .