void Universe::InitializeSystemClass(VMClass* systemClass, VMClass* superClass, const char* name) { StdString s_name(name); if (superClass != nullptr) { systemClass->SetSuperClass(superClass); VMClass* sysClassClass = systemClass->GetClass(); VMClass* superClassClass = superClass->GetClass(); sysClassClass->SetSuperClass(superClassClass); } else { VMClass* sysClassClass = systemClass->GetClass(); sysClassClass->SetSuperClass(load_ptr(classClass)); } VMClass* sysClassClass = systemClass->GetClass(); systemClass->SetInstanceFields(NewArray(0)); sysClassClass->SetInstanceFields(NewArray(0)); systemClass->SetInstanceInvokables(NewArray(0)); sysClassClass->SetInstanceInvokables(NewArray(0)); systemClass->SetName(SymbolFor(s_name)); ostringstream Str; Str << s_name << " class"; StdString classClassName(Str.str()); sysClassClass->SetName(SymbolFor(classClassName)); SetGlobal(systemClass->GetName(), systemClass); }
void CloneObjectsTest::testCloneClass() { VMClass* orig = GetUniverse()->NewClass(load_ptr(integerClass)); orig->SetName(GetUniverse()->NewSymbol("MyClass")); orig->SetSuperClass(load_ptr(doubleClass)); orig->SetInstanceFields(GetUniverse()->NewArray(2)); orig->SetInstanceInvokables(GetUniverse()->NewArray(4)); VMClass* clone = orig->Clone(); CPPUNIT_ASSERT((intptr_t)orig != (intptr_t)clone); CPPUNIT_ASSERT_EQUAL_MESSAGE("class differs!!", orig->clazz, clone->clazz); CPPUNIT_ASSERT_EQUAL_MESSAGE("objectSize differs!!", orig->objectSize, clone->objectSize); CPPUNIT_ASSERT_EQUAL_MESSAGE("numberOfFields differs!!", orig->numberOfFields, clone->numberOfFields); CPPUNIT_ASSERT_EQUAL_MESSAGE("superClass differs!!", orig->superClass, clone->superClass); CPPUNIT_ASSERT_EQUAL_MESSAGE("name differs!!", orig->name, clone->name); CPPUNIT_ASSERT_EQUAL_MESSAGE("instanceFields differs!!", orig->instanceFields, clone->instanceFields); CPPUNIT_ASSERT_EQUAL_MESSAGE("instanceInvokables differs!!", orig->instanceInvokables, clone->instanceInvokables); }