-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
73 lines (57 loc) · 1.53 KB
/
main.cpp
File metadata and controls
73 lines (57 loc) · 1.53 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
69
70
71
72
73
// Created by Red16 (I hare function pointers).
#include "Reflection.h"
using namespace Reflection;
bool IsMe()
{
return true;
}
int myValue()
{
return 50;
}
void init()
{
printf("init\n");
}
void init_with_args(const char* text)
{
printf("%s\n", text);
}
void setup_rf()
{
// first initilize the functions
# if 1
// using add macro
AddFunction(init);
AddFunction(myValue);
AddFunction(IsMe);
AddFunction(init_with_args);
#endif
# if 0
// manully add them lol -> tip use AddFunction macro
Manager::Add("init", reinterpret_cast<Pointer_t>(init));
Manager::Add("myValue", reinterpret_cast<Pointer_t>(myValue));
Manager::Add("IsMe", reinterpret_cast<Pointer_t>(IsMe));
#endif
# if 0
Manager("init").Add(reinterpret_cast<Pointer_t>(init));
Manager("myValue").Add(reinterpret_cast<Pointer_t>(myValue));
Manager("IsMe").Add(reinterpret_cast<Pointer_t>(IsMe));
Manager("init_with_args").Add(reinterpret_cast<Pointer_t>(init_with_args));
#endif
}
int main()
{
setup_rf();
// calling functions
Manager::Invoke<void>("init");
Manager::Invoke<void, const char*>("init_with_args", "I was called with some args hahahaha");
Manager init_with_args("init_with_args");
init_with_args.Invoke<void, const char*>("I was called with some args hahahaha");
Manager mv("init_with_args");
printf("myValue: %d", mv.Invoke<int>());
Manager isMe("IsMe");
const char* isMeChar = isMe.Invoke<bool>() ? "true" : "false";
printf("IsMe: %s", isMeChar);
return 0;
}