Subj : Re: Properties and Objects To : Joseph Smith From : Brendan Eich Date : Wed Dec 03 2003 03:58 pm Joseph Smith wrote: >JSBool JSParent::JSGetProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) >{ > if (JSVAL_IS_INT(id)) > { > JSParent *p = (JSParent *) JS_GetPrivate(cx, obj); > p=p; // Keep compiler happy > > What's this all about? BTW, tabs are a bad idea in source files. > switch (JSVAL_TO_INT(id)) > { > case child_prop: > { > // How do i return our m_childeren[index] object??? > // What i tried before to no avail using static [index] will >eventually use a > wxHashArray or something to that extent > *vp = OBJECT_TO_JSVAL(p->getJSChild(0)); > > You need to return an array-like object in *vp here. That object's getter, or a predefined element at the index given by JSVAL_TO_INT(id), is what would contain the child object. You're missing a level of object indirection, in other words. The id here is 'child', for an expression like 'p.child'. The expression 'p.child[40000]' involves another getProperty after the one you've implemented here, which runs with obj bound to the object denoted by 'p', and id to 'child'. So you need an array, or an object that acts like an array. /be .