in unmaintained/modules/js/eval.hpp [234:265]
const list<value> jsPropertiesToValues(const list<value>& propertiesSoFar, JSObject* o, JSObject* i, const js::JSContext& cx) {
const value jsValToValue(const jsval& jsv, const js::JSContext& cx);
jsid id;
if(!JS_NextProperty(cx, i, &id))
return propertiesSoFar;
jsval idv;
JS_IdToValue(cx, id, &idv);
if (idv == JSVAL_VOID)
return propertiesSoFar;
jsval jsv;
if(!JS_GetPropertyById(cx, o, id, &jsv))
return propertiesSoFar;
const value val = jsValToValue(jsv, cx);
if(JSVAL_IS_STRING(idv)) {
char* cname = JS_EncodeString(cx, JSVAL_TO_STRING(idv));
const string name = cname;
JS_free(cx, cname);
if (isNil(val) && !isList(val))
return jsPropertiesToValues(cons<value> (mklist<value> (element, c_str(name), val), propertiesSoFar), o, i, cx);
//return jsPropertiesToValues(propertiesSoFar, o, i, cx);
if (substr(name, 0, 1) == atsign)
return jsPropertiesToValues(cons<value>(mklist<value>(attribute, c_str(substr(name, 1)), val), propertiesSoFar), o, i, cx);
if (isList(val) && !isJSArray(val))
return jsPropertiesToValues(cons<value>(cons<value>(element, cons<value>(c_str(name), list<value>(val))), propertiesSoFar), o, i, cx);
return jsPropertiesToValues(cons<value> (mklist<value> (element, c_str(name), val), propertiesSoFar), o, i, cx);
}
return jsPropertiesToValues(cons(val, propertiesSoFar), o, i, cx);
}