webmcp

changeset 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 29b1f7a04934
children 839ff2b8d9f8 76ceed10d65b
files libraries/mondelefant/mondelefant_native.autodoc.lua libraries/mondelefant/mondelefant_native.c
line diff
     1.1 --- a/libraries/mondelefant/mondelefant_native.autodoc.lua	Fri Feb 05 01:26:00 2016 +0100
     1.2 +++ b/libraries/mondelefant/mondelefant_native.autodoc.lua	Tue Feb 09 20:09:34 2016 +0100
     1.3 @@ -93,10 +93,12 @@
     1.4  
     1.5  
     1.6  --[[--
     1.7 -db_list =                  -- database result being an empty list
     1.8 -<db_handle>:create_list()
     1.9 +db_list =                  -- database result being an empty list (or filled list)
    1.10 +<db_handle>:create_list(
    1.11 +  tbl                      -- optional table to be converted to a filled list
    1.12 +)
    1.13  
    1.14 -Creates an empty database result representing a list. The used meta-table is "result_metatable". The attribute "_connection" is set to the database handle, and the attribute "_type" is set to "list". The attribute "_class" is initialized to the default class prototype "class_prototype" of the module.
    1.15 +Creates a database result representing a list. The used meta-table is "result_metatable". The attribute "_connection" is set to the database handle, and the attribute "_type" is set to "list". The attribute "_class" is initialized to the default class prototype "class_prototype" of the module.
    1.16  
    1.17  --]]--
    1.18  -- implemented in mondelefant_native.c as
     2.1 --- a/libraries/mondelefant/mondelefant_native.c	Fri Feb 05 01:26:00 2016 +0100
     2.2 +++ b/libraries/mondelefant/mondelefant_native.c	Tue Feb 09 20:09:34 2016 +0100
     2.3 @@ -534,9 +534,14 @@
     2.4  static int mondelefant_conn_create_list(lua_State *L) {
     2.5    // ensure that first argument is a database connection:
     2.6    luaL_checkudata(L, 1, MONDELEFANT_CONN_MT_REGKEY);
     2.7 -  // create new table on stack position 2:
     2.8 -  lua_settop(L, 1);
     2.9 -  lua_newtable(L);  // 2
    2.10 +  // if no second argument is given, use an empty table:
    2.11 +  if (lua_isnoneornil(L, 2)) {
    2.12 +    lua_settop(L, 1);
    2.13 +    lua_newtable(L);  // 2
    2.14 +  } else {
    2.15 +    luaL_checktype(L, 2, LUA_TTABLE);
    2.16 +    lua_settop(L, 2);
    2.17 +  }
    2.18    // set meta-table for database result lists/objects:
    2.19    luaL_setmetatable(L, MONDELEFANT_RESULT_MT_REGKEY);
    2.20    // set "_connection" attribute to self:

Impressum / About Us