LuaJIT C++ FFI Proof of Concept

  • From: Lucien Greathouse <lpghatguy@xxxxxxxxx>
  • To: luajit <luajit@xxxxxxxxxxxxx>
  • Date: Sat, 17 Jan 2015 13:17:58 -0700

Howdy!

I built a C++ FFI for LuaJIT in some form over the past couple weeks that
relies on predefined binding files (not just C++ headers).

It handles name mangling, virtual methods, static methods, multiple
inheritance, class members, and struct layouts according to both the
Itanium C++ ABI (GCC, Clang Linux, Intel C++ Linux) and the MSVC C++ ABI
(MSVC, Clang Windows, Intel C++ Windows). Requiring that symbols and their
translations makes things a little bit easier for the runtime, but
definitely makes building a binding more difficult, especially since I
haven't produced a tool yet to make these binding files.

I'd like to build a nicer wrapper to handle classes in a way that's closer
to what you'd expect from OOP. Casting up and down shouldn't be too
difficult, since I just need a byte offset table for each ancestor class of
an object.

I've got a repository for it here: https://github.com/LPGhatguy/luajit-ffipp

Is a solution like this "acceptable enough" given how complex supporting
C++ would be in the style of the existing C FFI?

Other related posts:

  • » LuaJIT C++ FFI Proof of Concept - Lucien Greathouse