title: Any tips to reduce repetition when using Lua C functions
body: <p>I have a block of code that looks like this:</p>
  
  <pre><code>lua_newtable(L);
  
  lua_pushstring(L, "gid");
  lua_pushinteger(L, info[i].codepoint);
  lua_settable(L, -3);
  lua_pushstring(L, "cl");
  lua_pushinteger(L, info[i].cluster);
  lua_settable(L, -3);
  lua_pushstring(L, "ax");
  lua_pushnumber(L, pos[i].x_advance);
  lua_settable(L, -3);
  lua_pushstring(L, "ay");
  lua_pushnumber(L, pos[i].y_advance);
  lua_settable(L, -3);
  lua_pushstring(L, "dx");
  lua_pushnumber(L, pos[i].x_offset);
  lua_settable(L, -3);
  lua_pushstring(L, "dy");
  lua_pushnumber(L, pos[i].y_offset);
  lua_settable(L, -3);
  lua_pushstring(L, "w");
  lua_pushinteger(L, extents.width);
  lua_settable(L, -3);
  lua_pushstring(L, "h");
  lua_pushinteger(L, extents.height);
  lua_settable(L, -3);
  lua_pushstring(L, "yb");
  lua_pushinteger(L, extents.y_bearing);
  lua_settable(L, -3);
  lua_pushstring(L, "xb");
  lua_pushinteger(L, extents.x_bearing);
  lua_settable(L, -3);
  </code></pre>
  
  <p>What I am doing is just setting a few fields inside a table. The fields are either strings or numbers. Note how repetitive the code is.</p>
  
  <p>Is there a way to make this a bit cleaner, maybe using C macros?</p>