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

Function CCARRAY_FOREACH

scripting/javascript/bindings/ScriptingCore.cpp:1374–1416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1372 CAObject* obj;
1373 int i = 0;
1374 CCARRAY_FOREACH(arr, obj)
1375 {
1376 jsval arrElement;
1377
1378 //First, check whether object is associated with js object.
1379 js_proxy_t* jsproxy = js_get_or_create_proxy<CAObject>(cx, obj);
1380 if (jsproxy) {
1381 arrElement = OBJECT_TO_JSVAL(jsproxy->obj);
1382 }
1383 else {
1384 CCString* strVal = NULL;
1385 CCDictionary* dictVal = NULL;
1386 CCArray* arrVal = NULL;
1387// CCDouble* doubleVal = NULL;
1388// CCBool* boolVal = NULL;
1389// CCFloat* floatVal = NULL;
1390// CCInteger* intVal = NULL;
1391
1392 if((strVal = dynamic_cast<CCString *>(obj))) {
1393 arrElement = c_string_to_jsval(cx, strVal->getCString());
1394 } else if ((dictVal = dynamic_cast<CCDictionary*>(obj))) {
1395 arrElement = ccdictionary_to_jsval(cx, dictVal);
1396 } else if ((arrVal = dynamic_cast<CCArray*>(obj))) {
1397 arrElement = ccarray_to_jsval(cx, arrVal);
1398 }
1399 else {
1400 CCAssert(false, "the type isn't suppored.");
1401 }
1402// else if ((doubleVal = dynamic_cast<CCDouble*>(obj))) {
1403// arrElement = DOUBLE_TO_JSVAL(doubleVal->getValue());
1404// } else if ((floatVal = dynamic_cast<CCFloat*>(obj))) {
1405// arrElement = DOUBLE_TO_JSVAL(floatVal->getValue());
1406// } else if ((intVal = dynamic_cast<CCInteger*>(obj))) {
1407// arrElement = INT_TO_JSVAL(intVal->getValue());
1408// } else if ((boolVal = dynamic_cast<CCBool*>(obj))) {
1409// arrElement = BOOLEAN_TO_JSVAL(boolVal->getValue() ? JS_TRUE : JS_FALSE);
1410// }
1411 }
1412 if(!JS_SetElement(cx, jsretArr, i, &arrElement)) {
1413 break;
1414 }
1415 ++i;
1416 }
1417 return OBJECT_TO_JSVAL(jsretArr);
1418}
1419

Callers

nothing calls this directly

Calls 4

c_string_to_jsvalFunction · 0.85
ccdictionary_to_jsvalFunction · 0.85
ccarray_to_jsvalFunction · 0.85
OBJECT_TO_JSVALFunction · 0.50

Tested by

no test coverage detected