ffi and inline functions

  • From: Kaj Eijlers <bizziboi@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 13 May 2012 21:52:33 -0700

Hi group,

I am (also) trying to wrap some DirectX stuff and ran into a bit of a

I am playing with a module that defines the ffi for d3dx9math, and I want
to define some inline functions.
The lua file has the ffi.cdef for the functions in the dll and ends with
return ffi.load 'd3dx9_xx.dll'
That works.

However, some functions (like D3DXMatrixIdentity) are defined inline. For
consistency I'd want them to be prefixed with the same local as I use for
the dll (as in, my main says 'local d3d9math = require 'd3d9math', now I
want those inline functions to be associated to the metatable that drives
the object, but I didn't succeed, I can't set a metatable on d3d9math).

Does anyone have a pointer (or a reference ;o) ) on how to accomplish this?

I found it hard to tell whether to send this to the lua or luajit list,
since metatables are obviously lua, but ffi is not so much....


Other related posts: