|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
SIWG 1.3.31 and Lua 5.1.3, typemap(out) being ignored?I'm using SWIG 1.3.31 to generate wrappers for Lua 5.1.3 with the LNum patch.
LNum adds support for 64-bit integers and adds 'lua_pushinteger' and 'lua_totinteger' helper functions to work with them. I defined a typemap to handle these explicitly as follows: %typemap(in) Int64 { $1 = (Int64)lua_tointeger(L, $argnum) } %typemap(out) Int64 { lua_pushinteger(L, $1); SWIG_Arg++; } The 'in' typemap generates code I'd expect. The 'out' typemap seems to ignore my typemap altogether and generates default code. This has the unfortunate consequence of 'converting' my Int64 to a double. e.g. I have a function 'Int64 MyFunction(Int64 val)'. The generated SWIG wrapper looks like: static int _wrap_MyFunction(lua_State* L) { int SWIG_arg = -1; Int64 arg1; Int64 result; SWIG_check_num_args("MyFunction",1,1) arg1 = (Int64)lua_tointeger(L, 1); result = MyFunction(arg1); SWIG_arg=0; lua_pushnumber(L, (lua_Number) result); SWIG_arg++; return SWIG_arg; if(0) SWIG_fail; fail: lua_error(L); return SWIG_arg; } The work around I've come up with is to %ignore all the functions that return Int64 and define them myself using %native. This is really ugly and adding up to a lot of custom SWIG wrapper functions. It also means I need to be particularly careful going forward to write custom wrappers for any new functions that need to return Int64 values. Is there a way to get SWIG to generate 'out' code using my typemap? Thanks, -Aaron ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user |
|
|
Re: SIWG 1.3.31 and Lua 5.1.3, typemap(out) being ignored?Aaron Saarela wrote:
> I'm using SWIG 1.3.31 to generate wrappers for Lua 5.1.3 with the LNum patch. > LNum adds support for 64-bit integers and adds 'lua_pushinteger' and > 'lua_totinteger' helper functions to work with them. I defined a typemap to > handle these explicitly as follows: > > %typemap(in) Int64 > { > $1 = (Int64)lua_tointeger(L, $argnum) > } > > %typemap(out) Int64 > { > lua_pushinteger(L, $1); SWIG_Arg++; > } > > The 'in' typemap generates code I'd expect. > > The 'out' typemap seems to ignore my typemap altogether and generates default > code. This has the unfortunate consequence of 'converting' my Int64 to a > double. > > e.g. I have a function 'Int64 MyFunction(Int64 val)'. The generated SWIG > wrapper looks like: > > static int _wrap_MyFunction(lua_State* L) { > int SWIG_arg = -1; > Int64 arg1; > Int64 result; > > SWIG_check_num_args("MyFunction",1,1) > arg1 = (Int64)lua_tointeger(L, 1); > > result = MyFunction(arg1); > > SWIG_arg=0; > lua_pushnumber(L, (lua_Number) result); SWIG_arg++; > return SWIG_arg; > > if(0) SWIG_fail; > > fail: > lua_error(L); > return SWIG_arg; > } > > > The work around I've come up with is to %ignore all the functions that return > Int64 and define them myself using %native. This is really ugly and adding up > to a lot of custom SWIG wrapper functions. It also means I need to be > particularly careful going forward to write custom wrappers for any new > functions that need to return Int64 values. > > Is there a way to get SWIG to generate 'out' code using my typemap? > report as this would be a pretty fundamental problem if you are using typemaps correctly. William ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user |
|
|
|
|
|
Re: SIWG 1.3.31 and Lua 5.1.3, typemap(out) being ignored?Thanks for the hint. After updating to 1.3.35 the problem went away. >-----Original Message----- >From: William Fulton [mailto:william@...] On Behalf Of >William S Fulton >Sent: Thursday, June 12, 2008 4:25 PM >To: Aaron Saarela >Cc: swig-user@... >Subject: Re: [Swig-user] SIWG 1.3.31 and Lua 5.1.3, typemap(out) being >ignored? >> >Does the problem still exist with swig-1.3.35? If so please raise a bug >report as this would be a pretty fundamental problem if you are using >typemaps correctly. > >William ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Swig-user mailing list Swig-user@... https://lists.sourceforge.net/lists/listinfo/swig-user |
| Free Forum Powered by Nabble | Forum Help |