MCPcopy Create free account
hub / github.com/anjo76/angelscript / Equals

Method Equals

sdk/add_on/scriptarray/scriptarray.cpp:1173–1258  ·  view source on GitHub ↗

internal

Source from the content-addressed store, hash-verified

1171
1172// internal
1173bool CScriptArray::Equals(const void *a, const void *b, asIScriptContext *ctx, SArrayCache *cache) const
1174{
1175 if( !(subTypeId & ~asTYPEID_MASK_SEQNBR) )
1176 {
1177 // Simple compare of values
1178 switch( subTypeId )
1179 {
1180 #define COMPARE(T) *((const T*)a) == *((const T*)b)
1181 case asTYPEID_BOOL: return COMPARE(bool);
1182 case asTYPEID_INT8: return COMPARE(asINT8);
1183 case asTYPEID_INT16: return COMPARE(asINT16);
1184 case asTYPEID_INT32: return COMPARE(asINT32);
1185 case asTYPEID_INT64: return COMPARE(asINT64);
1186 case asTYPEID_UINT8: return COMPARE(asBYTE);
1187 case asTYPEID_UINT16: return COMPARE(asWORD);
1188 case asTYPEID_UINT32: return COMPARE(asDWORD);
1189 case asTYPEID_UINT64: return COMPARE(asQWORD);
1190 case asTYPEID_FLOAT: return COMPARE(float);
1191 case asTYPEID_DOUBLE: return COMPARE(double);
1192 default: return COMPARE(signed int); // All enums fall here. TODO: update this when enums can have different sizes and types
1193 #undef COMPARE
1194 }
1195 }
1196 else
1197 {
1198 int r = 0;
1199
1200 if( subTypeId & asTYPEID_OBJHANDLE )
1201 {
1202 // Allow the find to work even if the array contains null handles
1203 if( *(const void*const*)a == *(const void*const*)b ) return true;
1204 }
1205
1206 // Execute object opEquals if available
1207 if( cache && cache->eqFunc )
1208 {
1209 // TODO: Add proper error handling
1210 r = ctx->Prepare(cache->eqFunc); assert(r >= 0);
1211
1212 if( subTypeId & asTYPEID_OBJHANDLE )
1213 {
1214 r = ctx->SetObject(*((void**)const_cast<void*>(a))); assert(r >= 0);
1215 r = ctx->SetArgObject(0, *((void**)const_cast<void*>(b))); assert(r >= 0);
1216 }
1217 else
1218 {
1219 r = ctx->SetObject(const_cast<void*>(a)); assert(r >= 0);
1220 r = ctx->SetArgObject(0, const_cast<void*>(b)); assert(r >= 0);
1221 }
1222
1223 r = ctx->Execute();
1224
1225 if( r == asEXECUTION_FINISHED )
1226 return ctx->GetReturnByte() != 0;
1227
1228 return false;
1229 }
1230

Callers

nothing calls this directly

Calls 6

SetObjectMethod · 0.80
SetArgObjectMethod · 0.80
ExecuteMethod · 0.80
GetReturnByteMethod · 0.80
GetReturnDWordMethod · 0.80
PrepareMethod · 0.45

Tested by

no test coverage detected