aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-01-09 13:09:53 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-01-09 13:09:53 -0200
commit9f043e801733b0a5019c4e6e2a72abaf9ad7c5b0 (patch)
tree54f1ac9c81b072567955e7399376eec5cd745218
parent6ac047afc46cbee935587b5734ec37d2e667a598 (diff)
downloadlua-9f043e801733b0a5019c4e6e2a72abaf9ad7c5b0.tar.gz
lua-9f043e801733b0a5019c4e6e2a72abaf9ad7c5b0.tar.bz2
lua-9f043e801733b0a5019c4e6e2a72abaf9ad7c5b0.zip
luaL_arg_check now is inlined
-rw-r--r--lauxlib.c28
-rw-r--r--lauxlib.h8
2 files changed, 21 insertions, 15 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 922bc5d2..6de9c2bf 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -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
17void luaL_arg_check (int cond, int numarg, char *extramsg) 21void 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
32char *luaL_check_string (int numArg) 34char *luaL_check_string (int numArg)
diff --git a/lauxlib.h b/lauxlib.h
index ae043322..4fe65c99 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -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
20void luaL_openlib (struct luaL_reg *l, int n); 24void luaL_openlib (struct luaL_reg *l, int n);
21void luaL_arg_check (int cond, int numarg, char *extramsg); 25void luaL_argerror (int numarg, char *extramsg);
22char *luaL_check_string (int numArg); 26char *luaL_check_string (int numArg);
23char *luaL_opt_string (int numArg, char *def); 27char *luaL_opt_string (int numArg, char *def);
24double luaL_check_number (int numArg); 28double luaL_check_number (int numArg);