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

Method Construct

sdk/add_on/scriptarray/scriptarray.cpp:1009–1041  ·  view source on GitHub ↗

internal

Source from the content-addressed store, hash-verified

1007
1008// internal
1009void CScriptArray::Construct(SArrayBuffer *buf, asUINT start, asUINT end)
1010{
1011 if( (subTypeId & asTYPEID_MASK_OBJECT) && !(subTypeId & asTYPEID_OBJHANDLE) )
1012 {
1013 // Create an object using the default constructor/factory for each element
1014 void **max = (void**)(buf->data + end * sizeof(void*));
1015 void **d = (void**)(buf->data + start * sizeof(void*));
1016
1017 asIScriptEngine *engine = objType->GetEngine();
1018 asITypeInfo *subType = objType->GetSubType();
1019
1020 for( ; d < max; d++ )
1021 {
1022 *d = (void*)engine->CreateScriptObject(subType);
1023 if( *d == 0 )
1024 {
1025 // Set the remaining entries to null so the destructor
1026 // won't attempt to destroy invalid objects later
1027 memset(d, 0, sizeof(void*)*(max-d));
1028
1029 // There is no need to set an exception on the context,
1030 // as CreateScriptObject has already done that
1031 return;
1032 }
1033 }
1034 }
1035 else
1036 {
1037 // Set all elements to zero whether they are handles or primitives
1038 void *d = (void*)(buf->data + start * elementSize);
1039 memset(d, 0, (end-start)*elementSize);
1040 }
1041}
1042
1043// internal
1044void CScriptArray::Destruct(SArrayBuffer *buf, asUINT start, asUINT end)

Callers

nothing calls this directly

Calls 3

CreateScriptObjectMethod · 0.80
GetEngineMethod · 0.45
GetSubTypeMethod · 0.45

Tested by

no test coverage detected