SQRESULT sq_arrayappend(HSQUIRRELVM v,SQInteger idx) { sq_aux_paramscheck(v,2); SQObjectPtr *arr; _GETSAFE_OBJ(v, idx, OT_ARRAY,arr); _array(*arr)->Append(v->GetUp(-1)); v->Pop(); return SQ_OK; }
SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize) { sq_aux_paramscheck(v,1); SQObjectPtr *arr; _GETSAFE_OBJ(v, idx, OT_ARRAY,arr); if(newsize >= 0) { _array(*arr)->Resize(newsize); return SQ_OK; } return sq_throwerror(v,_SC("negative size")); }
SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize) { sq_aux_paramscheck(v,1); SQObjectPtr *arr; _GETSAFE_OBJ(v, idx, OT_ARRAY,arr); if(_array(*arr)->Size() > 0) { _array(*arr)->Resize(newsize); return SQ_OK; } return SQ_OK; }
SQRESULT sq_arraypop(HSQUIRRELVM v,SQInteger idx,SQBool pushval) { sq_aux_paramscheck(v, 1); SQObjectPtr *arr; _GETSAFE_OBJ(v, idx, OT_ARRAY,arr); if(_array(*arr)->Size() > 0) { if(pushval != 0){ v->Push(_array(*arr)->Top()); } _array(*arr)->Pop(); return SQ_OK; } return sq_throwerror(v, _SC("empty array")); }
SQRESULT sq_arrayreverse(HSQUIRRELVM v,SQInteger idx) { sq_aux_paramscheck(v, 1); SQObjectPtr *o; _GETSAFE_OBJ(v, idx, OT_ARRAY,o); SQArray *arr = _array(*o); if(arr->Size() > 0) { SQObjectPtr t; SQInteger size = arr->Size(); SQInteger n = size >> 1; size -= 1; for(SQInteger i = 0; i < n; i++) { t = arr->_values[i]; arr->_values[i] = arr->_values[size-i]; arr->_values[size-i] = t; } return SQ_OK; }