Software /
code /
prosody
Comparison
util-src/table.c @ 7889:b8d694646597
util-src/*.c: Attach pointer * to name instead of type
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 12 Feb 2017 16:42:29 +0100 |
parent | 7835:a809dcfd0c5b |
child | 7936:582bfb39337f |
comparison
equal
deleted
inserted
replaced
7888:74187ee6ed55 | 7889:b8d694646597 |
---|---|
1 #include <lua.h> | 1 #include <lua.h> |
2 #include <lauxlib.h> | 2 #include <lauxlib.h> |
3 | 3 |
4 static int Lcreate_table(lua_State* L) { | 4 static int Lcreate_table(lua_State *L) { |
5 lua_createtable(L, luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)); | 5 lua_createtable(L, luaL_checkinteger(L, 1), luaL_checkinteger(L, 2)); |
6 return 1; | 6 return 1; |
7 } | 7 } |
8 | 8 |
9 static int Lpack(lua_State* L) { | 9 static int Lpack(lua_State *L) { |
10 int arg; | 10 int arg; |
11 unsigned int n_args = lua_gettop(L); | 11 unsigned int n_args = lua_gettop(L); |
12 lua_createtable(L, n_args, 1); | 12 lua_createtable(L, n_args, 1); |
13 lua_insert(L, 1); | 13 lua_insert(L, 1); |
14 | |
14 for(arg = n_args; arg >= 1; arg--) { | 15 for(arg = n_args; arg >= 1; arg--) { |
15 lua_rawseti(L, 1, arg); | 16 lua_rawseti(L, 1, arg); |
16 } | 17 } |
18 | |
17 lua_pushinteger(L, n_args); | 19 lua_pushinteger(L, n_args); |
18 lua_setfield(L, -2, "n"); | 20 lua_setfield(L, -2, "n"); |
19 return 1; | 21 return 1; |
20 } | 22 } |
21 | 23 |
22 int luaopen_util_table(lua_State* L) { | 24 int luaopen_util_table(lua_State *L) { |
23 #if (LUA_VERSION_NUM > 501) | 25 #if (LUA_VERSION_NUM > 501) |
24 luaL_checkversion(L); | 26 luaL_checkversion(L); |
25 #endif | 27 #endif |
26 lua_newtable(L); | 28 lua_newtable(L); |
27 lua_pushcfunction(L, Lcreate_table); | 29 lua_pushcfunction(L, Lcreate_table); |