meta/runtime/test.gen.cc
2024-03-05 09:45:08 +08:00

92 lines
2.6 KiB
C++

#include "test.gen.h"
#include <memory>
/**
* Class
**/
test::Test::Test_Class::Test_Class() : ::meta::reflection::Class("test::Test", nullptr) {}
void
test::Test::Test_Class::Register()
{
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);
}
void
test::Test::Test_Class::AddBaseClassProxy(std::shared_ptr<::meta::reflection::Class> base)
{
AddBaseClass(base);
}
void
test::Test::Test_Class::AddMethodProxy(std::shared_ptr<::meta::reflection::Method> method)
{
AddMethod(method);
}
void
test::Test::Test_Class::AddFieldProxy(std::shared_ptr<::meta::reflection::Field> field)
{
AddField(field);
}
/**
* Field
**/
test::Test::Test_Field::Test_Field(const std::string &name,
std::shared_ptr<::meta::reflection::Class> parent)
: ::meta::reflection::Field(name, parent)
{}
::meta::reflection::any
test::Test::Test_Field::GetImpl(void *instance) const
{
::test::Test *obj = (::test::Test *) instance;
if (strcmp(Name().c_str(), "length_") == 0) { return obj->length_; }
if (strcmp(Name().c_str(), "size_") == 0) { return obj->size_; }
return ::meta::reflection::any{};
}
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);
}
}
/**
* Method
**/
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(); }
return ::meta::reflection::any{};
}