Re: Possible to store a reference to a lua table in an ffi struct?

  • From: Kaj Eijlers <bizziboi@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Sat, 22 Mar 2014 17:22:11 -0700

>
> Using that same technique, you can store just the
> vector<string>-replacement table in the metatable.  The downside of this
> approach is that you will need a different metatype/metatable for each
> instance (unless the intention is to share this vector<string> among among
> instances, i.e. a C++ static class member).
>
> For example:
> t = ffi.metatype( "struct { int a, b, c; }", { __index = { vstr = {} } })
> foo = t()
> foo.vstr[#foo.vstr+1] = "string1"
>
> -Evan
>
Hmmmmm, No I need a vector per instance, so I think I'll go with a member
that is a ctype with a metatable for push_back() and the likes. But thanks
for the idea, I'll keep it in mind :o)

Other related posts: