new object creation interface
This commit is contained in:
parent
c737f41d8a
commit
e937d189df
23 changed files with 103 additions and 84 deletions
|
|
@ -51,10 +51,8 @@ void objects_api::define(ObjectType* type) {
|
|||
type->type_methods.init();
|
||||
}
|
||||
|
||||
Object* objects_api::create(const std::string& name) {
|
||||
MODULE_SANITY_CHECK(gModuleObjects)
|
||||
|
||||
const ObjectType* type = types.get(name);
|
||||
Object* objects_api::create(const ObjectType* type) {
|
||||
ASSERT(type);
|
||||
|
||||
Object* obj_instance = ObjectMemAllocate(type);
|
||||
|
||||
|
|
@ -108,7 +106,7 @@ bool objects_api::compare(Object* first, Object* second) {
|
|||
}
|
||||
|
||||
Object* objects_api::instantiate(Object* in) {
|
||||
obj::Object* obj = NDO->create(in->type->name);
|
||||
obj::Object* obj = objects_api::createByName(in->type->name);
|
||||
tp::obj::objects_api::copy(obj, in);
|
||||
return obj;
|
||||
}
|
||||
|
|
@ -162,8 +160,8 @@ void objects_api::destroy(Object* in) const {
|
|||
return;
|
||||
}
|
||||
|
||||
if (in->refc > 1) {
|
||||
in->refc--;
|
||||
if (in->references > 1) {
|
||||
in->references--;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ Object* ObjectMemAllocate(const ObjectType* type) {
|
|||
object->down = nullptr;
|
||||
object->flags = 0;
|
||||
|
||||
object->refc = (alni) 1;
|
||||
object->references = (alni) 1;
|
||||
|
||||
if (bottom) {
|
||||
bottom->down = object;
|
||||
|
|
@ -69,7 +69,7 @@ void obj::assertNoLeaks() {
|
|||
printf("ERROR : not all objects are destroyed\n");
|
||||
ualni idx = 0;
|
||||
for (Object* object = bottom; object; object = object->up) {
|
||||
printf(" ===== Object - %llu. Ref count - %lli ===== \n", idx, object->refc);
|
||||
printf(" ===== Object - %llu. Ref count - %lli ===== \n", idx, object->references);
|
||||
logTypeData(object->type);
|
||||
idx++;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue