diff options
| -rw-r--r-- | lauxlib.c | 28 | ||||
| -rw-r--r-- | lauxlib.h | 8 |
2 files changed, 21 insertions, 15 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.6 1997/12/17 20:48:58 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.8 1998/01/09 15:06:07 roberto Exp $ |
| 3 | ** Auxiliar functions for building Lua libraries | 3 | ** Auxiliar functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -8,25 +8,27 @@ | |||
| 8 | #include <stdarg.h> | 8 | #include <stdarg.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| 10 | 10 | ||
| 11 | /* Please Notice: This file uses only the oficial API of Lua | ||
| 12 | ** Any function declared here could be written as an application | ||
| 13 | ** function. With care, these functions can be used by other libraries. | ||
| 14 | */ | ||
| 11 | #include "lauxlib.h" | 15 | #include "lauxlib.h" |
| 12 | #include "lua.h" | 16 | #include "lua.h" |
| 13 | #include "luadebug.h" | 17 | #include "luadebug.h" |
| 14 | 18 | ||
| 15 | 19 | ||
| 16 | 20 | ||
| 17 | void luaL_arg_check (int cond, int numarg, char *extramsg) | 21 | void luaL_argerror (int numarg, char *extramsg) |
| 18 | { | 22 | { |
| 19 | if (!cond) { | 23 | char *funcname; |
| 20 | char *funcname; | 24 | lua_getobjname(lua_stackedfunction(0), &funcname); |
| 21 | lua_getobjname(lua_stackedfunction(0), &funcname); | 25 | if (funcname == NULL) |
| 22 | if (funcname == NULL) | 26 | funcname = "???"; |
| 23 | funcname = "???"; | 27 | if (extramsg == NULL) |
| 24 | if (extramsg == NULL) | 28 | luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname); |
| 25 | luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname); | 29 | else |
| 26 | else | 30 | luaL_verror("bad argument #%d to function `%.50s' (%.100s)", |
| 27 | luaL_verror("bad argument #%d to function `%.50s' (%.100s)", | 31 | numarg, funcname, extramsg); |
| 28 | numarg, funcname, extramsg); | ||
| 29 | } | ||
| 30 | } | 32 | } |
| 31 | 33 | ||
| 32 | char *luaL_check_string (int numArg) | 34 | char *luaL_check_string (int numArg) |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.h,v 1.4 1997/12/09 13:35:19 roberto Exp roberto $ | 2 | ** $Id: lauxlib.h,v 1.5 1997/12/17 20:48:58 roberto Exp roberto $ |
| 3 | ** Auxiliar functions for building Lua libraries | 3 | ** Auxiliar functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -17,8 +17,12 @@ struct luaL_reg { | |||
| 17 | lua_CFunction func; | 17 | lua_CFunction func; |
| 18 | }; | 18 | }; |
| 19 | 19 | ||
| 20 | |||
| 21 | #define luaL_arg_check(cond,numarg,extramsg) if (!(cond)) \ | ||
| 22 | luaL_argerror(numarg,extramsg) | ||
| 23 | |||
| 20 | void luaL_openlib (struct luaL_reg *l, int n); | 24 | void luaL_openlib (struct luaL_reg *l, int n); |
| 21 | void luaL_arg_check (int cond, int numarg, char *extramsg); | 25 | void luaL_argerror (int numarg, char *extramsg); |
| 22 | char *luaL_check_string (int numArg); | 26 | char *luaL_check_string (int numArg); |
| 23 | char *luaL_opt_string (int numArg, char *def); | 27 | char *luaL_opt_string (int numArg, char *def); |
| 24 | double luaL_check_number (int numArg); | 28 | double luaL_check_number (int numArg); |
