Hello,
Yet again I'm having to ask for help as I'm clearly being stupid and/or there is something I'm missing...
After an epic effort upgrading our embedding from using Spidermoney 1.8.5 to Spidermonkey 78 it all now seems to be working nicely except for one odd problem reported by a user with object properties.
My embedding defines several classes with properties by using JS_InitClass with JSPropertySpec etc. What I'm doing looks virtually identical to the cookbook example at
https://github.com/mozilla-spidermonkey/spidermonkey-embedding-examples/blob/esr78/examples/cookbook.cpp#L703. The only difference I can see is that I use JS_NewObjectWithGivenPrototype instead of JS_NewObjectForConstructor (but I tried changing that and it made no difference)
However, for some reason I don't understand the properties that I define for my class do not return true for Object.prototype.hasOwnProperty() in Spidermonkey 78 but they did in Spidermonkey 1.8.5.
For example I define a Node class with properties x,y,z (and lots more...)
To do the upgrade I have been using all sorts of macros/pre-processor logic so that I can compile using either the old 1.8.5 version or the new 78 version of Spidermonkey until we are sure everything is working.
With the old 1.8.5 engine if I run the following code
var n = new Node(1.1, 2.2, 3.3);
for (a in n)
Message(" Property "+a+": "+n[a]);
Message(" n.hasOwnProperty('x') returns "+n.hasOwnProperty('x'));
I get the output
Property x: 1.100000023841858
Property y: 2.200000047683716
...
n.hasOwnProperty('x') returns true
However, in the new Spidermonkey 78 engine I get
Property x: 1.100000023841858
Property y: 2.200000047683716
...
n.hasOwnProperty('x') returns false
i.e. In the new Spidermonkey 78 engine I can still enumerate over the properties but some some unknown reason the properties are not defined in this class. Presumably the engine thinks they are somehow being defined in the prototype chain somewhere else...
There are differences as to what is exactly being executed in the different engines due to my macros but I'm running the same basic code with JS_InitClass etc.
My class stores private data and I am setting JSCLASS_HAS_PRIVATE
My properties are defined with the flags JSPROP_ENUMERATE|JSPROP_PERMANENT
No doubt I'm (yet again) being stupid and missing something obvious but I can't for the life of me see what the problem is.
Can anybody help?
Many thanks in advance for any assistance
Miles