remove initializer callbacks from method object

This commit is contained in:
IlyaShurupov 2024-03-25 11:40:56 +03:00 committed by Ilya Shurupov
parent 88b78d907a
commit 714bdaef12
3 changed files with 18 additions and 27 deletions

View file

@ -1,7 +1,7 @@
#include "compiler/Functions.hpp" #include "compiler/Functions.hpp"
#include "primitives/PrimitiveObjects.hpp" #include "primitives/PrimitiveObjects.hpp"
#include "core/ScriptSection.hpp"
using namespace tp; using namespace tp;
using namespace obj; using namespace obj;
@ -20,6 +20,7 @@ static void defineTypes() {
objects_api::define(&ColorObject::TypeData); objects_api::define(&ColorObject::TypeData);
objects_api::define(&InterpreterObject::TypeData); objects_api::define(&InterpreterObject::TypeData);
objects_api::define(&TypeObject::TypeData); objects_api::define(&TypeObject::TypeData);
objects_api::define(&MethodObject::TypeData);
} }
static void defineGroups() { static void defineGroups() {
@ -34,13 +35,14 @@ static void defineGroups() {
objects_api::addTypeToGroup(&EnumObject::TypeData, { "Primitives" }); objects_api::addTypeToGroup(&EnumObject::TypeData, { "Primitives" });
objects_api::addTypeToGroup(&ClassObject::TypeData, { "Primitives" }); objects_api::addTypeToGroup(&ClassObject::TypeData, { "Primitives" });
objects_api::addTypeToGroup(&ColorObject::TypeData, { "Primitives" }); objects_api::addTypeToGroup(&ColorObject::TypeData, { "Primitives" });
objects_api::addTypeToGroup(&MethodObject::TypeData, { "Primitives" });
objects_api::addTypeToGroup(&InterpreterObject::TypeData, { "scripting" }); objects_api::addTypeToGroup(&InterpreterObject::TypeData, { "scripting" });
} }
static bool init(const ModuleManifest*) { static bool init(const ModuleManifest*) {
objects_api::initialize(); objects_api::initialize();
MethodObject::Initialize(); ScriptSection::initialize();
defineTypes(); defineTypes();
defineGroups(); defineGroups();
@ -49,7 +51,7 @@ static bool init(const ModuleManifest*) {
} }
static void deinit(const ModuleManifest*) { static void deinit(const ModuleManifest*) {
MethodObject::UnInitialize(); ScriptSection::uninitialize();
objects_api::finalize(); objects_api::finalize();
} }

View file

@ -6,19 +6,6 @@
using namespace tp; using namespace tp;
using namespace obj; using namespace obj;
struct ObjectType MethodObject::TypeData = {
.base = nullptr,
.constructor = (object_constructor) MethodObject::constructor,
.destructor = (object_destructor) MethodObject::destructor,
.copy = (object_copy) MethodObject::copy,
.size = sizeof(MethodObject),
.name = "method",
.conversions = nullptr,
.save_size = (object_save_size) MethodObject::save_size,
.save = (object_save) MethodObject::save,
.load = (object_load) MethodObject::load,
};
void MethodObject::constructor(MethodObject* self) { void MethodObject::constructor(MethodObject* self) {
self->mScript = obj::ScriptSection::globalHandle()->createScript(); self->mScript = obj::ScriptSection::globalHandle()->createScript();
} }
@ -49,14 +36,6 @@ void MethodObject::load(ArchiverIn& file_self, obj::MethodObject* self) {
self->mScript = script_section->get_scritp_from_file_adress(script_table_file_address); self->mScript = script_section->get_scritp_from_file_adress(script_table_file_address);
} }
void MethodObject::Initialize() {
obj::ScriptSection::initialize();
objects_api::define(&MethodObject::TypeData);
objects_api::addTypeToGroup(&MethodObject::TypeData, { "Primitives" });
}
void MethodObject::UnInitialize() { obj::ScriptSection::uninitialize(); }
void MethodObject::compile() { Compile(this); } void MethodObject::compile() { Compile(this); }
MethodObject* MethodObject::create(const std::string& script) { MethodObject* MethodObject::create(const std::string& script) {
@ -65,3 +44,16 @@ MethodObject* MethodObject::create(const std::string& script) {
out->compile(); out->compile();
return out; return out;
} }
struct ObjectType MethodObject::TypeData = {
.base = nullptr,
.constructor = (object_constructor) MethodObject::constructor,
.destructor = (object_destructor) MethodObject::destructor,
.copy = (object_copy) MethodObject::copy,
.size = sizeof(MethodObject),
.name = "method",
.conversions = nullptr,
.save_size = (object_save_size) MethodObject::save_size,
.save = (object_save) MethodObject::save,
.load = (object_load) MethodObject::load,
};

View file

@ -18,9 +18,6 @@ namespace tp::obj {
static void save(MethodObject* self, ArchiverOut& file_self); static void save(MethodObject* self, ArchiverOut& file_self);
static void load(ArchiverIn& file_self, obj::MethodObject* self); static void load(ArchiverIn& file_self, obj::MethodObject* self);
static void Initialize();
static void UnInitialize();
void compile(); void compile();
static MethodObject* create(const std::string& script); static MethodObject* create(const std::string& script);