79 lines
2.2 KiB
Plaintext
79 lines
2.2 KiB
Plaintext
#include "{{class_name}}.gen.h"
|
|
#include <string.h>
|
|
|
|
namespace meta {
|
|
namespace reflection {
|
|
|
|
/**
|
|
* Field
|
|
**/
|
|
|
|
{{class_name}}_Field::{{class_name}}_Field(
|
|
const std::string& name,
|
|
std::shared_ptr<::meta::reflection::Class> parent)
|
|
: ::meta::reflection::Field(name, parent) {}
|
|
|
|
::meta::reflection::any GetImpl(void* instance) const {
|
|
::{{class_namespace}}::{{class_name}}* obj = (::{{class_namespace}}::{{class_name}}*)instance;
|
|
|
|
{% for field in class_fields %}
|
|
if (strcmp(name().c_str(), "{{field.name}}") == 0) { return obj->{{field.name}}; }
|
|
{% endfor %}
|
|
}
|
|
|
|
void SetImpl(void* instance, const ::meta::reflection::any& value) const {
|
|
::{{class_namespace}}::{{class_name}}* obj = (::{{class_namespace}}::{{class_name}}*)instance;
|
|
{% for field in class_fields %}
|
|
{% if not field.is_const %}
|
|
if(strcmp(name().c_str(), "{{field.name}}") == 0) { obj->{{field.name}} = value.as<{{field.type}}>();}
|
|
{% endif %}
|
|
{% endfor %}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Method
|
|
**/
|
|
{{class_name}}_Method::{{class_name}}_Method(
|
|
const std::string& name,
|
|
std::shared_ptr<::meta::reflection::Class> parent)
|
|
: ::meta::reflection::Method(name, parent) {}
|
|
|
|
::meta::reflection::any InvokeImpl(void* instance, const std::vector<void *> ¶ms) const {
|
|
::{{class_namespace}}::{{class_name}}* obj = (::{{class_namespace}}::{{class_name}}*)instance;
|
|
|
|
{% for method in class_methods %}
|
|
{# start if(, else if(, #}
|
|
{% if loop.is_first %}
|
|
if (strcmp(name.c_str(), "{{method.name}}") == 0) {
|
|
{% else %}
|
|
} else if (strcmp(name.c_str(), "{{method.name}}") == 0) {
|
|
{% endif %}
|
|
|
|
{% if method.return_type != "void" %}
|
|
return obj->{{method.name}}(
|
|
{% for param in method.params%}
|
|
*({{param.type}}*)params[{{loop.index}}]{% if not loop.is_last %}, {% endif %}
|
|
{% endfor %}
|
|
);
|
|
{% else %}
|
|
obj->{{method.name}}(
|
|
{% for param in method.params%}
|
|
*({{param.type}}*)params[{{loop.index}}]{% if not loop.last %}, {% endif %}
|
|
{% endfor %}
|
|
);
|
|
return;
|
|
{% endif %}
|
|
|
|
{% if loop.is_last %}
|
|
}
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
}
|
|
|
|
} // namespace reflection
|
|
} // namespace meta
|
|
|