From 4edae3f518353bb21a02fcda2dfcff83c5a72fc3 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 26 Jan 2012 12:08:39 +0100 Subject: New onCommit scripting system. --- server/src/macroparser.cc | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'server/src/macroparser.cc') diff --git a/server/src/macroparser.cc b/server/src/macroparser.cc index 7d3f367..be781aa 100644 --- a/server/src/macroparser.cc +++ b/server/src/macroparser.cc @@ -116,6 +116,11 @@ void MacroParser::characterData(std::string &data) assert(current_script); // No script present! current_script->code.append(data); } + + if(state == COMMIT_SCRIPT) { + assert(current_commit_script); // No script present! + current_commit_script->code.append(data); + } } void MacroParser::startTag(std::string name, attributes_t &attr) @@ -147,6 +152,18 @@ void MacroParser::startTag(std::string name, attributes_t &attr) return; } + // Enable oncommit parsing + if(name == "oncommit") { + if(state != MACRO) error("oncommit found outside macro."); + state = COMMIT_SCRIPTS; + + m->resume.attributes = attr; + + assert(m); // No macro is currently available, cannot create resume! + + return; + } + // Enable Query parsing if(name == "queries") { if(state != MACRO) error("queries found outside macro."); @@ -232,8 +249,18 @@ void MacroParser::startTag(std::string name, attributes_t &attr) current_resume_script = &(m->resume_scripts.back()); } break; + case COMMIT_SCRIPTS: + { + state = COMMIT_SCRIPT; + + Script s; + s.attributes = attr; + m->commit_scripts.push_back(s); + current_commit_script = &(m->commit_scripts.back()); + } + break; default: - error("