-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
68 lines (60 loc) · 2.32 KB
/
Copy pathmain.cpp
File metadata and controls
68 lines (60 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "cxx_simple_reflection.h"
#include "aether.h"
class BasicType_int16_t : public BasicType
{
public:
const char* GetName() const override { return "int16_t"; }
void SetValueByString( void* value, const char* str ) const override { *(int16_t*)value = atoi( str ); }
std::string GetValueAsString( const void* value ) const override { return std::to_string( *(int16_t*)value ); }
};
template <>
const BasicType* GetBasicType< int16_t >()
{
static BasicType_int16_t s_basicType;
return &s_basicType;
}
//------------------------------------------------------------------------------
// Something
//------------------------------------------------------------------------------
class Something
{
public:
int thing = 0;
};
Class meta_Something = Class( "Something", &NewFnT< Something > );
Var meta_Something_thing = Var( &meta_Something, "thing", offsetof( Something, thing ), GetBasicType< decltype(Something::thing) >() );
//------------------------------------------------------------------------------
// SomethingElse
//------------------------------------------------------------------------------
class SomethingElse
{
public:
SomethingElse() { AE_INFO( "SomethingElse ctor" ); }
int32_t thingInt = 7;
float thingFloat = 12.34f;
};
REGISTER_CLASS( SomethingElse );
REGISTER_CLASS_VAR( SomethingElse, thingInt );
REGISTER_CLASS_VAR( SomethingElse, thingFloat );
//------------------------------------------------------------------------------
// main
//------------------------------------------------------------------------------
int main()
{
const Class* somethingElseClass = GetClassByName( "SomethingElse" );
for ( auto var : somethingElseClass->vars )
{
const Var* v = var.second;
AE_INFO( "#::#\ttype:# offset:#", somethingElseClass->name, v->name, v->basicType->GetName(), v->varOffset );
}
SomethingElse* somethingElse = (SomethingElse*)somethingElseClass->newFn();
AE_INFO( "somethingElse->thingInt: #", somethingElse->thingInt );
AE_INFO( "somethingElse->thingFloat: #", somethingElse->thingFloat );
SetVar( somethingElseClass, somethingElse, "thingInt", "345" );
SetVar( somethingElseClass, somethingElse, "thingFloat", "23.45" );
AE_INFO( "somethingElse->thingInt: #", somethingElse->thingInt );
AE_INFO( "somethingElse->thingFloat: #", somethingElse->thingFloat );
// @TODO: Inheritence
AE_INFO( "done!" );
return 0;
}