- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbind_test.cpp
More file actions
Latest commit
74 lines (59 loc) · 1.18 KB
/
Copy pathbind_test.cpp
File metadata and controls
74 lines (59 loc) · 1.18 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
74
#include<lua.hpp>
#include<luabind/lua_include.hpp>
#include<luabind/luabind.hpp>
voidhoge(constint num)
{
printf("%d\n", num);
}
enumSTAGE
{
FIRST,
SECOND,
THIRD,
};
classoya
{
public:
int a_;
oya() { a_ = 0; }
};
classko : publicoya
{
public:
int b_;
ko() { b_ = a_; }
ko operator+(constint _s)
{
this->b_ += _s;
return *this;
}
};
voidmain()
{
lua_State* L = luaL_newstate();
luaL_openlibs(L);
// luabindを開く
luabind::open(L);
luabind::module(L)
[
luabind::def("hoge", &hoge),
luabind::class_<STAGE>("STAGE").enum_("constants")
[
luabind::value("FIRST", STAGE::FIRST),
luabind::value("SECOND", STAGE::SECOND),
luabind::value("THIRD", STAGE::THIRD)
],
luabind::class_<ko>("ko")
.def(luabind::constructor<>())
.def_readwrite("a_", &ko::a_)
.def_readwrite("b_", &ko::b_)
.def(luabind::self + (constint()) )
];
// Luaスクリプトを開く
if (luaL_loadfile(L, "test.lua") || lua_pcall(L, 0, 0, 0))
{
perror(lua_tostring(L, -1));
}
lua_close(L);
getchar();
}