Example #1]
Lua Code
aaa = {}
aaa.str = "test"
aaa.i = 10
test_struct(aaa)
aaa.str = "test"
aaa.i = 10
test_struct(aaa)
C++ Code
struct work {
char *str;
int i;
};
void test_struct(lua_tinker::table a)
{
work b;
strcpy(b.str, a.get<const char*>("str");
b.i = a.get<int>("i");
printf("%s, %d\n", b.str, b.i);
}
char *str;
int i;
};
void test_struct(lua_tinker::table a)
{
work b;
strcpy(b.str, a.get<const char*>("str");
b.i = a.get<int>("i");
printf("%s, %d\n", b.str, b.i);
}
Example #2]
Lua Code
test_func({"first", "second"})
C++ Code
template<typename>
void set(int index, T object)
{
m_obj->set(index, object);
}
template<typename>
T get(int index)
{
return m_obj->get<t>(index);
}
void test_func(lua_tinker::table test)
{
printf("%s, %s\n", test.get<const char*>(1), test.get<const char*>(2));
}
void set(int index, T object)
{
m_obj->set(index, object);
}
template<typename>
T get(int index)
{
return m_obj->get<t>(index);
}
void test_func(lua_tinker::table test)
{
printf("%s, %s\n", test.get<const char*>(1), test.get<const char*>(2));
}
LuaThinker 마지막 버전의 Sample3.cpp / Sample3.Lua 파일도 도움이 됨.