clean up object module

This commit is contained in:
IlyaShurupov 2024-03-23 12:32:57 +03:00
parent 4c66704830
commit 5d9e270aa9
68 changed files with 1223 additions and 1229 deletions

View file

@ -3,10 +3,10 @@
#include "core/Object.hpp"
namespace obj {
namespace tp::obj {
struct BoolObject : Object {
tp::alni val;
alni val;
static ObjectType TypeData;
static void constructor(BoolObject* self);
@ -14,11 +14,11 @@ namespace obj {
static BoolObject* create(bool in);
static void from_int(BoolObject* self, tp::alni in);
static void from_float(BoolObject* self, tp::alnf in);
static void from_int(BoolObject* self, alni in);
static void from_float(BoolObject* self, alnf in);
static void from_string(BoolObject* self, const std::string& in);
static std::string to_string(BoolObject* self);
static tp::alni to_int(BoolObject* self);
static tp::alnf to_float(BoolObject* self);
static alni to_int(BoolObject* self);
static alnf to_float(BoolObject* self);
};
};
}

View file

@ -2,7 +2,7 @@
#include "primitives/DictObject.hpp"
namespace obj {
namespace tp::obj {
struct ClassObject : Object {
@ -10,7 +10,7 @@ namespace obj {
static void copy(ClassObject* self, const ClassObject* in);
static void destructor(ClassObject* self);
static void constructor(ClassObject* self);
static tp::alni save_size(ClassObject* self);
static alni save_size(ClassObject* self);
static void save(ClassObject* self, ArchiverOut& file_self);
static void load(ArchiverIn& file_self, ClassObject* self);
@ -31,7 +31,7 @@ namespace obj {
Type* getMember(const std::string& id) {
auto idx = members->presents(id);
if (bool(idx)) {
return ((Type*)obj::ndo_cast(members->getSlotVal(idx), &Type::TypeData));
return ((Type*)ndo_cast(members->getSlotVal(idx), &Type::TypeData));
}
return NULL;
}
@ -43,4 +43,4 @@ namespace obj {
return out;
}
};
};
}

View file

@ -4,10 +4,10 @@
#include "core/Object.hpp"
#include "Color.hpp"
namespace obj {
namespace tp::obj {
struct ColorObject : Object {
tp::RGBA mCol;
RGBA mCol;
static ObjectType TypeData;
static ObjectTypeAriphmetics TypeAriphm;
@ -15,10 +15,10 @@ namespace obj {
static void constructor(Object* self);
static void copy(ColorObject* self, const ColorObject* in);
static void from_int(ColorObject* self, tp::alni in);
static void from_float(ColorObject* self, tp::alnf in);
static void from_int(ColorObject* self, alni in);
static void from_float(ColorObject* self, alnf in);
static std::string to_string(ColorObject* self);
static ColorObject* create(tp::RGBA in);
static ColorObject* create(RGBA in);
};
};
}

View file

@ -2,7 +2,7 @@
#include "core/Object.hpp"
namespace obj {
namespace tp::obj {
struct DictObject : Object {
static ObjectType TypeData;
@ -10,22 +10,22 @@ namespace obj {
static void destructor(Object* self);
static void constructor(Object* self);
static tp::alni save_size(DictObject* self);
static alni save_size(DictObject* self);
static void save(DictObject* self, ArchiverOut& file_self);
static void load(ArchiverIn& file_self, DictObject* self);
static tp::Buffer<Object*> childs_retrival(DictObject* self);
static tp::alni allocated_size(DictObject* self);
static tp::alni allocated_size_recursive(DictObject* self);
static Buffer<Object*> childs_retrival(DictObject* self);
static alni allocated_size(DictObject* self);
static alni allocated_size_recursive(DictObject* self);
void put(const std::string&, Object*);
void remove(const std::string&);
Object* get(const std::string&);
tp::Map<std::string, Object*>::Idx presents(const std::string&);
Object* getSlotVal(tp::Map<std::string, Object*>::Idx);
Map<std::string, Object*>::Idx presents(const std::string&);
Object* getSlotVal(Map<std::string, Object*>::Idx);
[[nodiscard]] const tp::Map<std::string, Object*>& getItems() const;
[[nodiscard]] const Map<std::string, Object*>& getItems() const;
private:
tp::Map<std::string, Object*> items;
Map<std::string, Object*> items;
};
};
}

View file

@ -3,32 +3,32 @@
#include "core/Object.hpp"
namespace obj {
namespace tp::obj {
struct EnumObject : Object {
// one entry is 2 * sizeof(alni) in size
tp::uhalni active;
tp::uhalni nentries;
tp::alni* entries;
uhalni active;
uhalni nentries;
alni* entries;
static ObjectType TypeData;
static void constructor(EnumObject* self);
static void destructor(EnumObject* self);
static void copy(EnumObject* self, const EnumObject* in);
void init(tp::InitialierList<const char*> list);
void init(InitialierList<const char*> list);
const char* getActiveName();
const char* getItemName(tp::uhalni idx);
const char* getItemName(uhalni idx);
static void from_int(EnumObject* self, tp::alni in);
static void from_float(EnumObject* self, tp::alnf in);
static void from_int(EnumObject* self, alni in);
static void from_float(EnumObject* self, alnf in);
static void from_string(EnumObject* self, const std::string& in);
static std::string to_string(EnumObject* self);
static tp::alni to_int(EnumObject* self);
static tp::alnf to_float(EnumObject* self);
static alni to_int(EnumObject* self);
static alnf to_float(EnumObject* self);
static bool compare(EnumObject* first, EnumObject* second);
static EnumObject* create(tp::InitialierList<const char*> list);
static EnumObject* create(InitialierList<const char*> list);
};
};
}

View file

@ -3,10 +3,10 @@
#include "core/Object.hpp"
namespace obj {
namespace tp::obj {
struct FloatObject : Object {
tp::alnf val;
alnf val;
static ObjectType TypeData;
static ObjectTypeAriphmetics TypeAriphm;
@ -14,13 +14,13 @@ namespace obj {
static void constructor(FloatObject* self);
static void copy(FloatObject* self, const FloatObject* in);
static FloatObject* create(tp::alnf in);
static FloatObject* create(alnf in);
static void from_int(FloatObject* self, tp::alni in);
static void from_float(FloatObject* self, tp::alnf in);
static void from_int(FloatObject* self, alni in);
static void from_float(FloatObject* self, alnf in);
static void from_string(FloatObject* self, const std::string& in);
static std::string to_string(FloatObject* self);
static tp::alni to_int(FloatObject* self);
static tp::alnf to_float(FloatObject* self);
static alni to_int(FloatObject* self);
static alnf to_float(FloatObject* self);
};
};
}

View file

@ -3,23 +3,23 @@
#include "core/Object.hpp"
namespace obj {
namespace tp::obj {
struct IntObject : Object {
tp::alni val;
alni val;
static ObjectType TypeData;
static ObjectTypeAriphmetics TypeAriphm;
static void constructor(Object* self);
static void copy(IntObject* self, const IntObject* in);
static IntObject* create(tp::alni in);
static IntObject* create(alni in);
static void from_int(Object* self, tp::alni in);
static void from_float(Object* self, tp::alnf in);
static void from_int(Object* self, alni in);
static void from_float(Object* self, alnf in);
static void from_string(Object* self, const std::string& in);
static std::string to_string(Object* self);
static tp::alni to_int(Object* self);
static tp::alnf to_float(Object* self);
static alni to_int(Object* self);
static alnf to_float(Object* self);
};
};
}

View file

@ -3,7 +3,7 @@
#include "interpreter/Interpreter.hpp"
#include "primitives/ClassObject.hpp"
namespace obj {
namespace tp::obj {
struct InterpreterObject : ClassObject {
static ObjectType TypeData;
Interpreter mInterpreter;
@ -12,8 +12,8 @@ namespace obj {
static void constructor(InterpreterObject* self);
static void load(ArchiverIn& file_self, InterpreterObject* self);
void exec(obj::ClassObject* self = nullptr, tp::InitialierList<Interpreter::GlobalDef> globals = {});
void exec(obj::ClassObject* self = nullptr, InitialierList<Interpreter::GlobalDef> globals = {});
void debug();
bool running();
};
};
}

View file

@ -3,7 +3,7 @@
#include "core/Object.hpp"
namespace obj {
namespace tp::obj {
struct LinkObject : Object {
static ObjectType TypeData;
@ -12,12 +12,12 @@ namespace obj {
static void copy(Object* self, const Object* in);
static LinkObject* create(Object* in);
static tp::alni save_size(LinkObject* self);
static alni save_size(LinkObject* self);
static void save(LinkObject* self, ArchiverOut& file_self);
static void load(ArchiverIn& file_self, LinkObject* self);
static tp::alni allocated_size(LinkObject* self);
static tp::alni allocated_size_recursive(LinkObject* self);
static tp::Buffer<Object*> childs_retrival(LinkObject* self);
static alni allocated_size(LinkObject* self);
static alni allocated_size_recursive(LinkObject* self);
static Buffer<Object*> childs_retrival(LinkObject* self);
Object* getLink();
void setLink(Object* obj);
@ -25,5 +25,4 @@ namespace obj {
private:
Object* link;
};
};
}

View file

@ -3,7 +3,7 @@
#include "core/Object.hpp"
namespace obj {
namespace tp::obj {
enum ListMethods {
LISTOBJECT_PUSH_BACK,
@ -16,21 +16,21 @@ namespace obj {
static void copy(Object* self, const Object* in);
static void destructor(Object* self);
static tp::alni allocated_size_recursive(ListObject* self);
static tp::alni allocated_size(ListObject* self);
static tp::Buffer<Object*> childs_retrival(ListObject* self);
static alni allocated_size_recursive(ListObject* self);
static alni allocated_size(ListObject* self);
static Buffer<Object*> childs_retrival(ListObject* self);
static void load(ArchiverIn& file_self, ListObject* self);
static void save(ListObject* self, ArchiverOut& file_self);
static tp::alni save_size(ListObject* self);
static alni save_size(ListObject* self);
[[nodiscard]] const tp::List<Object*>& getItems() const;
[[nodiscard]] const List<Object*>& getItems() const;
void pushBack(Object* obj);
void pushFront(Object* obj);
void popBack();
void delNode(tp::List<Object*>::Node*);
void delNode(List<Object*>::Node*);
private:
tp::List<Object*> items;
List<Object*> items;
};
};
}

View file

@ -3,7 +3,7 @@
#include "primitives/StringObject.hpp"
#include "interpreter/Script.hpp"
namespace obj {
namespace tp::obj {
struct MethodObject : Object {
@ -14,7 +14,7 @@ namespace obj {
static void constructor(MethodObject* self);
static void copy(MethodObject* self, MethodObject* in);
static void destructor(MethodObject* self);
static tp::alni save_size(MethodObject* self);
static alni save_size(MethodObject* self);
static void save(MethodObject* self, ArchiverOut& file_self);
static void load(ArchiverIn& file_self, obj::MethodObject* self);
@ -25,4 +25,4 @@ namespace obj {
static MethodObject* create(const std::string& script);
};
};
}

View file

@ -3,7 +3,7 @@
#include "core/Object.hpp"
namespace obj {
namespace tp::obj {
extern struct NullObject* NdoNull_globalInstance;
@ -15,18 +15,18 @@ namespace obj {
static Object* null_return() {
if (!NdoNull_globalInstance) {
NdoNull_globalInstance = (NullObject*) NDO->create("null");
obj::NDO->refinc(NdoNull_globalInstance);
NDO->increaseReferenceCount(NdoNull_globalInstance);
}
return (Object*) NdoNull_globalInstance;
}
static Object* null_return_ref() {
obj::NDO->refinc(null_return());
NDO->increaseReferenceCount(null_return());
return NdoNull_globalInstance;
}
};
#define NDO_NULL obj::NullObject::null_return()
#define NDO_NULL_REF obj::NullObject::null_return_ref()
#define NDO_NULL NullObject::null_return()
#define NDO_NULL_REF NullObject::null_return_ref()
};
}

View file

@ -3,7 +3,7 @@
#include "core/Object.hpp"
namespace obj {
namespace tp::obj {
struct StringObject : Object {
std::string val;
@ -14,11 +14,11 @@ namespace obj {
static void copy(Object* self, const Object* in);
static StringObject* create(const std::string& in);
static void from_int(StringObject* self, tp::alni in);
static void from_float(StringObject* self, tp::alnf in);
static void from_int(StringObject* self, alni in);
static void from_float(StringObject* self, alnf in);
static void from_string(StringObject* self, const std::string& in);
static std::string to_string(StringObject* self);
static tp::alni to_int(StringObject* self);
static tp::alnf to_float(StringObject* self);
static alni to_int(StringObject* self);
static alnf to_float(StringObject* self);
};
};
}

View file

@ -3,11 +3,10 @@
#include "core/Object.hpp"
namespace obj {
namespace tp::obj {
struct TypeObject : Object {
static ObjectType TypeData;
const ObjectType* mTypeRef;
static TypeObject* create(const ObjectType* type);
};
};
}