mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 20:38:22 +01:00
merged lua_typerrror.{c,h} into auxiliar.{c,h}
This commit is contained in:
parent
4b671f4551
commit
b3c4f46179
37
TODO
37
TODO
@ -1,3 +1,40 @@
|
|||||||
|
- merge luaL_typeerror into auxiliar to avoid using luaL prefix?
|
||||||
|
- document ipv5_v6only default option being set?
|
||||||
|
- document bind and connect behavior based on address?
|
||||||
|
- document tcp6 and udp6
|
||||||
|
- document dns.getaddrinfo
|
||||||
|
- check getaddrinfo's output format
|
||||||
|
- add functionality to query if object is ipv4 or 6?
|
||||||
|
- normalize error messages to have all first capitals or not?
|
||||||
|
- what is this lua_Reg vs lua_reg business?
|
||||||
|
what is this putchar vs addchar business?
|
||||||
|
is this the compat-5.2 stuff?
|
||||||
|
- why 2.1.1 rather than 2.1?
|
||||||
|
- update copyright date everywhere?
|
||||||
|
- what to do about author?
|
||||||
|
- any chance we can do without the compat for the final release?
|
||||||
|
- are only _API symbols being exported now?
|
||||||
|
it used to export all externs...
|
||||||
|
- document zero-sized send on udp vs. tcp?
|
||||||
|
- add http POST sample to manual
|
||||||
|
people keep asking stupid questions
|
||||||
|
- document unix socket and serial socket? add raw support?
|
||||||
|
if so, add tests?
|
||||||
|
- make sure unix conforms to tcp and udp style
|
||||||
|
- make sure serial conforms to tcp and udp style
|
||||||
|
does it need to use write/read instead of send/receive?
|
||||||
|
- documentation of dirty/getfd/setfd is problematic because of portability
|
||||||
|
same for unix and serial.
|
||||||
|
what to do about this? add a stronger disclaimer?
|
||||||
|
- nice getoption!
|
||||||
|
prefix all setters with set_ and all getters with get_?
|
||||||
|
- add what's new to manual
|
||||||
|
- remove references to Lua 5.0 from documentation, add 5.2?
|
||||||
|
- update lua and luasocket version in samples in documentation
|
||||||
|
- document headers.lua?
|
||||||
|
- fix makefile with decent defaults?
|
||||||
|
|
||||||
|
|
||||||
replace \r\n with \0xD\0xA in everything
|
replace \r\n with \0xD\0xA in everything
|
||||||
New mime support
|
New mime support
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "auxiliar.h"
|
#include "auxiliar.h"
|
||||||
#include "lua_typeerror.h"
|
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Exported functions
|
* Exported functions
|
||||||
@ -82,7 +81,7 @@ void auxiliar_add2group(lua_State *L, const char *classname, const char *groupna
|
|||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
int auxiliar_checkboolean(lua_State *L, int objidx) {
|
int auxiliar_checkboolean(lua_State *L, int objidx) {
|
||||||
if (!lua_isboolean(L, objidx))
|
if (!lua_isboolean(L, objidx))
|
||||||
luaL_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN));
|
auxiliar_typeerror(L, objidx, lua_typename(L, LUA_TBOOLEAN));
|
||||||
return lua_toboolean(L, objidx);
|
return lua_toboolean(L, objidx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,3 +147,14 @@ void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx) {
|
|||||||
void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) {
|
void *auxiliar_getclassudata(lua_State *L, const char *classname, int objidx) {
|
||||||
return luaL_checkudata(L, objidx, classname);
|
return luaL_checkudata(L, objidx, classname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*\
|
||||||
|
* Throws error when argument does not have correct type.
|
||||||
|
* Used to be part of lauxlib in Lua 5.1, was dropped from 5.2.
|
||||||
|
\*-------------------------------------------------------------------------*/
|
||||||
|
int auxiliar_typeerror (lua_State *L, int narg, const char *tname) {
|
||||||
|
const char *msg = lua_pushfstring(L, "%s expected, got %s", tname,
|
||||||
|
luaL_typename(L, narg));
|
||||||
|
return luaL_argerror(L, narg, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -42,5 +42,6 @@ void *auxiliar_getclassudata(lua_State *L, const char *groupname, int objidx);
|
|||||||
void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx);
|
void *auxiliar_getgroupudata(lua_State *L, const char *groupname, int objidx);
|
||||||
int auxiliar_checkboolean(lua_State *L, int objidx);
|
int auxiliar_checkboolean(lua_State *L, int objidx);
|
||||||
int auxiliar_tostring(lua_State *L);
|
int auxiliar_tostring(lua_State *L);
|
||||||
|
int auxiliar_typeerror(lua_State *L, int narg, const char *tname);
|
||||||
|
|
||||||
#endif /* AUXILIAR_H */
|
#endif /* AUXILIAR_H */
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
#include "lua_typeerror.h"
|
|
||||||
#include "lua.h"
|
|
||||||
#include "lauxlib.h"
|
|
||||||
|
|
||||||
int luaL_typeerror (lua_State *L, int narg, const char *tname)
|
|
||||||
{
|
|
||||||
const char *msg = lua_pushfstring(L, "%s expected, got %s",tname, luaL_typename(L, narg));
|
|
||||||
return luaL_argerror(L, narg, msg);
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
|||||||
#ifndef LUA_TYPEERROR_H_
|
|
||||||
#define LUA_TYPEERROR_H_
|
|
||||||
|
|
||||||
struct lua_State;
|
|
||||||
int luaL_typeerror (struct lua_State *L, int narg, const char *tname);
|
|
||||||
|
|
||||||
#endif
|
|
14
src/makefile
14
src/makefile
@ -1,10 +1,11 @@
|
|||||||
PLAT?=macosx
|
PLAT?=macosx
|
||||||
LUAV?=5.1
|
LUAV?=5.1
|
||||||
prefix=/usr/local
|
prefix=../../../build/lua/$(LUAV)
|
||||||
|
#prefix=/usr/local
|
||||||
#prefix=/opt/local
|
#prefix=/opt/local
|
||||||
#prefix=.
|
#prefix=.
|
||||||
|
|
||||||
LUAINC_macosx=/usr/local/include
|
LUAINC_macosx=../../../build/lua/$(LUAV)/include
|
||||||
#LUAINC_macosx=/opt/local/include
|
#LUAINC_macosx=/opt/local/include
|
||||||
#LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.2.0-beta/src
|
#LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.2.0-beta/src
|
||||||
#LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.1.4/src
|
#LUAINC_macosx=../../../../projects/lua_env/luaenv/lua_versions/lua-5.1.4/src
|
||||||
@ -131,8 +132,7 @@ SOCKET_OBJS= \
|
|||||||
except.$(O) \
|
except.$(O) \
|
||||||
select.$(O) \
|
select.$(O) \
|
||||||
tcp.$(O) \
|
tcp.$(O) \
|
||||||
udp.$(O) \
|
udp.$(O)
|
||||||
lua_typeerror.$(O)
|
|
||||||
|
|
||||||
#------
|
#------
|
||||||
# Modules belonging mime-core
|
# Modules belonging mime-core
|
||||||
@ -150,8 +150,7 @@ UNIX_OBJS=\
|
|||||||
timeout.$(O) \
|
timeout.$(O) \
|
||||||
io.$(O) \
|
io.$(O) \
|
||||||
usocket.$(O) \
|
usocket.$(O) \
|
||||||
unix.$(O) \
|
unix.$(O)
|
||||||
lua_typeerror.$(O)
|
|
||||||
|
|
||||||
#------
|
#------
|
||||||
# Modules belonging to serial (device streams)
|
# Modules belonging to serial (device streams)
|
||||||
@ -163,8 +162,7 @@ SERIAL_OBJS:=\
|
|||||||
timeout.$(O) \
|
timeout.$(O) \
|
||||||
io.$(O) \
|
io.$(O) \
|
||||||
usocket.$(O) \
|
usocket.$(O) \
|
||||||
serial.$(O) \
|
serial.$(O)
|
||||||
lua_typeerror.$(O)
|
|
||||||
|
|
||||||
#------
|
#------
|
||||||
# Files to install
|
# Files to install
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
#include "auxiliar.h"
|
#include "auxiliar.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "inet.h"
|
#include "inet.h"
|
||||||
#include "lua_typeerror.h"
|
|
||||||
|
|
||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Internal functions prototypes
|
* Internal functions prototypes
|
||||||
@ -122,7 +121,7 @@ int opt_get_ip_multicast_loop(lua_State *L, p_socket ps)
|
|||||||
int opt_set_linger(lua_State *L, p_socket ps)
|
int opt_set_linger(lua_State *L, p_socket ps)
|
||||||
{
|
{
|
||||||
struct linger li; /* obj, name, table */
|
struct linger li; /* obj, name, table */
|
||||||
if (!lua_istable(L, 3)) luaL_typeerror(L, 3, lua_typename(L, LUA_TTABLE));
|
if (!lua_istable(L, 3)) auxiliar_typeerror(L,3,lua_typename(L, LUA_TTABLE));
|
||||||
lua_pushstring(L, "on");
|
lua_pushstring(L, "on");
|
||||||
lua_gettable(L, 3);
|
lua_gettable(L, 3);
|
||||||
if (!lua_isboolean(L, -1))
|
if (!lua_isboolean(L, -1))
|
||||||
@ -203,7 +202,7 @@ int opt_set_ip6_v6only(lua_State *L, p_socket ps)
|
|||||||
static int opt_setmembership(lua_State *L, p_socket ps, int level, int name)
|
static int opt_setmembership(lua_State *L, p_socket ps, int level, int name)
|
||||||
{
|
{
|
||||||
struct ip_mreq val; /* obj, name, table */
|
struct ip_mreq val; /* obj, name, table */
|
||||||
if (!lua_istable(L, 3)) luaL_typeerror(L, 3, lua_typename(L, LUA_TTABLE));
|
if (!lua_istable(L, 3)) auxiliar_typeerror(L,3,lua_typename(L, LUA_TTABLE));
|
||||||
lua_pushstring(L, "multiaddr");
|
lua_pushstring(L, "multiaddr");
|
||||||
lua_gettable(L, 3);
|
lua_gettable(L, 3);
|
||||||
if (!lua_isstring(L, -1))
|
if (!lua_isstring(L, -1))
|
||||||
|
Loading…
Reference in New Issue
Block a user