| 1463 | asIScriptContext *cmpContext; |
| 1464 | asIScriptFunction *cmpFunc; |
| 1465 | bool operator()(void *a, void *b) const |
| 1466 | { |
| 1467 | if( !asc ) |
| 1468 | { |
| 1469 | // Swap items |
| 1470 | void *TEMP = a; |
| 1471 | a = b; |
| 1472 | b = TEMP; |
| 1473 | } |
| 1474 | |
| 1475 | int r = 0; |
| 1476 | |
| 1477 | // Allow sort to work even if the array contains null handles |
| 1478 | if( a == 0 ) return true; |
| 1479 | if( b == 0 ) return false; |
| 1480 | |
| 1481 | // Execute object opCmp |
| 1482 | if( cmpFunc ) |
| 1483 | { |
| 1484 | // TODO: Add proper error handling |
| 1485 | r = cmpContext->Prepare(cmpFunc); assert(r >= 0); |
| 1486 | r = cmpContext->SetObject(a); assert(r >= 0); |
| 1487 | r = cmpContext->SetArgObject(0, b); assert(r >= 0); |
| 1488 | r = cmpContext->Execute(); |
| 1489 | |
| 1490 | if( r == asEXECUTION_FINISHED ) |
| 1491 | { |
| 1492 | return (int)cmpContext->GetReturnDWord() < 0; |
| 1493 | } |
| 1494 | } |
| 1495 | |
| 1496 | return false; |
| 1497 | } |
| 1498 | } customLess = {asc, cmpContext, cache ? cache->cmpFunc : 0}; |
| 1499 | std::sort((void**)GetArrayItemPointer(start), (void**)GetArrayItemPointer(end), customLess); |
| 1500 |
nothing calls this directly
no test coverage detected