13
0

Add a Lua wrapper to Glib::build_filename()

This commit is contained in:
Robin Gareus 2016-09-12 12:02:07 +02:00
parent 55af1d539f
commit 656b3b9c28
3 changed files with 29 additions and 0 deletions

View File

@ -130,6 +130,14 @@ namespace ARDOUR { namespace LuaAPI {
* @returns 4 parameters: red, green, blue, alpha (in range 0..1)
*/
int hsla_to_rgba (lua_State *lua);
/* Creates a filename from a series of elements using the correct separator for filenames.
*
* No attempt is made to force the resulting filename to be an absolute path.
* If the first element is a relative path, the result will be a relative path.
*/
int build_filename (lua_State *lua);
} } /* namespace */
namespace ARDOUR { namespace LuaOSC {

View File

@ -346,6 +346,26 @@ ARDOUR::LuaAPI::hsla_to_rgba (lua_State *L)
return 4;
}
int
ARDOUR::LuaAPI::build_filename (lua_State *L)
{
std::vector<std::string> elem;
int top = lua_gettop(L);
if (top < 1) {
return luaL_argerror (L, 1, "invalid number of arguments, build_filename (path, ...)");
}
for (int i = 1; i <= top; ++i) {
int lt = lua_type (L, i);
if (lt != LUA_TSTRING) {
return luaL_argerror (L, i, "invalid argument type, expected string");
}
elem.push_back (luaL_checkstring(L, i));
}
luabridge::Stack<std::string>::push (L, Glib::build_filename (elem));
return 1;
}
luabridge::LuaRef::Proxy&
luabridge::LuaRef::Proxy::clone_instance (const void* classkey, void* p) {
lua_rawgeti (m_L, LUA_REGISTRYINDEX, m_tableRef);

View File

@ -1468,6 +1468,7 @@ LuaBindings::common (lua_State* L)
.addCFunction ("plugin_automation", ARDOUR::LuaAPI::plugin_automation)
.addCFunction ("hsla_to_rgba", ARDOUR::LuaAPI::hsla_to_rgba)
.addFunction ("usleep", Glib::usleep)
.addCFunction ("build_filename", ARDOUR::LuaAPI::build_filename)
.endNamespace () // end LuaAPI
.endNamespace ();// end ARDOUR
}