Subj : Re: dereferenced object To : netscape.public.mozilla.jseng From : "Thibaut" Date : Mon Apr 19 2004 05:08 pm i have another problem ... my code for the JSClass.getProperty hook is below : How do i get my array ? my problem is that when i want to get my array i do : Js_GetProperty(cx,obj,"my_array",&my_array) but since i declared the callback function below i can't call JS_GetProperty(...) because it calls my_getProperty instead ... my question is : how can i get my array now in the my_getProperty(...) ??? i'm sorry to bother you with all these questions but i'm a bit lost. thank you Thibaut //****************************************************** static JSBool my_getProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) { if (JSVAL_IS_INT(id)){ uint32 idx; JS_ValueToECMAUint32(cx, id,&idx); jsval jsval_liste; if (!JS_GetProperty(cx,obj,"my_array",&my_array)) ///// this line calls back my_getProperty(...) ... return JS_FALSE; JSObject *liste; if (!JS_ValueToObject(cx, jsval_liste, &liste)) return JS_FALSE; if (!JS_IsArrayObject(cx,obj)) return JS_FALSE; uint32 index; JS_ValueToECMAUint32(cx, id,&index); if (!JS_GetElement(cx, liste, idx,vp)) return JS_FALSE; } return JS_TRUE; } "Brendan Eich" a écrit dans le message de news: c5shfl$hoq2@ripley.netscape.com... > Thibaut wrote: > > What do you mean ?? > > > > This is what you told me : > > > >>Use the JSClass.getProperty hook for childNodes' class. It should > >>handle id parameters for which JSVAL_IS_INT(id) evaluates to true and > >>JSVAL_TO_INT(id) is >= 0 and < the length of the array. > > > > > > i know how to get a property , when i evaluate this in my application : > > Node.chilNodes.item(0) > > it works properly. but how can I implement this : Node.childNodes[0] > > so that it does the same job ??? > > i want to tell the js engine that when i apply [index] to chilNodes > > (Node.childNodes[index] ) it has to call the function item(index) > > (Node.childNodes.item(index) ) > > > > childNodes is not an array but an object with an arrayObject as property > > > Yes, I know. I meant what I wrote: the childNodes object should have a > JSClass whose getProperty handles non-negative int id gets by calling > item(i), where i = JSVAL_TO_INT(id). > > /be .