diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ingen/main.cpp | 7 | ||||
-rw-r--r-- | src/serialisation/Parser.cpp | 30 | ||||
-rw-r--r-- | src/serialisation/Parser.hpp | 9 | ||||
-rw-r--r-- | src/server/ingen_lv2.cpp | 12 |
4 files changed, 46 insertions, 12 deletions
diff --git a/src/ingen/main.cpp b/src/ingen/main.cpp index f93e333b..997fb66e 100644 --- a/src/ingen/main.cpp +++ b/src/ingen/main.cpp @@ -157,6 +157,10 @@ main(int argc, char** argv) world->set_engine(engine_interface); + if (world->local_engine()) { + world->local_engine()->activate(); + } + // Load a patch if (conf.option("load").is_valid() && engine_interface) { boost::optional<Path> parent; @@ -191,6 +195,7 @@ main(int argc, char** argv) } engine_interface->get("ingen:plugins"); + engine_interface->get("path:/"); world->parser()->parse_file( world, engine_interface.get(), uri, parent, symbol); } @@ -217,7 +222,7 @@ main(int argc, char** argv) signal(SIGINT, ingen_interrupt); signal(SIGTERM, ingen_interrupt); - // Activate the enginie + // Activate the engine world->local_engine()->activate(); // Run engine main loop until interrupt diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index 5197c175..198a520e 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -108,6 +108,7 @@ Parser::Parser(Ingen::Shared::World& world) Parser::PatchRecords Parser::find_patches(Ingen::Shared::World* world, + SerdEnv* env, const Glib::ustring& manifest_uri) { const Sord::URI ingen_Patch (*world->rdf_world(), NS_INGEN "Patch"); @@ -115,9 +116,7 @@ Parser::find_patches(Ingen::Shared::World* world, const Sord::URI rdfs_seeAlso(*world->rdf_world(), NS_RDFS "seeAlso"); Sord::Model model(*world->rdf_world(), manifest_uri); - SerdEnv* env = serd_env_new(NULL); model.load_file(env, SERD_TURTLE, manifest_uri); - serd_env_free(env); std::list<PatchRecord> records; for (Sord::Iter i = model.find(nil, rdf_type, ingen_Patch); !i.end(); ++i) { @@ -156,21 +155,35 @@ Parser::parse_file(Ingen::Shared::World* world, file_uri = Glib::ustring("file://") + file_uri; } + const bool is_bundle = (file_uri.substr(file_uri.length() - 4) != ".ttl"); + + if (is_bundle && file_uri[file_uri.length() - 1] != '/') { + file_uri.append("/"); + } + + SerdNode base_node = serd_node_from_string( + SERD_URI, (const uint8_t*)file_uri.c_str()); + SerdEnv* env = serd_env_new(&base_node); + if (file_uri.substr(file_uri.length() - 4) != ".ttl") { // Not a Turtle file, try to open it as a bundle if (file_uri[file_uri.length() - 1] != '/') { file_uri.append("/"); } - Parser::PatchRecords records = find_patches(world, file_uri + "manifest.ttl"); + Parser::PatchRecords records = find_patches(world, env, file_uri + "manifest.ttl"); if (!records.empty()) { file_uri = records.front().file_uri; } } + base_node = serd_node_from_string( + SERD_URI, (const uint8_t*)file_uri.c_str()); + serd_env_set_base_uri(env, &base_node); + // Load patch file into model Sord::Model model(*world->rdf_world(), file_uri); - SerdEnv* env = serd_env_new(NULL); model.load_file(env, SERD_TURTLE, file_uri); + serd_env_free(env); LOG(info) << "Parsing " << file_uri << endl; @@ -260,6 +273,7 @@ Parser::parse(Ingen::Shared::World* world, const Sord::Node& subject = i.get_subject(); const Sord::Node& rdf_class = i.get_object(); + assert(rdf_class.is_uri()); Subjects::iterator s = subjects.find(subject); if (s == subjects.end()) { std::set<Sord::Node> types; @@ -285,10 +299,18 @@ Parser::parse(Ingen::Shared::World* world, } else if (types.find(port_class) != types.end()) { parse_properties(world, target, model, subject, path, data); ret = path; + } else { + LOG(error) << "Subject has no known types" << endl; } if (!ret) { LOG(error) << "Failed to parse " << path << endl; + LOG(error) << "Types:" << endl; + for (std::set<Sord::Node>::const_iterator t = types.begin(); + t != types.end(); ++t) { + LOG(error) << " :: " << *t << endl; + assert((*t).is_uri()); + } return boost::optional<Path>(); } diff --git a/src/serialisation/Parser.hpp b/src/serialisation/Parser.hpp index b5e2db63..30c04bab 100644 --- a/src/serialisation/Parser.hpp +++ b/src/serialisation/Parser.hpp @@ -21,11 +21,11 @@ #include <string> #include <list> -#include <glibmm/ustring.h> - #include <boost/optional.hpp> +#include <glibmm/ustring.h> #include "raul/Path.hpp" +#include "serd/serd.h" #include "ingen/GraphObject.hpp" @@ -74,8 +74,9 @@ public: typedef std::list<PatchRecord> PatchRecords; - virtual PatchRecords find_patches(Shared::World* world, - const Glib::ustring& manifest_uri); + virtual PatchRecords find_patches(Shared::World* world, + SerdEnv* env, + const Glib::ustring& manifest_uri); private: boost::optional<Raul::Path> parse( diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index aa3c1f56..9ef1aede 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -399,9 +399,15 @@ Lib::Lib() typedef Serialisation::Parser::PatchRecords Records; - Records records(world->parser()->find_patches( - world, Glib::filename_to_uri( - Shared::bundle_file_path("manifest.ttl")))); + const std::string manifest_path = Shared::bundle_file_path("manifest.ttl"); + const SerdNode base_node = serd_node_from_string( + SERD_URI, (const uint8_t*)manifest_path.c_str()); + + SerdEnv* env = serd_env_new(&base_node); + Records records( + world->parser()->find_patches(world, env, + Glib::filename_to_uri(manifest_path))); + serd_env_free(env); for (Records::iterator i = records.begin(); i != records.end(); ++i) { patches.push_back( |