diff options
author | Robin Gareus <robin@gareus.org> | 2016-07-07 04:44:36 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-07-07 15:37:11 +0200 |
commit | 44a3f042a7a878af45ae893e0361d6a8be315da4 (patch) | |
tree | b7ee5d92f24aca24a7de4084f623dca0ea5eb68a /libs/ardour/ardour/lua_api.h | |
parent | 225a8a47a419e5e67a27b604bfd912498e3ad2cc (diff) |
prepare sharing C++ class instances across lua-interpreters
in particular: lua-lifefime (!) C++ instances.
This allows for dynamic allocation of custom user-data, bound to
the lifetime of the allocating lua-context.
Diffstat (limited to 'libs/ardour/ardour/lua_api.h')
-rw-r--r-- | libs/ardour/ardour/lua_api.h | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/libs/ardour/ardour/lua_api.h b/libs/ardour/ardour/lua_api.h index 9ae6bf2ff6..9af9649620 100644 --- a/libs/ardour/ardour/lua_api.h +++ b/libs/ardour/ardour/lua_api.h @@ -181,6 +181,46 @@ namespace ARDOUR { namespace LuaOSC { lo_address _addr; }; -} } /* namespace */ +} + +class LuaTableRef { + public: + LuaTableRef (); + ~LuaTableRef (); + + int get (lua_State* L); + int set (lua_State* L); + + private: + struct LuaTableEntry { + LuaTableEntry (int kt, int vt) + : keytype (kt) + , valuetype (vt) + { } + + int keytype; + std::string k_s; + unsigned int k_n; + + int valuetype; + // LUA_TUSERDATA + const void* c; + void* p; + // LUA_TBOOLEAN + bool b; + // LUA_TSTRING: + std::string s; + // LUA_TNUMBER: + double n; + }; + + std::vector<LuaTableEntry> _data; + + static void* findclasskey (lua_State *L, const void* key); + template<typename T> + static void assign (luabridge::LuaRef* rv, T key, const LuaTableEntry& s); +}; + +} /* namespace */ #endif // _ardour_lua_api_h_ |