- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
#include <clcpp/clcpp.h>
#include <clcpp/FunctionCall.h>
// Reflect the entire namespace and implement each class
clcpp_reflect(TestClassImpl)
namespace TestClassImpl
{
class A
{
public:
A()
{
x = 1;
y = 2;
z = 3;
}
int x, y, z;
};
struct B
{
B()
{
a = 1.5f;
b = 2.5f;
c = 3.5f;
}
float a, b, c;
};
}
clcpp_impl_class(TestClassImpl::A)
clcpp_impl_class(TestClassImpl::B)
void TestConstructorDestructor(clcpp::Database& db)
{
const clcpp::Class* ca = clcpp::GetType<TestClassImpl::A>()->AsClass();
const clcpp::Class* cb = clcpp::GetType<TestClassImpl::B>()->AsClass();
TestClassImpl::A* a = (TestClassImpl::A*)new char[sizeof(TestClassImpl::A)];
TestClassImpl::B* b = (TestClassImpl::B*)new char[sizeof(TestClassImpl::B)];
CallFunction(ca->constructor, a);
CallFunction(cb->constructor, b);
CallFunction(ca->destructor, a);
CallFunction(cb->destructor, b);
delete [] (char*) a;
delete [] (char*) b;
}
https://github.com/Celtoys/clReflect/blob/master/src/clReflectTest/TestClassImpl.cpp