diff options
author | Diego Nehab <diego.nehab@gmail.com> | 2015-08-21 15:39:34 -0300 |
---|---|---|
committer | Diego Nehab <diego.nehab@gmail.com> | 2015-08-21 15:39:34 -0300 |
commit | e75444ccd1f30a3b5fbc7cec4a85e831bd0560ed (patch) | |
tree | 71475c18fee070c770fc0fe25d0859b7d54c8fbb /src/auxiliar.c | |
parent | 321c0c9b1f7b6b83cd83b58e7e259f53eca69373 (diff) | |
download | luasocket-e75444ccd1f30a3b5fbc7cec4a85e831bd0560ed.tar.gz luasocket-e75444ccd1f30a3b5fbc7cec4a85e831bd0560ed.tar.bz2 luasocket-e75444ccd1f30a3b5fbc7cec4a85e831bd0560ed.zip |
New compat.h module implements luaL_setfuncs.
Makes initialization code simpler everywhere.
Diffstat (limited to 'src/auxiliar.c')
-rw-r--r-- | src/auxiliar.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/auxiliar.c b/src/auxiliar.c index de625e9..18fa8e4 100644 --- a/src/auxiliar.c +++ b/src/auxiliar.c | |||
@@ -26,7 +26,7 @@ void auxiliar_newclass(lua_State *L, const char *classname, luaL_Reg *func) { | |||
26 | luaL_newmetatable(L, classname); /* mt */ | 26 | luaL_newmetatable(L, classname); /* mt */ |
27 | /* create __index table to place methods */ | 27 | /* create __index table to place methods */ |
28 | lua_pushstring(L, "__index"); /* mt,"__index" */ | 28 | lua_pushstring(L, "__index"); /* mt,"__index" */ |
29 | lua_newtable(L); /* mt,"__index",it */ | 29 | lua_newtable(L); /* mt,"__index",it */ |
30 | /* put class name into class metatable */ | 30 | /* put class name into class metatable */ |
31 | lua_pushstring(L, "class"); /* mt,"__index",it,"class" */ | 31 | lua_pushstring(L, "class"); /* mt,"__index",it,"class" */ |
32 | lua_pushstring(L, classname); /* mt,"__index",it,"class",classname */ | 32 | lua_pushstring(L, classname); /* mt,"__index",it,"class",classname */ |
@@ -84,7 +84,7 @@ int auxiliar_checkboolean(lua_State *L, int objidx) { | |||
84 | } | 84 | } |
85 | 85 | ||
86 | /*-------------------------------------------------------------------------*\ | 86 | /*-------------------------------------------------------------------------*\ |
87 | * Return userdata pointer if object belongs to a given class, abort with | 87 | * Return userdata pointer if object belongs to a given class, abort with |
88 | * error otherwise | 88 | * error otherwise |
89 | \*-------------------------------------------------------------------------*/ | 89 | \*-------------------------------------------------------------------------*/ |
90 | void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx) { | 90 | void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx) { |
@@ -98,7 +98,7 @@ void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx) { | |||
98 | } | 98 | } |
99 | 99 | ||
100 | /*-------------------------------------------------------------------------*\ | 100 | /*-------------------------------------------------------------------------*\ |
101 | * Return userdata pointer if object belongs to a given group, abort with | 101 | * Return userdata pointer if object belongs to a given group, abort with |
102 | * error otherwise | 102 | * error otherwise |
103 | \*-------------------------------------------------------------------------*/ | 103 | \*-------------------------------------------------------------------------*/ |
104 | void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx) { | 104 | void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx) { |
@@ -121,7 +121,7 @@ void auxiliar_setclass(lua_State *L, const char *classname, int objidx) { | |||
121 | } | 121 | } |
122 | 122 | ||
123 | /*-------------------------------------------------------------------------*\ | 123 | /*-------------------------------------------------------------------------*\ |
124 | * Get a userdata pointer if object belongs to a given group. Return NULL | 124 | * Get a userdata pointer if object belongs to a given group. Return NULL |
125 | * otherwise | 125 | * otherwise |
126 | \*-------------------------------------------------------------------------*/ | 126 | \*-------------------------------------------------------------------------*/ |
127 | void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) { | 127 | void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) { |
@@ -139,7 +139,7 @@ void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) { | |||
139 | } | 139 | } |
140 | 140 | ||
141 | /*-------------------------------------------------------------------------*\ | 141 | /*-------------------------------------------------------------------------*\ |
142 | * Get a userdata pointer if object belongs to a given class. Return NULL | 142 | * Get a userdata pointer if object belongs to a given class. Return NULL |
143 | * otherwise | 143 | * otherwise |
144 | \*-------------------------------------------------------------------------*/ | 144 | \*-------------------------------------------------------------------------*/ |
145 | void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) { | 145 | void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) { |
@@ -151,7 +151,7 @@ void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) { | |||
151 | * Used to be part of lauxlib in Lua 5.1, was dropped from 5.2. | 151 | * Used to be part of lauxlib in Lua 5.1, was dropped from 5.2. |
152 | \*-------------------------------------------------------------------------*/ | 152 | \*-------------------------------------------------------------------------*/ |
153 | int auxiliar_typeerror (lua_State *L, int narg, const char *tname) { | 153 | int auxiliar_typeerror (lua_State *L, int narg, const char *tname) { |
154 | const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, | 154 | const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, |
155 | luaL_typename(L, narg)); | 155 | luaL_typename(L, narg)); |
156 | return luaL_argerror(L, narg, msg); | 156 | return luaL_argerror(L, narg, msg); |
157 | } | 157 | } |