reduce header dependencies (part 1/2)
[ardour.git] / libs / ardour / lua_api.cc
index 176a62005245e86f4360a2eb2f2e4402c332dade..9c562b0a059c7334f0677dabba6d0788cd9b04af 100644 (file)
@@ -28,6 +28,8 @@
 #include "ardour/plugin_insert.h"
 #include "ardour/plugin_manager.h"
 
+#include "LuaBridge/LuaBridge.h"
+
 #include "i18n.h"
 
 using namespace ARDOUR;
@@ -67,14 +69,9 @@ ARDOUR::LuaAPI::new_luaproc (Session *s, const string& name)
        return boost::shared_ptr<Processor> (new PluginInsert (*s, p));
 }
 
-
-boost::shared_ptr<Processor>
-ARDOUR::LuaAPI::new_plugin (Session *s, const string& name, ARDOUR::PluginType type, const string& preset)
+PluginInfoPtr
+ARDOUR::LuaAPI::new_plugin_info (const string& name, ARDOUR::PluginType type)
 {
-       if (!s) {
-               return boost::shared_ptr<Processor> ();
-       }
-
        PluginManager& manager = PluginManager::instance();
        PluginInfoList all_plugs;
        all_plugs.insert(all_plugs.end(), manager.ladspa_plugin_info().begin(), manager.ladspa_plugin_info().end());
@@ -91,13 +88,23 @@ ARDOUR::LuaAPI::new_plugin (Session *s, const string& name, ARDOUR::PluginType t
        all_plugs.insert(all_plugs.end(), manager.lv2_plugin_info().begin(), manager.lv2_plugin_info().end());
 #endif
 
-       PluginInfoPtr pip;
        for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
                if (((*i)->name == name || (*i)->unique_id == name) && (*i)->type == type) {
-                       pip = *i;
-                       break;
+                       return *i;
                }
        }
+       return PluginInfoPtr ();
+}
+
+boost::shared_ptr<Processor>
+ARDOUR::LuaAPI::new_plugin (Session *s, const string& name, ARDOUR::PluginType type, const string& preset)
+{
+       if (!s) {
+               return boost::shared_ptr<Processor> ();
+       }
+
+       PluginInfoPtr pip = new_plugin_info (name, type);
+
        if (!pip) {
                return boost::shared_ptr<Processor> ();
        }
@@ -146,9 +153,9 @@ ARDOUR::LuaAPI::set_processor_param (boost::shared_ptr<Processor> proc, uint32_t
 }
 
 int
-ARDOUR::LuaAPI::LuaOSCAddress::send (lua_State *L)
+ARDOUR::LuaOSC::Address::send (lua_State *L)
 {
-       LuaOSCAddress * const luaosc = luabridge::Userdata::get <LuaOSCAddress> (L, 1, false);
+       Address * const luaosc = luabridge::Userdata::get <Address> (L, 1, false);
        if (!luaosc) {
                return luaL_error (L, "Invalid pointer to OSC.Address");
        }
@@ -217,6 +224,6 @@ ARDOUR::LuaAPI::LuaOSCAddress::send (lua_State *L)
 
        int rv = lo_send_message (luaosc->_addr, path, msg);
        lo_message_free (msg);
-       luabridge::Stack<int>::push (L, rv);
+       luabridge::Stack<bool>::push (L, (rv == 0));
        return 1;
 }