static CLObject alloc_thread_object(CLObject type_object, sVMInfo* info) { CLObject obj; unsigned int size; size = object_size(); obj = alloc_heap_mem(size, type_object); return obj; }
static CLObject alloc_range_object(CLObject type_object) { CLObject obj; unsigned int size; size = object_size(); obj = alloc_heap_mem(size, type_object); return obj; }
static CLObject alloc_bytes_object(unsigned int len2, CLObject type_object, sVMInfo* info) { CLObject obj; CLObject obj2; unsigned int size; unsigned int chars_size; size = object_size(); obj = alloc_heap_mem(size, type_object); push_object(obj, info); chars_size = chars_object_size(len2); obj2 = alloc_heap_mem(chars_size, 0); CLBYTES(obj)->mData = obj2; pop_object(info); return obj; }
static CLObject alloc_bool_object() { CLObject obj; unsigned int size; CLObject type_object; type_object = gBoolTypeObject; size = object_size(); obj = alloc_heap_mem(size, type_object); return obj; }
BOOL Bytes_setValue(MVALUE** stack_ptr, MVALUE* lvar, sVMInfo* info, CLObject vm_type, sCLClass* klass) { CLObject self, value; unsigned int chars_size; CLObject obj2; CLObject new_obj; unsigned char* chars; unsigned char* chars2; int i; vm_mutex_lock(); self = lvar->mObjectValue.mValue; // self if(!check_type(self, gBytesTypeObject, info)) { vm_mutex_unlock(); return FALSE; } value = (lvar+1)->mObjectValue.mValue; if(!check_type(value, gBytesTypeObject, info)) { vm_mutex_unlock(); return FALSE; } chars_size = chars_object_size(CLBYTES(value)->mLen+1); obj2 = alloc_heap_mem(chars_size, 0); CLBYTES(self)->mData = obj2; CLBYTES(self)->mLen = CLBYTES(value)->mLen; chars = CLBYTES_DATA(self)->mChars; chars2 = CLBYTES_DATA(value)->mChars; for(i=0; i<CLBYTES(value)->mLen; i++) { chars[i] = chars2[i]; } chars[i] = 0; new_obj = create_bytes_object(CLBYTES_DATA(value)->mChars, CLBYTES(value)->mLen, gBytesTypeObject, info); (*stack_ptr)->mObjectValue.mValue = new_obj; // push result (*stack_ptr)++; vm_mutex_unlock(); return TRUE; }