Skip to content

Conversation

@Whateverest
Copy link

Hello,

love 11.5 on desktop is using luajit 2.1 which has builtin support for bitwise operations. Lua 5.1., which is currently used for building love.js, does not.

The following worked with love on desktop but not with love.js:

    require("bit")
    x = bit.bxor(1,2)

Of course one could simply implement the bitwise operations in pure lua, but that would be suboptimal performance-wise, compared to the C version anyway.

Using the MIT-licenced module from https://bitop.luajit.org/ makes it possible to use the same (efficient) lua-code on desktop as well as web.

The easiest (but probably not the prettiest) way to include this was to add the bit.c file directly to the lua-5.1-sources.
Using the modified megasource i managed to build a version of love.js that supports the "bit"-module.

Note that I have very limited knowledge of C/C++ and absolutely no knowledge of cmake. So I'm not sure if this PR can, or even should be merged like this.

love on desktop is using luajit 2.1 which has builtin support for bitwise ops.
Lua 5.1., which is currently used for building, love.js does not.

The following  worked with love on desktop but not with love.js:

        require("bit")
        x = bit.bxor(1,2)

Using the MIT-licenced module from https://bitop.luajit.org/ makes it possible to
use the same (efficient) code on desktop as well as web.

The easiest (and probably not the prettiest) way to include this was to add the bit.c file
directly to the lua-5.1-sources.
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

Successfully merging this pull request may close these issues.

1 participant