Separate objects context and interface
This commit is contained in:
parent
e937d189df
commit
55daf0f303
32 changed files with 362 additions and 384 deletions
|
|
@ -12,22 +12,22 @@ ConstObject::ConstObject(Object* mObj) :
|
|||
ConstObjectsPool::~ConstObjectsPool() {
|
||||
if (mDelete) {
|
||||
for (auto obj : mStrings) {
|
||||
obj::NDO->destroy(obj->val->mObj);
|
||||
objects_api::destroy(obj->val->mObj);
|
||||
}
|
||||
for (auto obj : mIntegers) {
|
||||
obj::NDO->destroy(obj->val->mObj);
|
||||
objects_api::destroy(obj->val->mObj);
|
||||
}
|
||||
for (auto obj : mFloats) {
|
||||
obj::NDO->destroy(obj->val->mObj);
|
||||
objects_api::destroy(obj->val->mObj);
|
||||
}
|
||||
for (auto obj : mMethods) {
|
||||
obj::NDO->destroy(obj->val->mObj);
|
||||
objects_api::destroy(obj->val->mObj);
|
||||
}
|
||||
if (mBoolFalse.mObj) {
|
||||
obj::NDO->destroy(mBoolFalse.mObj);
|
||||
objects_api::destroy(mBoolFalse.mObj);
|
||||
}
|
||||
if (mBoolTrue.mObj) {
|
||||
obj::NDO->destroy(mBoolTrue.mObj);
|
||||
objects_api::destroy(mBoolTrue.mObj);
|
||||
}
|
||||
}
|
||||
for (auto obj : mStrings) {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,21 @@
|
|||
using namespace tp;
|
||||
using namespace obj;
|
||||
|
||||
ObjectsContext* obj::gObjectsContext = nullptr;
|
||||
|
||||
void objects_api::initialize() {
|
||||
ASSERT(!gObjectsContext)
|
||||
gObjectsContext = new ObjectsContext();
|
||||
}
|
||||
|
||||
void objects_api::finalize() {
|
||||
assertNoLeaks();
|
||||
|
||||
ASSERT(gObjectsContext)
|
||||
delete gObjectsContext;
|
||||
gObjectsContext = nullptr;
|
||||
}
|
||||
|
||||
void obj::save_string(ArchiverOut& file, const std::string& string) {
|
||||
file << string.size();
|
||||
file.writeBytes(string.c_str(), string.size());
|
||||
|
|
@ -29,24 +44,22 @@ void obj::load_string(ArchiverIn& file, std::string& out) {
|
|||
Object* ObjectMemAllocate(const ObjectType* type);
|
||||
void ObjectMemDeallocate(Object* object);
|
||||
|
||||
objects_api* obj::NDO = nullptr;
|
||||
|
||||
void hierarchy_copy(Object* self, const Object* in, const ObjectType* type);
|
||||
void hierarchy_construct(Object* self, const ObjectType* type);
|
||||
|
||||
objects_api::objects_api() {
|
||||
ObjectsContext::ObjectsContext() {
|
||||
memSetVal(sl_callbacks, SAVE_LOAD_MAX_CALLBACK_SLOTS * sizeof(save_load_callbacks*), 0);
|
||||
interp = new Interpreter();
|
||||
}
|
||||
|
||||
objects_api::~objects_api() { delete interp; }
|
||||
ObjectsContext::~ObjectsContext() { delete interp; }
|
||||
|
||||
void hierarchy_copy(Object* self, const Object* in, const ObjectType* type);
|
||||
void hierarchy_construct(Object* self, const ObjectType* type);
|
||||
|
||||
void objects_api::define(ObjectType* type) {
|
||||
MODULE_SANITY_CHECK(gModuleObjects)
|
||||
|
||||
DEBUG_ASSERT(NDO && "using uninitialized objects api")
|
||||
DEBUG_ASSERT(!types.presents(type->name) && "Type Redefinition")
|
||||
types.put(type->name, type);
|
||||
DEBUG_ASSERT(gObjectsContext && "using uninitialized objects api")
|
||||
DEBUG_ASSERT(!gObjectsContext->types.presents(type->name) && "Type Redefinition")
|
||||
gObjectsContext->types.put(type->name, type);
|
||||
|
||||
type->type_methods.init();
|
||||
}
|
||||
|
|
@ -73,7 +86,7 @@ Object* objects_api::create(const ObjectType* type) {
|
|||
auto constructor_obj = classobj->members->getSlotVal(idx);
|
||||
auto constructor_method = objects_api::cast<MethodObject>(constructor_obj);
|
||||
if (constructor_method) {
|
||||
interp->execAll(constructor_method, classobj);
|
||||
gObjectsContext->interp->execAll(constructor_method, classobj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -154,7 +167,7 @@ std::string objects_api::toString(Object* self) {
|
|||
return self->type->conversions->to_string(self);
|
||||
}
|
||||
|
||||
void objects_api::destroy(Object* in) const {
|
||||
void objects_api::destroy(Object* in) {
|
||||
|
||||
if (!in) {
|
||||
return;
|
||||
|
|
@ -173,7 +186,7 @@ void objects_api::destroy(Object* in) const {
|
|||
auto constructor_obj = classobj->members->getSlotVal(idx);
|
||||
auto constructor_method = objects_api::cast<MethodObject>(constructor_obj);
|
||||
if (constructor_method) {
|
||||
interp->execAll(constructor_method, classobj);
|
||||
gObjectsContext->interp->execAll(constructor_method, classobj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -206,3 +219,11 @@ void hierarchy_construct(Object* self, const ObjectType* type) {
|
|||
type->constructor(self);
|
||||
}
|
||||
}
|
||||
|
||||
void objects_api::addTypeToGroup(ObjectType* type, InitialierList<const char*> path, alni cur_arg) {
|
||||
gObjectsContext->type_groups.addType(type, path, cur_arg);
|
||||
}
|
||||
|
||||
bool objects_api::isType(const char* name) { return gObjectsContext->types.presents(name).isValid(); }
|
||||
|
||||
const ObjectType* objects_api::getType(const char* name) { return gObjectsContext->types.get(name); }
|
||||
|
|
@ -54,7 +54,7 @@ void ObjectMemDeallocate(Object* object) {
|
|||
count--;
|
||||
}
|
||||
|
||||
void obj::logTypeData(const ObjectType* type) {
|
||||
void objects_api::logTypeData(const ObjectType* type) {
|
||||
printf("type - %s\n", type->name);
|
||||
if (type->base) {
|
||||
printf("Based on ");
|
||||
|
|
@ -62,9 +62,9 @@ void obj::logTypeData(const ObjectType* type) {
|
|||
}
|
||||
}
|
||||
|
||||
ualni obj::getObjCount() { return count; }
|
||||
ualni objects_api::getObjCount() { return count; }
|
||||
|
||||
void obj::assertNoLeaks() {
|
||||
void objects_api::assertNoLeaks() {
|
||||
if (bottom) {
|
||||
printf("ERROR : not all objects are destroyed\n");
|
||||
ualni idx = 0;
|
||||
|
|
@ -284,7 +284,7 @@ Object* objects_api::load(ArchiverIn& ndf, alni file_adress) {
|
|||
std::string type_name;
|
||||
load_string(ndf, type_name);
|
||||
|
||||
const ObjectType* object_type = NDO->types.get(type_name);
|
||||
const ObjectType* object_type = gObjectsContext->types.get(type_name);
|
||||
Object* out = ObjectMemAllocate(object_type);
|
||||
|
||||
if (!out) {
|
||||
|
|
@ -329,16 +329,18 @@ bool objects_api::save(Object* in, const std::string& path, bool compressed) {
|
|||
|
||||
// pre allocate
|
||||
for (alni i = 0; i < SAVE_LOAD_MAX_CALLBACK_SLOTS; i++) {
|
||||
if (sl_callbacks[i]) {
|
||||
DEBUG_ASSERT(sl_callbacks[i]->size);
|
||||
ndf.setFreeAddress(ndf.getFreeAddress() + sl_callbacks[i]->size(sl_callbacks[i]->self, ndf));
|
||||
if (gObjectsContext->sl_callbacks[i]) {
|
||||
DEBUG_ASSERT(gObjectsContext->sl_callbacks[i]->size);
|
||||
ndf.setFreeAddress(
|
||||
ndf.getFreeAddress() + gObjectsContext->sl_callbacks[i]->size(gObjectsContext->sl_callbacks[i]->self, ndf)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// pre-save
|
||||
for (alni i = 0; i < SAVE_LOAD_MAX_CALLBACK_SLOTS; i++) {
|
||||
if (sl_callbacks[i] && sl_callbacks[i]->pre_save) {
|
||||
sl_callbacks[i]->pre_save(sl_callbacks[i]->self, ndf);
|
||||
if (gObjectsContext->sl_callbacks[i] && gObjectsContext->sl_callbacks[i]->pre_save) {
|
||||
gObjectsContext->sl_callbacks[i]->pre_save(gObjectsContext->sl_callbacks[i]->self, ndf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -346,8 +348,8 @@ bool objects_api::save(Object* in, const std::string& path, bool compressed) {
|
|||
|
||||
// post-save
|
||||
for (alni i = 0; i < SAVE_LOAD_MAX_CALLBACK_SLOTS; i++) {
|
||||
if (sl_callbacks[i] && sl_callbacks[i]->post_save) {
|
||||
sl_callbacks[i]->post_save(sl_callbacks[i]->self, ndf);
|
||||
if (gObjectsContext->sl_callbacks[i] && gObjectsContext->sl_callbacks[i]->post_save) {
|
||||
gObjectsContext->sl_callbacks[i]->post_save(gObjectsContext->sl_callbacks[i]->self, ndf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -404,8 +406,8 @@ Object* objects_api::load(const std::string& path) {
|
|||
|
||||
// preload
|
||||
for (alni i = 0; i < SAVE_LOAD_MAX_CALLBACK_SLOTS; i++) {
|
||||
if (sl_callbacks[i] && sl_callbacks[i]->pre_load) {
|
||||
sl_callbacks[i]->pre_load(sl_callbacks[i]->self, ndf);
|
||||
if (gObjectsContext->sl_callbacks[i] && gObjectsContext->sl_callbacks[i]->pre_load) {
|
||||
gObjectsContext->sl_callbacks[i]->pre_load(gObjectsContext->sl_callbacks[i]->self, ndf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -413,8 +415,8 @@ Object* objects_api::load(const std::string& path) {
|
|||
|
||||
// post
|
||||
for (alni i = 0; i < SAVE_LOAD_MAX_CALLBACK_SLOTS; i++) {
|
||||
if (sl_callbacks[i] && sl_callbacks[i]->post_save) {
|
||||
sl_callbacks[i]->post_load(sl_callbacks[i]->self, ndf);
|
||||
if (gObjectsContext->sl_callbacks[i] && gObjectsContext->sl_callbacks[i]->post_save) {
|
||||
gObjectsContext->sl_callbacks[i]->post_load(gObjectsContext->sl_callbacks[i]->self, ndf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -432,6 +434,6 @@ Object* objects_api::load(const std::string& path) {
|
|||
}
|
||||
|
||||
void objects_api::add_sl_callbacks(save_load_callbacks* in) {
|
||||
sl_callbacks[sl_callbacks_load_idx] = in;
|
||||
sl_callbacks_load_idx++;
|
||||
gObjectsContext->sl_callbacks[gObjectsContext->sl_callbacks_load_idx] = in;
|
||||
gObjectsContext->sl_callbacks_load_idx++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,58 +1,44 @@
|
|||
|
||||
#include "compiler/Functions.hpp"
|
||||
|
||||
#include "primitives/BoolObject.hpp"
|
||||
#include "primitives/ClassObject.hpp"
|
||||
#include "primitives/ColorObject.hpp"
|
||||
#include "primitives/DictObject.hpp"
|
||||
#include "primitives/EnumObject.hpp"
|
||||
#include "primitives/FloatObject.hpp"
|
||||
#include "primitives/InterpreterObject.hpp"
|
||||
#include "primitives/IntObject.hpp"
|
||||
#include "primitives/LinkObject.hpp"
|
||||
#include "primitives/ListObject.hpp"
|
||||
#include "primitives/MethodObject.hpp"
|
||||
#include "primitives/NullObject.hpp"
|
||||
#include "primitives/StringObject.hpp"
|
||||
#include "primitives/TypeObject.hpp"
|
||||
#include "primitives/PrimitiveObjects.hpp"
|
||||
|
||||
using namespace tp;
|
||||
using namespace obj;
|
||||
|
||||
static void defineTypes() {
|
||||
NDO->define(&DictObject::TypeData);
|
||||
NDO->define(&IntObject::TypeData);
|
||||
NDO->define(&LinkObject::TypeData);
|
||||
NDO->define(&ListObject::TypeData);
|
||||
NDO->define(&NullObject::TypeData);
|
||||
NDO->define(&StringObject::TypeData);
|
||||
NDO->define(&BoolObject::TypeData);
|
||||
NDO->define(&FloatObject::TypeData);
|
||||
NDO->define(&EnumObject::TypeData);
|
||||
NDO->define(&ClassObject::TypeData);
|
||||
NDO->define(&ColorObject::TypeData);
|
||||
NDO->define(&InterpreterObject::TypeData);
|
||||
NDO->define(&TypeObject::TypeData);
|
||||
objects_api::define(&DictObject::TypeData);
|
||||
objects_api::define(&IntObject::TypeData);
|
||||
objects_api::define(&LinkObject::TypeData);
|
||||
objects_api::define(&ListObject::TypeData);
|
||||
objects_api::define(&NullObject::TypeData);
|
||||
objects_api::define(&StringObject::TypeData);
|
||||
objects_api::define(&BoolObject::TypeData);
|
||||
objects_api::define(&FloatObject::TypeData);
|
||||
objects_api::define(&EnumObject::TypeData);
|
||||
objects_api::define(&ClassObject::TypeData);
|
||||
objects_api::define(&ColorObject::TypeData);
|
||||
objects_api::define(&InterpreterObject::TypeData);
|
||||
objects_api::define(&TypeObject::TypeData);
|
||||
}
|
||||
|
||||
static void defineGroups() {
|
||||
NDO->type_groups.addType(&DictObject::TypeData, { "Primitives" });
|
||||
NDO->type_groups.addType(&IntObject::TypeData, { "Primitives" });
|
||||
NDO->type_groups.addType(&LinkObject::TypeData, { "Primitives" });
|
||||
NDO->type_groups.addType(&ListObject::TypeData, { "Primitives" });
|
||||
NDO->type_groups.addType(&NullObject::TypeData, { "Primitives" });
|
||||
NDO->type_groups.addType(&StringObject::TypeData, { "Primitives" });
|
||||
NDO->type_groups.addType(&BoolObject::TypeData, { "Primitives" });
|
||||
NDO->type_groups.addType(&FloatObject::TypeData, { "Primitives" });
|
||||
NDO->type_groups.addType(&EnumObject::TypeData, { "Primitives" });
|
||||
NDO->type_groups.addType(&ClassObject::TypeData, { "Primitives" });
|
||||
NDO->type_groups.addType(&ColorObject::TypeData, { "Primitives" });
|
||||
NDO->type_groups.addType(&InterpreterObject::TypeData, { "scripting" });
|
||||
objects_api::addTypeToGroup(&DictObject::TypeData, { "Primitives" });
|
||||
objects_api::addTypeToGroup(&IntObject::TypeData, { "Primitives" });
|
||||
objects_api::addTypeToGroup(&LinkObject::TypeData, { "Primitives" });
|
||||
objects_api::addTypeToGroup(&ListObject::TypeData, { "Primitives" });
|
||||
objects_api::addTypeToGroup(&NullObject::TypeData, { "Primitives" });
|
||||
objects_api::addTypeToGroup(&StringObject::TypeData, { "Primitives" });
|
||||
objects_api::addTypeToGroup(&BoolObject::TypeData, { "Primitives" });
|
||||
objects_api::addTypeToGroup(&FloatObject::TypeData, { "Primitives" });
|
||||
objects_api::addTypeToGroup(&EnumObject::TypeData, { "Primitives" });
|
||||
objects_api::addTypeToGroup(&ClassObject::TypeData, { "Primitives" });
|
||||
objects_api::addTypeToGroup(&ColorObject::TypeData, { "Primitives" });
|
||||
objects_api::addTypeToGroup(&InterpreterObject::TypeData, { "scripting" });
|
||||
}
|
||||
|
||||
static bool init(const ModuleManifest*) {
|
||||
if (!NDO) NDO = new objects_api();
|
||||
obj::initialize();
|
||||
objects_api::initialize();
|
||||
|
||||
MethodObject::Initialize();
|
||||
|
||||
|
|
@ -63,20 +49,12 @@ static bool init(const ModuleManifest*) {
|
|||
}
|
||||
|
||||
static void deinit(const ModuleManifest*) {
|
||||
|
||||
NullObject::uninit();
|
||||
MethodObject::UnInitialize();
|
||||
|
||||
obj::finalize();
|
||||
|
||||
assertNoLeaks();
|
||||
|
||||
delete NDO;
|
||||
NDO = nullptr;
|
||||
objects_api::finalize();
|
||||
}
|
||||
|
||||
static ModuleManifest* sModuleDependencies[] = {
|
||||
nullptr
|
||||
};
|
||||
static ModuleManifest* sModuleDependencies[] = { nullptr };
|
||||
|
||||
ModuleManifest obj::gModuleObjects = ModuleManifest("Objects", init, deinit, sModuleDependencies);
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ Script* ScriptSection::createScript() {
|
|||
|
||||
new (out) Script();
|
||||
out->mReadable = obj::StringObject::create("");
|
||||
obj::NDO->increaseReferenceCount(out->mReadable);
|
||||
objects_api::increaseReferenceCount(out->mReadable);
|
||||
return out;
|
||||
}
|
||||
|
||||
void ScriptSection::delete_script(Script* script) {
|
||||
script->~Script();
|
||||
obj::NDO->destroy(script->mReadable);
|
||||
objects_api::destroy(script->mReadable);
|
||||
|
||||
free((((script_data_head*) script) - 1));
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ void ScriptSection::save_script_table_to_file(ScriptSection* self, ArchiverOut&
|
|||
for (auto iter : self->mScripts) {
|
||||
|
||||
// scripts string obj ref
|
||||
auto obj_addres = obj::NDO->save(file, iter->mReadable);
|
||||
auto obj_addres = objects_api::save(file, iter->mReadable);
|
||||
file << obj_addres;
|
||||
|
||||
// constants length
|
||||
|
|
@ -108,7 +108,7 @@ void ScriptSection::save_script_table_to_file(ScriptSection* self, ArchiverOut&
|
|||
|
||||
for (auto const_obj : iter->mBytecode.mConstants) {
|
||||
// constant object addres
|
||||
auto obj_addres = obj::NDO->save(file, const_obj.data());
|
||||
auto obj_addres = objects_api::save(file, const_obj.data());
|
||||
file << obj_addres;
|
||||
}
|
||||
|
||||
|
|
@ -140,15 +140,15 @@ void load_constants(ScriptSection* self, ArchiverIn& file, alni start_addr) {
|
|||
alni str_addr;
|
||||
file >> str_addr;
|
||||
|
||||
NDO->destroy(script->mReadable); // we already have string object in the script when creating script
|
||||
script->mReadable = objects_api::cast<StringObject>(obj::NDO->load(file, str_addr));
|
||||
objects_api::destroy(script->mReadable); // we already have string object in the script when creating script
|
||||
script->mReadable = objects_api::cast<StringObject>(objects_api::load(file, str_addr));
|
||||
|
||||
file.setAddress(file.getAddress() + sizeof(alni)); // constants length
|
||||
|
||||
for (auto const_obj : script->mBytecode.mConstants) {
|
||||
alni consts_addr;
|
||||
file >> consts_addr;
|
||||
const_obj.data() = obj::NDO->load(file, consts_addr);
|
||||
const_obj.data() = objects_api::load(file, consts_addr);
|
||||
}
|
||||
|
||||
// instructions
|
||||
|
|
@ -192,7 +192,7 @@ void ScriptSection::load_script_table_from_file(ScriptSection* self, ArchiverIn&
|
|||
file >> consts_addr;
|
||||
|
||||
// skiping
|
||||
// new_script->mBytecode.mConstants[j] = obj::NDO->load(file, consts_addr);
|
||||
// new_script->mBytecode.mConstants[j] = objects_api::load(file, consts_addr);
|
||||
}
|
||||
|
||||
// mInstructions
|
||||
|
|
@ -238,10 +238,8 @@ void ScriptSection::initialize() {
|
|||
ASSERT(!gScriptSection);
|
||||
gScriptSection = new ScriptSection();
|
||||
|
||||
ASSERT(obj::NDO && "Forgot to initialize objects?");
|
||||
|
||||
slcb_script_section.self = gScriptSection;
|
||||
obj::NDO->add_sl_callbacks(&slcb_script_section);
|
||||
objects_api::add_sl_callbacks(&slcb_script_section);
|
||||
}
|
||||
|
||||
void ScriptSection::uninitialize() {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ TypeMethod obj::gDefaultTypeMethods[] = {
|
|||
.exec =
|
||||
[](const TypeMethod* tm) {
|
||||
if (tm->self->type->conversions && tm->self->type->conversions->to_string) {
|
||||
tm->ret.obj = StringObject::create(NDO->toString(tm->self));
|
||||
tm->ret.obj = StringObject::create(objects_api::toString(tm->self));
|
||||
}
|
||||
},
|
||||
.ret = { "string object", nullptr },
|
||||
|
|
@ -34,7 +34,7 @@ TypeMethod obj::gDefaultTypeMethods[] = {
|
|||
.exec =
|
||||
[](const TypeMethod* tm) {
|
||||
if (tm->self->type->conversions && tm->self->type->conversions->to_float) {
|
||||
tm->ret.obj = FloatObject::create(NDO->toFloat(tm->self));
|
||||
tm->ret.obj = FloatObject::create(objects_api::toFloat(tm->self));
|
||||
}
|
||||
},
|
||||
.ret = { "string object", nullptr },
|
||||
|
|
@ -107,7 +107,7 @@ halni TypeMethods::nMethods() const { return mNMethods; }
|
|||
void TypeMethod::operator()(Interpreter* interp) const {
|
||||
for (auto i = 1; i <= mNargs; i++) {
|
||||
args[mNargs - i].obj = interp->mOperandsStack.getOperand();
|
||||
// NDO->refinc(args[i].obj);
|
||||
// objects_api::refinc(args[i].obj);
|
||||
ASSERT(args[mNargs - i].obj && "expected an argument");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ void CallStack::enter(const CallStack::CallFrame& frame) {
|
|||
|
||||
frame.mMethod->mScript->mBytecode.mArgumentsLoaded = 0;
|
||||
frame.mMethod->mScript->mBytecode.mInstructionIdx = 0;
|
||||
obj::NDO->increaseReferenceCount(frame.mMethod);
|
||||
objects_api::increaseReferenceCount(frame.mMethod);
|
||||
mStack.append(frame);
|
||||
}
|
||||
|
||||
void CallStack::leave() {
|
||||
auto frame = mStack.last();
|
||||
obj::NDO->destroy(frame.mMethod);
|
||||
objects_api::destroy(frame.mMethod);
|
||||
mStack.pop();
|
||||
|
||||
if (mStack.size()) {
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
case OpCode::JUMP_IF:
|
||||
{
|
||||
auto cond = mOperandsStack.getOperand();
|
||||
if (NDO->toBool(cond)) {
|
||||
if (objects_api::toBool(cond)) {
|
||||
bytecode->mInstructionIdx += param(bytecode);
|
||||
} else {
|
||||
skip_param(bytecode);
|
||||
|
|
@ -178,7 +178,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
case OpCode::JUMP_IF_NOT:
|
||||
{
|
||||
auto cond = mOperandsStack.getOperand();
|
||||
if (!NDO->toBool(cond)) {
|
||||
if (!objects_api::toBool(cond)) {
|
||||
bytecode->mInstructionIdx += param(bytecode);
|
||||
} else {
|
||||
skip_param(bytecode);
|
||||
|
|
@ -195,7 +195,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
case OpCode::JUMP_IF_R:
|
||||
{
|
||||
auto cond = mOperandsStack.getOperand();
|
||||
if (NDO->toBool(cond)) {
|
||||
if (objects_api::toBool(cond)) {
|
||||
bytecode->mInstructionIdx -= param(bytecode);
|
||||
} else {
|
||||
skip_param(bytecode);
|
||||
|
|
@ -206,7 +206,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
case OpCode::JUMP_IF_NOT_R:
|
||||
{
|
||||
auto cond = mOperandsStack.getOperand();
|
||||
if (!NDO->toBool(cond)) {
|
||||
if (!objects_api::toBool(cond)) {
|
||||
bytecode->mInstructionIdx -= param(bytecode);
|
||||
} else {
|
||||
skip_param(bytecode);
|
||||
|
|
@ -224,7 +224,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
{
|
||||
auto obj = mOperandsStack.getOperand();
|
||||
if (obj->type->conversions && obj->type->conversions->to_string) {
|
||||
auto str = NDO->toString(obj);
|
||||
auto str = objects_api::toString(obj);
|
||||
printf("%s\n", str.c_str());
|
||||
} else {
|
||||
printf("Object with type '%s' has no string representation.\n", obj->type->name);
|
||||
|
|
@ -245,7 +245,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
auto id = mOperandsStack.getOperand<StringObject>();
|
||||
auto obj = mOperandsStack.getOperand();
|
||||
mScopeStack.addLocal(obj, id->val);
|
||||
NDO->increaseReferenceCount(obj);
|
||||
objects_api::increaseReferenceCount(obj);
|
||||
// mScopeStack.popTemp();
|
||||
break;
|
||||
}
|
||||
|
|
@ -255,7 +255,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
auto type = mOperandsStack.getOperand<StringObject>();
|
||||
|
||||
// basic types
|
||||
auto idx = NDO->types.presents(type->val);
|
||||
auto idx = objects_api::isType(type->val.c_str());
|
||||
if (idx) {
|
||||
Object* new_obj = objects_api::createByName(type->val.c_str());
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
|
||||
case OpCode::CLASS_CONSTRUCT:
|
||||
{
|
||||
auto class_obj = NDO->create<ClassObject>();
|
||||
auto class_obj = objects_api::create<ClassObject>();
|
||||
|
||||
for (auto local : mScopeStack.getCurrentScope()->mLocals) {
|
||||
class_obj->addMember(local->val, local->key);
|
||||
|
|
@ -333,7 +333,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
auto argument = mOperandsStack.getOperand();
|
||||
|
||||
while (argument) {
|
||||
NDO->increaseReferenceCount(argument);
|
||||
objects_api::increaseReferenceCount(argument);
|
||||
|
||||
auto argument_id = bytecode->mConstants[loadConstDataIdx(bytecode)];
|
||||
auto id = objects_api::cast<StringObject>(argument_id);
|
||||
|
|
@ -391,7 +391,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
ASSERT(left->type == right->type && "addition of different types is not implemented");
|
||||
ASSERT(left->type->arithmetics && left->type->arithmetics->add && "cannot add object of this type");
|
||||
|
||||
auto res = NDO->instantiate(left);
|
||||
auto res = objects_api::instantiate(left);
|
||||
res->type->arithmetics->add(res, right);
|
||||
|
||||
mScopeStack.addTemp(res);
|
||||
|
|
@ -406,7 +406,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
ASSERT(left->type == right->type && "addition of different types is not implemented");
|
||||
ASSERT(left->type->arithmetics && left->type->arithmetics->add && "cannot add object of this type");
|
||||
|
||||
auto res = NDO->instantiate(left);
|
||||
auto res = objects_api::instantiate(left);
|
||||
res->type->arithmetics->sub(res, right);
|
||||
|
||||
mScopeStack.addTemp(res);
|
||||
|
|
@ -421,7 +421,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
ASSERT(left->type == right->type && "addition of different types is not implemented");
|
||||
ASSERT(left->type->arithmetics && left->type->arithmetics->add && "cannot add object of this type");
|
||||
|
||||
auto res = NDO->instantiate(left);
|
||||
auto res = objects_api::instantiate(left);
|
||||
res->type->arithmetics->mul(res, right);
|
||||
|
||||
mScopeStack.addTemp(res);
|
||||
|
|
@ -436,7 +436,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
ASSERT(left->type == right->type && "addition of different types is not implemented");
|
||||
ASSERT(left->type->arithmetics && left->type->arithmetics->add && "cannot add object of this type");
|
||||
|
||||
auto res = NDO->instantiate(left);
|
||||
auto res = objects_api::instantiate(left);
|
||||
res->type->arithmetics->div(res, right);
|
||||
|
||||
mScopeStack.addTemp(res);
|
||||
|
|
@ -448,7 +448,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
{
|
||||
auto left = mOperandsStack.getOperand();
|
||||
auto right = mOperandsStack.getOperand();
|
||||
NDO->copy(left, right);
|
||||
objects_api::copy(left, right);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -495,7 +495,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
case OpCode::OBJ_LOAD:
|
||||
{
|
||||
auto path = mOperandsStack.getOperand<StringObject>();
|
||||
auto obj = NDO->load(path->val);
|
||||
auto obj = objects_api::load(path->val);
|
||||
mScopeStack.addTemp(obj);
|
||||
mOperandsStack.push(obj);
|
||||
break;
|
||||
|
|
@ -504,14 +504,14 @@ void Interpreter::stepBytecodeIn() {
|
|||
{
|
||||
auto path = mOperandsStack.getOperand<StringObject>();
|
||||
auto target = mOperandsStack.getOperand();
|
||||
NDO->save(target, path->val);
|
||||
objects_api::save(target, path->val);
|
||||
break;
|
||||
}
|
||||
|
||||
case OpCode::AND:
|
||||
{
|
||||
auto left = NDO->toBool(mOperandsStack.getOperand());
|
||||
auto right = NDO->toBool(mOperandsStack.getOperand());
|
||||
auto left = objects_api::toBool(mOperandsStack.getOperand());
|
||||
auto right = objects_api::toBool(mOperandsStack.getOperand());
|
||||
auto out = BoolObject::create(left && right);
|
||||
mScopeStack.addTemp(out);
|
||||
mOperandsStack.push(out);
|
||||
|
|
@ -519,8 +519,8 @@ void Interpreter::stepBytecodeIn() {
|
|||
}
|
||||
case OpCode::OR:
|
||||
{
|
||||
auto left = NDO->toBool(mOperandsStack.getOperand());
|
||||
auto right = NDO->toBool(mOperandsStack.getOperand());
|
||||
auto left = objects_api::toBool(mOperandsStack.getOperand());
|
||||
auto right = objects_api::toBool(mOperandsStack.getOperand());
|
||||
auto out = BoolObject::create(left || right);
|
||||
mScopeStack.addTemp(out);
|
||||
mOperandsStack.push(out);
|
||||
|
|
@ -528,7 +528,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
}
|
||||
case OpCode::NOT:
|
||||
{
|
||||
auto inv = NDO->toBool(mOperandsStack.getOperand());
|
||||
auto inv = objects_api::toBool(mOperandsStack.getOperand());
|
||||
auto out = BoolObject::create(!inv);
|
||||
mScopeStack.addTemp(out);
|
||||
mOperandsStack.push(out);
|
||||
|
|
@ -538,7 +538,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
{
|
||||
auto left = mOperandsStack.getOperand();
|
||||
auto right = mOperandsStack.getOperand();
|
||||
auto out = BoolObject::create(!NDO->compare(left, right));
|
||||
auto out = BoolObject::create(!objects_api::compare(left, right));
|
||||
mScopeStack.addTemp(out);
|
||||
mOperandsStack.push(out);
|
||||
break;
|
||||
|
|
@ -547,7 +547,7 @@ void Interpreter::stepBytecodeIn() {
|
|||
{
|
||||
auto left = mOperandsStack.getOperand();
|
||||
auto right = mOperandsStack.getOperand();
|
||||
auto out = BoolObject::create(NDO->compare(left, right));
|
||||
auto out = BoolObject::create(objects_api::compare(left, right));
|
||||
mScopeStack.addTemp(out);
|
||||
mOperandsStack.push(out);
|
||||
break;
|
||||
|
|
@ -555,8 +555,8 @@ void Interpreter::stepBytecodeIn() {
|
|||
|
||||
case OpCode::MORE:
|
||||
{
|
||||
auto left = NDO->toFloat(mOperandsStack.getOperand());
|
||||
auto right = NDO->toFloat(mOperandsStack.getOperand());
|
||||
auto left = objects_api::toFloat(mOperandsStack.getOperand());
|
||||
auto right = objects_api::toFloat(mOperandsStack.getOperand());
|
||||
auto out = BoolObject::create(left > right);
|
||||
mScopeStack.addTemp(out);
|
||||
mOperandsStack.push(out);
|
||||
|
|
@ -564,8 +564,8 @@ void Interpreter::stepBytecodeIn() {
|
|||
}
|
||||
case OpCode::LESS:
|
||||
{
|
||||
auto left = NDO->toFloat(mOperandsStack.getOperand());
|
||||
auto right = NDO->toFloat(mOperandsStack.getOperand());
|
||||
auto left = objects_api::toFloat(mOperandsStack.getOperand());
|
||||
auto right = objects_api::toFloat(mOperandsStack.getOperand());
|
||||
auto out = BoolObject::create(left < right);
|
||||
mScopeStack.addTemp(out);
|
||||
mOperandsStack.push(out);
|
||||
|
|
@ -573,8 +573,8 @@ void Interpreter::stepBytecodeIn() {
|
|||
}
|
||||
case OpCode::EQUAL_OR_MORE:
|
||||
{
|
||||
auto left = NDO->toFloat(mOperandsStack.getOperand());
|
||||
auto right = NDO->toFloat(mOperandsStack.getOperand());
|
||||
auto left = objects_api::toFloat(mOperandsStack.getOperand());
|
||||
auto right = objects_api::toFloat(mOperandsStack.getOperand());
|
||||
auto out = BoolObject::create(left >= right);
|
||||
mScopeStack.addTemp(out);
|
||||
mOperandsStack.push(out);
|
||||
|
|
@ -582,8 +582,8 @@ void Interpreter::stepBytecodeIn() {
|
|||
}
|
||||
case OpCode::EQUAL_OR_LESS:
|
||||
{
|
||||
auto left = NDO->toFloat(mOperandsStack.getOperand());
|
||||
auto right = NDO->toFloat(mOperandsStack.getOperand());
|
||||
auto left = objects_api::toFloat(mOperandsStack.getOperand());
|
||||
auto right = objects_api::toFloat(mOperandsStack.getOperand());
|
||||
auto out = BoolObject::create(left <= right);
|
||||
mScopeStack.addTemp(out);
|
||||
mOperandsStack.push(out);
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ using namespace obj;
|
|||
|
||||
Scope::~Scope() {
|
||||
for (auto local : mLocals) {
|
||||
obj::NDO->destroy(local->val);
|
||||
objects_api::destroy(local->val);
|
||||
}
|
||||
for (auto tmp : mTemps) {
|
||||
obj::NDO->destroy(tmp.data());
|
||||
objects_api::destroy(tmp.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -47,18 +47,18 @@ void ScopeStack::leaveScope() {
|
|||
}
|
||||
|
||||
void ScopeStack::addTemp(obj::Object* tmp) {
|
||||
obj::NDO->increaseReferenceCount(tmp);
|
||||
objects_api::increaseReferenceCount(tmp);
|
||||
mBuff[mIdx - 1].mTemps.pushBack(tmp);
|
||||
}
|
||||
|
||||
void ScopeStack::popTemp() {
|
||||
obj::NDO->destroy(mBuff[mIdx - 1].mTemps.last()->data);
|
||||
objects_api::destroy(mBuff[mIdx - 1].mTemps.last()->data);
|
||||
mBuff[mIdx - 1].mTemps.popBack();
|
||||
}
|
||||
|
||||
void ScopeStack::addTempReturn(obj::Object* ret) {
|
||||
if (mIdx >= 2) {
|
||||
obj::NDO->increaseReferenceCount(ret);
|
||||
objects_api::increaseReferenceCount(ret);
|
||||
mBuff[mIdx - 2].mTemps.pushBack(ret);
|
||||
}
|
||||
}
|
||||
|
|
@ -68,9 +68,9 @@ void ScopeStack::addLocal(obj::Object* local, const std::string& id) {
|
|||
Scope::ObjDict& locals = mBuff[mIdx - 1].mLocals;
|
||||
auto idx = locals.presents(id);
|
||||
if (idx) {
|
||||
obj::NDO->destroy(locals.getSlotVal(idx));
|
||||
objects_api::destroy(locals.getSlotVal(idx));
|
||||
}
|
||||
obj::NDO->increaseReferenceCount(local);
|
||||
objects_api::increaseReferenceCount(local);
|
||||
locals.put(id, local);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ void ClassObject::copy(ClassObject* self, const ClassObject* blueprint) {
|
|||
objects_api::copy(self->members, blueprint->members);
|
||||
}
|
||||
|
||||
void ClassObject::destructor(ClassObject* self) { NDO->destroy(self->members); }
|
||||
void ClassObject::destructor(ClassObject* self) { objects_api::destroy(self->members); }
|
||||
|
||||
void ClassObject::addMember(Object* obj, const std::string& id) { members->put(id, obj); }
|
||||
|
||||
|
|
@ -32,14 +32,14 @@ alni ClassObject::save_size(ClassObject* self) {
|
|||
|
||||
void ClassObject::save(ClassObject* self, ArchiverOut& file_self) {
|
||||
// save dict object
|
||||
alni ndo_object_adress = NDO->save(file_self, self->members);
|
||||
alni ndo_object_adress = objects_api::save(file_self, self->members);
|
||||
file_self << ndo_object_adress;
|
||||
}
|
||||
|
||||
void ClassObject::load(ArchiverIn& file_self, ClassObject* self) {
|
||||
alni ndo_object_address;
|
||||
file_self >> ndo_object_address;
|
||||
self->members = objects_api::cast<DictObject>(NDO->load(file_self, ndo_object_address));
|
||||
self->members = objects_api::cast<DictObject>(objects_api::load(file_self, ndo_object_address));
|
||||
tp::obj::objects_api::increaseReferenceCount(self->members);
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ alni allocated_size(ClassObject* self) { return sizeof(DictObject*); }
|
|||
|
||||
alni allocated_size_recursive(ClassObject* self) {
|
||||
alni out = sizeof(DictObject*);
|
||||
out += NDO->objsize_ram_recursive_util(self->members, self->members->type);
|
||||
out += objects_api::objsize_ram_recursive_util(self->members, self->members->type);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ void DictObject::copy(DictObject* self, const DictObject* src) {
|
|||
constructor(self);
|
||||
|
||||
for (auto item : src->items) {
|
||||
auto instance = NDO->instantiate(item->val);
|
||||
auto instance = objects_api::instantiate(item->val);
|
||||
self->items.put(item->key, instance);
|
||||
}
|
||||
}
|
||||
|
||||
void DictObject::destructor(DictObject* self) {
|
||||
for (auto item : self->items) {
|
||||
NDO->destroy(item->val);
|
||||
objects_api::destroy(item->val);
|
||||
}
|
||||
self->items.~Map();
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ void DictObject::save(DictObject* self, ArchiverOut& file_self) {
|
|||
// save hashmap pairs
|
||||
for (auto item : self->items) {
|
||||
// item val
|
||||
alni ndo_object_adress = NDO->save(file_self, item->val);
|
||||
alni ndo_object_adress = objects_api::save(file_self, item->val);
|
||||
file_self << ndo_object_adress;
|
||||
|
||||
// item key
|
||||
|
|
@ -70,7 +70,7 @@ void DictObject::load(ArchiverIn& file_self, DictObject* self) {
|
|||
// read val
|
||||
alni ndo_object_adress;
|
||||
file_self >> ndo_object_adress;
|
||||
Object* val = NDO->load(file_self, ndo_object_adress);
|
||||
Object* val = objects_api::load(file_self, ndo_object_adress);
|
||||
|
||||
// read key value
|
||||
std::string key;
|
||||
|
|
@ -105,21 +105,21 @@ alni DictObject::allocated_size(DictObject* self) {
|
|||
alni DictObject::allocated_size_recursive(DictObject* self) {
|
||||
alni out = allocated_size(self);
|
||||
for (auto item : self->items) {
|
||||
out += NDO->objsize_ram_recursive_util(item->val, item->val->type);
|
||||
out += objects_api::objsize_ram_recursive_util(item->val, item->val->type);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void DictObject::put(const std::string& str, Object* obj) {
|
||||
DEBUG_ASSERT(obj);
|
||||
NDO->increaseReferenceCount(obj);
|
||||
objects_api::increaseReferenceCount(obj);
|
||||
items.put(str, obj);
|
||||
}
|
||||
|
||||
void DictObject::remove(const std::string& str) {
|
||||
auto idx = items.presents(str);
|
||||
if (idx) {
|
||||
NDO->destroy(items.getSlotVal(idx));
|
||||
objects_api::destroy(items.getSlotVal(idx));
|
||||
items.remove(str);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ using namespace obj;
|
|||
void LinkObject::constructor(LinkObject* self) { self->link = nullptr; }
|
||||
|
||||
void LinkObject::destructor(LinkObject* self) {
|
||||
if (self->link) NDO->destroy(self->link);
|
||||
if (self->link) objects_api::destroy(self->link);
|
||||
}
|
||||
|
||||
void LinkObject::copy(LinkObject* self, const LinkObject* in) { self->setLink(in->link); }
|
||||
|
|
@ -21,7 +21,7 @@ alni LinkObject::save_size(LinkObject* self) { return sizeof(alni); }
|
|||
|
||||
void LinkObject::save(LinkObject* self, ArchiverOut& file_self) {
|
||||
if (self->link != nullptr) {
|
||||
alni link_object_save_adress = NDO->save(file_self, self->link);
|
||||
alni link_object_save_adress = objects_api::save(file_self, self->link);
|
||||
file_self << link_object_save_adress;
|
||||
} else {
|
||||
alni null = -1;
|
||||
|
|
@ -37,8 +37,8 @@ void LinkObject::load(ArchiverIn& file_self, LinkObject* self) {
|
|||
if (saved_object_adress == -1) {
|
||||
self->link = nullptr;
|
||||
} else {
|
||||
self->link = NDO->load(file_self, saved_object_adress);
|
||||
NDO->increaseReferenceCount(self->link);
|
||||
self->link = objects_api::load(file_self, saved_object_adress);
|
||||
objects_api::increaseReferenceCount(self->link);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ alni LinkObject::allocated_size(LinkObject* self) { return sizeof(Object*); }
|
|||
alni LinkObject::allocated_size_recursive(LinkObject* self) {
|
||||
alni out = sizeof(Object*);
|
||||
if (self->link) {
|
||||
out += NDO->objsize_ram_recursive_util(self->link, self->link->type);
|
||||
out += objects_api::objsize_ram_recursive_util(self->link, self->link->type);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
|
@ -61,8 +61,8 @@ alni LinkObject::allocated_size_recursive(LinkObject* self) {
|
|||
Object* LinkObject::getLink() { return link; }
|
||||
|
||||
void LinkObject::setLink(Object* obj) {
|
||||
if (link) NDO->destroy(link);
|
||||
if (obj) NDO->increaseReferenceCount(obj);
|
||||
if (link) objects_api::destroy(link);
|
||||
if (obj) objects_api::increaseReferenceCount(obj);
|
||||
link = obj;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ void ListObject::copy(ListObject* in, const ListObject* target) {
|
|||
|
||||
void ListObject::destructor(ListObject* in) {
|
||||
for (auto item : in->items) {
|
||||
NDO->destroy(item.data());
|
||||
objects_api::destroy(item.data());
|
||||
}
|
||||
in->items.removeAll();
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ void ListObject::save(ListObject* self, ArchiverOut& file_self) {
|
|||
file_self << len;
|
||||
|
||||
for (auto item : self->items) {
|
||||
alni ndo_object_adress = NDO->save(file_self, item.data());
|
||||
alni ndo_object_adress = objects_api::save(file_self, item.data());
|
||||
file_self << ndo_object_adress;
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ void ListObject::load(ArchiverIn& file_self, ListObject* self) {
|
|||
for (alni i = 0; i < len; i++) {
|
||||
alni ndo_object_adress;
|
||||
file_self >> ndo_object_adress;
|
||||
self->pushBack(NDO->load(file_self, ndo_object_adress));
|
||||
self->pushBack(objects_api::load(file_self, ndo_object_adress));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -71,30 +71,30 @@ alni ListObject::allocated_size_recursive(ListObject* self) {
|
|||
ASSERT(false)
|
||||
// alni out = self->items.sizeAllocatedMem();
|
||||
for (auto item : self->items) {
|
||||
// out += NDO->objsize_ram_recursive_util(item.data(), item->type);
|
||||
// out += objects_api::objsize_ram_recursive_util(item.data(), item->type);
|
||||
}
|
||||
// return out;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ListObject::pushBack(Object* obj) {
|
||||
obj::NDO->increaseReferenceCount(obj);
|
||||
obj::objects_api::increaseReferenceCount(obj);
|
||||
items.pushBack(obj);
|
||||
}
|
||||
|
||||
void ListObject::pushFront(Object* obj) {
|
||||
obj::NDO->increaseReferenceCount(obj);
|
||||
obj::objects_api::increaseReferenceCount(obj);
|
||||
items.pushFront(obj);
|
||||
}
|
||||
|
||||
void ListObject::delNode(tp::List<Object*>::Node* node) {
|
||||
obj::NDO->destroy(node->data);
|
||||
obj::objects_api::destroy(node->data);
|
||||
items.deleteNode(node);
|
||||
}
|
||||
|
||||
void ListObject::popBack() {
|
||||
auto obj = items.last();
|
||||
if (obj) obj::NDO->destroy(obj->data);
|
||||
if (obj) obj::objects_api::destroy(obj->data);
|
||||
items.popBack();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ void MethodObject::load(ArchiverIn& file_self, obj::MethodObject* self) {
|
|||
|
||||
void MethodObject::Initialize() {
|
||||
obj::ScriptSection::initialize();
|
||||
NDO->define(&MethodObject::TypeData);
|
||||
obj::NDO->type_groups.addType(&MethodObject::TypeData, { "Primitives" });
|
||||
objects_api::define(&MethodObject::TypeData);
|
||||
objects_api::addTypeToGroup(&MethodObject::TypeData, { "Primitives" });
|
||||
}
|
||||
|
||||
void MethodObject::UnInitialize() { obj::ScriptSection::uninitialize(); }
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ bool uninit_flag = false;
|
|||
|
||||
void NullObject::uninit() {
|
||||
uninit_flag = true;
|
||||
NDO->destroy(NdoNull_globalInstance);
|
||||
objects_api::destroy(NdoNull_globalInstance);
|
||||
NdoNull_globalInstance = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,13 +16,11 @@ static alni save_size(TypeObject* self) { return save_string_size(self->mTypeRef
|
|||
static void save(TypeObject* self, ArchiverOut& file_self) { save_string(file_self, self->mTypeRef->name); }
|
||||
|
||||
static void load(ArchiverIn& file_self, TypeObject* self) {
|
||||
std::string nameid;
|
||||
load_string(file_self, nameid);
|
||||
std::string name;
|
||||
load_string(file_self, name);
|
||||
|
||||
auto idx = NDO->types.presents(nameid);
|
||||
|
||||
if (idx) {
|
||||
self->mTypeRef = NDO->types.getSlotVal(idx);
|
||||
if (objects_api::isType(name.c_str())) {
|
||||
self->mTypeRef = objects_api::getType(name.c_str());
|
||||
} else {
|
||||
self->mTypeRef = &NullObject::TypeData;
|
||||
}
|
||||
|
|
@ -31,10 +29,8 @@ static void load(ArchiverIn& file_self, TypeObject* self) {
|
|||
static alni allocated_size(TypeObject* self) { return sizeof(alni); }
|
||||
|
||||
static void from_string(TypeObject* self, const std::string& in) {
|
||||
auto idx = NDO->types.presents(in);
|
||||
|
||||
if (idx) {
|
||||
self->mTypeRef = NDO->types.getSlotVal(idx);
|
||||
if (objects_api::isType(in.c_str())) {
|
||||
self->mTypeRef = objects_api::getType(in.c_str());
|
||||
} else {
|
||||
self->mTypeRef = &NullObject::TypeData;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue