Re: opaque pointers and metatype

  • From: Cosmin Apreutesei <cosmin.apreutesei@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sun, 2 Mar 2014 05:09:24 +0200

I also wanted to mention a solution that I have found for this:

Replacing

   typedef struct OpaqueStruct * handle;

with

   typedef struct {void* p} handle;

and metatype'ing on handle, solves all the problems, i.e. it allows me to
  - avoid creation of 1-element arrays
  - hook the C methods that take handle* as the first argument into
the metatype directly, without a Lua wrapper.

What do you think, is this a good way to do it? It seems better than
the previous one to me.

Other related posts: