Page 1 of 1

Steamworks FFI

Posted: Tue Dec 17, 2019 8:47 am
by ivan
This is a cross-platform LuaJIT/FFI wrapper for Steamworks v1.47. The library provides easy and simple Steamworks integration, using the original redistributable binaries provided by Valve.

https://bitbucket.org/itraykov/sworks-ffi/src/master/

Re: Steamworks FFI

Posted: Tue Dec 17, 2019 10:45 am
by grump

Code: Select all

ffi.C.strtoull("0xffffffffffffffff", nil, 16)
LuaJIT accepts a ULL suffix for this.

Code: Select all

0xffffffffffffffffULL

Re: Steamworks FFI

Posted: Tue Dec 17, 2019 1:36 pm
by raidho36
Yeah, I mean, it's LuaJIT-exclusive anyway, you can't make this work in regular Lua.

Re: Steamworks FFI

Posted: Tue Dec 17, 2019 2:35 pm
by ivan
Thanks grump, I will add that change although I have tested it and it works fine with either:

Code: Select all

a = ffi.C.strtoull("0xffffffffffffffff", nil, 16)
b = ffi.C.strtoull("0xffffffffffffffffULL", nil, 16)

assert(a == b)
In general, pure Lua can't handle such large numbers:

Code: Select all

n = 0xffffffffffffffff

Re: Steamworks FFI

Posted: Tue Dec 17, 2019 2:41 pm
by grump
ivan wrote:
Tue Dec 17, 2019 2:35 pm
In general, pure Lua can't handle such large numbers:

Code: Select all

n = 0xffffffffffffffff
The point is that you can use the ULL suffix to write 64 bit integer literals directly in LuaJIT, there's no need to call strtoull.

Code: Select all

assert(0xffffffffffffffffULL == ffi.C.strtoull("0xffffffffffffffff", nil, 16))
http://luajit.org/ext_ffi_api.html (see "Extensions to the Lua parser" at the bottom of the page)

Re: Steamworks FFI

Posted: Tue Dec 17, 2019 2:55 pm
by ivan
I see, that's even better. I will have to see how this change would affect the rest of the code.
Thanks grump!

Re: Steamworks FFI

Posted: Mon Jan 06, 2020 10:56 am
by ReFreezed
Nice, this is very useful!