internal
| 999 | |
| 1000 | // internal |
| 1001 | bool CScriptArray::Less(const void *a, const void *b, bool asc, asIScriptContext *ctx, SArrayCache *cache) |
| 1002 | { |
| 1003 | if( !asc ) |
| 1004 | { |
| 1005 | // Swap items |
| 1006 | const void *TEMP = a; |
| 1007 | a = b; |
| 1008 | b = TEMP; |
| 1009 | } |
| 1010 | |
| 1011 | if( !(subTypeId & ~asTYPEID_MASK_SEQNBR) ) |
| 1012 | { |
| 1013 | // Simple compare of values |
| 1014 | switch( subTypeId ) |
| 1015 | { |
| 1016 | #define COMPARE(T) *((T*)a) < *((T*)b) |
| 1017 | case asTYPEID_BOOL: return COMPARE(bool); |
| 1018 | case asTYPEID_INT8: return COMPARE(signed char); |
| 1019 | case asTYPEID_UINT8: return COMPARE(unsigned char); |
| 1020 | case asTYPEID_INT16: return COMPARE(signed short); |
| 1021 | case asTYPEID_UINT16: return COMPARE(unsigned short); |
| 1022 | case asTYPEID_INT32: return COMPARE(signed int); |
| 1023 | case asTYPEID_UINT32: return COMPARE(unsigned int); |
| 1024 | case asTYPEID_FLOAT: return COMPARE(float); |
| 1025 | case asTYPEID_DOUBLE: return COMPARE(double); |
| 1026 | default: return COMPARE(signed int); // All enums fall in this case |
| 1027 | #undef COMPARE |
| 1028 | } |
| 1029 | } |
| 1030 | else |
| 1031 | { |
| 1032 | int r = 0; |
| 1033 | |
| 1034 | if( subTypeId & asTYPEID_OBJHANDLE ) |
| 1035 | { |
| 1036 | // Allow sort to work even if the array contains null handles |
| 1037 | if( *(void**)a == 0 ) return true; |
| 1038 | if( *(void**)b == 0 ) return false; |
| 1039 | } |
| 1040 | |
| 1041 | // Execute object opCmp |
| 1042 | if( cache && cache->cmpFunc ) |
| 1043 | { |
| 1044 | // TODO: Add proper error handling |
| 1045 | r = ctx->Prepare(cache->cmpFunc); assert(r >= 0); |
| 1046 | |
| 1047 | if( subTypeId & asTYPEID_OBJHANDLE ) |
| 1048 | { |
| 1049 | r = ctx->SetObject(*((void**)a)); assert(r >= 0); |
| 1050 | r = ctx->SetArgObject(0, *((void**)b)); assert(r >= 0); |
| 1051 | } |
| 1052 | else |
| 1053 | { |
| 1054 | r = ctx->SetObject((void*)a); assert(r >= 0); |
| 1055 | r = ctx->SetArgObject(0, (void*)b); assert(r >= 0); |
| 1056 | } |
| 1057 | |
| 1058 | r = ctx->Execute(); |
nothing calls this directly
no outgoing calls
no test coverage detected