From d9338083192084613e5530b02710b796252d342b Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 12 Aug 2010 10:57:04 +0000 Subject: New scripting system part2. --- server/src/macroparser.cc | 65 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 16 deletions(-) (limited to 'server/src/macroparser.cc') diff --git a/server/src/macroparser.cc b/server/src/macroparser.cc index fe7f6e3..2bd482e 100644 --- a/server/src/macroparser.cc +++ b/server/src/macroparser.cc @@ -84,6 +84,7 @@ MacroParser::MacroParser(std::string macrofile) m = NULL; current_map = NULL; current_script = NULL; + current_resume_script = NULL; file = macrofile; @@ -101,9 +102,9 @@ MacroParser::~MacroParser() void MacroParser::characterData(std::string &data) { - if(state == RESUME) { - assert(m); // No macro present! - m->resume.attributes["format"].append(data); + if(state == RESUME_SCRIPT) { + assert(current_resume_script); // No macro present! + current_resume_script->code.append(data); } if(state == MAP) { @@ -117,7 +118,8 @@ void MacroParser::characterData(std::string &data) } } -void MacroParser::startTag(std::string name, std::map< std::string, std::string> attributes) +void MacroParser::startTag(std::string name, + std::map< std::string, std::string> attributes) { // Create macro and enable parsing of queries, maps and widgets if(name == "macro") { @@ -203,18 +205,36 @@ void MacroParser::startTag(std::string name, std::map< std::string, std::string> return; } - // Create Query + // Create script if(name == "script") { - if(state != SCRIPTS) error("script found outside scripts."); - state = SCRIPT; - - assert(m); // No macro is currently available, cannot create map! - - Script s; - s.attributes = attributes; - m->scripts.push_back(s); - current_script = &(m->scripts.back()); + assert(m); // No macro is currently available, cannot create script! + + switch(state) { + case SCRIPTS: + { + state = SCRIPT; + + Script s; + s.attributes = attributes; + m->scripts.push_back(s); + current_script = &(m->scripts.back()); + } + break; + case RESUME: + { + state = RESUME_SCRIPT; + + Script s; + s.attributes = attributes; + m->resume_scripts.push_back(s); + current_resume_script = &(m->resume_scripts.back()); + } + break; + default: + error("