diff options
author | Diego Nehab <diego.nehab@gmail.com> | 2012-04-16 20:41:48 +0800 |
---|---|---|
committer | Diego Nehab <diego.nehab@gmail.com> | 2012-04-16 20:41:48 +0800 |
commit | b3c4f46179ed5b27ca76a824f8730fa50dbaae0b (patch) | |
tree | b5056d95f3307c49d942262387bba2ec3c949451 | |
parent | 4b671f4551e98ac9e1d9a7407d3dffdd7eb1d3dc (diff) | |
download | luasocket-b3c4f46179ed5b27ca76a824f8730fa50dbaae0b.tar.gz luasocket-b3c4f46179ed5b27ca76a824f8730fa50dbaae0b.tar.bz2 luasocket-b3c4f46179ed5b27ca76a824f8730fa50dbaae0b.zip |
merged lua_typerrror.{c,h} into auxiliar.{c,h}
-rw-r--r-- | TODO | 37 | ||||
-rw-r--r-- | src/auxiliar.c | 14 | ||||
-rw-r--r-- | src/auxiliar.h | 1 | ||||
-rw-r--r-- | src/lua_typeerror.c | 10 | ||||
-rw-r--r-- | src/lua_typeerror.h | 7 | ||||
-rw-r--r-- | src/makefile | 14 | ||||
-rw-r--r-- | src/options.c | 5 |
7 files changed, 58 insertions, 30 deletions
@@ -1,3 +1,40 @@ | |||
1 | - merge luaL_typeerror into auxiliar to avoid using luaL prefix? | ||
2 | - document ipv5_v6only default option being set? | ||
3 | - document bind and connect behavior based on address? | ||
4 | - document tcp6 and udp6 | ||
5 | - document dns.getaddrinfo | ||
6 | - check getaddrinfo's output format | ||
7 | - add functionality to query if object is ipv4 or 6? | ||
8 | - normalize error messages to have all first capitals or not? | ||
9 | - what is this lua_Reg vs lua_reg business? | ||
10 | what is this putchar vs addchar business? | ||
11 | is this the compat-5.2 stuff? | ||
12 | - why 2.1.1 rather than 2.1? | ||
13 | - update copyright date everywhere? | ||
14 | - what to do about author? | ||
15 | - any chance we can do without the compat for the final release? | ||
16 | - are only _API symbols being exported now? | ||
17 | it used to export all externs... | ||
18 | - document zero-sized send on udp vs. tcp? | ||
19 | - add http POST sample to manual | ||
20 | people keep asking stupid questions | ||
21 | - document unix socket and serial socket? add raw support? | ||
22 | if so, add tests? | ||
23 | - make sure unix conforms to tcp and udp style | ||
24 | - make sure serial conforms to tcp and udp style | ||
25 | does it need to use write/read instead of send/receive? | ||
26 | - documentation of dirty/getfd/setfd is problematic because of portability | ||
27 | same for unix and serial. | ||
28 | what to do about this? add a stronger disclaimer? | ||
29 | - nice getoption! | ||
30 | prefix all setters with set_ and all getters with get_? | ||
31 | - add what's new to manual | ||
32 | - remove references to Lua 5.0 from documentation, add 5.2? | ||
33 | - update lua and luasocket version in samples in documentation | ||
34 | - document headers.lua? | ||
35 | - fix makefile with decent defaults? | ||
36 | |||
37 | |||
1 | replace \r\n with \0xD\0xA in everything | 38 | replace \r\n with \0xD\0xA in everything |
2 | New mime support | 39 | New mime support |
3 | 40 | ||
diff --git a/src/auxiliar.c b/src/auxiliar.c index 3396fc1..c4e5260 100644 --- a/src/auxiliar.c +++ b/src/auxiliar.c | |||
@@ -8,7 +8,6 @@ | |||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | 9 | ||
10 | #include "auxiliar.h" | 10 | #include "auxiliar.h" |
11 | #include "lua_typeerror.h" | ||
12 | 11 | ||
13 | /*=========================================================================*\ | 12 | /*=========================================================================*\ |
14 | * Exported functions | 13 | * Exported functions |
@@ -82,7 +81,7 @@ void auxiliar_add2group(lua_State *L, const char *classname, const char *groupna | |||
82 | \*-------------------------------------------------------------------------*/ | 81 | \*-------------------------------------------------------------------------*/ |
83 | int auxiliar_checkboolean(lua_State *L, int objidx) { | 82 | int auxiliar_checkboolean(lua_State *L, int objidx) { |
84 | if (!lua_isboolean(L, objidx)) | 83 | if (!lua_isboolean(L, objidx)) |
85 | luaL_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN)); | 84 | auxiliar_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN)); |
86 | return lua_toboolean(L, objidx); | 85 | return lua_toboolean(L, objidx); |
87 | } | 86 | } |
88 | 87 | ||
@@ -148,3 +147,14 @@ void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) { | |||
148 | void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) { | 147 | void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) { |
149 | return luaL_checkudata(L, objidx, classname); | 148 | return luaL_checkudata(L, objidx, classname); |
150 | } | 149 | } |
150 | |||
151 | /*-------------------------------------------------------------------------*\ | ||
152 | * Throws error when argument does not have correct type. | ||
153 | * Used to be part of lauxlib in Lua 5.1, was dropped from 5.2. | ||
154 | \*-------------------------------------------------------------------------*/ | ||
155 | int auxiliar_typeerror (lua_State *L, int narg, const char *tname) { | ||
156 | const char *msg = lua_pushfstring(L, "%s expected, got %s", tname, | ||
157 | luaL_typename(L, narg)); | ||
158 | return luaL_argerror(L, narg, msg); | ||
159 | } | ||
160 | |||
diff --git a/src/auxiliar.h b/src/auxiliar.h index c53b39e..ea99013 100644 --- a/src/auxiliar.h +++ b/src/auxiliar.h | |||
@@ -42,5 +42,6 @@ void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx); | |||
42 | void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx); | 42 | void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx); |
43 | int auxiliar_checkboolean(lua_State *L, int objidx); | 43 | int auxiliar_checkboolean(lua_State *L, int objidx); |
44 | int auxiliar_tostring(lua_State *L); | 44 | int auxiliar_tostring(lua_State *L); |
45 | int auxiliar_typeerror(lua_State *L, int narg, const char *tname); | ||
45 | 46 | ||
46 | #endif /* AUXILIAR_H */ | 47 | #endif /* AUXILIAR_H */ |
diff --git a/src/lua_typeerror.c b/src/lua_typeerror.c deleted file mode 100644 index d6a3d76..0000000 --- a/src/lua_typeerror.c +++ /dev/null | |||
@@ -1,10 +0,0 @@ | |||
1 | #include "lua_typeerror.h" | ||
2 | #include "lua.h" | ||
3 | #include "lauxlib.h" | ||
4 | |||
5 | int luaL_typeerror (lua_State *L, int narg, const char *tname) | ||
6 | { | ||
7 | const char *msg = lua_pushfstring(L, "%s expected, got %s",tname, luaL_typename(L, narg)); | ||
8 | return luaL_argerror(L, narg, msg); | ||
9 | } | ||
10 | |||
diff --git a/src/lua_typeerror.h b/src/lua_typeerror.h deleted file mode 100644 index 4f2aafd..0000000 --- a/src/lua_typeerror.h +++ /dev/null | |||
@@ -1,7 +0,0 @@ | |||
1 | #ifndef LUA_TYPEERROR_H_ | ||
2 | #define LUA_TYPEERROR_H_ | ||
3 | |||
4 | struct lua_State; | ||
5 | int luaL_typeerror (struct lua_State *L, int narg, const char *tname); | ||
6 | |||
7 | #endif | ||
diff --git a/src/makefile b/src/makefile index a38ff98..0665c14 100644 --- a/src/makefile +++ b/src/makefile | |||
@@ -1,10 +1,11 @@ | |||
1 | PLAT?=macosx | 1 | PLAT?=macosx |
2 | LUAV?=5.1 | 2 | LUAV?=5.1 |
3 | prefix=/usr/local | 3 | prefix=../../../build/lua/$(LUAV) |
4 | #prefix=/usr/local | ||
4 | #prefix=/opt/local | 5 | #prefix=/opt/local |
5 | #prefix=. | 6 | #prefix=. |
6 | 7 | ||
7 | LUAINC_macosx=/usr/local/include | 8 | LUAINC_macosx=../../../build/lua/$(LUAV)/include |
8 | #LUAINC_macosx=/opt/local/include | 9 | #LUAINC_macosx=/opt/local/include |
9 | #LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.2.0-beta/src | 10 | #LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.2.0-beta/src |
10 | #LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.1.4/src | 11 | #LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.1.4/src |
@@ -131,8 +132,7 @@ SOCKET_OBJS= \ | |||
131 | except.$(O) \ | 132 | except.$(O) \ |
132 | select.$(O) \ | 133 | select.$(O) \ |
133 | tcp.$(O) \ | 134 | tcp.$(O) \ |
134 | udp.$(O) \ | 135 | udp.$(O) |
135 | lua_typeerror.$(O) | ||
136 | 136 | ||
137 | #------ | 137 | #------ |
138 | # Modules belonging mime-core | 138 | # Modules belonging mime-core |
@@ -150,8 +150,7 @@ UNIX_OBJS=\ | |||
150 | timeout.$(O) \ | 150 | timeout.$(O) \ |
151 | io.$(O) \ | 151 | io.$(O) \ |
152 | usocket.$(O) \ | 152 | usocket.$(O) \ |
153 | unix.$(O) \ | 153 | unix.$(O) |
154 | lua_typeerror.$(O) | ||
155 | 154 | ||
156 | #------ | 155 | #------ |
157 | # Modules belonging to serial (device streams) | 156 | # Modules belonging to serial (device streams) |
@@ -163,8 +162,7 @@ SERIAL_OBJS:=\ | |||
163 | timeout.$(O) \ | 162 | timeout.$(O) \ |
164 | io.$(O) \ | 163 | io.$(O) \ |
165 | usocket.$(O) \ | 164 | usocket.$(O) \ |
166 | serial.$(O) \ | 165 | serial.$(O) |
167 | lua_typeerror.$(O) | ||
168 | 166 | ||
169 | #------ | 167 | #------ |
170 | # Files to install | 168 | # Files to install |
diff --git a/src/options.c b/src/options.c index ab9e621..c122ead 100644 --- a/src/options.c +++ b/src/options.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include "auxiliar.h" | 11 | #include "auxiliar.h" |
12 | #include "options.h" | 12 | #include "options.h" |
13 | #include "inet.h" | 13 | #include "inet.h" |
14 | #include "lua_typeerror.h" | ||
15 | 14 | ||
16 | /*=========================================================================*\ | 15 | /*=========================================================================*\ |
17 | * Internal functions prototypes | 16 | * Internal functions prototypes |
@@ -122,7 +121,7 @@ int opt_get_ip_multicast_loop(lua_State *L, p_socket ps) | |||
122 | int opt_set_linger(lua_State *L, p_socket ps) | 121 | int opt_set_linger(lua_State *L, p_socket ps) |
123 | { | 122 | { |
124 | struct linger li; /* obj, name, table */ | 123 | struct linger li; /* obj, name, table */ |
125 | if (!lua_istable(L, 3)) luaL_typeerror(L, 3, lua_typename(L, LUA_TTABLE)); | 124 | if (!lua_istable(L, 3)) auxiliar_typeerror(L,3,lua_typename(L, LUA_TTABLE)); |
126 | lua_pushstring(L, "on"); | 125 | lua_pushstring(L, "on"); |
127 | lua_gettable(L, 3); | 126 | lua_gettable(L, 3); |
128 | if (!lua_isboolean(L, -1)) | 127 | if (!lua_isboolean(L, -1)) |
@@ -203,7 +202,7 @@ int opt_set_ip6_v6only(lua_State *L, p_socket ps) | |||
203 | static int opt_setmembership(lua_State *L, p_socket ps, int level, int name) | 202 | static int opt_setmembership(lua_State *L, p_socket ps, int level, int name) |
204 | { | 203 | { |
205 | struct ip_mreq val; /* obj, name, table */ | 204 | struct ip_mreq val; /* obj, name, table */ |
206 | if (!lua_istable(L, 3)) luaL_typeerror(L, 3, lua_typename(L, LUA_TTABLE)); | 205 | if (!lua_istable(L, 3)) auxiliar_typeerror(L,3,lua_typename(L, LUA_TTABLE)); |
207 | lua_pushstring(L, "multiaddr"); | 206 | lua_pushstring(L, "multiaddr"); |
208 | lua_gettable(L, 3); | 207 | lua_gettable(L, 3); |
209 | if (!lua_isstring(L, -1)) | 208 | if (!lua_isstring(L, -1)) |