Wireshark-dev: Re: [Wireshark-dev] [Wireshark-users] bit operations are missingfrom lua binding
From: Stig Bjørlykke <stig@xxxxxxxxxxxxx>
Date: Sat, 6 Jun 2009 10:44:43 +0200
On Fri, Jun 5, 2009 at 10:37 PM, Sam Roberts<vieuxtech@xxxxxxxxx> wrote:
> Add this for up to 64 bit support, for completion:
> [...]

I have this code locally, but as you noted the UInt64 type does not
work correctly.  The __tostring is not called when trying to convert a
value to string (which leads to an error "string expected, got
userdata"), and adding a __gc does nothing.  I will have a look at
this later, unless someone beats me to it.

> Btw, I don't understand why the UInt64 userdata encapsulates a pointer
> to a UInt64 instead of the uint itself. It makes it a bit harder to
> use (you need the g_malloc()).

This is noted in wslua_tvb.c:
"Lua uses one single number representation which can be chosen at
compile time and since it is often set to IEEE 754 double precision
floating point, we cannot store a 64 bit integer with full precision.
For details, see: http://lua-users.org/wiki/FloatingPoint";


> Also, the UInt64s are leaking memory. I guess the idea is a uint64
> userdata can have a reference to memory it doesn't own,
> which is why it doesn't define __gc to g_free() the memory?

I will add the __gc when I get the UInt64 type working correctly :)


-- 
Stig Bjørlykke