diff options
author | Stefan Radomski <sradomski@mintwerk.de> | 2016-02-23 11:28:18 (GMT) |
---|---|---|
committer | Stefan Radomski <sradomski@mintwerk.de> | 2016-02-23 11:28:18 (GMT) |
commit | 7212d5a3dbbd2845d09df96b2c345132c8a24931 (patch) | |
tree | 194bf3525bc7b607013301b79dde6c9950ccbf2e /test/src | |
parent | 8e62f3801b98bf4b7f7f85b848b2fe6339c99162 (diff) | |
download | uscxml-7212d5a3dbbd2845d09df96b2c345132c8a24931.zip uscxml-7212d5a3dbbd2845d09df96b2c345132c8a24931.tar.gz uscxml-7212d5a3dbbd2845d09df96b2c345132c8a24931.tar.bz2 |
Some refactoring for improved compile times
Diffstat (limited to 'test/src')
-rw-r--r-- | test/src/test-arabica-namespaces.cpp | 13 | ||||
-rw-r--r-- | test/src/test-arabica-xpath.cpp | 2 | ||||
-rw-r--r-- | test/src/test-c-inline.c | 3 | ||||
-rw-r--r-- | test/src/test-c-inline.c.scxml.c | 26 | ||||
-rw-r--r-- | test/src/test-c-machine.cpp | 2 | ||||
-rw-r--r-- | test/src/test-predicates.cpp | 37 | ||||
-rw-r--r-- | test/src/test-promela-parser.cpp | 1 | ||||
-rw-r--r-- | test/src/test-w3c.cpp | 4 |
8 files changed, 51 insertions, 37 deletions
diff --git a/test/src/test-arabica-namespaces.cpp b/test/src/test-arabica-namespaces.cpp index 3214d9f..ced9578 100644 --- a/test/src/test-arabica-namespaces.cpp +++ b/test/src/test-arabica-namespaces.cpp @@ -7,7 +7,8 @@ #include <DOM/SAX2DOM/SAX2DOM.hpp> #include <DOM/io/Stream.hpp> #include "uscxml/Interpreter.h" -#include "uscxml/DOMUtils.h" +#include "uscxml/dom/DOMUtils.h" +#include "uscxml/dom/NameSpacingParser.h" using namespace Arabica::DOM; using namespace Arabica::XPath; @@ -25,8 +26,8 @@ parsed = cloneDocument(parsed);\ insertBaz(parsed);\ std::cout << parsed.first << std::endl;\ validateRootFooBarBaz(parsed);\ -assert(InterpreterImpl::filterChildElements(origNS.xmlNSPrefix + "bar", origDoc.getDocumentElement()).size() == 3);\ -assert(InterpreterImpl::filterChildElements(origNS.xmlNSPrefix + "baz", origDoc.getDocumentElement()).size() == 0); +assert(DOMUtils::filterChildElements(origNS.xmlNSPrefix + "bar", origDoc.getDocumentElement()).size() == 3);\ +assert(DOMUtils::filterChildElements(origNS.xmlNSPrefix + "baz", origDoc.getDocumentElement()).size() == 0); /** @@ -96,7 +97,7 @@ static void validateRootFoo(std::pair<Document<std::string>, NameSpaceInfo>& par assert(TAGNAME_CAST(root) == nsInfo.xmlNSPrefix + "root"); assert(LOCALNAME_CAST(root) == "root"); - NodeSet<std::string> foosFiltered = InterpreterImpl::filterChildElements(nsInfo.xmlNSPrefix + "foo", root); + NodeSet<std::string> foosFiltered = DOMUtils::filterChildElements(nsInfo.xmlNSPrefix + "foo", root); assert(foosFiltered.size() == 3); NodeSet<std::string> foosXPath = _xpath.evaluate("//" + nsInfo.xpathPrefix + "foo", root).asNodeSet(); assert(foosXPath.size() == 3); @@ -118,7 +119,7 @@ static void validateRootFooBar(std::pair<Document<std::string>, NameSpaceInfo>& Node<std::string> root = document.getDocumentElement(); _xpath.setNamespaceContext(*nsInfo.getNSContext()); - NodeSet<std::string> barsFiltered = InterpreterImpl::filterChildElements(nsInfo.xmlNSPrefix + "bar", root); + NodeSet<std::string> barsFiltered = DOMUtils::filterChildElements(nsInfo.xmlNSPrefix + "bar", root); assert(barsFiltered.size() == 3); NodeSet<std::string> barsXPath = _xpath.evaluate("//" + nsInfo.xpathPrefix + "bar", root).asNodeSet(); assert(barsXPath.size() == 3); @@ -143,7 +144,7 @@ static void validateRootFooBarBaz(std::pair<Document<std::string>, NameSpaceInfo assert(TAGNAME_CAST(root) == nsInfo.xmlNSPrefix + "root"); assert(LOCALNAME_CAST(root) == "root"); - NodeSet<std::string> bazsFiltered = InterpreterImpl::filterChildElements(nsInfo.xmlNSPrefix + "baz", root); + NodeSet<std::string> bazsFiltered = DOMUtils::filterChildElements(nsInfo.xmlNSPrefix + "baz", root); assert(bazsFiltered.size() == 3); NodeSet<std::string> bazsXPath = _xpath.evaluate("//" + nsInfo.xpathPrefix + "baz", root).asNodeSet(); assert(bazsXPath.size() == 3); diff --git a/test/src/test-arabica-xpath.cpp b/test/src/test-arabica-xpath.cpp index 998f4aa..9e21624 100644 --- a/test/src/test-arabica-xpath.cpp +++ b/test/src/test-arabica-xpath.cpp @@ -5,7 +5,7 @@ #include <DOM/io/Stream.hpp> #include <iostream> #include <string> -#include "uscxml/DOMUtils.h" +#include "uscxml/dom/DOMUtils.h" #define string_type std::string #define string_adaptor Arabica::default_string_adaptor<std::string> diff --git a/test/src/test-c-inline.c b/test/src/test-c-inline.c index c12ac73..a4b237c 100644 --- a/test/src/test-c-inline.c +++ b/test/src/test-c-inline.c @@ -28,10 +28,11 @@ void enteredFoo() { int main(int argc, char** argv) { uscxml_ctx ctx; + int err = USCXML_ERR_OK; + memset(&ctx, 0, sizeof(uscxml_ctx)); ctx.machine = &USCXML_MACHINE_TEST_INLINE; - int err = USCXML_ERR_OK; while(err != USCXML_ERR_DONE) { err = uscxml_step(&ctx); } diff --git a/test/src/test-c-inline.c.scxml.c b/test/src/test-c-inline.c.scxml.c index d586bb3..740d030 100644 --- a/test/src/test-c-inline.c.scxml.c +++ b/test/src/test-c-inline.c.scxml.c @@ -60,7 +60,7 @@ */ #ifndef USCXML_MAX_NR_TRANS_BYTES -# define USCXML_MAX_NR_TRANS_BYTES 0 +# define USCXML_MAX_NR_TRANS_BYTES 1 #endif /** @@ -165,12 +165,14 @@ typedef struct uscxml_elem_invoke uscxml_elem_invoke; typedef struct uscxml_elem_send uscxml_elem_send; typedef struct uscxml_elem_param uscxml_elem_param; typedef struct uscxml_elem_data uscxml_elem_data; +typedef struct uscxml_elem_assign uscxml_elem_assign; typedef struct uscxml_elem_donedata uscxml_elem_donedata; typedef struct uscxml_elem_foreach uscxml_elem_foreach; typedef void* (*dequeue_internal_t)(const uscxml_ctx* ctx); typedef void* (*dequeue_external_t)(const uscxml_ctx* ctx); -typedef int (*is_enabled_t)(const uscxml_ctx* ctx, const uscxml_transition* transition, const void* event); +typedef int (*is_enabled_t)(const uscxml_ctx* ctx, const uscxml_transition* transition); +typedef int (*is_matched_t)(const uscxml_ctx* ctx, const uscxml_transition* transition, const void* event); typedef int (*is_true_t)(const uscxml_ctx* ctx, const char* expr); typedef int (*exec_content_t)(const uscxml_ctx* ctx, const uscxml_state* state, const void* event); typedef int (*raise_done_event_t)(const uscxml_ctx* ctx, const uscxml_state* state, const uscxml_elem_donedata* donedata); @@ -182,7 +184,7 @@ typedef int (*exec_content_send_t)(const uscxml_ctx* ctx, const uscxml_elem_send typedef int (*exec_content_foreach_init_t)(const uscxml_ctx* ctx, const uscxml_elem_foreach* foreach); typedef int (*exec_content_foreach_next_t)(const uscxml_ctx* ctx, const uscxml_elem_foreach* foreach); typedef int (*exec_content_foreach_done_t)(const uscxml_ctx* ctx, const uscxml_elem_foreach* foreach); -typedef int (*exec_content_assign_t)(const uscxml_ctx* ctx, const char* location, const char* expr); +typedef int (*exec_content_assign_t)(const uscxml_ctx* ctx, const uscxml_elem_assign* assign); typedef int (*exec_content_init_t)(const uscxml_ctx* ctx, const uscxml_elem_data* data); typedef int (*exec_content_cancel_t)(const uscxml_ctx* ctx, const char* sendid, const char* sendidexpr); typedef int (*exec_content_finalize_t)(const uscxml_ctx* ctx, const uscxml_elem_invoke* invoker, const void* event); @@ -218,6 +220,15 @@ struct uscxml_elem_data { }; /** + * All information pertaining to an <assign> element. + */ +struct uscxml_elem_assign { + const char* location; + const char* expr; + const char* content; +}; + +/** * All information pertaining to any state element. */ struct uscxml_state { @@ -335,6 +346,7 @@ struct uscxml_ctx { dequeue_internal_t dequeue_internal; dequeue_external_t dequeue_external; is_enabled_t is_enabled; + is_matched_t is_matched; is_true_t is_true; raise_done_event_t raise_done_event; @@ -420,9 +432,6 @@ static const uscxml_state _uscxml_9FAC9BE9_states[2] = { #ifndef USCXML_NO_ELEM_INFO -static const uscxml_transition _uscxml_9FAC9BE9_transitions[0] = { -}; - #endif #ifndef USCXML_NO_ELEM_INFO @@ -441,7 +450,7 @@ const uscxml_machine _uscxml_9FAC9BE9_machine = { /* datamodel */ "native", /* uuid */ "9FAC9BE9A82F66AFD36A205557064B27", /* states */ &_uscxml_9FAC9BE9_states[0], - /* transitions */ &_uscxml_9FAC9BE9_transitions[0], + /* transitions */ NULL, /* parent */ NULL, /* donedata */ &_uscxml_9FAC9BE9_elem_donedatas[0], /* script */ NULL @@ -656,7 +665,8 @@ SELECT_TRANSITIONS: if ((USCXML_GET_TRANS(i).event == NULL && ctx->event == NULL) || (USCXML_GET_TRANS(i).event != NULL && ctx->event != NULL)) { /* is it enabled? */ - if (ctx->is_enabled(ctx, &USCXML_GET_TRANS(i), ctx->event) > 0) { + if ((ctx->event == NULL || ctx->is_matched(ctx, &USCXML_GET_TRANS(i), ctx->event) > 0) && + (USCXML_GET_TRANS(i).condition == NULL || ctx->is_enabled(ctx, &USCXML_GET_TRANS(i)) > 0)) { /* remember that we found a transition */ ctx->flags |= USCXML_CTX_TRANSITION_FOUND; diff --git a/test/src/test-c-machine.cpp b/test/src/test-c-machine.cpp index b4864e2..815993e 100644 --- a/test/src/test-c-machine.cpp +++ b/test/src/test-c-machine.cpp @@ -23,7 +23,7 @@ #include "uscxml/Convenience.h" #include "uscxml/URL.h" #include "uscxml/concurrency/Timer.h" -//#include "uscxml/DOMUtils.h" +//#include "uscxml/dom/DOMUtils.h" #include "uscxml/Factory.h" //#include "uscxml/Interpreter.h" #include "uscxml/UUID.h" diff --git a/test/src/test-predicates.cpp b/test/src/test-predicates.cpp index 7ba9225..0aff104 100644 --- a/test/src/test-predicates.cpp +++ b/test/src/test-predicates.cpp @@ -1,5 +1,6 @@ #define protected public #include "uscxml/Interpreter.h" +#include "uscxml/util/String.h" #undef protected #include <iostream> @@ -54,35 +55,35 @@ int main(int argc, char** argv) { { std::string idrefs("id1"); - std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs); + std::list<std::string> tokenizedIdrefs = tokenize(idrefs); assert(tokenizedIdrefs.size() == 1); assert(tokenizedIdrefs.front().compare("id1") == 0); } { std::string idrefs(" id1"); - std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs); + std::list<std::string> tokenizedIdrefs = tokenize(idrefs); assert(tokenizedIdrefs.size() == 1); assert(tokenizedIdrefs.front().compare("id1") == 0); } { std::string idrefs(" id1 "); - std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs); + std::list<std::string> tokenizedIdrefs = tokenize(idrefs); assert(tokenizedIdrefs.size() == 1); assert(tokenizedIdrefs.front().compare("id1") == 0); } { std::string idrefs(" \tid1\n "); - std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs); + std::list<std::string> tokenizedIdrefs = tokenize(idrefs); assert(tokenizedIdrefs.size() == 1); assert(tokenizedIdrefs.front().compare("id1") == 0); } { std::string idrefs("id1 id2 id3"); - std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs); + std::list<std::string> tokenizedIdrefs = tokenize(idrefs); assert(tokenizedIdrefs.size() == 3); assert(tokenizedIdrefs.front().compare("id1") == 0); tokenizedIdrefs.pop_front(); @@ -93,7 +94,7 @@ int main(int argc, char** argv) { { std::string idrefs("\t id1 \nid2\n\n id3\t"); - std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs); + std::list<std::string> tokenizedIdrefs = tokenize(idrefs); assert(tokenizedIdrefs.size() == 3); assert(tokenizedIdrefs.front().compare("id1") == 0); tokenizedIdrefs.pop_front(); @@ -104,7 +105,7 @@ int main(int argc, char** argv) { { std::string idrefs("id1 \nid2 \tid3"); - std::list<std::string> tokenizedIdrefs = InterpreterImpl::tokenizeIdRefs(idrefs); + std::list<std::string> tokenizedIdrefs = tokenize(idrefs); assert(tokenizedIdrefs.size() == 3); assert(tokenizedIdrefs.front().compare("id1") == 0); tokenizedIdrefs.pop_front(); @@ -115,20 +116,20 @@ int main(int argc, char** argv) { std::string transEvents; transEvents = "error"; - assert(InterpreterImpl::nameMatch(transEvents, "error")); - assert(!InterpreterImpl::nameMatch(transEvents, "foo")); + assert(nameMatch(transEvents, "error")); + assert(!nameMatch(transEvents, "foo")); transEvents = " error foo"; - assert(InterpreterImpl::nameMatch(transEvents, "error")); - assert(InterpreterImpl::nameMatch(transEvents, "error.send")); - assert(InterpreterImpl::nameMatch(transEvents, "error.send.failed")); - assert(InterpreterImpl::nameMatch(transEvents, "foo")); - assert(InterpreterImpl::nameMatch(transEvents, "foo.bar")); - assert(!InterpreterImpl::nameMatch(transEvents, "errors.my.custom")); - assert(!InterpreterImpl::nameMatch(transEvents, "errorhandler.mistake")); + assert(nameMatch(transEvents, "error")); + assert(nameMatch(transEvents, "error.send")); + assert(nameMatch(transEvents, "error.send.failed")); + assert(nameMatch(transEvents, "foo")); + assert(nameMatch(transEvents, "foo.bar")); + assert(!nameMatch(transEvents, "errors.my.custom")); + assert(!nameMatch(transEvents, "errorhandler.mistake")); // is the event name case sensitive? - // assert(!InterpreterImpl::nameMatch(transEvents, "errOr.send")); - assert(!InterpreterImpl::nameMatch(transEvents, "foobar")); + // assert(!nameMatch(transEvents, "errOr.send")); + assert(!nameMatch(transEvents, "foobar")); } catch(std::exception e) { std::cout << e.what(); return false; diff --git a/test/src/test-promela-parser.cpp b/test/src/test-promela-parser.cpp index cab19ab..f3ac4cc 100644 --- a/test/src/test-promela-parser.cpp +++ b/test/src/test-promela-parser.cpp @@ -9,6 +9,7 @@ #include <assert.h> #include <boost/algorithm/string.hpp> #include <iostream> +#include <DOM/SAX2DOM/SAX2DOM.hpp> #include <DOM/Document.hpp> using namespace uscxml; diff --git a/test/src/test-w3c.cpp b/test/src/test-w3c.cpp index 0ac33a7..669db30 100644 --- a/test/src/test-w3c.cpp +++ b/test/src/test-w3c.cpp @@ -21,7 +21,7 @@ # endif -#include "uscxml/DOMUtils.h" +#include "uscxml/dom/DOMUtils.h" #include "uscxml/concurrency/Timer.h" #include "uscxml/Factory.h" @@ -178,7 +178,7 @@ int main(int argc, char** argv) { if (delayFactor != 1) { Arabica::DOM::Document<std::string> document = interpreter.getDocument(); Arabica::DOM::Element<std::string> root = document.getDocumentElement(); - Arabica::XPath::NodeSet<std::string> sends = InterpreterImpl::filterChildElements(interpreter.getNameSpaceInfo().xmlNSPrefix + "send", root, true); + Arabica::XPath::NodeSet<std::string> sends = DOMUtils::filterChildElements(interpreter.getNameSpaceInfo().xmlNSPrefix + "send", root, true); for (int i = 0; i < sends.size(); i++) { Arabica::DOM::Element<std::string> send = Arabica::DOM::Element<std::string>(sends[i]); |