Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backporting to Lua 5.1 #18

Open
ggcrunchy opened this issue May 8, 2024 · 1 comment
Open

Backporting to Lua 5.1 #18

ggcrunchy opened this issue May 8, 2024 · 1 comment

Comments

@ggcrunchy
Copy link

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() and lua_pushinteger(), and then there are the opcodes in meta.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.)

@randy408
Copy link
Collaborator

randy408 commented May 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants