From f694ff62fe5044edf40021d6a2cce1c472acb55b Mon Sep 17 00:00:00 2001 From: Paul-Arthur SAUVAGEOT Date: Thu, 23 Oct 2014 16:58:58 +0200 Subject: [PATCH] Patch name are now registered when parsing a patch --- src/PdFileParser.cpp | 12 +++++++++--- src/PdGraph.cpp | 3 ++- src/PdGraph.h | 2 +- src/ZenGarden.cpp | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/PdFileParser.cpp b/src/PdFileParser.cpp index f1890327..af2b425e 100644 --- a/src/PdFileParser.cpp +++ b/src/PdFileParser.cpp @@ -125,13 +125,19 @@ PdGraph *PdFileParser::execute(PdMessage *initMsg, PdGraph *graph, PdContext *co if (!strcmp(hashType, "#N")) { char *objectType = strtok(NULL, " "); if (!strcmp(objectType, "canvas")) { + int canvasX = atoi(strtok(NULL, " ")); + int canvasY = atoi(strtok(NULL, " ")); + int canvasW = atoi(strtok(NULL, " ")); + int canvasH = atoi(strtok(NULL, " ")); + const char *canvasName = strtok(NULL, " "); + // A new graph is defined inline. No arguments are passed (from this line) // the graphId is not incremented as this is a subpatch, not an abstraction // NOTE(mhroth): pixel location is not recorded PdGraph *newGraph = NULL; if (graph == NULL) { // if no parent graph exists initMessage->initWithTimestampAndNumElements(0.0, 0); // make a dummy initMessage - newGraph = new PdGraph(initMessage, NULL, context, context->getNextGraphId()); + newGraph = new PdGraph(initMessage, NULL, context, context->getNextGraphId(), "root"); if (!rootPath.empty()) { // inform the root graph of where it is in the file system, if this information exists. // This will allow abstractions to be correctly loaded. @@ -139,9 +145,9 @@ PdGraph *PdFileParser::execute(PdMessage *initMsg, PdGraph *graph, PdContext *co } } else { if (isSubPatch) { - newGraph = new PdGraph(graph->getArguments(), graph, context, graph->getGraphId()); + newGraph = new PdGraph(graph->getArguments(), graph, context, graph->getGraphId(), canvasName); } else { - newGraph = new PdGraph(initMsg, graph, context, context->getNextGraphId()); + newGraph = new PdGraph(initMsg, graph, context, context->getNextGraphId(), "???"); isSubPatch = true; } graph->addObject(0, 0, newGraph); // add the new graph to the current one as an object diff --git a/src/PdGraph.cpp b/src/PdGraph.cpp index 5f35aac0..46475005 100644 --- a/src/PdGraph.cpp +++ b/src/PdGraph.cpp @@ -40,7 +40,7 @@ // a PdGraph begins with zero inlets and zero outlets. These will be added as inlet/~ and outlet/~ // objects are added to the graph -PdGraph::PdGraph(PdMessage *initMessage, PdGraph *parentGraph, PdContext *context, int graphId) : +PdGraph::PdGraph(PdMessage *initMessage, PdGraph *parentGraph, PdContext *context, int graphId, const char *graphName) : DspObject(0, 0, 0, 0, (parentGraph == NULL) ? context->getBlockSize() : parentGraph->getBlockSize(), parentGraph) { this->parentGraph = parentGraph; // == NULL if this is a root graph this->context = context; @@ -62,6 +62,7 @@ PdGraph::PdGraph(PdMessage *initMessage, PdGraph *parentGraph, PdContext *contex graphArguments->setFloat(0, (float) graphId); // $0 memcpy(graphArguments->getElement(1), initMessage->getElement(0), numInitElements * sizeof(MessageAtom)); graphArguments = graphArguments->copyToHeap(); + name = graphName; } PdGraph::~PdGraph() { diff --git a/src/PdGraph.h b/src/PdGraph.h index 5caa0639..aa99776e 100644 --- a/src/PdGraph.h +++ b/src/PdGraph.h @@ -45,7 +45,7 @@ class PdGraph : public DspObject { public: /** Instantiate an empty graph. */ - PdGraph(PdMessage *initMessage, PdGraph *graph, PdContext *context, int graphId); + PdGraph(PdMessage *initMessage, PdGraph *graph, PdContext *context, int graphId, const char *graphName); ~PdGraph(); /** diff --git a/src/ZenGarden.cpp b/src/ZenGarden.cpp index 572a8487..12645673 100644 --- a/src/ZenGarden.cpp +++ b/src/ZenGarden.cpp @@ -152,7 +152,7 @@ ZGGraph *zg_context_new_empty_graph(PdContext *context) { PdMessage *initMessage = PD_MESSAGE_ON_STACK(0); // create an empty message to use for initialisation initMessage->initWithTimestampAndNumElements(0.0, 0); // the new graph has no parent graph and is created in the given context with a unique id - PdGraph *graph = new PdGraph(initMessage, NULL, context, context->getNextGraphId()); + PdGraph *graph = new PdGraph(initMessage, NULL, context, context->getNextGraphId(), "root"); return graph; }