Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lua script to C++ code

Tags:

c

stack

lua

I am writing C functions for Lua. I have many calls like lua_gettable, lua_touserdata, etc

My C function may receive complex structures like table with tables as fields.

It is hard for me to program stacked machine.

Is there way to write Lua script that would be converted to C code.

Or some other tools that may help me to code such C functions for lua scripts.

Thanks.

PS

Here is example:-

local data = {}
data.x = {}
data.x.y = 1
myCfunc(data)

int myCfunc(lua_State * L){
 lua_pushstring(L, "x");
 lua_gettable(L, 2);
 lua_pushstring(L, "y");
 lua_gettable(L, -2);
 double y = lua_tonumber(L, -1);
 lua_pop(L, 2);
}

instead of

function myCfunc(data)
 y = data.x.y
end

My real code is much more complex and I am looking for some automated code generation that will help me.

like image 787
Max Avatar asked Oct 31 '25 08:10

Max


1 Answers

Try LuaToCee.

like image 56
lhf Avatar answered Nov 03 '25 03:11

lhf