13
0

Add a locale-independent float/double format Lua method

print(ARDOUR.LuaAPI.ascii_dtostr(1.5))
This commit is contained in:
Robin Gareus 2018-08-14 23:49:43 +02:00
parent 6434bf9dd3
commit d9a3866299
3 changed files with 13 additions and 0 deletions

View File

@ -187,6 +187,10 @@ namespace ARDOUR { namespace LuaAPI {
*/
int color_to_rgba (lua_State *lua);
/**
*/
std::string ascii_dtostr (const double d);
/**
* Creates a filename from a series of elements using the correct separator for filenames.
*

View File

@ -527,6 +527,14 @@ ARDOUR::LuaAPI::hsla_to_rgba (lua_State *L)
return 4;
}
std::string
ARDOUR::LuaAPI::ascii_dtostr (const double d)
{
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
g_ascii_dtostr (buf, sizeof(buf), d);
return std::string (buf);
}
int
ARDOUR::LuaAPI::color_to_rgba (lua_State *L)
{

View File

@ -2330,6 +2330,7 @@ LuaBindings::common (lua_State* L)
.addCFunction ("plugin_automation", ARDOUR::LuaAPI::plugin_automation)
.addCFunction ("hsla_to_rgba", ARDOUR::LuaAPI::hsla_to_rgba)
.addCFunction ("color_to_rgba", ARDOUR::LuaAPI::color_to_rgba)
.addFunction ("ascii_dtostr", ARDOUR::LuaAPI::ascii_dtostr)
.addFunction ("usleep", Glib::usleep)
.addFunction ("monotonic_time", ::g_get_monotonic_time)
.addCFunction ("build_filename", ARDOUR::LuaAPI::build_filename)