diff options
author | Miles Bader <miles@gnu.org> | 2013-08-29 20:07:24 +0900 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2013-08-30 06:56:33 +0100 |
commit | c746ae7a0fcae2e5a317c6fd8a2e44603ec24178 (patch) | |
tree | 0cd65350a96abe2f300b8bd0d08365e05ac8c646 /Lib | |
parent | 663c41e24861ebdc14563b2c1e77d1329d11225a (diff) | |
download | swig-c746ae7a0fcae2e5a317c6fd8a2e44603ec24178.tar.gz |
Include Lua error locus in SWIG error messages
This is standard information in Lua error messages, and makes it much
easier to find bugs.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/lua/luarun.swg | 15 | ||||
-rw-r--r-- | Lib/lua/typemaps.i | 20 | ||||
-rw-r--r-- | Lib/lua/wchar.i | 2 |
3 files changed, 18 insertions, 19 deletions
diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index dea8dd7a0..c705e38e5 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -185,19 +185,20 @@ typedef struct { /* Contract support */ #define SWIG_contract_assert(expr, msg) \ - if (!(expr)) { lua_pushstring(L, (char *) msg); goto fail; } else + if (!(expr)) { SWIG_Lua_pusherrstring(L, (char *) msg); goto fail; } else + /* helper #defines */ #define SWIG_fail {goto fail;} #define SWIG_fail_arg(func_name,argnum,type) \ - {lua_pushfstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\ + {SWIG_Lua_pushferrstring(L,"Error in %s (arg %d), expected '%s' got '%s'",\ func_name,argnum,type,SWIG_Lua_typename(L,argnum));\ goto fail;} #define SWIG_fail_ptr(func_name,argnum,type) \ SWIG_fail_arg(func_name,argnum,(type && type->str)?type->str:"void*") #define SWIG_check_num_args(func_name,a,b) \ if (lua_gettop(L)<a || lua_gettop(L)>b) \ - {lua_pushfstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\ + {SWIG_Lua_pushferrstring(L,"Error in %s expected %d..%d args, got %d",func_name,a,b,lua_gettop(L));\ goto fail;} @@ -250,8 +251,7 @@ SWIGINTERN int SWIG_Lua_set_immutable(lua_State* L) /* there should be 1 param passed in: the new value */ #ifndef SWIGLUA_IGNORE_SET_IMMUTABLE lua_pop(L,1); /* remove it */ - lua_pushstring(L,"This variable is immutable"); - lua_error(L); + luaL_error(L,"This variable is immutable"); #endif return 0; /* should not return anything */ } @@ -786,9 +786,8 @@ SWIGRUNTIME void* SWIG_Lua_MustGetPtr(lua_State* L,int index,swig_type_info *typ int argnum,const char* func_name){ void* result; if (!SWIG_IsOK(SWIG_ConvertPtr(L,index,&result,type,flags))){ - lua_pushfstring(L,"Error in %s, expected a %s at argument number %d\n", - func_name,(type && type->str)?type->str:"void*",argnum); - lua_error(L); + luaL_error (L,"Error in %s, expected a %s at argument number %d\n", + func_name,(type && type->str)?type->str:"void*",argnum); } return result; } diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i index a7ecec528..7a095a1e0 100644 --- a/Lib/lua/typemaps.i +++ b/Lib/lua/typemaps.i @@ -250,12 +250,12 @@ SWIGINTERN int SWIG_table_size(lua_State* L, int index) SWIGINTERN TYPE* SWIG_get_##NAME##_num_array_fixed(lua_State* L, int index, int size){\ TYPE *array;\ if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) {\ - lua_pushfstring(L,"expected a table of size %d",size);\ + SWIG_Lua_pushferrstring(L,"expected a table of size %d",size);\ return 0;\ }\ array=SWIG_ALLOC_ARRAY(TYPE,size);\ if (!SWIG_read_##NAME##_num_array(L,index,array,size)){\ - lua_pushstring(L,"table must contain numbers");\ + SWIG_Lua_pusherrstring(L,"table must contain numbers");\ SWIG_FREE_ARRAY(array);\ return 0;\ }\ @@ -265,17 +265,17 @@ SWIGINTERN int SWIG_table_size(lua_State* L, int index) {\ TYPE *array;\ if (!lua_istable(L,index)) {\ - lua_pushstring(L,"expected a table");\ + SWIG_Lua_pusherrstring(L,"expected a table");\ return 0;\ }\ *size=SWIG_itable_size(L,index);\ if (*size<1){\ - lua_pushstring(L,"table appears to be empty");\ + SWIG_Lua_pusherrstring(L,"table appears to be empty");\ return 0;\ }\ array=SWIG_ALLOC_ARRAY(TYPE,*size);\ if (!SWIG_read_##NAME##_num_array(L,index,array,*size)){\ - lua_pushstring(L,"table must contain numbers");\ + SWIG_Lua_pusherrstring(L,"table must contain numbers");\ SWIG_FREE_ARRAY(array);\ return 0;\ }\ @@ -451,12 +451,12 @@ SWIGINTERN int SWIG_read_ptr_array(lua_State* L,int index,void **array,int size, SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swig_type_info *type){ void **array; if (!lua_istable(L,index) || SWIG_itable_size(L,index) != size) { - lua_pushfstring(L,"expected a table of size %d",size); + SWIG_Lua_pushferrstring(L,"expected a table of size %d",size); return 0; } array=SWIG_ALLOC_ARRAY(void*,size); if (!SWIG_read_ptr_array(L,index,array,size,type)){ - lua_pushfstring(L,"table must contain pointers of type %s",type->name); + SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name); SWIG_FREE_ARRAY(array); return 0; } @@ -465,17 +465,17 @@ SWIGINTERN void** SWIG_get_ptr_array_fixed(lua_State* L, int index, int size,swi SWIGINTERN void** SWIG_get_ptr_array_var(lua_State* L, int index, int* size,swig_type_info *type){ void **array; if (!lua_istable(L,index)) { - lua_pushstring(L,"expected a table"); + SWIG_Lua_pusherrstring(L,"expected a table"); return 0; } *size=SWIG_itable_size(L,index); if (*size<1){ - lua_pushstring(L,"table appears to be empty"); + SWIG_Lua_pusherrstring(L,"table appears to be empty"); return 0; } array=SWIG_ALLOC_ARRAY(void*,*size); if (!SWIG_read_ptr_array(L,index,array,*size,type)){ - lua_pushfstring(L,"table must contain pointers of type %s",type->name); + SWIG_Lua_pushferrstring(L,"table must contain pointers of type %s",type->name); SWIG_FREE_ARRAY(array); return 0; } diff --git a/Lib/lua/wchar.i b/Lib/lua/wchar.i index 14a94257f..141ecc41f 100644 --- a/Lib/lua/wchar.i +++ b/Lib/lua/wchar.i @@ -31,7 +31,7 @@ wchar_t* str2wstr(const char *str, int len) %typemap(in, checkfn="SWIG_lua_isnilstring", fragment="SWIG_lua_isnilstring") wchar_t * %{ $1 = str2wstr(lua_tostring( L, $input ),lua_rawlen( L, $input )); -if ($1==0) {lua_pushfstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;} +if ($1==0) {SWIG_Lua_pushferrstring(L,"Error in converting to wchar (arg %d)",$input);goto fail;} %} %typemap(freearg) wchar_t * |