-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cc
More file actions
70 lines (52 loc) · 1.27 KB
/
main.cc
File metadata and controls
70 lines (52 loc) · 1.27 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
#include <iostream>
#include <Lua.hh>
void test() {
std::cout << "Hello, world! " << std::endl;
}
void test1(int a) {
std::cout << a << std::endl;
}
int test2() {
return 2;
}
int test3(int a) {
return a + 1;
}
class test_class : public util::LuaClass {
public:
static void export_me(util::Lua& vm) {
vm.export_class<test_class>();
}
static void export_class(util::Lua& vm) {
vm.export_constructor<test_class>();
vm.export_method("test", &test_class::test);
vm.export_method("test1", &test_class::test1);
vm.export_method("test2", &test_class::test2);
vm.export_method("test3", &test_class::test3);
}
static const std::string class_name() {
return "test_class";
}
void test() {
std::cout << "Hello, world [test_class]" << std::endl;
}
int test1() {
return 1;
}
int test2(int a) {
return a*2;
}
void test3(int a) {
std::cout << a << std::endl;
}
};
int main(int argc, char *argv[]) {
util::Lua l;
l.export_function("test", &test);
l.export_function("test1", &test1);
l.export_function("test2", &test2);
l.export_function("test3", &test3);
test_class::export_me(l);
l.file("test.lua");
return 0;
}