clean up object module

This commit is contained in:
IlyaShurupov 2024-03-23 12:32:57 +03:00 committed by Ilya Shurupov
parent e78885d452
commit f8c82b7e29
68 changed files with 1223 additions and 1229 deletions

View file

@ -2,8 +2,8 @@
#include "primitives/BoolObject.hpp"
using namespace obj;
using namespace tp;
using namespace obj;
void BoolObject::constructor(BoolObject* self) { self->val = false; }

View file

@ -3,8 +3,8 @@
#include "primitives/DictObject.hpp"
#include "primitives/NullObject.hpp"
using namespace obj;
using namespace tp;
using namespace obj;
void ClassObject::constructor(ClassObject* self) {
self->members = NDO_CAST(DictObject, NDO->create("dict"));
@ -38,7 +38,7 @@ void ClassObject::load(ArchiverIn& file_self, ClassObject* self) {
alni ndo_object_adress;
file_self >> ndo_object_adress;
self->members = NDO_CAST(DictObject, NDO->load(file_self, ndo_object_adress));
NDO->refinc(self->members);
NDO->increaseReferenceCount(self->members);
}
tp::Buffer<Object*> childs_retrival(ClassObject* self) {

View file

@ -1,8 +1,8 @@
#include "primitives/ColorObject.hpp"
using namespace obj;
using namespace tp;
using namespace obj;
void ColorObject::constructor(Object* self) { NDO_CAST(ColorObject, self)->mCol = tp::RGBA(1.f); }

View file

@ -2,8 +2,8 @@
#include "primitives/DictObject.hpp"
#include "primitives/StringObject.hpp"
using namespace obj;
using namespace tp;
using namespace obj;
void DictObject::constructor(Object* self) {
NDO_CASTV(DictObject, self, dict);
@ -19,7 +19,7 @@ void DictObject::copy(Object* in, const Object* target) {
constructor(self);
for (auto item : src->items) {
auto instance = NDO->instatiate(item->val);
auto instance = NDO->instantiate(item->val);
self->items.put(item->key, instance);
}
}
@ -120,7 +120,7 @@ alni DictObject::allocated_size_recursive(DictObject* self) {
void DictObject::put(const std::string& str, Object* obj) {
DEBUG_ASSERT(obj);
NDO->refinc(obj);
NDO->increaseReferenceCount(obj);
items.put(str, obj);
}

View file

@ -4,8 +4,8 @@
#include <malloc.h>
#include <cstring>
using namespace obj;
using namespace tp;
using namespace obj;
void EnumObject::constructor(EnumObject* self) {
self->active = 0;

View file

@ -1,7 +1,7 @@
#include "primitives/FloatObject.hpp"
using namespace obj;
using namespace tp;
using namespace obj;
void FloatObject::constructor(FloatObject* self) { self->val = 0; }

View file

@ -1,8 +1,8 @@
#include "primitives/IntObject.hpp"
using namespace obj;
using namespace tp;
using namespace obj;
void IntObject::constructor(Object* self) { NDO_CAST(IntObject, self)->val = 0; }

View file

@ -3,8 +3,8 @@
#include "primitives/LinkObject.hpp"
#include "primitives/MethodObject.hpp"
using namespace obj;
using namespace tp;
using namespace obj;
void InterpreterObject::constructor(InterpreterObject* self) {
new (&self->mInterpreter) Interpreter();

View file

@ -1,8 +1,8 @@
#include "primitives/LinkObject.hpp"
using namespace obj;
using namespace tp;
using namespace obj;
void LinkObject::constructor(Object* self) { NDO_CAST(LinkObject, self)->link = 0; }
@ -38,7 +38,7 @@ void LinkObject::load(ArchiverIn& file_self, LinkObject* self) {
self->link = nullptr;
} else {
self->link = NDO->load(file_self, saved_object_adress);
NDO->refinc(self->link);
NDO->increaseReferenceCount(self->link);
}
}
@ -62,7 +62,7 @@ Object* LinkObject::getLink() { return link; }
void LinkObject::setLink(Object* obj) {
if (link) NDO->destroy(link);
if (obj) NDO->refinc(obj);
if (obj) NDO->increaseReferenceCount(obj);
link = obj;
}

View file

@ -2,8 +2,8 @@
#include "primitives/IntObject.hpp"
#include "primitives/ListObject.hpp"
using namespace obj;
using namespace tp;
using namespace obj;
void ListObject::constructor(Object* in) {
NDO_CASTV(ListObject, in, self);
@ -17,7 +17,7 @@ void ListObject::copy(Object* in, const Object* target) {
destructor(in);
for (auto item : src->items) {
self->pushBack(NDO->instatiate(item.data()));
self->pushBack(NDO->instantiate(item.data()));
}
}
@ -84,12 +84,12 @@ alni ListObject::allocated_size_recursive(ListObject* self) {
}
void ListObject::pushBack(Object* obj) {
obj::NDO->refinc(obj);
obj::NDO->increaseReferenceCount(obj);
items.pushBack(obj);
}
void ListObject::pushFront(Object* obj) {
obj::NDO->refinc(obj);
obj::NDO->increaseReferenceCount(obj);
items.pushFront(obj);
}

View file

@ -3,6 +3,7 @@
#include "core/ScriptSection.hpp"
#include "primitives/MethodObject.hpp"
using namespace tp;
using namespace obj;
struct ObjectType MethodObject::TypeData = {
@ -52,7 +53,7 @@ void MethodObject::Initialize() {
void MethodObject::UnInitialize() { obj::ScriptSection::uninitialize(); }
void MethodObject::compile() { BCgen::Compile(this); }
void MethodObject::compile() { Compile(this); }
MethodObject* MethodObject::create(const std::string& script) {
auto out = (MethodObject*) NDO->create(MethodObject::TypeData.name);

View file

@ -2,8 +2,8 @@
#include "primitives/NullObject.hpp"
using namespace obj;
using namespace tp;
using namespace obj;
obj::NullObject* obj::NdoNull_globalInstance = nullptr;
bool uninit_flag = false;

View file

@ -2,8 +2,8 @@
#include "primitives/StringObject.hpp"
using namespace obj;
using namespace tp;
using namespace obj;
void StringObject::constructor(Object* self) { new (&NDO_CAST(StringObject, self)->val) std::string(); }

View file

@ -2,8 +2,8 @@
#include "primitives/TypeObject.hpp"
#include "primitives/NullObject.hpp"
using namespace obj;
using namespace tp;
using namespace obj;
TypeObject* TypeObject::create(const ObjectType* type) {
NDO_CASTV(TypeObject, NDO->create("typeobject"), out);