Open ggcrunchy opened 4 months ago
I guess you could replace all the luaL_checkinteger()
and lua_pushinteger()
's for entities with checkentity()
and pushentity()
and do compile-time checking for Lua <5.3.
The tests will probably not pass because there's a lot of checks for non-zero entity id's, maybe you could get away with returning lightuserdata
for non-zero id's and nil
/ 0
otherwise. You have to consider what would work best in actual Lua code.
The occasional arithmetic on >32bit integers is probably a no-go and is why I never bothered with older Lua versions, 5.2 has been EOL since 2015, even 5.3 is EOL at this point.
Hi.
I'm attempting what's described in the title. :)
I still have a few 5.3-specific functions to shim, but nothing that sounds too awful.
Am now trying to deal with the integers.
From what I can see, I can find all of the entity usage with
luaL_checkinteger()
andlua_pushinteger()
, and then there are the opcodes inmeta.c
. Anything else to be aware of? (In flecs proper I suppose there might be the DSLs to consider.)It looks like there's an integer vs. number case in the serialization logic, so a
lua_Number
(as suggested by this comment) won't be quite enough, but I'm thinking a light userdata would work on 64-bit targets, and maybe some hybrid number / full userdata approach otherwise, with some helper functions around them.(Maybe later I could adopt the LNUM patch, but not for the time being.)