Subj : Re: Another JS question To : Issac Goldstand From : Brendan Eich Date : Thu May 06 2004 12:02 pm Issac Goldstand wrote: > JSIDArray *jids=JS_Enumerate(cx,obj); > for (int i=0;i< jids->length;i++) { > if (JS_IdToValue(cx,jids->vector[i],&rval)) { > ... examine and process rval ... You'd then call JS_GetUCProperty or JS_GetElement, depending on whether JSVAL_IS_STRING(rval) -- if it is, call JS_GetStringChars and JS_GetStringLength to gather the name and length parameters to JS_GetUCProperty; else JSVAL_IS_INT(rval) and you can index into the object using JSVAL_TO_INT(rval). > } else { > ... handle unexpected "holes" in JSIDArray No, if JS_IdToValue returns false (which can't happen in the current codebase, btw), there was an error and you should propagate it. That says to test if (!JS_IdToValue(...)) and return JS_FALSE, avoiding the else clause. > } > } > > Or am I totally barking up the wrong tree? No, you've got the right API. Just don't treat false returns from cx-bearing APIs as non-errors. /be .