MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / Equals

Method Equals

src/server/angelscript/add_on/scriptarray/scriptarray.cpp:1110–1193  ·  view source on GitHub ↗

internal

Source from the content-addressed store, hash-verified

1108
1109// internal
1110bool CScriptArray::Equals(const void *a, const void *b, asIScriptContext *ctx, SArrayCache *cache) const
1111{
1112 if( !(subTypeId & ~asTYPEID_MASK_SEQNBR) )
1113 {
1114 // Simple compare of values
1115 switch( subTypeId )
1116 {
1117 #define COMPARE(T) *((T*)a) == *((T*)b)
1118 case asTYPEID_BOOL: return COMPARE(bool);
1119 case asTYPEID_INT8: return COMPARE(signed char);
1120 case asTYPEID_UINT8: return COMPARE(unsigned char);
1121 case asTYPEID_INT16: return COMPARE(signed short);
1122 case asTYPEID_UINT16: return COMPARE(unsigned short);
1123 case asTYPEID_INT32: return COMPARE(signed int);
1124 case asTYPEID_UINT32: return COMPARE(unsigned int);
1125 case asTYPEID_FLOAT: return COMPARE(float);
1126 case asTYPEID_DOUBLE: return COMPARE(double);
1127 default: return COMPARE(signed int); // All enums fall here
1128 #undef COMPARE
1129 }
1130 }
1131 else
1132 {
1133 int r = 0;
1134
1135 if( subTypeId & asTYPEID_OBJHANDLE )
1136 {
1137 // Allow the find to work even if the array contains null handles
1138 if( *(void**)a == *(void**)b ) return true;
1139 }
1140
1141 // Execute object opEquals if available
1142 if( cache && cache->eqFunc )
1143 {
1144 // TODO: Add proper error handling
1145 r = ctx->Prepare(cache->eqFunc); assert(r >= 0);
1146
1147 if( subTypeId & asTYPEID_OBJHANDLE )
1148 {
1149 r = ctx->SetObject(*((void**)a)); assert(r >= 0);
1150 r = ctx->SetArgObject(0, *((void**)b)); assert(r >= 0);
1151 }
1152 else
1153 {
1154 r = ctx->SetObject((void*)a); assert(r >= 0);
1155 r = ctx->SetArgObject(0, (void*)b); assert(r >= 0);
1156 }
1157
1158 r = ctx->Execute();
1159
1160 if( r == asEXECUTION_FINISHED )
1161 return ctx->GetReturnByte() != 0;
1162
1163 return false;
1164 }
1165
1166 // Execute object opCmp if available
1167 if( cache && cache->cmpFunc )

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