meta/runtime/test.gen.cc

91 lines
2.5 KiB
C++
Raw Permalink Normal View History

2024-03-05 00:13:53 +08:00
#include "test.gen.h"
#include <memory>
/**
* Class
**/
2024-03-05 11:48:41 +08:00
test::Test::Test_Class::Test_Class()
: ::meta::reflection::Class("test::Test", nullptr)
2024-03-05 09:45:08 +08:00
{
2024-03-05 11:48:41 +08:00
}
void test::Test::Test_Class::Register() {
2024-03-05 00:13:53 +08:00
auto self = new test::Test::Test_Class();
auto clz = std::shared_ptr<::meta::reflection::Class>(self);
// self->AddBaseClassProxy();
self->AddMethod(std::make_shared<test::Test::Test_Method>("size", clz));
self->AddMethod(std::make_shared<test::Test::Test_Method>("length", clz));
self->AddField(std::make_shared<test::Test::Test_Field>("length_", clz));
self->AddField(std::make_shared<test::Test::Test_Field>("size_", clz));
::meta::reflection::Registry::Instance()->RegisterClass(clz);
}
2024-03-05 11:48:41 +08:00
void test::Test::Test_Class::AddBaseClassProxy(std::shared_ptr<::meta::reflection::Class> base) {
2024-03-05 00:13:53 +08:00
AddBaseClass(base);
}
2024-03-05 11:48:41 +08:00
void test::Test::Test_Class::AddMethodProxy(std::shared_ptr<::meta::reflection::Method> method) {
2024-03-05 00:13:53 +08:00
AddMethod(method);
}
2024-03-05 11:48:41 +08:00
void test::Test::Test_Class::AddFieldProxy(std::shared_ptr<::meta::reflection::Field> field) {
2024-03-05 00:13:53 +08:00
AddField(field);
}
2024-03-05 11:48:41 +08:00
2024-03-05 00:13:53 +08:00
/**
* Field
**/
2024-03-05 11:48:41 +08:00
test::Test::Test_Field::Test_Field(
const std::string& name,
std::shared_ptr<::meta::reflection::Class> parent)
: ::meta::reflection::Field(name, parent) {}
2024-03-05 00:13:53 +08:00
2024-03-05 11:48:41 +08:00
::meta::reflection::any test::Test::Test_Field::GetImpl(void* instance) const {
::test::Test* obj = (::test::Test*)instance;
2024-03-05 00:13:53 +08:00
if (strcmp(Name().c_str(), "length_") == 0) {
2024-03-05 11:48:41 +08:00
return obj->length_;
2024-03-05 00:13:53 +08:00
}
if (strcmp(Name().c_str(), "size_") == 0) {
2024-03-05 11:48:41 +08:00
return obj->size_;
2024-03-05 00:13:53 +08:00
}
2024-03-05 11:48:41 +08:00
return ::meta::reflection::any{};
2024-03-05 00:13:53 +08:00
}
2024-03-05 11:48:41 +08:00
void test::Test::Test_Field::SetImpl(void* instance, const ::meta::reflection::any& value) const {
::test::Test* obj = (::test::Test*)instance;
if(strcmp(Name().c_str(), "length_") == 0) { obj->length_ = ::meta::reflection::any_cast<int>(value);}
if(strcmp(Name().c_str(), "size_") == 0) { obj->size_ = ::meta::reflection::any_cast<int>(value);}
}
2024-03-05 00:13:53 +08:00
/**
* Method
**/
2024-03-05 11:48:41 +08:00
test::Test::Test_Method::Test_Method(
const std::string& name,
std::shared_ptr<::meta::reflection::Class> parent)
: ::meta::reflection::Method(name, parent) {}
::meta::reflection::any test::Test::Test_Method::InvokeImpl(void* instance, const std::vector<::meta::reflection::any> &params) const {
::test::Test* obj = (::test::Test*)instance;
if (strcmp(Name().c_str(), "size") == 0) {
return
obj->
size(
);
}
if (strcmp(Name().c_str(), "length") == 0) {
return
obj->
length(
);
}
2024-03-05 00:13:53 +08:00
return ::meta::reflection::any{};
}
2024-03-05 11:48:41 +08:00