Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Setting property attributes after calling JS_SetProperty()

22 views
Skip to first unread message

harry.b...@gmail.com

unread,
Jul 1, 2020, 11:58:45 AM7/1/20
to
Hi,


I'm currently trying to upgrade a program from using JS 1.8.5 to JS 76. In doing this, I've come across a function in which we try to:

- set a property that doesn't initially exist on an object, using JS_SetProperty(),

- then set that property's attributes to be JSPROP_PERMANENT, using JS_SetPropertyAttributes().

However, in JS 76, JS_SetPropertyAttributes() doesn't appear to exist. Instead, I've had to:

- get the property descriptor, using JS_GetPropertyDescriptor(),

- then set the attributes using .setAttributes().

I'm struggling to find any documentation on the matter so I'm not sure if this is even correct. Is there a new/alternative function to replace JS_SetPropertyAttributes() with?


Many thanks,
Harry

Tom Schuster

unread,
Jul 1, 2020, 4:23:24 PM7/1/20
to harry.b...@gmail.com, JS list
Hi!

You can instead use JS_DefineProperty to directly set the property
attributes while defining a new property.

Example:
if (!JS_DefineProperty(cx, object, "name", value, JSPROP_PERMANENT)) {
return false;
}

Cheers,
Tom
> _______________________________________________
> dev-tech-js-engine mailing list
> dev-tech-...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
0 new messages