-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuaContextTests.cpp
More file actions
66 lines (52 loc) · 2.26 KB
/
LuaContextTests.cpp
File metadata and controls
66 lines (52 loc) · 2.26 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
// Copyright 2006-12 HumaNature Studios Inc.
#include "CorePch.h"
#include "LuaContext.h"
// extern and call testlua to use; TODO.m - probably should unit test this huh...
namespace core {
class Event;
class Test
{
public:
void set0() { logWarn("Set0", "!"); }
void set1(int p1) { logWarn("Set1", "%d", p1); }
void set2(int p1, int p2) { logWarn("Set2", "%d, %d", p1, p2); }
void set3(int p1, int p2, int p3) { logWarn("Set3", "%d, %d, %d", p1, p2, p3); }
void set4(int p1, int p2, int p3, int p4) { logWarn("Set4", "%d, %d, %d, %d", p1, p2, p3, p4); }
void set5(int p1, int p2, int p3, int p4, int p5) { logWarn("Set5", "%d, %d, %d, %d, %d", p1, p2, p3, p4, p5); }
};
void gset0() { logWarn("gSet0", "!"); }
void gset1(int p1) { logWarn("gSet1", "%d", p1); }
void gset2(int p1, int p2) { logWarn("gSet2", "%d, %d", p1, p2); }
void gset3(int p1, int p2, int p3) { logWarn("gSet3", "%d, %d, %d", p1, p2, p3); }
void gset4(int p1, int p2, int p3, int p4) { logWarn("gSet4", "%d, %d, %d, %d", p1, p2, p3, p4); }
void gset5(int p1, int p2, int p3, int p4, int p5) { logWarn("gSet5", "%d, %d, %d, %d, %d", p1, p2, p3, p4, p5); }
Test t;
void testLua()
{
LuaContext c;
c.bind("set0", &t, &Test::set0);
c.bind("set1", &t, &Test::set1);
c.bind("set2", &t, &Test::set2);
c.bind("set3", &t, &Test::set3);
c.bind("set4", &t, &Test::set4);
c.bind("set5", &t, &Test::set5);
c.bindGlobal("gset0", &gset0);
c.bindGlobal("gset1", &gset1);
c.bindGlobal("gset2", &gset2);
c.bindGlobal("gset3", &gset3);
c.bindGlobal("gset4", &gset4);
c.bindGlobal("gset5", &gset5);
c.executeString("set0();");
c.executeString("set1(1);");
c.executeString("set2(1, 2);");
c.executeString("set3(1, 2, 3);");
c.executeString("set4(1, 2, 3, 4);");
c.executeString("set5(1, 2, 3, 4, 5);");
c.executeString("gset0();");
c.executeString("gset1(1);");
c.executeString("gset2(1, 2);");
c.executeString("gset3(1, 2, 3);");
c.executeString("gset4(1, 2, 3, 4);");
c.executeString("gset5(1, 2, 3, 4, 5);");
}
} // namespace core