13
0
Commit Graph

6 Commits

Author SHA1 Message Date
520dcf8cdf rework lua-bridge C++ variable references
Since lua functions are closures, C++ methods that pass arguments by
reference cannot be used directly. The previous approach (boost::ref)
failed with clang. Assume the following:

  void foo (float&) { }
  static inline float& bar () {
    boost::reference_wrapper<float> r (42);
    return r.get ();
  }

  foo ( bar () );

With gcc, "r" goes out of scope after foo's arguments are processed
and all is well.
But with clang,  "r" already leave scope when *inlined* bar() returns.

Solution: allocate some user-data on the lua-stack to hold the reference.
There is no reference to this user-data so lua will eventually
garbage collect it.

(theoretically, creating the table which holds the return-values
could trigger an emergency garbage collection when memory is low and
free the reference just while they're being pushed to the table, then
gain FuncArgs<Params> already dereferenced them all as variable on the
C stack -- probably again compiler specific)
2016-07-18 23:52:40 +02:00
829da7eb33 refactor lua header includes 2016-03-23 17:00:10 +01:00
618ef9f923 Prepare Lua Binding Documentation (JSON) 2016-03-20 20:54:36 +01:00
a8ae47ada2 LuaBridge: support argument references via table return 2016-02-22 22:06:47 +01:00
12a58015a3 customize LuaBridge
* introduce boost::shared_ptr support
* support enum & const
* allow to add non-class member functions
* STL iterators (vector, list, set, bitset & map)
* support reference arguments (framecnt_t&)
* add support for arrays of basic types (e.g. float*, int*)
* fix compiler warnings
2016-02-22 22:06:47 +01:00
e98f21dd29 add LuaBridge
https://github.com/vinniefalco/LuaBridge
2016-02-22 22:06:47 +01:00