remove macros use in objects mofule

This commit is contained in:
IlyaShurupov 2024-03-24 21:55:25 +03:00 committed by Ilya Shurupov
parent c6260f7c48
commit 9e2e7f5809
31 changed files with 362 additions and 386 deletions

View file

@ -4,28 +4,27 @@
using namespace tp;
using namespace obj;
void IntObject::constructor(Object* self) { NDO_CAST(IntObject, self)->val = 0; }
void IntObject::constructor(IntObject* self) { self->val = 0; }
void IntObject::copy(IntObject* self, const IntObject* in) { self->val = in->val; }
IntObject* IntObject::create(alni in) {
NDO_CASTV(IntObject, NDO->create("int"), out)->val = in;
auto out = objects_api::cast<IntObject>(NDO->create("int"));
out->val = in;
return out;
}
void IntObject::from_int(Object* self, alni in) { NDO_CAST(IntObject, self)->val = in; }
void IntObject::from_int(IntObject* self, alni in) { self->val = in; }
void IntObject::from_float(Object* self, alnf in) { NDO_CAST(IntObject, self)->val = (alni) in; }
void IntObject::from_float(IntObject* self, alnf in) { self->val = (alni) in; }
void IntObject::from_string(Object* self, const std::string& in) {
NDO_CAST(IntObject, self)->val = std::stol(in);
}
void IntObject::from_string(IntObject* self, const std::string& in) { self->val = std::stol(in); }
std::string IntObject::to_string(Object* self) { return std::to_string(NDO_CAST(IntObject, self)->val); }
std::string IntObject::to_string(IntObject* self) { return std::to_string(self->val); }
alni IntObject::to_int(Object* self) { return alni(NDO_CAST(IntObject, self)->val); }
alni IntObject::to_int(IntObject* self) { return alni(self->val); }
alnf IntObject::to_float(Object* self) { return alnf(NDO_CAST(IntObject, self)->val); }
alnf IntObject::to_float(IntObject* self) { return alnf(self->val); }
static alni save_size(IntObject* self) { return sizeof(alni); }
@ -34,12 +33,12 @@ static void save(IntObject* self, ArchiverOut& file_self) { file_self << self->v
static void load(ArchiverIn& file_self, IntObject* self) { file_self >> self->val; }
struct ObjectTypeConversions IntObjectTypeConversions = {
.from_int = IntObject::from_int,
.from_float = IntObject::from_float,
.from_string = IntObject::from_string,
.to_string = IntObject::to_string,
.to_int = IntObject::to_int,
.to_float = IntObject::to_float,
.from_int = (object_from_int) IntObject::from_int,
.from_float = (object_from_float) IntObject::from_float,
.from_string = (object_from_string) IntObject::from_string,
.to_string = (object_to_string) IntObject::to_string,
.to_int = (object_to_int) IntObject::to_int,
.to_float = (object_to_float) IntObject::to_float,
};
void divide(IntObject* self, IntObject* in) { self->val /= in->val; }
@ -59,7 +58,7 @@ struct ObjectTypeAriphmetics IntObject::TypeAriphm = {
struct obj::ObjectType obj::IntObject::TypeData = {
.base = nullptr,
.constructor = IntObject::constructor,
.constructor = (object_constructor) IntObject::constructor,
.destructor = nullptr,
.copy = (object_copy) IntObject::copy,
.size = sizeof(IntObject),