webmcp

diff libraries/mondelefant/mondelefant_native.c @ 440:66d7a0ac9c9d

Allow <db_handle>:create_list(...) to create a non-empty list by passing a table as argument (needed for references)
author jbe
date Tue Feb 09 20:09:34 2016 +0100 (2016-02-09)
parents 1dbbe4c62f08
children 07e7e218d8df
line diff
     1.1 --- a/libraries/mondelefant/mondelefant_native.c	Fri Feb 05 01:26:00 2016 +0100
     1.2 +++ b/libraries/mondelefant/mondelefant_native.c	Tue Feb 09 20:09:34 2016 +0100
     1.3 @@ -534,9 +534,14 @@
     1.4  static int mondelefant_conn_create_list(lua_State *L) {
     1.5    // ensure that first argument is a database connection:
     1.6    luaL_checkudata(L, 1, MONDELEFANT_CONN_MT_REGKEY);
     1.7 -  // create new table on stack position 2:
     1.8 -  lua_settop(L, 1);
     1.9 -  lua_newtable(L);  // 2
    1.10 +  // if no second argument is given, use an empty table:
    1.11 +  if (lua_isnoneornil(L, 2)) {
    1.12 +    lua_settop(L, 1);
    1.13 +    lua_newtable(L);  // 2
    1.14 +  } else {
    1.15 +    luaL_checktype(L, 2, LUA_TTABLE);
    1.16 +    lua_settop(L, 2);
    1.17 +  }
    1.18    // set meta-table for database result lists/objects:
    1.19    luaL_setmetatable(L, MONDELEFANT_RESULT_MT_REGKEY);
    1.20    // set "_connection" attribute to self:

Impressum / About Us