Re: Pass int64

Niki Bowe <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Done correctly that is the best solution. Itll allow you to do 
arithmetic on 64 bit integers in lua.
Though there is a bit more to it than that.
lua_Number will need to be able to hold int64 values without loss.
which means youll need to either go with int64 as lua_Number (ie integer 
only lua)
or long double as lua_Number (non portable. no guarantee it can 
represent all 64 bit ints. eg 
http://msdn.microsoft.com/en-us/library/9cx8xs15.aspx).
or use askos lnum patch against lua and use int64 integers and leave non 
integers as doubles (my fave).

If you are really only ever pushing in "small" int64s (ie ones that are 
representable as ints)
Then you might be better off writing wrapper functions and registering 
those.
(and praying that you never really need the full int64 range)

On the other hand if you dont need to do calculations and cant/wont 
change lua to support int64 then there is another option:
On one of our platforms we work with an API that takes and returns 64 
bit numbers.
We dont need to perform calculations on them, we just need to use them 
as opaque values.
So we added a luabind converter that wraps the 64 bit value in a user data.
works for us. downside is that it creates garbage any time we push 64 
bit numbers into lua. but we dont do it often.


Cheers
Niki Bowe


Tom McCubbin wrote:
> I really like that! 
>
> Just make sure any binary modules are also recompiled w/ the new 
> luaconf.h settings!
>
> (you dog...I should have said that ;) )  nice
>
> On Tue, 2009-05-26 at 14:53 -0500, James Porter wrote:
>> > I'm sure there is a better/slicker way to achieve it, but this would be the
>> > long typed, least thought out approach
>>
>> Depending on the particulars, an easy way to address this would be to
>> recompile Lua with LUA_INTEGER #defined to __int64 in luaconf.h
>>
>> - Jim
>>
>> ------------------------------------------------------------------------------
>> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
>> is a gathering of tech-side developers & brand creativity professionals. Meet
>> the minds behind Google Creative Lab, Visual Complexity, Processing, & 
>> iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
>> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
>> _______________________________________________
>> luabind-user mailing list
>> [email protected] <mailto:[email protected]>
>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>>     
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
> is a gathering of tech-side developers & brand creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, & 
> iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
> ------------------------------------------------------------------------
>
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com

_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.