title: Lua script to C++ code
body: <p>I am writing C functions for Lua.
  I have many calls like lua_gettable, lua_touserdata, etc</p>
  
  <p>My C function may receive complex structures like table with tables as fields.</p>
  
  <p>It is hard for me to program stacked machine.</p>
  
  <p>Is there way to write Lua script that would be converted to C code.</p>
  
  <p>Or some other tools that may help me to code such C functions for lua scripts.</p>
  
  <p>Thanks.</p>
  
  <p>PS</p>
  
  <p>Here is example:-</p>
  
  <pre><code>local data = {}
  data.x = {}
  data.x.y = 1
  myCfunc(data)
  </code></pre>
  
  <hr>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>function myCfunc(data)
   y = data.x.y
  end
  </code></pre>
  
  <p>My real code is much more complex and I am looking for some 
  automated code generation that will help me.</p>