Brendan Eich | 23 Jun 22:00
Picon
Favicon

Re: Help needed in grokking property getter idval arg (for native array wrapping).

On Jun 23, 6:09 am, "Spriggs, Jim" <J.Spri...@raylase.de> wrote:
>     JSObject* arrObj = JS_NewArrayObject(cx, 0, NULL);

Why are you making a standard Array object if you want a custom array-
like object? You should make your own object with its own JSClass.
That JSClass would have GetArrayElement as its getProperty function.

>         // define arr property with explicit getter
>     JS_DefineProperty(cx, global, "arr", OBJECT_TO_JSVAL(arrObj), GetArrayElement, NULL,
JSPROP_SHARED | JSPROP_READONLY);

You defined a global property named "arr" with a custom getter invoked
to compute the value of that property. Not to compute values of index
properties in arrObj.

/be

Gmane