MCPcopy Create free account
hub / github.com/CytopiaTeam/Cytopia / Equals

Method Equals

external/as_add_on/scriptarray/scriptarray.cpp:1145–1228  ·  view source on GitHub ↗

internal

Source from the content-addressed store, hash-verified

1143
1144// internal
1145bool CScriptArray::Equals(const void *a, const void *b, asIScriptContext *ctx, SArrayCache *cache) const
1146{
1147 if( !(subTypeId & ~asTYPEID_MASK_SEQNBR) )
1148 {
1149 // Simple compare of values
1150 switch( subTypeId )
1151 {
1152 #define COMPARE(T) *((T*)a) == *((T*)b)
1153 case asTYPEID_BOOL: return COMPARE(bool);
1154 case asTYPEID_INT8: return COMPARE(signed char);
1155 case asTYPEID_UINT8: return COMPARE(unsigned char);
1156 case asTYPEID_INT16: return COMPARE(signed short);
1157 case asTYPEID_UINT16: return COMPARE(unsigned short);
1158 case asTYPEID_INT32: return COMPARE(signed int);
1159 case asTYPEID_UINT32: return COMPARE(unsigned int);
1160 case asTYPEID_FLOAT: return COMPARE(float);
1161 case asTYPEID_DOUBLE: return COMPARE(double);
1162 default: return COMPARE(signed int); // All enums fall here
1163 #undef COMPARE
1164 }
1165 }
1166 else
1167 {
1168 int r = 0;
1169
1170 if( subTypeId & asTYPEID_OBJHANDLE )
1171 {
1172 // Allow the find to work even if the array contains null handles
1173 if( *(void**)a == *(void**)b ) return true;
1174 }
1175
1176 // Execute object opEquals if available
1177 if( cache && cache->eqFunc )
1178 {
1179 // TODO: Add proper error handling
1180 r = ctx->Prepare(cache->eqFunc); assert(r >= 0);
1181
1182 if( subTypeId & asTYPEID_OBJHANDLE )
1183 {
1184 r = ctx->SetObject(*((void**)a)); assert(r >= 0);
1185 r = ctx->SetArgObject(0, *((void**)b)); assert(r >= 0);
1186 }
1187 else
1188 {
1189 r = ctx->SetObject((void*)a); assert(r >= 0);
1190 r = ctx->SetArgObject(0, (void*)b); assert(r >= 0);
1191 }
1192
1193 r = ctx->Execute();
1194
1195 if( r == asEXECUTION_FINISHED )
1196 return ctx->GetReturnByte() != 0;
1197
1198 return false;
1199 }
1200
1201 // Execute object opCmp if available
1202 if( cache && cache->cmpFunc )

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected