| 1541 | asIScriptContext *cmpContext; |
| 1542 | asIScriptFunction *cmpFunc; |
| 1543 | bool operator()(void *a, void *b) const |
| 1544 | { |
| 1545 | if( !asc ) |
| 1546 | { |
| 1547 | // Swap items |
| 1548 | void *TEMP = a; |
| 1549 | a = b; |
| 1550 | b = TEMP; |
| 1551 | } |
| 1552 | |
| 1553 | int r = 0; |
| 1554 | |
| 1555 | // Allow sort to work even if the array contains null handles |
| 1556 | if( a == 0 ) return true; |
| 1557 | if( b == 0 ) return false; |
| 1558 | |
| 1559 | // Execute object opCmp |
| 1560 | if( cmpFunc ) |
| 1561 | { |
| 1562 | // TODO: Add proper error handling |
| 1563 | r = cmpContext->Prepare(cmpFunc); assert(r >= 0); |
| 1564 | r = cmpContext->SetObject(a); assert(r >= 0); |
| 1565 | r = cmpContext->SetArgObject(0, b); assert(r >= 0); |
| 1566 | r = cmpContext->Execute(); |
| 1567 | |
| 1568 | if( r == asEXECUTION_FINISHED ) |
| 1569 | { |
| 1570 | return (int)cmpContext->GetReturnDWord() < 0; |
| 1571 | } |
| 1572 | } |
| 1573 | |
| 1574 | return false; |
| 1575 | } |
| 1576 | } customLess = {asc, cmpContext, cache ? cache->cmpFunc : 0}; |
| 1577 | std::sort((void**)GetArrayItemPointer(start), (void**)GetArrayItemPointer(end), customLess); |
| 1578 |
nothing calls this directly
no test coverage detected