Lua接口全自动生成工具,支持指针、自定义数据类型。
double* testFunc(float* n1, int n2, const char* str);
static int Lua_testFunc(lua_State* L)
{
/* get params from lua */
float n1 = luaL_checknumber(L, 1);
int n2 = luaL_checkinteger(L, 2);
const char* str = luaL_checkstring(L, 3);
/* call c function */
double testFunc_retval = *testFunc(&n1, n2, str);
/* push c function return value to lua */
lua_pushnumber(L, testFunc_retval);
return 1;
}
value = testFunc(3.14, 2, "hello C2Lua")
print(value)