calio / lua-capnproto

Lua-capnp is a pure lua implementation of capnproto based on luajit.
BSD 2-Clause "Simplified" License
70 stars 24 forks source link

Effort to port Lua Capnproto to Lua 5.1 for a Big Endian system #2

Open wdicarlo opened 10 years ago

wdicarlo commented 10 years ago

Hi, I am quite new to Lua world and to capnproto. So, it is difficult for me to make an estimation of the effort needed to port your code to standard Lua 5.1 (no Luajit) for a Big Endian system (PPC). Any hint would be appreciated.

Thank you Walter

calio commented 10 years ago

Hi wdicarlo,

Thanks for your interest. There are a few things you need to do if you want to port it to Lua 5.1:

  1. For performance reasons, I use LuaJIT's FFI extension to manage string buffers. There is a FFI port for Lua https://github.com/jmckaskill/luaffi. I've done something to lua-capnproto using this library, but haven't finished yet. You can check this library out.
  2. I also use LuaJIT's 64 bit number extension: "0LL', "0ULL". See "Extensions to the Lua Parser" section of http://luajit.org/ext_ffi_api.html#literals. This is a big problem when you are porting. Because there is no convenient way to describe 64 bit number in Lua 5.1 AFAIK. You may need to use something else to represent 64bit integer numbers.
  3. Endianness. Now some bit operation functions (like "fix_float64_default") depends on little endian. You need to modify them to work on big endian environment.

These things are what I can think of for now. If you have any questions, feel free to ask me.