diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-10-07 04:40:59 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-10-07 04:40:59 +0000 |
commit | f4dadea763c1959a27dead24df3ee6c54c209842 (patch) | |
tree | c13b294a8ca5438d59b60e3f5a25a4f7c1fc9a1b /src/auxiliar.c | |
parent | 562d8cceb704a96a7b2f9acc4bc229ab9f5c6541 (diff) | |
download | luasocket-f4dadea763c1959a27dead24df3ee6c54c209842.tar.gz luasocket-f4dadea763c1959a27dead24df3ee6c54c209842.tar.bz2 luasocket-f4dadea763c1959a27dead24df3ee6c54c209842.zip |
Before compiling on Windows.
Diffstat (limited to 'src/auxiliar.c')
-rw-r--r-- | src/auxiliar.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/src/auxiliar.c b/src/auxiliar.c index b228785..fcc7e23 100644 --- a/src/auxiliar.c +++ b/src/auxiliar.c | |||
@@ -15,7 +15,7 @@ | |||
15 | /*-------------------------------------------------------------------------*\ | 15 | /*-------------------------------------------------------------------------*\ |
16 | * Initializes the module | 16 | * Initializes the module |
17 | \*-------------------------------------------------------------------------*/ | 17 | \*-------------------------------------------------------------------------*/ |
18 | int aux_open(lua_State *L) { | 18 | int auxiliar_open(lua_State *L) { |
19 | (void) L; | 19 | (void) L; |
20 | return 0; | 20 | return 0; |
21 | } | 21 | } |
@@ -24,7 +24,7 @@ int aux_open(lua_State *L) { | |||
24 | * Creates a new class with given methods | 24 | * Creates a new class with given methods |
25 | * Methods whose names start with __ are passed directly to the metatable. | 25 | * Methods whose names start with __ are passed directly to the metatable. |
26 | \*-------------------------------------------------------------------------*/ | 26 | \*-------------------------------------------------------------------------*/ |
27 | void aux_newclass(lua_State *L, const char *classname, luaL_reg *func) { | 27 | void auxiliar_newclass(lua_State *L, const char *classname, luaL_reg *func) { |
28 | luaL_newmetatable(L, classname); /* mt */ | 28 | luaL_newmetatable(L, classname); /* mt */ |
29 | /* create __index table to place methods */ | 29 | /* create __index table to place methods */ |
30 | lua_pushstring(L, "__index"); /* mt,"__index" */ | 30 | lua_pushstring(L, "__index"); /* mt,"__index" */ |
@@ -47,7 +47,7 @@ void aux_newclass(lua_State *L, const char *classname, luaL_reg *func) { | |||
47 | /*-------------------------------------------------------------------------*\ | 47 | /*-------------------------------------------------------------------------*\ |
48 | * Prints the value of a class in a nice way | 48 | * Prints the value of a class in a nice way |
49 | \*-------------------------------------------------------------------------*/ | 49 | \*-------------------------------------------------------------------------*/ |
50 | int aux_tostring(lua_State *L) { | 50 | int auxiliar_tostring(lua_State *L) { |
51 | char buf[32]; | 51 | char buf[32]; |
52 | if (!lua_getmetatable(L, 1)) goto error; | 52 | if (!lua_getmetatable(L, 1)) goto error; |
53 | lua_pushstring(L, "__index"); | 53 | lua_pushstring(L, "__index"); |
@@ -68,7 +68,7 @@ error: | |||
68 | /*-------------------------------------------------------------------------*\ | 68 | /*-------------------------------------------------------------------------*\ |
69 | * Insert class into group | 69 | * Insert class into group |
70 | \*-------------------------------------------------------------------------*/ | 70 | \*-------------------------------------------------------------------------*/ |
71 | void aux_add2group(lua_State *L, const char *classname, const char *groupname) { | 71 | void auxiliar_add2group(lua_State *L, const char *classname, const char *groupname) { |
72 | luaL_getmetatable(L, classname); | 72 | luaL_getmetatable(L, classname); |
73 | lua_pushstring(L, groupname); | 73 | lua_pushstring(L, groupname); |
74 | lua_pushboolean(L, 1); | 74 | lua_pushboolean(L, 1); |
@@ -79,7 +79,7 @@ void aux_add2group(lua_State *L, const char *classname, const char *groupname) { | |||
79 | /*-------------------------------------------------------------------------*\ | 79 | /*-------------------------------------------------------------------------*\ |
80 | * Make sure argument is a boolean | 80 | * Make sure argument is a boolean |
81 | \*-------------------------------------------------------------------------*/ | 81 | \*-------------------------------------------------------------------------*/ |
82 | int aux_checkboolean(lua_State *L, int objidx) { | 82 | int auxiliar_checkboolean(lua_State *L, int objidx) { |
83 | if (!lua_isboolean(L, objidx)) | 83 | if (!lua_isboolean(L, objidx)) |
84 | luaL_typerror(L, objidx, lua_typename(L, LUA_TBOOLEAN)); | 84 | luaL_typerror(L, objidx, lua_typename(L, LUA_TBOOLEAN)); |
85 | return lua_toboolean(L, objidx); | 85 | return lua_toboolean(L, objidx); |
@@ -89,8 +89,8 @@ int aux_checkboolean(lua_State *L, int objidx) { | |||
89 | * Return userdata pointer if object belongs to a given class, abort with | 89 | * Return userdata pointer if object belongs to a given class, abort with |
90 | * error otherwise | 90 | * error otherwise |
91 | \*-------------------------------------------------------------------------*/ | 91 | \*-------------------------------------------------------------------------*/ |
92 | void *aux_checkclass(lua_State *L, const char *classname, int objidx) { | 92 | void *auxiliar_checkclass(lua_State *L, const char *classname, int objidx) { |
93 | void *data = aux_getclassudata(L, classname, objidx); | 93 | void *data = auxiliar_getclassudata(L, classname, objidx); |
94 | if (!data) { | 94 | if (!data) { |
95 | char msg[45]; | 95 | char msg[45]; |
96 | sprintf(msg, "%.35s expected", classname); | 96 | sprintf(msg, "%.35s expected", classname); |
@@ -103,8 +103,8 @@ void *aux_checkclass(lua_State *L, const char *classname, int objidx) { | |||
103 | * Return userdata pointer if object belongs to a given group, abort with | 103 | * Return userdata pointer if object belongs to a given group, abort with |
104 | * error otherwise | 104 | * error otherwise |
105 | \*-------------------------------------------------------------------------*/ | 105 | \*-------------------------------------------------------------------------*/ |
106 | void *aux_checkgroup(lua_State *L, const char *groupname, int objidx) { | 106 | void *auxiliar_checkgroup(lua_State *L, const char *groupname, int objidx) { |
107 | void *data = aux_getgroupudata(L, groupname, objidx); | 107 | void *data = auxiliar_getgroupudata(L, groupname, objidx); |
108 | if (!data) { | 108 | if (!data) { |
109 | char msg[45]; | 109 | char msg[45]; |
110 | sprintf(msg, "%.35s expected", groupname); | 110 | sprintf(msg, "%.35s expected", groupname); |
@@ -116,7 +116,7 @@ void *aux_checkgroup(lua_State *L, const char *groupname, int objidx) { | |||
116 | /*-------------------------------------------------------------------------*\ | 116 | /*-------------------------------------------------------------------------*\ |
117 | * Set object class | 117 | * Set object class |
118 | \*-------------------------------------------------------------------------*/ | 118 | \*-------------------------------------------------------------------------*/ |
119 | void aux_setclass(lua_State *L, const char *classname, int objidx) { | 119 | void auxiliar_setclass(lua_State *L, const char *classname, int objidx) { |
120 | luaL_getmetatable(L, classname); | 120 | luaL_getmetatable(L, classname); |
121 | if (objidx < 0) objidx--; | 121 | if (objidx < 0) objidx--; |
122 | lua_setmetatable(L, objidx); | 122 | lua_setmetatable(L, objidx); |
@@ -126,10 +126,7 @@ void aux_setclass(lua_State *L, const char *classname, int objidx) { | |||
126 | * Get a userdata pointer if object belongs to a given group. Return NULL | 126 | * Get a userdata pointer if object belongs to a given group. Return NULL |
127 | * otherwise | 127 | * otherwise |
128 | \*-------------------------------------------------------------------------*/ | 128 | \*-------------------------------------------------------------------------*/ |
129 | void *aux_getgroupudata(lua_State *L, const char *groupname, int objidx) { | 129 | void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) { |
130 | #if 0 | ||
131 | return lua_touserdata(L, objidx); | ||
132 | #else | ||
133 | if (!lua_getmetatable(L, objidx)) | 130 | if (!lua_getmetatable(L, objidx)) |
134 | return NULL; | 131 | return NULL; |
135 | lua_pushstring(L, groupname); | 132 | lua_pushstring(L, groupname); |
@@ -141,17 +138,12 @@ void *aux_getgroupudata(lua_State *L, const char *groupname, int objidx) { | |||
141 | lua_pop(L, 2); | 138 | lua_pop(L, 2); |
142 | return lua_touserdata(L, objidx); | 139 | return lua_touserdata(L, objidx); |
143 | } | 140 | } |
144 | #endif | ||
145 | } | 141 | } |
146 | 142 | ||
147 | /*-------------------------------------------------------------------------*\ | 143 | /*-------------------------------------------------------------------------*\ |
148 | * Get a userdata pointer if object belongs to a given class. Return NULL | 144 | * Get a userdata pointer if object belongs to a given class. Return NULL |
149 | * otherwise | 145 | * otherwise |
150 | \*-------------------------------------------------------------------------*/ | 146 | \*-------------------------------------------------------------------------*/ |
151 | void *aux_getclassudata(lua_State *L, const char *classname, int objidx) { | 147 | void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) { |
152 | #if 0 | ||
153 | return lua_touserdata(L, objidx); | ||
154 | #else | ||
155 | return luaL_checkudata(L, objidx, classname); | 148 | return luaL_checkudata(L, objidx, classname); |
156 | #endif | ||
157 | } | 149 | } |