MCPcopy Create free account
hub / github.com/9miao/CrossApp / CCDICT_FOREACH

Function CCDICT_FOREACH

scripting/javascript/bindings/ScriptingCore.cpp:1424–1467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1422 JSObject* jsRet = JS_NewObject(cx, NULL, NULL, NULL);
1423 CCDictElement* pElement = NULL;
1424 CCDICT_FOREACH(dict, pElement)
1425 {
1426 jsval dictElement;
1427 CAObject* obj = pElement->getObject();
1428 //First, check whether object is associated with js object.
1429 js_proxy_t* jsproxy = js_get_or_create_proxy<CAObject>(cx, obj);
1430 if (jsproxy) {
1431 dictElement = OBJECT_TO_JSVAL(jsproxy->obj);
1432 }
1433 else {
1434 CCString* strVal = NULL;
1435 CCDictionary* dictVal = NULL;
1436 CCArray* arrVal = NULL;
1437// CCDouble* doubleVal = NULL;
1438// CCBool* boolVal = NULL;
1439// CCFloat* floatVal = NULL;
1440// CCInteger* intVal = NULL;
1441
1442 if((strVal = dynamic_cast<CCString *>(obj))) {
1443 dictElement = c_string_to_jsval(cx, strVal->getCString());
1444 } else if ((dictVal = dynamic_cast<CCDictionary*>(obj))) {
1445 dictElement = ccdictionary_to_jsval(cx, dictVal);
1446 } else if ((arrVal = dynamic_cast<CCArray*>(obj))) {
1447 dictElement = ccarray_to_jsval(cx, arrVal);
1448 }
1449 else {
1450 CCAssert(false, "the type isn't suppored.");
1451 }
1452// else if ((doubleVal = dynamic_cast<CCDouble*>(obj))) {
1453// dictElement = DOUBLE_TO_JSVAL(doubleVal->getValue());
1454// } else if ((floatVal = dynamic_cast<CCFloat*>(obj))) {
1455// dictElement = DOUBLE_TO_JSVAL(floatVal->getValue());
1456// } else if ((intVal = dynamic_cast<CCInteger*>(obj))) {
1457// dictElement = INT_TO_JSVAL(intVal->getValue());
1458// } else if ((boolVal = dynamic_cast<CCBool*>(obj))) {
1459// dictElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE);
1460// }
1461 }
1462 const char* key = pElement->getStrKey();
1463 if (key && strlen(key) > 0)
1464 {
1465 JS_SetProperty(cx, jsRet, key, &dictElement);
1466 }
1467 }
1468 return OBJECT_TO_JSVAL(jsRet);
1469}
1470

Callers

nothing calls this directly

Calls 5

c_string_to_jsvalFunction · 0.85
ccdictionary_to_jsvalFunction · 0.85
ccarray_to_jsvalFunction · 0.85
getObjectMethod · 0.80
OBJECT_TO_JSVALFunction · 0.50

Tested by

no test coverage detected