internal
| 945 | |
| 946 | // internal |
| 947 | void CScriptArray::Construct(SArrayBuffer *buf, asUINT start, asUINT end) |
| 948 | { |
| 949 | if( (subTypeId & asTYPEID_MASK_OBJECT) && !(subTypeId & asTYPEID_OBJHANDLE) ) |
| 950 | { |
| 951 | // Create an object using the default constructor/factory for each element |
| 952 | void **max = (void**)(buf->data + end * sizeof(void*)); |
| 953 | void **d = (void**)(buf->data + start * sizeof(void*)); |
| 954 | |
| 955 | asIScriptEngine *engine = objType->GetEngine(); |
| 956 | asITypeInfo *subType = objType->GetSubType(); |
| 957 | |
| 958 | for( ; d < max; d++ ) |
| 959 | { |
| 960 | *d = (void*)engine->CreateScriptObject(subType); |
| 961 | if( *d == 0 ) |
| 962 | { |
| 963 | // Set the remaining entries to null so the destructor |
| 964 | // won't attempt to destroy invalid objects later |
| 965 | memset(d, 0, sizeof(void*)*(max-d)); |
| 966 | |
| 967 | // There is no need to set an exception on the context, |
| 968 | // as CreateScriptObject has already done that |
| 969 | return; |
| 970 | } |
| 971 | } |
| 972 | } |
| 973 | else |
| 974 | { |
| 975 | // Set all elements to zero whether they are handles or primitives |
| 976 | void *d = (void*)(buf->data + start * elementSize); |
| 977 | memset(d, 0, (end-start)*elementSize); |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | // internal |
| 982 | void CScriptArray::Destruct(SArrayBuffer *buf, asUINT start, asUINT end) |