lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks, Sam.

I tried doing this:
  tyr.tcrdbrnum:types('double', 'pointer')  --( that's return type, arg type(s), in case you don't speak Alien ) ( and Alien will try to convert that double to lua_Number )
for the 'uint64 returning' ones, which gives 'nan';

and this:
  tyr.tcrdbrnum:types('string', 'pointer')
which segfaults the program.

I'm not going to bother to try with the others, which take that type, since I suppose I already need to write some C anyway; better do it 'right' while I'm at it.

--( And yes, I decided to go with an Alien binding for now, rather than implement the tyrant protocol in Lua, out of laziness. I like Alien; I hope it doesn't bite. )--

Phoenix Sol


On Wed, Jul 8, 2009 at 9:30 PM, Sam Roberts <vieuxtech@gmail.com> wrote:
On Wed, Jul 8, 2009 at 1:15 PM, Phoenix Sol<phoenix@burninglabs.com> wrote:
> K; Sounds like good advice; thanks, Sam.
>
> To answer your questions re manipulating these timestamps, though:
> I don't think they require much (or any) manipulation.
>
> This is probably overkill, but here are the prototypes I am looking at:

Judging from those APIs, something that might work is that for
returning uint64, return a lua_Number if it can fit without loss of
precision, otherwise a string.

So, you'd have to be a bit careful when calling tcrdbsize(), it could
return a number or a string. If you really want a number, you would
have to call tonumber() on the return value, which will work, it'll
just get converted to a large floating point number, and a bit of
precision will be lost.

For uint64 arguments, do the opposite, if it's already a number, use
it. If its a string, call strtoull().

Just a thought.

Cheers,
Sam