From a56f28b0db56ff3e39f0b50e4c55c52b7aeec696 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Wed, 20 Feb 2013 22:13:02 +0100 Subject: See detailled log - Builds on windows again - All HTTP requests are no passed into interpreter - New response element to reply with data - Moved basichttp URL - New HTTP servlet invoker to register additional URLs - More bugfixes than I care to mention --- CMakeLists.txt | 73 +- apps/mmi-browser.cpp | 3 + apps/samples/vrml-server.scxml | 26 +- contrib/cmake/FindEVENT.cmake | 17 +- contrib/cmake/FindGLOG.cmake | 4 + contrib/cmake/FindSWI.cmake | 119 ++- contrib/cmake/FindV8.cmake | 20 + contrib/dom/idl/SCXMLEvent.idl | 3 +- contrib/dom/scripts/CodeGeneratorArabicaV8.pm | 4 + contrib/prebuilt/include/SWI-cpp.h | 1093 ++++++++++++++++++++ src/uscxml/Factory.cpp | 41 +- src/uscxml/Factory.h | 63 +- src/uscxml/Interpreter.cpp | 559 +++++++--- src/uscxml/Interpreter.h | 40 +- src/uscxml/Message.cpp | 55 +- src/uscxml/Message.h | 5 +- src/uscxml/URL.cpp | 894 ++++++++-------- src/uscxml/URL.cpp.old | 519 ++++++++++ src/uscxml/URL.h | 246 +++-- src/uscxml/URL.h.old | 154 +++ .../concurrency/eventqueue/DelayedEventQueue.cpp | 3 +- .../datamodel/ecmascript/v8/V8DataModel.cpp | 20 +- .../plugins/datamodel/ecmascript/v8/V8DataModel.h | 1 - .../plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp | 84 +- .../plugins/datamodel/ecmascript/v8/dom/V8Attr.h | 88 +- .../datamodel/ecmascript/v8/dom/V8CDATASection.cpp | 12 +- .../datamodel/ecmascript/v8/dom/V8CDATASection.h | 44 +- .../ecmascript/v8/dom/V8CharacterData.cpp | 144 +-- .../datamodel/ecmascript/v8/dom/V8CharacterData.h | 106 +- .../datamodel/ecmascript/v8/dom/V8Comment.cpp | 12 +- .../datamodel/ecmascript/v8/dom/V8Comment.h | 44 +- .../ecmascript/v8/dom/V8DOMImplementation.cpp | 108 +- .../ecmascript/v8/dom/V8DOMImplementation.h | 60 +- .../datamodel/ecmascript/v8/dom/V8Document.cpp | 558 +++++----- .../datamodel/ecmascript/v8/dom/V8Document.h | 170 +-- .../ecmascript/v8/dom/V8DocumentFragment.cpp | 12 +- .../ecmascript/v8/dom/V8DocumentFragment.h | 44 +- .../datamodel/ecmascript/v8/dom/V8DocumentType.cpp | 112 +- .../datamodel/ecmascript/v8/dom/V8DocumentType.h | 98 +- .../datamodel/ecmascript/v8/dom/V8Element.cpp | 418 ++++---- .../datamodel/ecmascript/v8/dom/V8Element.h | 158 +-- .../datamodel/ecmascript/v8/dom/V8Entity.cpp | 42 +- .../plugins/datamodel/ecmascript/v8/dom/V8Entity.h | 80 +- .../ecmascript/v8/dom/V8EntityReference.cpp | 12 +- .../ecmascript/v8/dom/V8EntityReference.h | 44 +- .../datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp | 258 ++--- .../datamodel/ecmascript/v8/dom/V8NamedNodeMap.h | 108 +- .../plugins/datamodel/ecmascript/v8/dom/V8Node.cpp | 594 +++++------ .../plugins/datamodel/ecmascript/v8/dom/V8Node.h | 250 ++--- .../datamodel/ecmascript/v8/dom/V8NodeList.cpp | 54 +- .../datamodel/ecmascript/v8/dom/V8NodeList.h | 54 +- .../datamodel/ecmascript/v8/dom/V8NodeSet.cpp | 44 +- .../datamodel/ecmascript/v8/dom/V8NodeSet.h | 82 +- .../datamodel/ecmascript/v8/dom/V8Notation.cpp | 32 +- .../datamodel/ecmascript/v8/dom/V8Notation.h | 56 +- .../ecmascript/v8/dom/V8ProcessingInstruction.cpp | 44 +- .../ecmascript/v8/dom/V8ProcessingInstruction.h | 58 +- .../datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp | 102 +- .../datamodel/ecmascript/v8/dom/V8SCXMLEvent.h | 114 +- .../plugins/datamodel/ecmascript/v8/dom/V8Text.cpp | 44 +- .../plugins/datamodel/ecmascript/v8/dom/V8Text.h | 50 +- .../datamodel/ecmascript/v8/dom/V8XPathResult.cpp | 104 +- .../datamodel/ecmascript/v8/dom/V8XPathResult.h | 108 +- src/uscxml/plugins/element/fetch/FetchElement.cpp | 108 ++ src/uscxml/plugins/element/fetch/FetchElement.h | 48 + .../plugins/element/response/ResponseElement.cpp | 68 ++ .../plugins/element/response/ResponseElement.h | 42 + .../invoker/filesystem/dirmon/DirMonInvoker.cpp | 16 +- .../plugins/invoker/http/HTTPServletInvoker.cpp | 147 +++ .../plugins/invoker/http/HTTPServletInvoker.h | 55 + .../plugins/invoker/umundo/UmundoInvoker.cpp | 16 +- src/uscxml/plugins/invoker/umundo/UmundoInvoker.h | 8 +- .../basichttp/libevent/EventIOProcessor.cpp | 395 ++----- .../basichttp/libevent/EventIOProcessor.h | 79 +- src/uscxml/server/HTTPServer.cpp | 223 ++++ src/uscxml/server/HTTPServer.h | 92 ++ test/CMakeLists.txt | 64 +- test/run-scxml-test-framework.sh | 7 +- .../uscxml/test-custom-executable-content.scxml | 19 + test/samples/uscxml/test-ecmascript.scxml | 8 +- test/samples/uscxml/test-http-servlet.scxml | 41 + test/samples/uscxml/test-response-element.scxml | 14 + .../test-ext/node/require/require.json | 12 - .../test-ext/node/require/require.scxml | 56 - .../test-ext/node/require/script2.js | 1 - .../test-ext/node/require/script3.js | 1 - .../test-ext/node/require/script4.js | 1 - .../test-ext/node/require/submodule1.js | 1 - .../test-ext/node/require/submodule2.js | 1 - .../test-ext/node/require/submodule3.js | 1 - .../test-ext/node/require/submodule4.js | 1 - test/scxml-test-framework/test-ext/node/runner.js | 11 - .../test/actionSend/send1.json | 14 +- .../test/actionSend/send1.scxml | 38 +- .../test/actionSend/send2.json | 14 +- .../test/actionSend/send2.scxml | 44 +- .../test/actionSend/send3.json | 14 +- .../test/actionSend/send3.scxml | 44 +- .../test/actionSend/send4.json | 14 +- .../test/actionSend/send4.scxml | 68 +- .../test/actionSend/send5.json | 14 +- .../test/actionSend/send5.scxml | 70 +- .../test/actionSend/send6.json | 14 +- .../test/actionSend/send6.scxml | 72 +- .../test/actionSend/send7.json | 14 +- .../test/actionSend/send7.scxml | 52 +- .../test/actionSend/send8.json | 14 +- .../test/actionSend/send8.scxml | 52 +- .../test/assign-current-small-step/test0.json | 14 +- .../test/assign-current-small-step/test0.scxml | 63 +- .../test/assign-current-small-step/test1.json | 14 +- .../test/assign-current-small-step/test1.scxml | 49 +- .../test/assign-current-small-step/test2.json | 14 +- .../test/assign-current-small-step/test2.scxml | 69 +- .../test/assign-current-small-step/test3.json | 30 +- .../test/assign-current-small-step/test3.scxml | 75 +- .../test/assign-current-small-step/test4.json | 14 +- .../test/assign-current-small-step/test4.scxml | 45 +- .../test/assign-next-small-step/test0.json | 12 - .../test/assign-next-small-step/test0.scxml | 49 - .../test/assign-next-small-step/test1.json | 12 - .../test/assign-next-small-step/test1.scxml | 53 - .../test/assign-next-small-step/test2.json | 13 - .../test/assign-next-small-step/test2.scxml | 78 -- .../test/assign-next-small-step/test3.json | 22 - .../test/assign-next-small-step/test3.scxml | 81 -- .../test/atom3-basic-tests/m0.json | 22 +- .../test/atom3-basic-tests/m0.scxml | 37 +- .../test/atom3-basic-tests/m1.json | 22 +- .../test/atom3-basic-tests/m1.scxml | 7 +- .../test/atom3-basic-tests/m2.json | 22 +- .../test/atom3-basic-tests/m2.scxml | 7 +- .../test/atom3-basic-tests/m3.json | 38 +- .../test/atom3-basic-tests/m3.scxml | 7 +- test/scxml-test-framework/test/basic/basic0.json | 4 +- test/scxml-test-framework/test/basic/basic0.scxml | 11 +- test/scxml-test-framework/test/basic/basic1.json | 14 +- test/scxml-test-framework/test/basic/basic1.scxml | 19 +- test/scxml-test-framework/test/basic/basic2.json | 22 +- test/scxml-test-framework/test/basic/basic2.scxml | 24 +- .../test/cond-js/TestConditionalTransition.json | 54 +- .../test/cond-js/TestConditionalTransition.scxml | 116 +-- test/scxml-test-framework/test/cond-js/test0.json | 14 +- test/scxml-test-framework/test/cond-js/test0.scxml | 19 +- test/scxml-test-framework/test/cond-js/test1.json | 14 +- test/scxml-test-framework/test/cond-js/test1.scxml | 23 +- test/scxml-test-framework/test/cond-js/test2.json | 14 +- test/scxml-test-framework/test/cond-js/test2.scxml | 19 +- .../test/default-initial-state/initial1.json | 14 +- .../test/default-initial-state/initial1.scxml | 16 +- .../test/default-initial-state/initial2.json | 14 +- .../test/default-initial-state/initial2.scxml | 16 +- .../test/default-initial-state/initial3.json | 14 - .../test/default-initial-state/initial3.scxml | 33 - .../test/delayedSend/send1.json | 24 +- .../test/delayedSend/send1.scxml | 43 +- .../test/delayedSend/send2.json | 24 +- .../test/delayedSend/send2.scxml | 39 +- .../test/delayedSend/send3.json | 24 +- .../test/delayedSend/send3.scxml | 39 +- .../test/documentOrder/documentOrder0.json | 14 +- .../test/documentOrder/documentOrder0.scxml | 29 +- test/scxml-test-framework/test/foreach/test1.json | 14 +- test/scxml-test-framework/test/foreach/test1.scxml | 51 +- .../test/hierarchy+documentOrder/test0.json | 14 +- .../test/hierarchy+documentOrder/test0.scxml | 43 +- .../test/hierarchy+documentOrder/test1.json | 14 +- .../test/hierarchy+documentOrder/test1.scxml | 43 +- .../scxml-test-framework/test/hierarchy/hier0.json | 14 +- .../test/hierarchy/hier0.scxml | 29 +- .../scxml-test-framework/test/hierarchy/hier1.json | 14 +- .../test/hierarchy/hier1.scxml | 29 +- .../scxml-test-framework/test/hierarchy/hier2.json | 14 +- .../test/hierarchy/hier2.scxml | 29 +- .../test/history/history0.json | 38 +- .../test/history/history0.scxml | 39 +- .../test/history/history1.json | 38 +- .../test/history/history1.scxml | 43 +- .../test/history/history2.json | 38 +- .../test/history/history2.scxml | 43 +- .../test/history/history3.json | 38 +- .../test/history/history3.scxml | 67 +- .../test/history/history4.json | 78 +- .../test/history/history4.scxml | 143 +-- .../test/history/history5.json | 30 +- .../test/history/history5.scxml | 99 +- .../test/history/history6.json | 46 +- .../test/history/history6.scxml | 59 +- test/scxml-test-framework/test/if-else/test0.json | 14 +- test/scxml-test-framework/test/if-else/test0.scxml | 155 ++- .../test/in/TestInPredicate.json | 86 +- .../test/in/TestInPredicate.scxml | 172 ++- .../test/internal-transitions/test0.json | 17 + .../test/internal-transitions/test0.scxml | 56 + .../test/internal-transitions/test1.json | 18 + .../test/internal-transitions/test1.scxml | 89 ++ .../test/more-parallel/test0.json | 14 +- .../test/more-parallel/test0.scxml | 18 +- .../test/more-parallel/test1.json | 14 +- .../test/more-parallel/test1.scxml | 27 +- .../test/more-parallel/test10.json | 17 + .../test/more-parallel/test10.scxml | 63 ++ .../test/more-parallel/test2.json | 14 +- .../test/more-parallel/test2.scxml | 31 +- .../test/more-parallel/test3.json | 14 +- .../test/more-parallel/test3.scxml | 35 +- .../test/more-parallel/test4.json | 14 +- .../test/more-parallel/test4.scxml | 27 +- .../test/more-parallel/test5.json | 16 +- .../test/more-parallel/test5.scxml | 27 +- .../test/more-parallel/test6.json | 14 +- .../test/more-parallel/test6.scxml | 55 +- .../test/more-parallel/test7.json | 14 +- .../test/more-parallel/test7.scxml | 53 +- .../test/more-parallel/test8.json | 14 +- .../test/more-parallel/test8.scxml | 61 +- .../test/more-parallel/test9.json | 14 +- .../test/more-parallel/test9.scxml | 61 +- .../test/multiple-events-per-transition/test1.json | 30 +- .../multiple-events-per-transition/test1.scxml | 26 +- .../test/parallel+interrupt/test0.json | 14 +- .../test/parallel+interrupt/test0.scxml | 29 +- .../test/parallel+interrupt/test1.json | 14 +- .../test/parallel+interrupt/test1.scxml | 47 +- .../test/parallel+interrupt/test10.json | 16 +- .../test/parallel+interrupt/test10.scxml | 39 +- .../test/parallel+interrupt/test11.json | 16 +- .../test/parallel+interrupt/test11.scxml | 43 +- .../test/parallel+interrupt/test12.json | 16 +- .../test/parallel+interrupt/test12.scxml | 43 +- .../test/parallel+interrupt/test13.json | 16 +- .../test/parallel+interrupt/test13.scxml | 43 +- .../test/parallel+interrupt/test14.json | 16 +- .../test/parallel+interrupt/test14.scxml | 87 +- .../test/parallel+interrupt/test15.json | 16 +- .../test/parallel+interrupt/test15.scxml | 67 +- .../test/parallel+interrupt/test16.json | 16 +- .../test/parallel+interrupt/test16.scxml | 33 +- .../test/parallel+interrupt/test17.json | 16 +- .../test/parallel+interrupt/test17.scxml | 33 +- .../test/parallel+interrupt/test18.json | 16 +- .../test/parallel+interrupt/test18.scxml | 27 +- .../test/parallel+interrupt/test19.json | 16 +- .../test/parallel+interrupt/test19.scxml | 41 +- .../test/parallel+interrupt/test2.json | 14 +- .../test/parallel+interrupt/test2.scxml | 39 +- .../test/parallel+interrupt/test20.json | 16 +- .../test/parallel+interrupt/test20.scxml | 37 +- .../test/parallel+interrupt/test21.json | 16 +- .../test/parallel+interrupt/test21.scxml | 37 +- .../test/parallel+interrupt/test22.json | 16 +- .../test/parallel+interrupt/test22.scxml | 41 +- .../test/parallel+interrupt/test23.json | 16 +- .../test/parallel+interrupt/test23.scxml | 27 +- .../test/parallel+interrupt/test24.json | 16 +- .../test/parallel+interrupt/test24.scxml | 41 +- .../test/parallel+interrupt/test25.json | 16 +- .../test/parallel+interrupt/test25.scxml | 37 +- .../test/parallel+interrupt/test26.json | 16 +- .../test/parallel+interrupt/test26.scxml | 37 +- .../test/parallel+interrupt/test27.json | 16 +- .../test/parallel+interrupt/test27.scxml | 41 +- .../test/parallel+interrupt/test28.json | 16 +- .../test/parallel+interrupt/test28.scxml | 31 +- .../test/parallel+interrupt/test29.json | 16 +- .../test/parallel+interrupt/test29.scxml | 31 +- .../test/parallel+interrupt/test3.json | 16 +- .../test/parallel+interrupt/test3.scxml | 45 +- .../test/parallel+interrupt/test30.json | 16 +- .../test/parallel+interrupt/test30.scxml | 41 +- .../test/parallel+interrupt/test31.json | 16 +- .../test/parallel+interrupt/test31.scxml | 45 +- .../test/parallel+interrupt/test4.json | 16 +- .../test/parallel+interrupt/test4.scxml | 51 +- .../test/parallel+interrupt/test5.json | 16 +- .../test/parallel+interrupt/test5.scxml | 51 +- .../test/parallel+interrupt/test6.json | 14 +- .../test/parallel+interrupt/test6.scxml | 59 +- .../test/parallel+interrupt/test7.json | 16 +- .../test/parallel+interrupt/test7.scxml | 49 +- .../test/parallel+interrupt/test8.json | 16 +- .../test/parallel+interrupt/test8.scxml | 49 +- .../test/parallel+interrupt/test9.json | 16 +- .../test/parallel+interrupt/test9.scxml | 47 +- test/scxml-test-framework/test/parallel/test0.json | 4 +- .../scxml-test-framework/test/parallel/test0.scxml | 19 +- test/scxml-test-framework/test/parallel/test1.json | 16 +- .../scxml-test-framework/test/parallel/test1.scxml | 56 - .../test/parallel/test1.scxml.fail | 51 + test/scxml-test-framework/test/parallel/test2.json | 16 +- .../scxml-test-framework/test/parallel/test2.scxml | 59 +- test/scxml-test-framework/test/parallel/test3.json | 16 +- .../scxml-test-framework/test/parallel/test3.scxml | 79 +- .../test/script-src/script-0-0.js | 2 +- .../test/script-src/script-1-0.js | 2 +- .../test/script-src/script-1-1.js | 2 +- .../test/script-src/script-2-0.js | 2 +- .../test/script-src/script-2-1.js | 2 +- .../test/script-src/script-2-2.js | 2 +- .../test/script-src/script-2-3.js | 2 +- .../test/script-src/script-3-0.js | 2 +- .../test/script-src/test0.json | 14 +- .../test/script-src/test0.scxml | 31 +- .../test/script-src/test1.json | 14 +- .../test/script-src/test1.scxml | 51 +- .../test/script-src/test2.json | 14 +- .../test/script-src/test2.scxml | 63 +- .../test/script-src/test3.json | 14 +- .../test/script-src/test3.scxml | 35 +- test/scxml-test-framework/test/script/test0.json | 14 +- test/scxml-test-framework/test/script/test0.scxml | 49 +- test/scxml-test-framework/test/script/test1.json | 14 +- test/scxml-test-framework/test/script/test1.scxml | 58 +- test/scxml-test-framework/test/script/test2.json | 14 +- test/scxml-test-framework/test/script/test2.scxml | 105 +- .../scxml-prefix-event-name-matching/star0.json | 14 +- .../scxml-prefix-event-name-matching/star0.scxml | 24 +- .../scxml-prefix-event-name-matching/test0.json | 70 +- .../scxml-prefix-event-name-matching/test0.scxml | 44 +- .../scxml-prefix-event-name-matching/test1.json | 70 +- .../scxml-prefix-event-name-matching/test1.scxml | 52 +- .../scxml-test-framework/test/send-data/send1.json | 25 +- .../test/send-data/send1.scxml | 82 +- .../test/send-internal/test0.json | 14 +- .../test/send-internal/test0.scxml | 80 +- .../test/targetless-transition/test0.json | 14 +- .../test/targetless-transition/test0.scxml | 40 +- .../test/targetless-transition/test1.json | 22 +- .../test/targetless-transition/test1.scxml | 46 +- .../test/targetless-transition/test2.json | 22 +- .../test/targetless-transition/test2.scxml | 52 +- .../test/targetless-transition/test3.json | 22 +- .../test/targetless-transition/test3.scxml | 102 +- test/src/scxml-test-framework-client.cpp | 130 ++- test/src/test-communication.cpp | 31 - test/src/test-communication.cpp.old | 31 + test/src/test-completion.cpp | 20 - test/src/test-completion.cpp.old | 20 + test/src/test-curl-multi-api.cpp | 347 +++++++ test/src/test-ecmascript-v8.cpp | 24 - test/src/test-ecmascript-v8.cpp.old | 24 + test/src/test-execution.cpp | 16 - test/src/test-execution.cpp.old | 16 + test/src/test-prolog-swi.cpp | 93 -- test/src/test-prolog-swi.cpp.old | 93 ++ 345 files changed, 10930 insertions(+), 8026 deletions(-) create mode 100644 contrib/prebuilt/include/SWI-cpp.h create mode 100644 src/uscxml/URL.cpp.old create mode 100644 src/uscxml/URL.h.old create mode 100644 src/uscxml/plugins/element/fetch/FetchElement.cpp create mode 100644 src/uscxml/plugins/element/fetch/FetchElement.h create mode 100644 src/uscxml/plugins/element/response/ResponseElement.cpp create mode 100644 src/uscxml/plugins/element/response/ResponseElement.h create mode 100644 src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp create mode 100644 src/uscxml/plugins/invoker/http/HTTPServletInvoker.h create mode 100644 src/uscxml/server/HTTPServer.cpp create mode 100644 src/uscxml/server/HTTPServer.h create mode 100644 test/samples/uscxml/test-custom-executable-content.scxml create mode 100644 test/samples/uscxml/test-http-servlet.scxml create mode 100644 test/samples/uscxml/test-response-element.scxml delete mode 100644 test/scxml-test-framework/test-ext/node/require/require.json delete mode 100644 test/scxml-test-framework/test-ext/node/require/require.scxml delete mode 100644 test/scxml-test-framework/test-ext/node/require/script2.js delete mode 100644 test/scxml-test-framework/test-ext/node/require/script3.js delete mode 100644 test/scxml-test-framework/test-ext/node/require/script4.js delete mode 100644 test/scxml-test-framework/test-ext/node/require/submodule1.js delete mode 100644 test/scxml-test-framework/test-ext/node/require/submodule2.js delete mode 100644 test/scxml-test-framework/test-ext/node/require/submodule3.js delete mode 100644 test/scxml-test-framework/test-ext/node/require/submodule4.js delete mode 100644 test/scxml-test-framework/test-ext/node/runner.js delete mode 100644 test/scxml-test-framework/test/assign-next-small-step/test0.json delete mode 100644 test/scxml-test-framework/test/assign-next-small-step/test0.scxml delete mode 100644 test/scxml-test-framework/test/assign-next-small-step/test1.json delete mode 100644 test/scxml-test-framework/test/assign-next-small-step/test1.scxml delete mode 100644 test/scxml-test-framework/test/assign-next-small-step/test2.json delete mode 100644 test/scxml-test-framework/test/assign-next-small-step/test2.scxml delete mode 100644 test/scxml-test-framework/test/assign-next-small-step/test3.json delete mode 100644 test/scxml-test-framework/test/assign-next-small-step/test3.scxml delete mode 100644 test/scxml-test-framework/test/default-initial-state/initial3.json delete mode 100644 test/scxml-test-framework/test/default-initial-state/initial3.scxml create mode 100644 test/scxml-test-framework/test/internal-transitions/test0.json create mode 100644 test/scxml-test-framework/test/internal-transitions/test0.scxml create mode 100644 test/scxml-test-framework/test/internal-transitions/test1.json create mode 100644 test/scxml-test-framework/test/internal-transitions/test1.scxml create mode 100644 test/scxml-test-framework/test/more-parallel/test10.json create mode 100644 test/scxml-test-framework/test/more-parallel/test10.scxml delete mode 100644 test/scxml-test-framework/test/parallel/test1.scxml create mode 100644 test/scxml-test-framework/test/parallel/test1.scxml.fail delete mode 100644 test/src/test-communication.cpp create mode 100644 test/src/test-communication.cpp.old delete mode 100644 test/src/test-completion.cpp create mode 100644 test/src/test-completion.cpp.old create mode 100644 test/src/test-curl-multi-api.cpp delete mode 100644 test/src/test-ecmascript-v8.cpp create mode 100644 test/src/test-ecmascript-v8.cpp.old delete mode 100644 test/src/test-execution.cpp create mode 100644 test/src/test-execution.cpp.old delete mode 100644 test/src/test-prolog-swi.cpp create mode 100644 test/src/test-prolog-swi.cpp.old diff --git a/CMakeLists.txt b/CMakeLists.txt index f9d8864..0b655db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.4) # specify USCXML version SET(USCXML_VERSION_MAJOR "0") SET(USCXML_VERSION_MINOR "0") -SET(USCXML_VERSION_PATCH "3") +SET(USCXML_VERSION_PATCH "4") SET(USCXML_VERSION ${USCXML_VERSION_MAJOR}.${USCXML_VERSION_MINOR}.${USCXML_VERSION_PATCH}) # build type has to be set before the project definition @@ -134,9 +134,9 @@ include_directories(${USCXML_PREBUILT_LIBRARY_PATH}/include) #message("CMAKE_FIND_ROOT_PATH: ${CMAKE_FIND_ROOT_PATH}") if (WIN32) - include_directories(${PROJECT_SOURCE_DIR}/contrib/snippets) + include_directories(${PROJECT_SOURCE_DIR}/contrib/src/getopt) endif() -include_directories(${PROJECT_SOURCE_DIR}/contrib/src/jsmn/) +include_directories(${PROJECT_SOURCE_DIR}/contrib/src/jsmn) ############################################################ # General setup @@ -373,6 +373,13 @@ list (APPEND USCXML_CORE_LIBS ${EVENT_LIBRARY}) # Actual files of core library ############################################################ +file(GLOB_RECURSE USCXML_SERVER + src/uscxml/server/*.cpp + src/uscxml/server/*.h +) +source_group("Interpreter" FILES ${USCXML_SERVER}) +list (APPEND USCXML_FILES ${USCXML_SERVER}) + file(GLOB_RECURSE USCXML_CONCURRENCY src/uscxml/concurrency/*.cpp src/uscxml/concurrency/*.h @@ -416,7 +423,7 @@ if (BUILD_AS_PLUGINS) endif() ################################################# -# optional libraries we can build as plugins +# optional things we can build as plugins # sample invoker - include to make sure it compiles file(GLOB_RECURSE SAMPLE_INVOKER @@ -453,6 +460,42 @@ else() endif() +# Fetch element + +file(GLOB_RECURSE FETCH_ELEMENT + src/uscxml/plugins/element/fetch/*.cpp + src/uscxml/plugins/element/fetch/*.h +) +source_group("Element" FILES ${FETCH_ELEMENT}) +if (BUILD_AS_PLUGINS) + add_library( + element_fetch SHARED + ${FETCH_ELEMENT}) + target_link_libraries(element_fetch uscxml) + set_target_properties(element_fetch PROPERTIES FOLDER "Plugin Element") +else() + list (APPEND USCXML_FILES ${FETCH_ELEMENT}) +endif() + + +# Response element + +file(GLOB_RECURSE RESPONSE_ELEMENT + src/uscxml/plugins/element/response/*.cpp + src/uscxml/plugins/element/response/*.h +) +source_group("Element" FILES ${RESPONSE_ELEMENT}) +if (BUILD_AS_PLUGINS) + add_library( + element_response SHARED + ${RESPONSE_ELEMENT}) + target_link_libraries(element_response uscxml) + set_target_properties(element_response PROPERTIES FOLDER "Plugin Element") +else() + list (APPEND USCXML_FILES ${RESPONSE_ELEMENT}) +endif() + + # DirMon invoker to watch for filesystem changes file(GLOB_RECURSE DIRMON_INVOKER @@ -646,6 +689,24 @@ else() endif() +# HTTP server invoker + +file(GLOB_RECURSE HTTPSERVER_INVOKER + src/uscxml/plugins/invoker/http/*.cpp + src/uscxml/plugins/invoker/http/*.h) +source_group("Invoker" FILES ${HTTPSERVER_INVOKER}) +if (BUILD_AS_PLUGINS) + add_library( + invoker_httpserver SHARED + ${HTTPSERVER_INVOKER}) + target_link_libraries(invoker_httpserver + uscxml) + set_target_properties(invoker_httpserver PROPERTIES FOLDER "Plugin Invoker") +else() + list (APPEND USCXML_FILES ${HTTPSERVER_INVOKER}) +endif() + + # Heartbeat invoker file(GLOB_RECURSE HEARTBEAT_INVOKER @@ -760,7 +821,9 @@ if (BUILD_TESTS) add_subdirectory(test) endif() -add_subdirectory(src/bindings) +if (NOT WIN32) + add_subdirectory(src/bindings) +endif() ############################################################ # Header Files diff --git a/apps/mmi-browser.cpp b/apps/mmi-browser.cpp index 3ebe153..7cdd392 100644 --- a/apps/mmi-browser.cpp +++ b/apps/mmi-browser.cpp @@ -27,7 +27,9 @@ int main(int argc, char** argv) { printUsageAndExit(); } +#ifndef _WIN32 opterr = 0; +#endif int option; while ((option = getopt(argc, argv, "l:p:")) != -1) { switch(option) { @@ -55,6 +57,7 @@ int main(int argc, char** argv) { interpreter->setCmdLineOptions(argc, argv); interpreter->start(); while(interpreter->runOnMainThread(25)); + delete interpreter; } return EXIT_SUCCESS; diff --git a/apps/samples/vrml-server.scxml b/apps/samples/vrml-server.scxml index 82560ef..e88be4c 100644 --- a/apps/samples/vrml-server.scxml +++ b/apps/samples/vrml-server.scxml @@ -1,11 +1,31 @@ - + + + + + + + + @@ -41,6 +61,6 @@ - + \ No newline at end of file diff --git a/contrib/cmake/FindEVENT.cmake b/contrib/cmake/FindEVENT.cmake index 6a47584..ef6089b 100644 --- a/contrib/cmake/FindEVENT.cmake +++ b/contrib/cmake/FindEVENT.cmake @@ -10,10 +10,25 @@ FIND_PATH(EVENT_INCLUDE_DIR event2/event.h HINTS $ENV{EVENT_SRC} ) -FIND_LIBRARY(EVENT_LIBRARY +FIND_LIBRARY(EVENT_LIBRARY_RELEASE NAMES event libevent HINTS $ENV{EVENT_SRC}/.libs/ ) +if (EVENT_LIBRARY_RELEASE) + list(APPEND EVENT_LIBRARY optimized ${EVENT_LIBRARY_RELEASE}) +endif() + +FIND_LIBRARY(EVENT_LIBRARY_DEBUG + NAMES event_d libevent_d + HINTS $ENV{EVENT_SRC}/.libs/ +) +if (EVENT_LIBRARY_DEBUG) + list(APPEND EVENT_LIBRARY debug ${EVENT_LIBRARY_DEBUG}) +else() + if (UNIX) + list(APPEND EVENT_LIBRARY debug ${EVENT_LIBRARY_RELEASE}) + endif() +endif() if (NOT WIN32) FIND_LIBRARY(EVENT_LIBRARY_THREADS diff --git a/contrib/cmake/FindGLOG.cmake b/contrib/cmake/FindGLOG.cmake index de7236f..5dc74c1 100644 --- a/contrib/cmake/FindGLOG.cmake +++ b/contrib/cmake/FindGLOG.cmake @@ -24,6 +24,10 @@ FIND_LIBRARY(GLOG_LIBRARY_DEBUG ) if (GLOG_LIBRARY_DEBUG) list(APPEND GLOG_LIBRARY debug ${GLOG_LIBRARY_DEBUG}) +else() + if (UNIX) + list(APPEND V8_LIBRARY debug ${GLOG_LIBRARY_RELEASE}) + endif() endif() INCLUDE(FindPackageHandleStandardArgs) diff --git a/contrib/cmake/FindSWI.cmake b/contrib/cmake/FindSWI.cmake index fb30be4..1106633 100644 --- a/contrib/cmake/FindSWI.cmake +++ b/contrib/cmake/FindSWI.cmake @@ -1,5 +1,28 @@ -set (SWI_SEARCH_PATHS $ENV{SWI_DIR}) +set(64BIT_HOST OFF) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(64BIT_HOST ON) +endif() + +set(SWI_PLATFORM_ID) +if (UNIX) + if (APPLE AND 64BIT_HOST) + set(SWI_PLATFORM_ID "x86_64-${CMAKE_SYSTEM_NAME}${CMAKE_SYSTEM_VERSION}") + else() + set(SWI_PLATFORM_ID "${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_NAME}${CMAKE_SYSTEM_VERSION}") + endif() +else() + set(SWI_PLATFORM_ID "${CMAKE_SYSTEM_PROCESSOR}-windows") +endif() + +if (SWI_PLATFORM_ID) + string(TOLOWER ${SWI_PLATFORM_ID} SWI_PLATFORM_ID) +endif() + +#message("SWI_PLATFORM_ID: ${SWI_PLATFORM_ID}") + +set (SWI_SEARCH_PATHS) list (APPEND SWI_SEARCH_PATHS + $ENV{SWI_DIR} ${CMAKE_FIND_ROOT_PATH} "/usr/lib/swi-prolog/" "/opt/local/" @@ -7,12 +30,9 @@ list (APPEND SWI_SEARCH_PATHS "C:/Program Files/swipl" ) -set(64BIT_HOST OFF) -if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(64BIT_HOST ON) -endif() +#message("SWI_SEARCH_PATHS: ${SWI_SEARCH_PATHS}") -set (SWI_HOME) +set (SWI_VERSION) set (LOOP_DONE 0) foreach(SWI_SEARCH_PATH ${SWI_SEARCH_PATHS}) if(NOT LOOP_DONE) @@ -21,59 +41,58 @@ foreach(SWI_SEARCH_PATH ${SWI_SEARCH_PATHS}) set(LOOP_DONE 1) list(SORT SWI_VERSIONS) list(REVERSE SWI_VERSIONS) - list(GET SWI_VERSIONS 0 SWI_HOME) + list(GET SWI_VERSIONS 0 SWI_VERSION) + STRING(REGEX REPLACE ".*(([0-9]+).([0-9]+).([0-9]+))$" "\\1" SWI_VERSION "${SWI_VERSION}") endif() endif() endforeach() -set (SWI_PLATFORM_PATH) -set (LOOP_DONE 0) -if (SWI_HOME) +# -- find prolog headers +FIND_PATH(SWI_INCLUDE_DIR SWI-Prolog.h + PATH_SUFFIXES + include + lib/swipl-${SWI_VERSION}/include + PATHS ${SWI_SEARCH_PATHS} +) - set(SWI_CPU_SUFFIX ${CMAKE_SYSTEM_PROCESSOR}) - if (APPLE) - if (64BIT_HOST) - set(SWI_CPU_SUFFIX "x86_64") - endif() - endif() +FIND_PATH(SWI_CPP_INCLUDE_DIR SWI-cpp.h + PATH_SUFFIXES + packages/cpp + lib/swipl-${SWI_VERSION}/include + PATHS ${SWI_SEARCH_PATHS} +) - file(GLOB SWI_PLATFORMS ${SWI_HOME}/lib/*) - foreach(SWI_PLATFORM ${SWI_PLATFORMS}) - STRING(REGEX REPLACE "${SWI_HOME}/lib/" "" REL_SWI_PLATFORM ${SWI_PLATFORM}) - if(NOT LOOP_DONE) - if (REL_SWI_PLATFORM MATCHES ".*${SWI_CPU_SUFFIX}.*") - set (SWI_PLATFORM_PATH ${SWI_PLATFORM}) - set(LOOP_DONE 1) - endif() - endif() - endforeach() -endif() +FIND_PROGRAM(SWI_BINARY swipl + PATH_SUFFIXES + src + lib/swipl-${SWI_VERSION}/bin/${SWI_PLATFORM_ID} + PATHS ${SWI_SEARCH_PATHS} +) -#message(STATUS "SWI_PLATFORM_PATH: ${SWI_PLATFORM_PATH}, SWI_HOME: ${SWI_HOME}") +FIND_LIBRARY(SWI_LIBRARY_RELEASE + NAMES libswipl swipl + PATH_SUFFIXES + lib/${SWI_PLATFORM_ID} # still in source directory + lib/swipl-${SWI_VERSION}/lib/${SWI_PLATFORM_ID} # after make install + PATHS ${SWI_SEARCH_PATHS} +) -if (SWI_PLATFORM_PATH OR SWI_INCLUDE_HINT) - FIND_PATH(SWI_INCLUDE_DIR SWI-Prolog.h - PATH_SUFFIXES include - PATHS ${SWI_HOME} - HINTS ${SWI_INCLUDE_HINT} - ) - - FIND_LIBRARY(SWI_LIBRARY_RELEASE - NAMES libswipl swipl - PATHS ${SWI_PLATFORM_PATH} - HINTS ${SWI_LIBRARY_HINT} - ) +FIND_LIBRARY(SWI_LIBRARY_DEBUG + NAMES libswipl_d swipl_d + PATH_SUFFIXES + lib/${SWI_PLATFORM_ID} # still in source directory + lib/swipl-${SWI_VERSION}/lib/${SWI_PLATFORM_ID} # after make install + PATHS ${SWI_SEARCH_PATHS} +) - if (SWI_LIBRARY_RELEASE) - list(APPEND SWI_LIBRARY optimized ${SWI_LIBRARY_RELEASE}) - set(SWI_BINARY ${SWI_PLATFORM_PATH}) +if (NOT SWI_LIBRARY_DEBUG)# no explicit debug build, just reuse release + if (UNIX) + set(SWI_LIBRARY_DEBUG ${SWI_LIBRARY_RELEASE}) endif() +endif() - - FIND_LIBRARY(SWI_LIBRARY_DEBUG - NAMES libswipl_d swipl_d - PATHS ${SWI_PLATFORM_PATH} - ) +if (SWI_LIBRARY_RELEASE) + list(APPEND SWI_LIBRARY optimized ${SWI_LIBRARY_RELEASE}) if (SWI_LIBRARY_DEBUG) list(APPEND SWI_LIBRARY debug ${SWI_LIBRARY_DEBUG}) elseif(UNIX) @@ -83,6 +102,8 @@ if (SWI_PLATFORM_PATH OR SWI_INCLUDE_HINT) endif() endif() +#message(FATAL_ERROR "SWI_BINARY: ${SWI_BINARY} / SWI_LIBRARY_RELEASE: ${SWI_LIBRARY_RELEASE} / SWI_LIBRARY_DEBUG: ${SWI_LIBRARY_DEBUG} / SWI_INCLUDE_DIR: ${SWI_INCLUDE_DIR} / SWI_CPP_INCLUDE_DIR: ${SWI_CPP_INCLUDE_DIR}") + INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(SWI DEFAULT_MSG SWI_LIBRARY SWI_INCLUDE_DIR SWI_BINARY) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SWI DEFAULT_MSG SWI_LIBRARY SWI_BINARY SWI_INCLUDE_DIR SWI_CPP_INCLUDE_DIR) MARK_AS_ADVANCED(SWI_LIBRARY SWI_INCLUDE_DIR) diff --git a/contrib/cmake/FindV8.cmake b/contrib/cmake/FindV8.cmake index 4606e67..819bedd 100644 --- a/contrib/cmake/FindV8.cmake +++ b/contrib/cmake/FindV8.cmake @@ -18,6 +18,14 @@ if (V8_LIBRARY_BASE_RELEASE) list(APPEND V8_LIBRARY optimized ${V8_LIBRARY_BASE_RELEASE}) endif() +FIND_LIBRARY(V8_LIBRARY_SNAPSHOT_RELEASE + NAMES v8_snapshot + HINTS $ENV{V8_SRC}/out/native/ +) +if (V8_LIBRARY_SNAPSHOT_RELEASE) + list(APPEND V8_LIBRARY optimized ${V8_LIBRARY_SNAPSHOT_RELEASE}) +endif() + FIND_LIBRARY(V8_LIBRARY_BASE_DEBUG NAMES v8_base_d v8_d v8_base_g v8_g HINTS $ENV{V8_SRC}/out/native/ @@ -30,6 +38,18 @@ else() endif() endif() +FIND_LIBRARY(V8_LIBRARY_SNAPSHOT_DEBUG + NAMES v8_snapshot_d + HINTS $ENV{V8_SRC}/out/native/ +) +if (V8_LIBRARY_SNAPSHOT_DEBUG) + list(APPEND V8_LIBRARY debug ${V8_LIBRARY_SNAPSHOT_DEBUG}) +else() + if (UNIX AND V8_LIBRARY_SNAPSHOT_RELEASE) + list(APPEND V8_LIBRARY debug ${V8_LIBRARY_SNAPSHOT_RELEASE}) + endif() +endif() + INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(V8 DEFAULT_MSG V8_LIBRARY V8_INCLUDE_DIR) MARK_AS_ADVANCED(V8_LIBRARY V8_INCLUDE_DIR) diff --git a/contrib/dom/idl/SCXMLEvent.idl b/contrib/dom/idl/SCXMLEvent.idl index f70c4d4..4f3438e 100644 --- a/contrib/dom/idl/SCXMLEvent.idl +++ b/contrib/dom/idl/SCXMLEvent.idl @@ -1,6 +1,5 @@ [ - AttributesArePublic, - DontDestroyWrapped + AttributesArePublic ] interface SCXMLEvent { // NodeType diff --git a/contrib/dom/scripts/CodeGeneratorArabicaV8.pm b/contrib/dom/scripts/CodeGeneratorArabicaV8.pm index 738e981..0c7d1b5 100644 --- a/contrib/dom/scripts/CodeGeneratorArabicaV8.pm +++ b/contrib/dom/scripts/CodeGeneratorArabicaV8.pm @@ -137,6 +137,7 @@ sub GenerateHeader # - Add default header template push(@headerContent, GenerateHeaderContentHeader($interface)); + $headerIncludes{"string"} = 1; $headerIncludes{"uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h"} = 1; $headerIncludes{"DOM/Node.hpp"} = 1; $headerIncludes{"v8.h"} = 1; @@ -146,6 +147,7 @@ sub GenerateHeader $headerIncludes{"V8${parent}.h"} = 1; } + push(@headerContent, "#include \\n"); foreach my $headerInclude (sort keys(%headerIncludes)) { if ($headerInclude =~ /wtf|v8\.h/) { push(@headerContent, "#include \<${headerInclude}\>\n"); @@ -234,6 +236,8 @@ sub GenerateClassPrototypeHeader v8::Local instance = tmpl->InstanceTemplate(); v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + instance->SetInternalFieldCount(1); END diff --git a/contrib/prebuilt/include/SWI-cpp.h b/contrib/prebuilt/include/SWI-cpp.h new file mode 100644 index 0000000..d32a052 --- /dev/null +++ b/contrib/prebuilt/include/SWI-cpp.h @@ -0,0 +1,1093 @@ +/* $Id$ + + Part of SWI-Prolog + + Author: Jan Wielemaker + E-mail: J.Wielemaker@cs.vu.nl + WWW: http://www.swi-prolog.org + Copyright (C): 1985-2009, University of Amsterdam + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _SWI_CPP_H +#define _SWI_CPP_H + +#include +#include +#ifndef __APPLE__ +#include +#endif + +#ifdef __BORLANDC__ +#define __inline inline +#endif + +#ifdef _MSC_VER /* MSVC doesn't know throw doesn't return */ +#define PL_THROWN(value) return value; +#else +#define PL_THROWN(v) (void)0 +#endif + +class PlTerm; +class PlTermv; + + /******************************* + * PROLOG CONSTANTS * + *******************************/ + +class PlFunctor +{ +public: + functor_t functor; + + PlFunctor(const char *name, int arity) + { functor = PL_new_functor(PL_new_atom(name), arity); + } +}; + + +class PlAtom +{ +public: + atom_t handle; + + PlAtom(atom_t h) + { handle = h; + } + PlAtom(const char *text) + { handle = PL_new_atom(text); + } + PlAtom(const PlTerm &t); + + operator const char *(void) + { return PL_atom_chars(handle); + } + + int operator ==(const char *s) + { return strcmp(s, PL_atom_chars(handle)) == 0; + } + int operator ==(const PlAtom &a) + { return handle == a.handle; + } +}; + + /******************************* + * GENERIC PROLOG TERM * + *******************************/ + + +class PlTerm +{ +public: + term_t ref; + + PlTerm(); + PlTerm(term_t t) + { ref = t; + } + + /* C --> PlTerm */ + PlTerm(const char *text); + PlTerm(long val); + PlTerm(double val); + PlTerm(const PlAtom &a); + PlTerm(void *ptr); + + /* PlTerm --> C */ + operator term_t(void) const + { return ref; + } + operator char *(void) const; + operator long(void) const; + operator int(void) const; + operator double(void) const; + operator PlAtom(void) const; + operator void *(void) const; + + int type() + { return PL_term_type(ref); + } + + /* Compounds */ + PlTerm operator [](int index) const; + int arity(); + const char *name(); + + /* UNIFY */ + int operator =(const PlTerm &t2); /* term */ + int operator =(const PlAtom &a); /* atom */ + int operator =(const char *v); /* atom (from char *) */ + int operator =(long v); /* integer */ + int operator =(int v); /* integer */ + int operator =(double v); /* float */ + int operator =(const PlFunctor &f); /* functor */ + + /* Comparison standard order terms */ + int operator ==(const PlTerm &t2) + { return PL_compare(ref, t2.ref) == 0; + } + int operator !=(const PlTerm &t2) + { return PL_compare(ref, t2.ref) != 0; + } + int operator <(const PlTerm &t2) + { return PL_compare(ref, t2.ref) < 0; + } + int operator >(const PlTerm &t2) + { return PL_compare(ref, t2.ref) > 0; + } + int operator <=(const PlTerm &t2) + { return PL_compare(ref, t2.ref) <= 0; + } + int operator >=(const PlTerm &t2) + { return PL_compare(ref, t2.ref) >= 0; + } + /* comparison (long) */ + int operator ==(long v); + int operator !=(long v); + int operator <(long v); + int operator >(long v); + int operator <=(long v); + int operator >=(long v); + + /* comparison (string) */ + int operator ==(const char *s); + int operator ==(const PlAtom &a); +}; + + + /******************************* + * TERM VECTOR * + *******************************/ + +class PlTermv +{ +public: + term_t a0; + int size; + + PlTermv(int n) + { a0 = PL_new_term_refs(n); + size = n; + } + PlTermv(int n, term_t t0) + { a0 = t0; + size = n; + } + + /* create from args */ + PlTermv(PlTerm m0); + PlTermv(PlTerm m0, PlTerm m1); + PlTermv(PlTerm m0, PlTerm m1, PlTerm m2); + PlTermv(PlTerm m0, PlTerm m1, PlTerm m2, PlTerm m3); + PlTermv(PlTerm m0, PlTerm m1, PlTerm m2, PlTerm m3, PlTerm m4); + + PlTerm operator [](int n) const; +}; + + /******************************* + * SPECIALISED TERMS * + *******************************/ + +class PlCompound : public PlTerm +{ +public: + + PlCompound(const char *text); + PlCompound(const char *functor, const PlTermv &args); +}; + + +class PlString : public PlTerm +{ +public: + + PlString(const char *text); + PlString(const char *text, int len); +}; + + +class PlCodeList : public PlTerm +{ +public: + + PlCodeList(const char *text); +}; + + +class PlCharList : public PlTerm +{ +public: + + PlCharList(const char *text); +}; + + + /******************************* + * EXCEPTIONS * + *******************************/ + +class PlException : public PlTerm +{ +public: + PlException() + { term_t ex = PL_exception(0); + if ( ex ) + ref = ex; + else + PL_fatal_error("No exception"); + } + + PlException(const PlTerm &t) + { ref = t.ref; + } + + operator const char *(void); + + int plThrow() + { return PL_raise_exception(ref); + } + + void cppThrow(); +}; + + +class PlTypeError : public PlException +{ +public: + + PlTypeError(const PlTerm &t) : PlException(t) {} + + PlTypeError(const char *expected, PlTerm actual) : + PlException(PlCompound("error", + PlTermv(PlCompound("type_error", + PlTermv(expected, actual)), + PlTerm()))) + { + } +}; + + +class PlDomainError : public PlException +{ +public: + + PlDomainError(const PlTerm &t) : PlException(t) {} + + PlDomainError(const char *expected, PlTerm actual) : + PlException(PlCompound("error", + PlTermv(PlCompound("domain_error", + PlTermv(expected, actual)), + PlTerm()))) + { + } +}; + + +class PlResourceError : public PlException +{ +public: + PlResourceError() : PlException() {} + + PlResourceError(const PlTerm &t) : PlException(t) {} + + PlResourceError(const char *resource) : + PlException(PlCompound("error", + PlTermv(PlCompound("resource_error", + PlTermv(PlTerm(resource))), + PlTerm()))) + { + } +}; + + +class PlTermvDomainError : public PlException +{ +public: + + PlTermvDomainError(int size, int n) : + PlException(PlCompound("error", + PlTermv(PlCompound("domain_error", + PlTermv(PlCompound("argv", + size), + PlTerm((long)n))), + PlTerm()))) + { + } +}; + + + /******************************* + * PLTERM IMPLEMENTATION * + *******************************/ + +__inline +PlTerm::PlTerm() +{ if ( !(ref = PL_new_term_ref()) ) + throw PlResourceError(); +} + +__inline +PlTerm::PlTerm(const char *text) +{ if ( !(ref = PL_new_term_ref()) || + !PL_put_atom_chars(ref, text) ) + throw PlResourceError(); +} + +__inline +PlTerm::PlTerm(long val) +{ if ( !(ref = PL_new_term_ref()) || + !PL_put_integer(ref, val) ) + throw PlResourceError(); +} + +__inline +PlTerm::PlTerm(double val) +{ ref = PL_new_term_ref(); + + if ( !PL_put_float(ref, val) ) + throw PlResourceError(); +} + +__inline +PlTerm::PlTerm(const PlAtom &a) +{ if ( !(ref = PL_new_term_ref()) ) + throw PlResourceError(); + + PL_put_atom(ref, a.handle); +} + +__inline +PlTerm::PlTerm(void *ptr) +{ if ( !(ref = PL_new_term_ref()) || + !PL_put_pointer(ref, ptr) ) + throw PlResourceError(); +} + + /******************************* + * SPECIALISED IMPLEMENTATIONS * + *******************************/ + +__inline +PlString::PlString(const char *text) : PlTerm() +{ if ( !PL_put_string_chars(ref, text) ) + throw PlResourceError(); +} + +__inline +PlString::PlString(const char *text, int len) : PlTerm() +{ if ( !PL_put_string_nchars(ref, len, text) ) + throw PlResourceError(); +} + +__inline +PlCodeList::PlCodeList(const char *text) : PlTerm() +{ if ( !PL_put_list_codes(ref, text) ) + throw PlResourceError(); +} + +__inline +PlCharList::PlCharList(const char *text) : PlTerm() +{ if ( !PL_put_list_chars(ref, text) ) + throw PlResourceError(); +} + + + /******************************* + * LISTS * + *******************************/ + +class PlTail : public PlTerm +{ +public: + + PlTail(const PlTerm &l) + { if ( PL_is_variable(l.ref) || PL_is_list(l.ref) ) + { if ( !(ref = PL_copy_term_ref(l.ref)) ) + throw PlResourceError(); + } else + throw PlTypeError("list", l.ref); + } + + /* building */ + int append(const PlTerm &e) + { term_t tmp, ex; + + if ( (tmp = PL_new_term_ref()) && + PL_unify_list(ref, tmp, ref) && + PL_unify(tmp, e.ref) ) + { PL_reset_term_refs(tmp); + return TRUE; + } + + if ( (ex = PL_exception(0)) ) + throw PlResourceError(ex); + + return FALSE; + } + int close() + { return PL_unify_nil(ref); + } + + /* enumerating */ + int next(PlTerm &t) + { if ( PL_get_list(ref, t, ref) ) + return TRUE; + + if ( PL_get_nil(ref) ) + return FALSE; + + throw PlTypeError("list", ref); + PL_THROWN(FALSE); + } +}; + + + /******************************* + * REGISTER * + *******************************/ + + +class PlRegister +{ +public: + + PlRegister(const char *module, const char *name, int arity, + foreign_t (f)(term_t t0, int a, control_t ctx)) + { PL_register_foreign_in_module(module, name, arity, (void *)f, PL_FA_VARARGS); + } + + PlRegister(const char *module, const char *name, foreign_t (*f)(PlTerm a0)) + { PL_register_foreign_in_module(module, name, 1, (void *)f, 0); + } + PlRegister(const char *module, const char *name, foreign_t (*f)(PlTerm a0, PlTerm a1)) + { PL_register_foreign_in_module(module, name, 2, (void *)f, 0); + } + PlRegister(const char *module, const char *name, foreign_t (*f)(PlTerm a0, PlTerm a1, PlTerm a2)) + { PL_register_foreign_in_module(module, name, 3, (void *)f, 0); + } + + // for non-deterministic calls + PlRegister(const char *module, const char *name, int arity, + foreign_t (f)(term_t t0, int a, control_t ctx), short flags) + { PL_register_foreign_in_module(module, name, arity, (void *)f, flags); + } + +}; + + + /******************************* + * CALLING PROLOG * + *******************************/ + +class PlFrame +{ +public: + fid_t fid; + + PlFrame() + { fid = PL_open_foreign_frame(); + } + + ~PlFrame() + { PL_close_foreign_frame(fid); + } + + void rewind() + { PL_rewind_foreign_frame(fid); + } +}; + + +class PlQuery +{ +public: + qid_t qid; + + PlQuery(const char *name, const PlTermv &av) + { predicate_t p = PL_predicate(name, av.size, "user"); + + qid = PL_open_query((module_t)0, PL_Q_CATCH_EXCEPTION, p, av.a0); + if ( !qid ) + throw PlResourceError(); + } + PlQuery(const char *module, const char *name, const PlTermv &av) + { atom_t ma = PL_new_atom(module); + atom_t na = PL_new_atom(name); + module_t m = PL_new_module(ma); + predicate_t p = PL_pred(PL_new_functor(na, av.size), m); + + PL_unregister_atom(ma); + PL_unregister_atom(na); + + qid = PL_open_query(m, PL_Q_CATCH_EXCEPTION, p, av.a0); + if ( !qid ) + throw PlResourceError(); + } + + ~PlQuery() + { PL_cut_query(qid); + } + + int next_solution(); +}; + + +__inline int +PlCall(const char *predicate, const PlTermv &args) +{ PlQuery q(predicate, args); + return q.next_solution(); +} + +__inline int +PlCall(const char *module, const char *predicate, const PlTermv &args) +{ PlQuery q(module, predicate, args); + return q.next_solution(); +} + +__inline int +PlCall(const char *goal) +{ PlQuery q("call", PlTermv(PlCompound(goal))); + return q.next_solution(); +} + + + + /******************************* + * ATOM (BODY) * + *******************************/ + +__inline +PlAtom::PlAtom(const PlTerm &t) +{ atom_t a; + + if ( PL_get_atom(t.ref, &a) ) + handle = a; + else + throw PlTypeError("atom", t); +} + + + /******************************* + * TERM (BODY) * + *******************************/ + + /* PlTerm --> C */ + +__inline PlTerm::operator char *(void) const +{ char *s; + + if ( PL_get_chars(ref, &s, CVT_ALL|CVT_WRITE|BUF_RING) ) + return s; + + throw PlTypeError("text", ref); + PL_THROWN(NULL); +} + +__inline PlTerm::operator long(void) const +{ long v; + + if ( PL_get_long(ref, &v) ) + return v; + + throw PlTypeError("integer", ref); + PL_THROWN(0L); +} + +__inline PlTerm::operator int(void) const +{ int v; + + if ( PL_get_integer(ref, &v) ) + return v; + + throw PlTypeError("integer", ref); + PL_THROWN(0); +} + +__inline PlTerm::operator double(void) const +{ double v; + + if ( PL_get_float(ref, &v) ) + return v; + + throw PlTypeError("float", ref); + PL_THROWN(0.0); +} + +__inline PlTerm::operator PlAtom(void) const +{ atom_t v; + + if ( PL_get_atom(ref, &v) ) + return PlAtom(v); + + throw PlTypeError("atom", ref); + PL_THROWN((atom_t)0); +} + +__inline PlTerm::operator void *(void) const +{ void *ptr; + + if ( PL_get_pointer(ref, &ptr) ) + return ptr; + + throw PlTypeError("pointer", ref); + PL_THROWN(NULL); +} + + /* compounds */ + +__inline PlTerm +PlTerm::operator [](int index) const +{ PlTerm t; + + if ( PL_get_arg(index, ref, t.ref) ) + return t; + + if ( !PL_is_compound(ref) ) + throw PlTypeError("compound", ref); + else + { if ( !PL_put_integer(t.ref, index) ) + throw PlResourceError(); + + if ( index < 1 ) + throw PlDomainError("not_less_than_zero", t.ref); + else + throw PlDomainError("arity", t.ref); /* TBD: proper exception */ + } + PL_THROWN((term_t)0); +} + + +__inline int +PlTerm::arity() +{ atom_t name; + int arity; + + if ( PL_get_name_arity(ref, &name, &arity) ) + return arity; + + throw PlTypeError("compound", ref); + PL_THROWN(0); +} + + +__inline const char * +PlTerm::name() +{ atom_t name; + int arity; + + if ( PL_get_name_arity(ref, &name, &arity) ) + return PL_atom_chars(name); + + throw PlTypeError("compound", ref); + PL_THROWN(NULL); +} + + + /* Unification */ + +__inline int PlTerm::operator =(const PlTerm &t2) /* term = term */ +{ int rc = PL_unify(ref, t2.ref); + term_t ex; + + if ( !rc && (ex=PL_exception(0)) ) + throw PlResourceError(ex); + return rc; +} + +__inline int PlTerm::operator =(const PlAtom &a) /* term = atom */ +{ int rc = PL_unify_atom(ref, a.handle); + term_t ex; + + if ( !rc && (ex=PL_exception(0)) ) + throw PlResourceError(ex); + return rc; +} + +__inline int PlTerm::operator =(const char *v) /* term = atom */ +{ int rc = PL_unify_atom_chars(ref, v); + term_t ex; + + if ( !rc && (ex=PL_exception(0)) ) + throw PlResourceError(ex); + return rc; +} + +__inline int PlTerm::operator =(long v) +{ int rc = PL_unify_integer(ref, v); + term_t ex; + + if ( !rc && (ex=PL_exception(0)) ) + throw PlResourceError(ex); + return rc; +} + +__inline int PlTerm::operator =(int v) +{ int rc = PL_unify_integer(ref, v); + term_t ex; + + if ( !rc && (ex=PL_exception(0)) ) + throw PlResourceError(ex); + return rc; +} + +__inline int PlTerm::operator =(double v) +{ int rc = PL_unify_float(ref, v); + term_t ex; + + if ( !rc && (ex=PL_exception(0)) ) + throw PlResourceError(ex); + return rc; +} + +__inline int PlTerm::operator =(const PlFunctor &f) +{ int rc = PL_unify_functor(ref, f.functor); + term_t ex; + + if ( !rc && (ex=PL_exception(0)) ) + throw PlResourceError(ex); + return rc; +} + + /* comparison */ + + +__inline int PlTerm::operator ==(long v) +{ long v0; + + if ( PL_get_long(ref, &v0) ) + return v0 == v; + + throw PlTypeError("integer", ref); + PL_THROWN(0); +} + +__inline int PlTerm::operator !=(long v) +{ long v0; + + if ( PL_get_long(ref, &v0) ) + return v0 != v; + + throw PlTypeError("integer", ref); + PL_THROWN(0); +} + +__inline int PlTerm::operator <(long v) +{ long v0; + + if ( PL_get_long(ref, &v0) ) + return v0 < v; + + throw PlTypeError("integer", ref); + PL_THROWN(0); +} + +__inline int PlTerm::operator >(long v) +{ long v0; + + if ( PL_get_long(ref, &v0) ) + return v0 > v; + + throw PlTypeError("integer", ref); + PL_THROWN(0); +} + +__inline int PlTerm::operator <=(long v) +{ long v0; + + if ( PL_get_long(ref, &v0) ) + return v0 <= v; + + throw PlTypeError("integer", ref); + PL_THROWN(0); +} + +__inline int PlTerm::operator >=(long v) +{ long v0; + + if ( PL_get_long(ref, &v0) ) + return v0 >= v; + + throw PlTypeError("integer", ref); + PL_THROWN(0); +} + + /* comparison (string) */ + +__inline int PlTerm::operator ==(const char *s) +{ char *s0; + + if ( PL_get_chars(ref, &s0, CVT_ALL) ) + return strcmp(s0, s) == 0; + + throw PlTypeError("text", ref); + PL_THROWN(0); +} + + +__inline int PlTerm::operator ==(const PlAtom &a) +{ atom_t v; + + if ( PL_get_atom(ref, &v) ) + return v == a.handle; + + throw PlTypeError("atom", ref); + PL_THROWN(0); +} + + + /******************************* + * COMPPOUND (BODY) * + *******************************/ + + +__inline +PlCompound::PlCompound(const char *text) : PlTerm() +{ term_t t = PL_new_term_ref(); + + if ( !PL_chars_to_term(text, t) ) + throw PlException(t); + + PL_put_term(ref, t); +} + +__inline +PlCompound::PlCompound(const char *functor, const PlTermv &args) : PlTerm() +{ if ( !PL_cons_functor_v(ref, + PL_new_functor(PL_new_atom(functor), args.size), + args.a0) ) + throw PlResourceError(); +} + + /******************************* + * TERMV (BODY) * + *******************************/ + + +__inline PlTermv::PlTermv(PlTerm m0) +{ size = 1; + a0 = m0.ref; +} + +__inline PlTermv::PlTermv(PlTerm m0, PlTerm m1) +{ size = 2; + if ( !(a0 = PL_new_term_refs(2)) ) + throw PlResourceError(); + PL_put_term(a0+0, m0); + PL_put_term(a0+1, m1); +} + +__inline PlTermv::PlTermv(PlTerm m0, PlTerm m1, PlTerm m2) +{ size = 3; + if ( !(a0 = PL_new_term_refs(3)) ) + throw PlResourceError(); + PL_put_term(a0+0, m0); + PL_put_term(a0+1, m1); + PL_put_term(a0+2, m2); +} + +__inline PlTermv::PlTermv(PlTerm m0, PlTerm m1, PlTerm m2, PlTerm m3) +{ size = 4; + if ( !(a0 = PL_new_term_refs(4)) ) + throw PlResourceError(); + PL_put_term(a0+0, m0); + PL_put_term(a0+1, m1); + PL_put_term(a0+2, m2); + + PL_put_term(a0+3, m3); +} + +__inline PlTermv::PlTermv(PlTerm m0, PlTerm m1, PlTerm m2, + PlTerm m3, PlTerm m4) +{ size = 5; + if ( !(a0 = PL_new_term_refs(5)) ) + throw PlResourceError(); + PL_put_term(a0+0, m0); + PL_put_term(a0+1, m1); + PL_put_term(a0+2, m2); + PL_put_term(a0+3, m3); + PL_put_term(a0+4, m4); +} + + +__inline PlTerm +PlTermv::operator [](int n) const +{ if ( n < 0 || n >= size ) + throw PlTermvDomainError(size, n); + + return PlTerm(a0+n); +} + + + /******************************* + * EXCEPTIONS (BODY) * + *******************************/ + +__inline PlException::operator const char *(void) +{ PlFrame fr; +#ifdef USE_PRINT_MESSAGE + PlTermv av(2); + + av[0] = PlCompound("print_message", + PlTermv("error", ref)); + PlQuery q("$write_on_string", av); + if ( q.next_solution() ) + return (char *)av[1]; +#else + PlTermv av(2); + av[0] = PlTerm(ref); + PlQuery q("$messages", "message_to_string", av); + if ( q.next_solution() ) + return (char *)av[1]; +#endif + return "[ERROR: Failed to generate message. Internal error]\n"; +} + + +__inline void +PlException::cppThrow() +{ term_t a = PL_new_term_ref(); + atom_t name; + int arity; + + if ( PL_get_arg(1, ref, a) && + PL_get_name_arity(a, &name, &arity) ) + { const char *s = PL_atom_chars(name); + + if ( strcmp(s, "type_error") == 0 ) + throw PlTypeError(ref); + if ( strcmp(s, "domain_error") == 0 ) + throw PlDomainError(ref); + if ( strcmp(s, "resource_error") == 0 ) + throw PlResourceError(ref); + } + + throw *this; +} + + + /******************************* + * QUERY (BODY) * + *******************************/ + +__inline int +PlQuery::next_solution() +{ int rval; + + if ( !(rval = PL_next_solution(qid)) ) + { term_t ex; + + if ( (ex = PL_exception(qid)) ) + PlException(ex).cppThrow(); + } + return rval; +} + + + /******************************* + * ENGINE * + *******************************/ + +class PlError +{ +public: + char *message; + + PlError(const char *msg) + { message = new char[strlen(msg+1)]; + strcpy(message, msg); + } +}; + + +class PlEngine +{ +public: + + PlEngine(int argc, char **argv) + { if ( !PL_initialise(argc, argv) ) + throw PlError("failed to initialise"); + } + + PlEngine(char *av0) + { int ac = 0; + char **av = (char **)malloc(sizeof(char *) * 2); + + av[ac++] = av0; + + if ( !PL_initialise(1, av) ) + throw PlError("failed to initialise"); + } + + ~PlEngine() + { PL_cleanup(0); + } +}; + + + /******************************* + * REGISTER PREDICATES * + *******************************/ + +#ifndef PROLOG_MODULE +#define PROLOG_MODULE (const char*)NULL +#endif + +#define PREDICATE(name, arity) \ + static foreign_t \ + pl_ ## name ## __ ## arity(PlTermv _av); \ + static foreign_t \ + _pl_ ## name ## __ ## arity(term_t t0, int a, control_t c) \ + { try \ + { \ + return pl_ ## name ## __ ## arity(PlTermv(arity, t0)); \ + } catch ( PlException &ex ) \ + { return ex.plThrow(); \ + } \ + } \ + static PlRegister _x ## name ## __ ## arity(PROLOG_MODULE, #name, arity, \ + _pl_ ## name ## __ ## arity); \ + static foreign_t pl_ ## name ## __ ## arity(PlTermv _av) + + +#define PREDICATE_NONDET(name, arity) \ + static foreign_t \ + pl_ ## name ## __ ## arity(PlTermv _av, foreign_t handle); \ + static foreign_t \ + _pl_ ## name ## __ ## arity(term_t t0, int a, control_t c) \ + { try \ + { \ + return pl_ ## name ## __ ## arity(PlTermv(arity, t0), (foreign_t)c); \ + } catch ( PlException &ex ) \ + { return ex.plThrow(); \ + } \ + } \ + static PlRegister _x ## name ## __ ## arity(PROLOG_MODULE, #name, arity, \ + _pl_ ## name ## __ ## arity, \ + PL_FA_NONDETERMINISTIC | PL_FA_VARARGS); \ + static foreign_t pl_ ## name ## __ ## arity(PlTermv _av, foreign_t handle) + +#define A1 _av[0] +#define A2 _av[1] +#define A3 _av[2] +#define A4 _av[3] +#define A5 _av[4] +#define A6 _av[5] +#define A7 _av[6] +#define A8 _av[7] +#define A9 _av[8] +#define A10 _av[9] + +#endif /*_SWI_CPP_H*/ diff --git a/src/uscxml/Factory.cpp b/src/uscxml/Factory.cpp index 4481257..d299e7b 100644 --- a/src/uscxml/Factory.cpp +++ b/src/uscxml/Factory.cpp @@ -11,6 +11,7 @@ # include "uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h" # include "uscxml/plugins/invoker/scxml/USCXMLInvoker.h" +# include "uscxml/plugins/invoker/http/HTTPServletInvoker.h" # include "uscxml/plugins/invoker/heartbeat/HeartbeatInvoker.h" # include "uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.h" @@ -39,6 +40,10 @@ # include "uscxml/plugins/datamodel/prolog/swi/SWIDataModel.h" # endif +# include "uscxml/plugins/element/fetch/FetchElement.h" +# include "uscxml/plugins/element/response/ResponseElement.h" + + #endif namespace uscxml { @@ -129,6 +134,10 @@ Factory::Factory() { registerInvoker(invoker); } { + HTTPServletInvoker* invoker = new HTTPServletInvoker(); + registerInvoker(invoker); + } + { HeartbeatInvoker* invoker = new HeartbeatInvoker(); registerInvoker(invoker); } @@ -141,6 +150,15 @@ Factory::Factory() { registerIOProcessor(ioProcessor); } + { + FetchElement* element = new FetchElement(); + registerExecutableContent(element); + } + { + ResponseElement* element = new ResponseElement(); + registerExecutableContent(element); + } + #endif } @@ -189,6 +207,13 @@ void Factory::registerInvoker(InvokerImpl* invoker) { } } +void Factory::registerExecutableContent(ExecutableContentImpl* executableContent) { + std::string localName = executableContent->getLocalName(); + std::string nameSpace = executableContent->getNamespace(); + _executableContent[std::make_pair(localName, nameSpace)] = executableContent; +} + + boost::shared_ptr Factory::createInvoker(const std::string& type, Interpreter* interpreter) { Factory* factory = getInstance(); if (factory->_invokerAliases.find(type) == factory->_invokerAliases.end()) { @@ -198,7 +223,7 @@ boost::shared_ptr Factory::createInvoker(const std::string& type, I std::string canonicalName = factory->_invokerAliases[type]; if (factory->_invokers.find(canonicalName) == factory->_invokers.end()) { - LOG(ERROR) << "Invoker " << type << " known as " << canonicalName << " but not prototype is available in factory"; + LOG(ERROR) << "Invoker " << type << " known as " << canonicalName << " but no prototype is available in factory"; return boost::shared_ptr(); } @@ -214,7 +239,7 @@ boost::shared_ptr Factory::createDataModel(const std::string& typ std::string canonicalName = factory->_dataModelAliases[type]; if (factory->_dataModels.find(canonicalName) == factory->_dataModels.end()) { - LOG(ERROR) << "DataModel " << type << " known as " << canonicalName << " but not prototype is available in factory"; + LOG(ERROR) << "DataModel " << type << " known as " << canonicalName << " but no prototype is available in factory"; return boost::shared_ptr(); } @@ -230,13 +255,23 @@ boost::shared_ptr Factory::createIOProcessor(const std::string& std::string canonicalName = factory->_ioProcessorAliases[type]; if (factory->_ioProcessors.find(canonicalName) == factory->_ioProcessors.end()) { - LOG(ERROR) << "IOProcessor " << type << " known as " << canonicalName << " but not prototype is available in factory"; + LOG(ERROR) << "IOProcessor " << type << " known as " << canonicalName << " but no prototype is available in factory"; return boost::shared_ptr(); } return factory->_ioProcessors[canonicalName]->create(interpreter); } +boost::shared_ptr Factory::createExecutableContent(const std::string& localName, const std::string& nameSpace, Interpreter* interpreter) { + Factory* factory = getInstance(); + std::string actualNameSpace = (nameSpace.length() == 0 ? "http://www.w3.org/2005/07/scxml" : nameSpace); + if (factory->_executableContent.find(std::make_pair(localName, actualNameSpace)) == factory->_executableContent.end()) { + LOG(ERROR) << "Executable content " << localName << " in " << actualNameSpace << " not available in factory"; + return boost::shared_ptr(); + } + return factory->_executableContent[std::make_pair(localName, actualNameSpace)]->create(interpreter); +} + Factory* Factory::getInstance() { if (_instance == NULL) { diff --git a/src/uscxml/Factory.h b/src/uscxml/Factory.h index 8004366..9397e36 100644 --- a/src/uscxml/Factory.h +++ b/src/uscxml/Factory.h @@ -35,13 +35,63 @@ inline bool isNumeric( const char* pszInput, int nNumberBase) { class Interpreter; -#if 0 -class ExecutableContent { +class ExecutableContentImpl { public: - ExecutableContent() {}; - virtual boost::shared_ptr* create(Interpreter* interpreter) = 0; + ExecutableContentImpl() {}; + virtual ~ExecutableContentImpl() {}; + virtual boost::shared_ptr create(Interpreter* interpreter) = 0; + + virtual void setInterpreter(Interpreter* interpreter) { + _interpreter = interpreter; + } + + virtual std::string getLocalName() = 0; ///< The name of the element. + virtual std::string getNamespace() = 0; ///< The namespace of the element. + virtual void enterElement(const Arabica::DOM::Node& node) = 0; ///< Invoked when entering the element as part of evaluating executable content. + virtual void exitElement(const Arabica::DOM::Node& node) = 0; ///< Invoked when exiting the element as part of evaluating executable content. + virtual bool processChildren() = 0; ///< Whether or not the interpreter should process this elements children. + +protected: + Interpreter* _interpreter; }; -#endif + +class ExecutableContent { +public: + ExecutableContent() : _impl() {} + ExecutableContent(boost::shared_ptr const impl) : _impl(impl) { } + ExecutableContent(const ExecutableContent& other) : _impl(other._impl) { } + virtual ~ExecutableContent() {}; + + operator bool() const { + return _impl; + } + bool operator< (const ExecutableContent& other) const { + return _impl < other._impl; + } + bool operator==(const ExecutableContent& other) const { + return _impl == other._impl; + } + bool operator!=(const ExecutableContent& other) const { + return _impl != other._impl; + } + ExecutableContent& operator= (const ExecutableContent& other) { + _impl = other._impl; + return *this; + } + + void setInterpreter(Interpreter* interpreter) { + _impl->setInterpreter(interpreter); + } + + std::string getLocalName() { return _impl->getLocalName(); } + std::string getNamespace() { return _impl->getNamespace(); } + void enterElement(const Arabica::DOM::Node& node) { return _impl->enterElement(node); } + void exitElement(const Arabica::DOM::Node& node) { return _impl->exitElement(node); } + bool processChildren() { return _impl->processChildren(); } +protected: + boost::shared_ptr _impl; + + }; class IOProcessorImpl { public: @@ -264,10 +314,12 @@ public: void registerIOProcessor(IOProcessorImpl* ioProcessor); void registerDataModel(DataModelImpl* dataModel); void registerInvoker(InvokerImpl* invoker); + void registerExecutableContent(ExecutableContentImpl* executableContent); static boost::shared_ptr createDataModel(const std::string& type, Interpreter* interpreter); static boost::shared_ptr createIOProcessor(const std::string& type, Interpreter* interpreter); static boost::shared_ptr createInvoker(const std::string& type, Interpreter* interpreter); + static boost::shared_ptr createExecutableContent(const std::string& localName, const std::string& nameSpace, Interpreter* interpreter); static Factory* getInstance(); @@ -277,6 +329,7 @@ public: std::map _ioProcessorAliases; std::map _invokers; std::map _invokerAliases; + std::map, ExecutableContentImpl*> _executableContent; static std::string pluginPath; diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp index 4f1f31f..448bb7c 100644 --- a/src/uscxml/Interpreter.cpp +++ b/src/uscxml/Interpreter.cpp @@ -3,6 +3,8 @@ #include "uscxml/URL.h" #include "uscxml/debug/SCXMLDotWriter.h" +#include "uscxml/plugins/invoker/http/HTTPServletInvoker.h" + #include #include @@ -17,6 +19,7 @@ #include #include +#define VERBOSE 0 namespace uscxml { @@ -34,6 +37,7 @@ Interpreter::Interpreter() : Arabica::SAX2DOM::Parser() { _thread = NULL; _sendQueue = NULL; _parentQueue = NULL; + _httpServlet = NULL; _running = false; _done = false; @@ -67,7 +71,14 @@ Interpreter* Interpreter::fromURI(const std::string& uri) { return NULL; } } - Arabica::SAX::InputSource inputSource(absUrl.asString()); + Arabica::SAX::InputSource inputSource; + + // this is required for windows filenames and does not harm on unices + if (boost::iequals(absUrl.scheme(), "file")) { + inputSource.setSystemId(absUrl.path()); + } else { + inputSource.setSystemId(absUrl.asString()); + } Interpreter* interpreter = fromInputSource(inputSource); // try to establish URI root for relative src attributes in document @@ -161,8 +172,6 @@ Interpreter* Interpreter::fromInputSource(Arabica::SAX::InputSource } void Interpreter::init() { - _sendQueue = new DelayedEventQueue(); - _sendQueue->start(); if (_document) { NodeList scxmls = _document.getElementsByTagNameNS(_nsURL, "scxml"); if (scxmls.getLength() > 0) { @@ -174,9 +183,15 @@ void Interpreter::init() { assert(scxmls.size() > 0); assert(scxmls[0] == _scxml); - normalize(_document); if (_name.length() == 0) _name = (HAS_ATTR(_scxml, "name") ? ATTR(_scxml, "name") : getUUID()); + + normalize(_document); + + _sendQueue = new DelayedEventQueue(); + _httpServlet = new HTTPServletInvoker(this); + _sendQueue->start(); + } else { LOG(ERROR) << "Cannot find SCXML element" << std::endl; } @@ -193,6 +208,8 @@ Interpreter::~Interpreter() { } if (_sendQueue) delete _sendQueue; + if (_httpServlet) + delete _httpServlet; } void Interpreter::start() { @@ -297,9 +314,6 @@ void Interpreter::interpret() { initialElem.appendChild(transitionElem); _scxml.appendChild(initialElem); initialTransitions.push_back(transitionElem); - - } else { - initialTransitions.push_back(initialTransitions[0]); } enterStates(initialTransitions); @@ -335,7 +349,12 @@ void Interpreter::initializeData(const Arabica::DOM::Node& data) { toAbsoluteURI(srcURL); std::stringstream ss; - ss << srcURL; + if (_cachedURLs.find(srcURL.asString()) != _cachedURLs.end()) { + ss << _cachedURLs[srcURL.asString()]; + } else { + ss << srcURL; + _cachedURLs[srcURL.asString()] = srcURL; + } _dataModel.assign(ATTR(data, "id"), ss.str()); } else if (data.hasChildNodes()) { @@ -445,7 +464,7 @@ void Interpreter::mainEventLoop() { } else { Event internalEvent = _internalQueue.front(); _internalQueue.pop_front(); -#if 0 +#if VERBOSE std::cout << "Received internal event " << internalEvent.name << std::endl; #endif if (_dataModel) @@ -475,15 +494,15 @@ void Interpreter::mainEventLoop() { continue; // assume that we have a legal configuration as soon as the internal queue is empty - assert(hasLegalConfiguration()); +// assert(hasLegalConfiguration()); monIter = _monitors.begin(); - if (!_sendQueue || _sendQueue->isEmpty()) { +// if (!_sendQueue || _sendQueue->isEmpty()) { while(monIter != _monitors.end()) { (*monIter)->onStableConfiguration(this); monIter++; } - } +// } // whenever we have a stable configuration, run the mainThread hooks with 200fps while(_externalQueue.isEmpty() && _thread == NULL) { @@ -491,6 +510,9 @@ void Interpreter::mainEventLoop() { } Event externalEvent = _externalQueue.pop(); +#if VERBOSE + std::cout << "Received externalEvent event " << externalEvent.name << std::endl; +#endif externalEvent.type = Event::EXTERNAL; // make sure it is set to external if (!_running) exitInterpreter(); @@ -580,17 +602,17 @@ void Interpreter::internalDoneSend(const Arabica::DOM::Node& state) LOG(ERROR) << "param element is missing expr or location or no datamodel is specified"; continue; } - event.compound[ATTR(doneChilds.item(i), "name")] = paramValue; + event.data.compound[ATTR(doneChilds.item(i), "name")] = paramValue; } if (boost::iequals(TAGNAME(doneChilds.item(i)), _xmlNSPrefix + "content")) { if (HAS_ATTR(doneChilds.item(i), "expr")) { if (_dataModel) { - event.compound["content"] = Data(_dataModel.evalAsString(ATTR(doneChilds.item(i), "expr")), Data::VERBATIM); + event.data.compound["content"] = Data(_dataModel.evalAsString(ATTR(doneChilds.item(i), "expr")), Data::VERBATIM); } else { LOG(ERROR) << "content element has expr attribute but no datamodel is specified."; } } else if (doneChilds.item(i).hasChildNodes()) { - event.compound["content"] = Data(doneChilds.item(i).getFirstChild().getNodeValue(), Data::VERBATIM); + event.data.compound["content"] = Data(doneChilds.item(i).getFirstChild().getNodeValue(), Data::VERBATIM); } else { LOG(ERROR) << "content element does not specify any content."; } @@ -599,7 +621,7 @@ void Interpreter::internalDoneSend(const Arabica::DOM::Node& state) } } - event.name = "done.state." + parent.getAttribute("id"); + event.name = "done.state." + ATTR(stateElem.getParentNode(), "id"); // parent?! _internalQueue.push_back(event); } @@ -678,12 +700,16 @@ void Interpreter::send(const Arabica::DOM::Node& element) { } // namelist if (HAS_ATTR(element, "namelist")) { - std::vector names = tokenizeIdRefs(ATTR(element, "namelist")); - for (int i = 0; i < names.size(); i++) { - std::string namelistValue = _dataModel.evalAsString(names[i]); - sendReq.namelist[names[i]] = namelistValue; - sendReq.compound[names[i]] = Data(namelistValue, Data::VERBATIM); - } + if (_dataModel) { + std::vector names = tokenizeIdRefs(ATTR(element, "namelist")); + for (int i = 0; i < names.size(); i++) { + std::string namelistValue = _dataModel.evalAsString(names[i]); + sendReq.namelist[names[i]] = namelistValue; + sendReq.data.compound[names[i]] = Data(namelistValue, Data::VERBATIM); + } + } else { + LOG(ERROR) << "Namelist attribute at send requires datamodel to be defined"; + } } // params @@ -705,7 +731,7 @@ void Interpreter::send(const Arabica::DOM::Node& element) { std::string paramKey = ATTR(params[i], "name"); boost::algorithm::to_lower(paramKey); sendReq.params.insert(std::make_pair(paramKey, paramValue)); - sendReq.compound[paramKey] = Data(paramValue, Data::VERBATIM); + sendReq.data.compound[paramKey] = Data(paramValue, Data::VERBATIM); } // content @@ -717,15 +743,15 @@ void Interpreter::send(const Arabica::DOM::Node& element) { if (_dataModel) { std::string contentValue = _dataModel.evalAsString(ATTR(contents[0], "expr")); sendReq.content = contentValue; - sendReq.atom = contentValue; - sendReq.type = Data::VERBATIM; +// sendReq.data.atom = contentValue; +// sendReq.data.type = Data::VERBATIM; } else { LOG(ERROR) << "content element has expr attribute but no datamodel is specified."; } } else if (contents[0].hasChildNodes()) { sendReq.content = contents[0].getFirstChild().getNodeValue(); - sendReq.atom = sendReq.content; - sendReq.type = Data::VERBATIM; +// sendReq.data.atom = sendReq.content; +// sendReq.data.type = Data::VERBATIM; } else { LOG(ERROR) << "content element does not specify any content."; } @@ -848,7 +874,7 @@ void Interpreter::invoke(const Arabica::DOM::Node& element) { if (_dataModel) { paramValue = _dataModel.evalAsString(ATTR(params[i], "expr")); } else { - paramValue = ATTR(params[i], "expr"); + LOG(ERROR) << "Cannot use param expr without a datamodel!"; } } else if(HAS_ATTR(params[i], "location") && _dataModel) { paramValue = _dataModel.evalAsString(ATTR(params[i], "location")); @@ -873,14 +899,18 @@ void Interpreter::invoke(const Arabica::DOM::Node& element) { Invoker invoker(Factory::createInvoker(invokeReq.type, this)); if (invoker) { tthread::lock_guard lock(_mutex); - invoker.setInvokeId(invokeReq.invokeid); - invoker.setType(invokeReq.type); - invoker.setInterpreter(this); - _invokers[invokeReq.invokeid] = invoker; - LOG(INFO) << "Added invoker " << invokeReq.type << " at " << invokeReq.invokeid; - invoker.invoke(invokeReq); - if (_dataModel) { - _dataModel.assign("_invokers['" + invokeReq.invokeid + "']", invoker.getDataModelVariables()); + try { + invoker.setInvokeId(invokeReq.invokeid); + invoker.setType(invokeReq.type); + invoker.setInterpreter(this); + _invokers[invokeReq.invokeid] = invoker; + LOG(INFO) << "Added invoker " << invokeReq.type << " at " << invokeReq.invokeid; + invoker.invoke(invokeReq); + if (_dataModel) { + _dataModel.assign("_invokers['" + invokeReq.invokeid + "']", invoker.getDataModelVariables()); + } + } catch (...) { + LOG(ERROR) << "Invoker " << invokeReq.type << " threw an exception"; } } else { LOG(ERROR) << "No invoker known for type " << invokeReq.type; @@ -936,8 +966,23 @@ Arabica::XPath::NodeSet Interpreter::selectTransitions(const std::s for (unsigned int j = 0; j < sortedAncestors.size(); j++) { NodeSet transitions = filterChildElements(_xmlNSPrefix + "transition", sortedAncestors[j]); for (unsigned int k = 0; k < transitions.size(); k++) { - if (((Arabica::DOM::Element)transitions[k]).hasAttribute("event") && - nameMatch(((Arabica::DOM::Element)transitions[k]).getAttribute("event"), event) && + std::string eventName; + if (HAS_ATTR(transitions[k], "event")) { + eventName = ATTR(transitions[k], "event"); + } else if(HAS_ATTR(transitions[k], "eventexpr")) { + if (_dataModel) { + eventName = _dataModel.evalAsString(ATTR(transitions[k], "eventexpr")); + } else { + LOG(ERROR) << "Transition has eventexpr attribute with no datamodel defined"; + goto LOOP; + } + } else { + LOG(ERROR) << "Transition has neither event nor eventexpr attribute"; + goto LOOP; + } + + if (eventName.length() > 0 && + nameMatch(eventName, event) && hasConditionMatch(transitions[k])) { enabledTransitions.push_back(transitions[k]); goto LOOP; @@ -1010,7 +1055,7 @@ Arabica::XPath::NodeSet Interpreter::selectEventlessTransitions() { for (unsigned int j = 0; j < ancestors.size(); j++) { NodeSet transitions = filterChildElements(_xmlNSPrefix + "transition", ancestors[j]); for (unsigned int k = 0; k < transitions.size(); k++) { - if (!((Arabica::DOM::Element)transitions[k]).hasAttribute("event") && hasConditionMatch(transitions[k])) { + if (!HAS_ATTR(transitions[k], "event") && hasConditionMatch(transitions[k])) { enabledTransitions.push_back(transitions[k]); goto LOOP; } @@ -1035,13 +1080,19 @@ LOOP: } bool Interpreter::hasConditionMatch(const Arabica::DOM::Node& conditional) { - try { - if (_dataModel && HAS_ATTR(conditional, "cond")) - return _dataModel.evalAsBool(ATTR(conditional, "cond")); - } catch (Event e) { - LOG(ERROR) << "Syntax error in cond attribute of " << TAGNAME(conditional) << " element:" << std::endl << e << std::endl; - return false; - } + + if (HAS_ATTR(conditional, "cond")) { + if (!_dataModel) { + LOG(ERROR) << "Cannot check a condition without a datamodel"; + return false; + } + try { + return _dataModel.evalAsBool(ATTR(conditional, "cond")); + } catch (Event e) { + LOG(ERROR) << "Syntax error in cond attribute of " << TAGNAME(conditional) << " element:" << std::endl << e << std::endl; + return false; + } + } return true; // no condition is always true } @@ -1052,8 +1103,8 @@ Arabica::XPath::NodeSet Interpreter::filterPreempted(const Arabica: for (unsigned int j = i+1; j < enabledTransitions.size(); j++) { Arabica::DOM::Node t2 = enabledTransitions[j]; if (isPreemptingTransition(t2, t)) { -#if 0 - std::cout << "Preempting transitions: " << std::endl << t2 << std::endl << t; +#if VERBOSE + std::cout << "Transition preempted!: " << std::endl << t2 << std::endl << t << std::endl; #endif goto LOOP; } @@ -1069,7 +1120,7 @@ bool Interpreter::isPreemptingTransition(const Arabica::DOM::Node& assert(t1); assert(t2); -#if 0 +#if VERBOSE std::cout << "Checking preemption: " << std::endl << t1 << std::endl << t2 << std::endl; #endif @@ -1101,6 +1152,7 @@ bool Interpreter::isPreemptingTransition(const Arabica::DOM::Node& /** * filterPreempted approach from chris nuernberger */ +#if 0 Arabica::DOM::Node Interpreter::getTransitionSubgraph(const Arabica::DOM::Node& transition) { Arabica::XPath::NodeSet targets = getTargetStates(transition); Arabica::DOM::Node source = getSourceState(transition); @@ -1123,6 +1175,7 @@ Arabica::DOM::Node Interpreter::getTransitionSubgraph(const Arabica targets.push_back(source); return findLCCA(targets); } +#endif void Interpreter::microstep(const Arabica::XPath::NodeSet& enabledTransitions) { #if 0 @@ -1164,9 +1217,7 @@ void Interpreter::exitInterpreter() { } void Interpreter::executeTransitionContent(const Arabica::XPath::NodeSet& enabledTransitions) { - for (int i = 0; i < enabledTransitions.size(); i++) { - executeContent(enabledTransitions[i]); - } + executeContent(enabledTransitions); } void Interpreter::executeContent(const NodeList& content) { @@ -1177,11 +1228,27 @@ void Interpreter::executeContent(const NodeList& content) { } } +void Interpreter::executeContent(const NodeSet& content) { + for (unsigned int i = 0; i < content.size(); i++) { + if (content[i].getNodeType() != Node_base::ELEMENT_NODE) + continue; + executeContent(content[i]); + } +} + void Interpreter::executeContent(const Arabica::DOM::Node& content) { if (content.getNodeType() != Node_base::ELEMENT_NODE) return; if (false) { + } else if (boost::iequals(TAGNAME(content), _xmlNSPrefix + "onentry") || + boost::iequals(TAGNAME(content), _xmlNSPrefix + "onexit") || + boost::iequals(TAGNAME(content), _xmlNSPrefix + "transition")) { + // --- CONVENIENCE LOOP -------------------------- + NodeList executable = content.getChildNodes(); + for (int i = 0; i < executable.getLength(); i++) { + executeContent(executable.item(i)); + } } else if (boost::iequals(TAGNAME(content), _xmlNSPrefix + "raise")) { // --- RAISE -------------------------- if (HAS_ATTR(content, "event")) { @@ -1305,8 +1372,14 @@ ELSIF_ELEM_MATCH: } std::stringstream srcContent; - srcContent << scriptUrl; + if (_cachedURLs.find(scriptUrl.asString()) != _cachedURLs.end()) { + srcContent << _cachedURLs[scriptUrl.asString()]; + } else { + srcContent << scriptUrl; + _cachedURLs[scriptUrl.asString()] = scriptUrl; + } + try { _dataModel.eval(srcContent.str()); } catch (Event e) { @@ -1349,10 +1422,27 @@ ELSIF_ELEM_MATCH: } else if (boost::iequals(TAGNAME(content), _xmlNSPrefix + "invoke")) { // --- INVOKE -------------------------- } else { - NodeList executable = content.getChildNodes(); - for (int i = 0; i < executable.getLength(); i++) { - executeContent(executable.item(i)); - } + // --- Custom Executable Content + ExecutableContent execContent; + if (_executableContent.find(content) == _executableContent.end()) { + execContent = Factory::createExecutableContent(content.getLocalName(), content.getNamespaceURI(), this); + if (!execContent) { + LOG(ERROR) << "No custom executable content known for " << content.getLocalName() << " in " << content.getNamespaceURI(); + return; + } + _executableContent[content] = execContent; + } else { + execContent = _executableContent[content]; + } + + execContent.enterElement(content); + if (execContent.processChildren()) { + NodeList executable = content.getChildNodes(); + for (int i = 0; i < executable.getLength(); i++) { + executeContent(executable.item(i)); + } + } + execContent.exitElement(content); } } @@ -1363,7 +1453,7 @@ void Interpreter::exitStates(const Arabica::XPath::NodeSet& enabled NodeSet statesToExit; std::set::iterator monIter; -#if 1 +#if VERBOSE std::cout << "Enabled exit transitions: " << std::endl; for (int i = 0; i < enabledTransitions.size(); i++) { std::cout << enabledTransitions[i] << std::endl; @@ -1395,7 +1485,7 @@ void Interpreter::exitStates(const Arabica::XPath::NodeSet& enabled tmpStates.push_back(source); tmpStates.insert(tmpStates.end(), tStates.begin(), tStates.end()); -#if 1 +#if VERBOSE std::cout << "tmpStates: "; for (int i = 0; i < tmpStates.size(); i++) { std::cout << ATTR(tmpStates[i], "id") << ", "; @@ -1405,7 +1495,7 @@ void Interpreter::exitStates(const Arabica::XPath::NodeSet& enabled ancestor = findLCCA(tmpStates); } -#if 1 +#if VERBOSE std::cout << "Ancestor: " << ATTR(ancestor, "id") << std::endl;; #endif @@ -1416,10 +1506,10 @@ void Interpreter::exitStates(const Arabica::XPath::NodeSet& enabled } } -#if 1 +#if VERBOSE std::cout << "States to exit: "; for (int i = 0; i < statesToExit.size(); i++) { - std::cout << ATTR(statesToExit[i], "id") << ", "; + std::cout << LOCALNAME(statesToExit[i]) << ":" << ATTR(statesToExit[i], "id") << ", "; } std::cout << std::endl; @@ -1503,12 +1593,13 @@ void Interpreter::exitStates(const Arabica::XPath::NodeSet& enabled } +#ifdef ORIG_ENTERSTATES void Interpreter::enterStates(const Arabica::XPath::NodeSet& enabledTransitions) { NodeSet statesToEnter; NodeSet statesForDefaultEntry; std::set::iterator monIter; -#if 1 +#if VERBOSE std::cout << "Enabled enter transitions: " << std::endl; for (int i = 0; i < enabledTransitions.size(); i++) { std::cout << enabledTransitions[i] << std::endl; @@ -1522,7 +1613,7 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet& enable std::string transitionType = (boost::iequals(transition.getAttribute("type"), "internal") ? "internal" : "external"); NodeSet tStates = getTargetStates(transition); -#if 1 +#if VERBOSE std::cout << "Target States: "; for (int i = 0; i < tStates.size(); i++) { std::cout << ATTR(tStates[i], "id") << ", "; @@ -1532,7 +1623,7 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet& enable Arabica::DOM::Node ancestor; Arabica::DOM::Node source = getSourceState(transition); -#if 1 +#if VERBOSE std::cout << "Source States: " << ATTR(source, "id") << std::endl; #endif assert(source); @@ -1556,7 +1647,7 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet& enable ancestor = findLCCA(tmpStates); } -#if 1 +#if VERBOSE std::cout << "Ancestor: " << ATTR(ancestor, "id") << std::endl; #endif @@ -1564,10 +1655,10 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet& enable addStatesToEnter(tStates[j], statesToEnter, statesForDefaultEntry); } -#if 1 +#if VERBOSE std::cout << "States to enter: "; for (int i = 0; i < statesToEnter.size(); i++) { - std::cout << ATTR(statesToEnter[i], "id") << ", "; + std::cout << LOCALNAME(statesToEnter[i]) << ":" << ATTR(statesToEnter[i], "id") << ", "; } std::cout << std::endl; #endif @@ -1575,7 +1666,7 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet& enable for (int j = 0; j < tStates.size(); j++) { NodeSet ancestors = getProperAncestors(tStates[j], ancestor); -#if 1 +#if VERBOSE std::cout << "Proper Ancestors of " << ATTR(tStates[j], "id") << " and " << ATTR(ancestor, "id") << ": "; for (int i = 0; i < ancestors.size(); i++) { std::cout << ATTR(ancestors[i], "id") << ", "; @@ -1628,9 +1719,8 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet& enable } // execute onentry executable content NodeSet onEntryElems = filterChildElements(_xmlNSPrefix + "onEntry", stateElem); - for (int j = 0; j < onEntryElems.size(); j++) { - executeContent(onEntryElems[j]); - } + executeContent(onEntryElems); + if (isMember(stateElem, statesForDefaultEntry)) { // execute initial transition content for compund states Arabica::XPath::NodeSet transitions = _xpath.evaluate("" + _xpathPrefix + "initial/" + _xpathPrefix + "transition", stateElem).asNodeSet(); @@ -1675,6 +1765,248 @@ void Interpreter::enterStates(const Arabica::XPath::NodeSet& enable } } + +void Interpreter::addStatesToEnter(const Arabica::DOM::Node& state, + Arabica::XPath::NodeSet& statesToEnter, + Arabica::XPath::NodeSet& statesForDefaultEntry) { + std::string stateId = ((Arabica::DOM::Element)state).getAttribute("id"); + +#if VERBOSE + std::cout << "Adding state to enter: " << stateId << std::endl; +#endif + if (isHistory(state)) { + if (_historyValue.find(stateId) != _historyValue.end()) { + Arabica::XPath::NodeSet historyValue = _historyValue[stateId]; + +#if VERBOSE + std::cout << "History State " << ATTR(state, "id") << ": "; + for (int i = 0; i < historyValue.size(); i++) { + std::cout << ATTR(historyValue[i], "id") << ", "; + } + std::cout << std::endl; +#endif + + for (int i = 0; i < historyValue.size(); i++) { + addStatesToEnter(historyValue[i], statesToEnter, statesForDefaultEntry); + NodeSet ancestors = getProperAncestors(historyValue[i], state); + +#if VERBOSE + std::cout << "Proper Ancestors: "; + for (int i = 0; i < ancestors.size(); i++) { + std::cout << ATTR(ancestors[i], "id") << ", "; + } + std::cout << std::endl; +#endif + + for (int j = 0; j < ancestors.size(); j++) { + statesToEnter.push_back(ancestors[j]); + } + } + } else { + NodeSet transitions = filterChildElements(_xmlNSPrefix + "transition", state); + for (int i = 0; i < transitions.size(); i++) { + NodeSet targets = getTargetStates(transitions[i]); + for (int j = 0; j < targets.size(); j++) { + addStatesToEnter(targets[j], statesToEnter, statesForDefaultEntry); + + // Modifications from chris nuernberger + NodeSet ancestors = getProperAncestors(targets[j], state); + for (int k = 0; k < ancestors.size(); k++) { + statesToEnter.push_back(ancestors[k]); + } + } + } + } + } else { + statesToEnter.push_back(state); + if (isCompound(state)) { + statesForDefaultEntry.push_back(state); + + addStatesToEnter(getInitialState(state), statesToEnter, statesForDefaultEntry); + +# if 0 + NodeSet tStates = getTargetStates(getInitialState(state)); + for (int i = 0; i < tStates.size(); i++) { + addStatesToEnter(tStates[i], statesToEnter, statesForDefaultEntry); + } +# endif + // addStatesToEnter(getInitialState(state), statesToEnter, statesForDefaultEntry); + // NodeSet tStates = getTargetStates(getInitialState(state)); + + } else if(isParallel(state)) { + NodeSet childStates = getChildStates(state); + for (int i = 0; i < childStates.size(); i++) { + addStatesToEnter(childStates[i], statesToEnter, statesForDefaultEntry); + } + } + } +} +#endif + +#ifdef ENTERSTATES_02_2013 +void Interpreter::enterStates(const Arabica::XPath::NodeSet& enabledTransitions) { + NodeSet statesToEnter; + NodeSet statesForDefaultEntry; + std::set::iterator monIter; + + computeEntrySet(enabledTransitions, statesToEnter, statesForDefaultEntry); + statesToEnter.sort(); // entry order is document order + for (int i = 0; i < statesToEnter.size(); i++) { + Arabica::DOM::Element s = (Arabica::DOM::Element)statesToEnter[i]; + _configuration.push_back(s); + _statesToInvoke.push_back(s); + + if (_binding == LATE && ATTR(s, "isFirstEntry").size() > 0) { + NodeSet dataModelElems = filterChildElements(_xmlNSPrefix + "datamodel", s); + if(dataModelElems.size() > 0 && _dataModel) { + Arabica::XPath::NodeSet dataElems = filterChildElements(_xmlNSPrefix + "data", dataModelElems[0]); + for (int j = 0; j < dataElems.size(); j++) { + initializeData(dataElems[j]); + } + } + s.setAttribute("isFirstEntry", ""); + } + executeContent(filterChildElements(_xmlNSPrefix + "onEntry", s)); + if (isMember(s, statesForDefaultEntry)) { + executeContent(getInitialState(s)); // TODO: This part is unclear + } + +#if VERBOSE + std::cout << "Is state " << ATTR(s, "id") << " final?"; +#endif + if (isFinal(s)) { + if (parentIsScxmlState(s)) { + _running = false; + _done = true; + } else { + Arabica::DOM::Element parent = (Arabica::DOM::Element)s.getParentNode(); + Arabica::DOM::Element grandParent = (Arabica::DOM::Element)parent.getParentNode(); + internalDoneSend(parent); + + if (isParallel(grandParent)) { + Arabica::XPath::NodeSet childs = getChildStates(grandParent); + bool inFinalState = true; + for (int j = 0; j < childs.size(); j++) { + if (!isInFinalState(childs[j])) { + inFinalState = false; + break; + } + } + if (inFinalState) { + internalDoneSend(grandParent); + } + } + } + } + } +} +void Interpreter::computeEntrySet(const Arabica::XPath::NodeSet& transitions, + Arabica::XPath::NodeSet& statesToEnter, + Arabica::XPath::NodeSet& statesForDefaultEntry) { + for (int i = 0; i < transitions.size(); i++) { + NodeSet targets = getTargetStates(transitions[i]); + for (int j = 0; j < targets.size(); j++) { + statesToEnter.push_back(targets[i]); + } + } + for (int i = 0; i < transitions.size(); i++) { + Arabica::DOM::Node ancestor = getTransitionDomain(transitions[i]); + NodeSet targets = getTargetStates(transitions[i]); + for (int j = 0; j < targets.size(); j++) { + addAncestorStatesToEnter(targets[j], ancestor, statesToEnter, statesForDefaultEntry); + } + } +} +void Interpreter::addDescendentStatesToEnter(const Arabica::DOM::Node& state, + Arabica::XPath::NodeSet& statesToEnter, + Arabica::XPath::NodeSet& statesForDefaultEntry) { + if (isHistory(state)) { + if (_historyValue.find(ATTR(state, "id")) != _historyValue.end()) { + Arabica::XPath::NodeSet history = _historyValue[ATTR(state, "id")]; + for (int i = 0; i < history.size(); i++) { + addDescendentStatesToEnter(history[i], statesToEnter, statesForDefaultEntry); + addAncestorStatesToEnter(history[i], state.getParentNode(), statesToEnter, statesForDefaultEntry); + } + } else { + NodeSet transitions = filterChildElements(_xmlNSPrefix + "transition", state); + for (int i = 0; i < transitions.size(); i++) { + NodeSet targets = getTargetStates(transitions[i]); + for (int j = 0; j < targets.size(); j++) { + addDescendentStatesToEnter(targets[j],statesToEnter,statesForDefaultEntry); + addAncestorStatesToEnter(targets[j], state.getParentNode(), statesToEnter, statesForDefaultEntry); + } + } + } + } else { + statesToEnter.push_back(state); + if (isCompound(state)) { + statesForDefaultEntry.push_back(state); + Node initial = getInitialState(state); + addDescendentStatesToEnter(initial, statesToEnter, statesForDefaultEntry); + addAncestorStatesToEnter(initial, state.getParentNode(), statesToEnter, statesForDefaultEntry); + } else if (isParallel(state)) { + NodeSet childs = getChildStates(state); + for (int i = 0; i < childs.size(); i++) { + bool someAreDescendants = false; + for (int j = 0; i < statesToEnter.size(); j++) { + if (isDescendant(statesToEnter[j], childs[i])) + someAreDescendants = true; + } + if (!someAreDescendants) { + addDescendentStatesToEnter(childs[i], statesToEnter, statesForDefaultEntry); + } + } + } + } +} + +void Interpreter::addAncestorStatesToEnter(const Arabica::DOM::Node& state, + const Arabica::DOM::Node& ancestor, + Arabica::XPath::NodeSet& statesToEnter, + Arabica::XPath::NodeSet& statesForDefaultEntry) { + NodeSet properAncs = getProperAncestors(state, ancestor); + for (int k = 0; k < properAncs.size(); k++) { + statesToEnter.push_back(properAncs[k]); + if (isParallel(properAncs[k])) { + NodeSet childs = getChildStates(properAncs[k]); + for (int i = 0; i < childs.size(); i++) { + bool someAreDescendants = false; + for (int j = 0; i < statesToEnter.size(); j++) { + if (isDescendant(statesToEnter[j], childs[i])) + someAreDescendants = true; + } + if (!someAreDescendants) { + addDescendentStatesToEnter(childs[i], statesToEnter, statesForDefaultEntry); + } + } + } + } +} + +Arabica::DOM::Node Interpreter::getTransitionDomain(const Arabica::DOM::Node& transition) { + Arabica::DOM::Node source = getSourceState(transition); + if (isTargetless(transition)) { + return source; + } + + Arabica::XPath::NodeSet targets = getTargetStates(transition); + if (boost::iequals(ATTR(transition, "type"), "internal") && isCompound(source)) { + bool allDescendants = true; + for (int i = 0; i < targets.size(); i++) { + if (!isDescendant(targets[i], source)) { + allDescendants = false; + break; + } + } + if (allDescendants) + return source; + } + + targets.push_back(source); + return findLCCA(targets); +} + +#endif bool Interpreter::parentIsScxmlState(Arabica::DOM::Node state) { Arabica::DOM::Element stateElem = (Arabica::DOM::Element)state; @@ -1710,79 +2042,6 @@ bool Interpreter::isMember(const Arabica::DOM::Node& node, const Ar return false; } -void Interpreter::addStatesToEnter(const Arabica::DOM::Node& state, - Arabica::XPath::NodeSet& statesToEnter, - Arabica::XPath::NodeSet& statesForDefaultEntry) { - std::string stateId = ((Arabica::DOM::Element)state).getAttribute("id"); - -#if 1 - std::cout << "Adding state to enter: " << stateId << std::endl; -#endif - if (isHistory(state)) { - if (_historyValue.find(stateId) != _historyValue.end()) { - Arabica::XPath::NodeSet historyValue = _historyValue[stateId]; - -#if 1 - std::cout << "History State " << ATTR(state, "id") << ": "; - for (int i = 0; i < historyValue.size(); i++) { - std::cout << ATTR(historyValue[i], "id") << ", "; - } - std::cout << std::endl; -#endif - - for (int i = 0; i < historyValue.size(); i++) { - addStatesToEnter(historyValue[i], statesToEnter, statesForDefaultEntry); - NodeSet ancestors = getProperAncestors(historyValue[i], state); - -#if 1 - std::cout << "Proper Ancestors: "; - for (int i = 0; i < ancestors.size(); i++) { - std::cout << ATTR(ancestors[i], "id") << ", "; - } - std::cout << std::endl; -#endif - - for (int j = 0; j < ancestors.size(); j++) { - statesToEnter.push_back(ancestors[j]); - } - } - } else { - NodeSet transitions = filterChildElements(_xmlNSPrefix + "transition", state); - for (int i = 0; i < transitions.size(); i++) { - NodeSet targets = getTargetStates(transitions[i]); - for (int j = 0; j < targets.size(); j++) { - addStatesToEnter(targets[j], statesToEnter, statesForDefaultEntry); - - // Modifications from chris nuernberger - NodeSet ancestors = getProperAncestors(targets[j], state); - for (int k = 0; k < ancestors.size(); k++) { - statesToEnter.push_back(ancestors[k]); - } - } - } - } - } else { - statesToEnter.push_back(state); - if (isCompound(state)) { - statesForDefaultEntry.push_back(state); -#if 0 - NodeSet tStates = getTargetStates(getInitialState(state)); - for (int i = 0; i < tStates.size(); i++) { - addStatesToEnter(tStates[i], statesToEnter, statesForDefaultEntry); - } -#endif - addStatesToEnter(getInitialState(state), statesToEnter, statesForDefaultEntry); -// NodeSet tStates = getTargetStates(getInitialState(state)); - - } else if(isParallel(state)) { - NodeSet childStates = getChildStates(state); - for (int i = 0; i < childStates.size(); i++) { - addStatesToEnter(childStates[i], statesToEnter, statesForDefaultEntry); - } - } - } -} - Arabica::XPath::NodeSet Interpreter::getChildStates(const Arabica::DOM::Node& state) { Arabica::XPath::NodeSet childs; @@ -1899,6 +2158,10 @@ Arabica::DOM::Node Interpreter::getInitialState(Arabica::DOM::Node< state = state.getNextSibling(); } +#if VERBOSE + std::cout << "Getting initial state of " << TAGNAME(state) << " " << ATTR(state, "id") << std::endl; +#endif + assert(isCompound(state) || isParallel(state)); // initial attribute at element @@ -1925,8 +2188,10 @@ Arabica::DOM::Node Interpreter::getInitialState(Arabica::DOM::Node< NodeSet Interpreter::getTargetStates(const Arabica::DOM::Node& transition) { NodeSet targetStates; + assert(boost::iequals(LOCALNAME(transition), "transition")); + // if we are called with a state, process all its transitions - if (isState(transition)) { + if (isState(transition) || (transition.getNodeType() == Node_base::ELEMENT_NODE && boost::iequals(_xmlNSPrefix + "initial", TAGNAME(transition)))) { NodeList childs = transition.getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { if (childs.item(i).getNodeType() == Node_base::ELEMENT_NODE && boost::iequals(TAGNAME(childs.item(i)), _xmlNSPrefix + "transition")) { @@ -2027,6 +2292,8 @@ bool Interpreter::isWithinSameChild(const Arabica::DOM::Node& trans // @todo: do we need to look at parallel as well? if (_xpath.evaluate("" + _xpathPrefix + "state[id=\"" + target + "\"]", transition.getParentNode()).asNodeSet().size() > 0) return true; + if (_xpath.evaluate("" + _xpathPrefix + "parallel[id=\"" + target + "\"]", transition.getParentNode()).asNodeSet().size() > 0) + return true; } return false; } diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h index 7b30fd9..9ec4eb1 100644 --- a/src/uscxml/Interpreter.h +++ b/src/uscxml/Interpreter.h @@ -24,8 +24,12 @@ #include "uscxml/Message.h" #include "uscxml/Factory.h" +#define ORIG_ENTERSTATES + namespace uscxml { +class HTTPServletInvoker; + class InterpreterMonitor { public: virtual ~InterpreterMonitor() {} @@ -146,6 +150,8 @@ public: return _sessionId; } + HTTPServletInvoker* getHTTPServlet() { return _httpServlet; } + bool runOnMainThread(int fps, bool blocking = true); static bool isMember(const Arabica::DOM::Node& node, const Arabica::XPath::NodeSet& set); @@ -209,22 +215,44 @@ protected: uscxml::concurrency::BlockingQueue* _parentQueue; DelayedEventQueue* _sendQueue; + HTTPServletInvoker* _httpServlet; + std::set _monitors; static URL toBaseURI(const URL& url); void microstep(const Arabica::XPath::NodeSet& enabledTransitions); - void exitStates(const Arabica::XPath::NodeSet& enabledTransitions); - void enterStates(const Arabica::XPath::NodeSet& enabledTransitions); void executeTransitionContent(const Arabica::XPath::NodeSet& enabledTransitions); void executeContent(const Arabica::DOM::Node& content); void executeContent(const Arabica::DOM::NodeList& content); + void executeContent(const Arabica::XPath::NodeSet& content); void initializeData(const Arabica::DOM::Node& data); void exitInterpreter(); +#ifdef ORIG_ENTERSTATES + void enterStates(const Arabica::XPath::NodeSet& enabledTransitions); void addStatesToEnter(const Arabica::DOM::Node& state, Arabica::XPath::NodeSet& statesToEnter, Arabica::XPath::NodeSet& statesForDefaultEntry); +#endif + +#ifdef ENTERSTATES_02_2013 + void enterStates(const Arabica::XPath::NodeSet& enabledTransitions); + void computeEntrySet(const Arabica::XPath::NodeSet& transitions, + Arabica::XPath::NodeSet& statesToEnter, + Arabica::XPath::NodeSet& statesForDefaultEntry); + void addDescendentStatesToEnter(const Arabica::DOM::Node& state, + Arabica::XPath::NodeSet& statesToEnter, + Arabica::XPath::NodeSet& statesForDefaultEntry); + void addAncestorStatesToEnter(const Arabica::DOM::Node& state, + const Arabica::DOM::Node& ancestor, + Arabica::XPath::NodeSet& statesToEnter, + Arabica::XPath::NodeSet& statesForDefaultEntry); + Arabica::DOM::Node getTransitionDomain(const Arabica::DOM::Node& transition); + +#endif + + void exitStates(const Arabica::XPath::NodeSet& enabledTransitions); Arabica::XPath::NodeSet selectEventlessTransitions(); Arabica::XPath::NodeSet selectTransitions(const std::string& event); @@ -242,13 +270,13 @@ protected: static bool nameMatch(const std::string& transitionEvent, const std::string& event); Arabica::XPath::NodeSet filterPreempted(const Arabica::XPath::NodeSet& enabledTransitions); - bool hasConditionMatch(const Arabica::DOM::Node& conditional); bool isPreemptingTransition(const Arabica::DOM::Node& t1, const Arabica::DOM::Node& t2); - bool isInFinalState(const Arabica::DOM::Node& state); bool isWithinSameChild(const Arabica::DOM::Node& transition); + bool hasConditionMatch(const Arabica::DOM::Node& conditional); + bool isInFinalState(const Arabica::DOM::Node& state); bool parentIsScxmlState(Arabica::DOM::Node state); - Arabica::DOM::Node getTransitionSubgraph(const Arabica::DOM::Node& transition); +// Arabica::DOM::Node getTransitionSubgraph(const Arabica::DOM::Node& transition); static std::vector tokenizeIdRefs(const std::string& idRefs); @@ -267,9 +295,11 @@ protected: std::map > _sendIds; std::map _invokers; std::map _autoForwardees; + std::map, ExecutableContent> _executableContent; /// We need to remember to adapt them when the DOM is operated upon std::map > _cachedStates; + std::map _cachedURLs; }; } diff --git a/src/uscxml/Message.cpp b/src/uscxml/Message.cpp index 9453508..1466b6a 100644 --- a/src/uscxml/Message.cpp +++ b/src/uscxml/Message.cpp @@ -5,6 +5,7 @@ //#include "uscxml/Interpreter.h" #include #include +#include #ifdef HAS_STRING_H #include @@ -109,7 +110,7 @@ Arabica::DOM::Document Data::toDocument() { Arabica::DOM::Document Event::toDocument() { Arabica::DOM::DOMImplementation domFactory = Arabica::SimpleDOM::DOMImplementation::getDOMImplementation(); - Arabica::DOM::Document document = Data::toDocument(); + Arabica::DOM::Document document = data.toDocument(); Arabica::DOM::Element scxmlMsg = document.getDocumentElement(); @@ -178,17 +179,47 @@ Data Data::fromXML(const std::string& xmlString) { Data Data::fromJSON(const std::string& jsonString) { Data data; + jsmn_parser p; - // unimplemented -// assert(false); + jsmntok_t* t = NULL; - jsmn_parser p; - jsmntok_t t[1024]; - memset(&t, 0, sizeof(t)); - jsmn_init(&p); + // we do not know the number of tokens beforehand, start with something sensible and increase + int rv; + int frac = 32; // this will get decreased to 16 to first iteration for 1/16 length/token ratio + do { + jsmn_init(&p); + + frac /= 2; + int nrTokens = jsonString.size() / frac; + if (t != NULL) { + free(t); +// LOG(INFO) << "Increasing JSON length to token ratio to 1/" << frac; + } + t = (jsmntok_t*)malloc(nrTokens * sizeof(jsmntok_t)); + if (t == NULL) { + LOG(ERROR) << "Cannot parse JSON, ran out of memory!"; + return data; + } + memset(t, 0, nrTokens * sizeof(jsmntok_t)); + + rv = jsmn_parse(&p, jsonString.c_str(), t, nrTokens); + } while (rv == JSMN_ERROR_NOMEM && frac > 1); - int rv = jsmn_parse(&p, jsonString.c_str(), t, 1024); if (rv != 0) { + switch (rv) { + case JSMN_ERROR_NOMEM: + LOG(ERROR) << "Cannot parse JSON, not enough tokens were provided!"; + break; + case JSMN_ERROR_INVAL: + LOG(ERROR) << "Cannot parse JSON, invalid character inside JSON string!"; + break; + case JSMN_ERROR_PART: + LOG(ERROR) << "Cannot parse JSON, the string is not a full JSON packet, more bytes expected!"; + break; + default: + break; + } + free(t); return data; } @@ -216,7 +247,7 @@ Data Data::fromJSON(const std::string& jsonString) { // there are no more tokens if (t[currTok].end == 0 || tokenStack.empty()) break; - + // next token starts after current one => pop if (t[currTok].end > tokenStack.back().end) tokenStack.pop_back(); @@ -233,6 +264,8 @@ Data Data::fromJSON(const std::string& jsonString) { } } while (true); + + free(t); return data; } @@ -271,7 +304,7 @@ Event Event::fromXML(const std::string& xmlString) { break; } } - event.compound[key] = Data(value, VERBATIM); + event.data.compound[key] = Data(value, Data::VERBATIM); } } } @@ -401,7 +434,7 @@ std::ostream& operator<< (std::ostream& os, const Event& event) { if (event.origintype.size() > 0) os << indent << " origintype: " << event.origintype << std::endl; _dataIndentation++; - os << indent << " data: " << (Data)event << std::endl; + os << indent << " data: " << event.data << std::endl; _dataIndentation--; return os; } diff --git a/src/uscxml/Message.h b/src/uscxml/Message.h index 43eecdf..96ff6c8 100644 --- a/src/uscxml/Message.h +++ b/src/uscxml/Message.h @@ -52,7 +52,7 @@ protected: #endif }; -class Event : public Data { +class Event { public: enum Type { INTERNAL = 1, @@ -70,7 +70,8 @@ public: Arabica::DOM::Node dom; std::string sendid; std::string invokeid; - + Data data; + static Event fromXML(const std::string& xmlString); Arabica::DOM::Document toDocument(); std::string toXMLString() { diff --git a/src/uscxml/URL.cpp b/src/uscxml/URL.cpp index 015ed6c..8656cd2 100644 --- a/src/uscxml/URL.cpp +++ b/src/uscxml/URL.cpp @@ -1,23 +1,8 @@ -#include -#include -#include -#include - #include -#include - -#include -#include -#ifndef WIN32 -#include -#endif -#include -#include - -#include "uscxml/Common.h" #include "URL.h" #include "uscxml/config.h" +#include #include /* defines FILENAME_MAX */ #ifdef _WIN32 @@ -36,484 +21,493 @@ #include // mkstemp legacy #endif +#include + namespace uscxml { +URLImpl::URLImpl(const std::string& url) : _handle(NULL), _uri(url), _isDownloaded(false), _hasFailed(false) { + _handle = curl_easy_init(); + if (_handle == NULL) { + LOG(ERROR) << "curl_easy_init returned NULL, this is bad!"; + } +} + URLImpl::~URLImpl() { - if (_localFile.length() > 0) - remove(_localFile.c_str()); + if (_handle != NULL) + curl_easy_cleanup(_handle); } - -const bool URLImpl::toAbsoluteCwd() { - char currPath[FILENAME_MAX]; - if (!getcwd(currPath, sizeof(currPath))) { - return false; - } - currPath[sizeof(currPath) - 1] = '\0'; /* not really required */ - return toAbsolute(std::string("file://" + std::string(currPath) + "/")); + +size_t URLImpl::writeHandler(void *ptr, size_t size, size_t nmemb, void *userdata) { + URLImpl* url = (URLImpl*)userdata; + url->_inContent.write((char*)ptr, size * nmemb); + + monIter_t monIter = url->_monitors.begin(); + while(monIter != url->_monitors.end()) { + (*monIter)->contentChunkReceived(URL(url->shared_from_this()), std::string((char*)ptr, size * nmemb)); + monIter++; + } + + return size * nmemb; } -std::string URLImpl::getLocalFilename(const std::string& suffix) { - if (_localFile.length() > 0) - return _localFile; - - if (_uri.scheme().compare("file") == 0) - return _uri.path(); - - // try hard to find a temporary directory - const char* tmpDir = NULL; - if (tmpDir == NULL) - tmpDir = getenv("TMPDIR"); - if (tmpDir == NULL) - tmpDir = getenv("TMP"); - if (tmpDir == NULL) - tmpDir = getenv("TEMP"); - if (tmpDir == NULL) - tmpDir = getenv("USERPROFILE"); - if (tmpDir == NULL) - tmpDir = "/tmp"; - - char* tmpl = (char*)malloc(strlen(tmpDir) + 11 + suffix.length()); - char* writePtr = tmpl; - memcpy(writePtr, tmpDir, strlen(tmpDir)); - writePtr += strlen(tmpDir); - memcpy(writePtr, "scxmlXXXXXX", 11); - writePtr += 11; - memcpy(writePtr, suffix.c_str(), suffix.length()); - writePtr += suffix.length(); - tmpl[writePtr - tmpl] = 0; +size_t URLImpl::headerHandler(void *ptr, size_t size, size_t nmemb, void *userdata) { + URLImpl* url = (URLImpl*)userdata; + url->_inHeader.write((char*)ptr, size * nmemb); -#ifdef _WIN32 - _mktemp_s(tmpl, strlen(tmpl) + 1); - int fd = _open(tmpl, _O_CREAT, _S_IREAD | _S_IWRITE); -#else - int fd = mkstemps(tmpl, suffix.length()); -#endif - if (fd < 0) { - LOG(ERROR) << "mkstemp: " << strerror(errno) << std::endl; - return ""; - } -#ifdef WIN32 - _close(fd); -#else - close(fd); -#endif - return std::string(tmpl); -} + monIter_t monIter = url->_monitors.begin(); + while(monIter != url->_monitors.end()) { + (*monIter)->headerChunkReceived(URL(url->shared_from_this()), std::string((char*)ptr, size * nmemb)); + monIter++; + } -boost::shared_ptr URLImpl::toLocalFile(const std::string& content, const std::string& suffix) { - boost::shared_ptr urlImpl = boost::shared_ptr(new URLImpl()); - urlImpl->_localFile = urlImpl->getLocalFilename(suffix); - urlImpl->_uri = std::string("file://") + urlImpl->_localFile; - - std::ofstream file(urlImpl->_localFile.c_str(), std::ios_base::out); - if(file.is_open()) { - file << content; - file.close(); - } else { - return boost::shared_ptr(); - } - - return urlImpl; + return size * nmemb; } -const bool URLImpl::toAbsolute(const std::string& baseUrl) { - if (_uri.is_absolute()) - return true; - _uri = Arabica::io::URI(baseUrl, _uri.as_string()); - if (!_uri.is_absolute()) - return false; - return true; +void URLImpl::downloadStarted() { + LOG(INFO) << "Starting download of " << asString() << std::endl; + _inContent.str(""); + _inContent.clear(); + _inHeader.str(""); + _inHeader.clear(); + + monIter_t monIter = _monitors.begin(); + while(monIter != _monitors.end()) { + (*monIter)->downloadStarted(URL(shared_from_this())); + monIter++; + } } -const std::string URLImpl::asLocalFile(const std::string& suffix, bool reload) { - // this is already a local file - if (_uri.scheme().compare("file") == 0) - return _uri.path(); - - if (_localFile.length() > 0 && !reload) - return _localFile; - - if (_localFile.length() > 0) - remove(_localFile.c_str()); +void URLImpl::downloadCompleted() { + tthread::lock_guard lock(_mutex); - _localFile = getLocalFilename(suffix); + LOG(INFO) << "Finished downloading " << asString() << " with " << _inContent.str().size() << " bytes"; - std::ofstream file(_localFile.c_str(), std::ios_base::out); - if(file.is_open()) { - file << URL(this->shared_from_this()); - file.close(); - } else { - _localFile = ""; - } + _hasFailed = false; + _isDownloaded = true; + _condVar.notify_all(); - return _localFile; + monIter_t monIter = _monitors.begin(); + while(monIter != _monitors.end()) { + (*monIter)->downloadCompleted(URL(shared_from_this())); + monIter++; + } } -std::ostream & operator<<(std::ostream & stream, const URL& url) { - - std::string urlString = url.asString(); - std::string fileURL = "file://"; - - // strip file:// to support relative filenames - if(urlString.substr(0, fileURL.size()) == fileURL) { - urlString = urlString.substr(fileURL.size()); -#ifdef _WIN32 - urlString = urlString.substr(0,1) + ":" + urlString.substr(1); -// std::replace( urlString.begin(), urlString.end(), '/', '\\'); -#endif - } -// LOG(ERROR) << "Trying to open " << urlString; - URL_FILE *handle = url_fopen(urlString.c_str(), "r"); +void URLImpl::downloadFailed(int errorCode) { + tthread::lock_guard lock(_mutex); + + LOG(ERROR) << "Downloading " << asString() << " failed: " << strerror(errorCode); + + _hasFailed = true; + _isDownloaded = false; + _condVar.notify_all(); + + monIter_t monIter = _monitors.begin(); + while(monIter != _monitors.end()) { + (*monIter)->downloadFailed(URL(shared_from_this()), errorCode); + monIter++; + } - if(!handle) { - LOG(ERROR) << "Cannot open URL " << url.asString(); - return stream; - } - - int nread; - char buffer[256]; - - do { - nread = url_fread(buffer, 1,sizeof(buffer), handle); - stream.write(buffer, nread); - } while(nread); - - url_fclose(handle); - return stream; } - -/* we use a global one for convenience */ -CURLM *multi_handle; - -/* curl calls this routine to get more data */ -static size_t write_callback(char *buffer, - size_t size, - size_t nitems, - void *userp) { - char *newbuff; - size_t rembuff; - - URL_FILE *url = (URL_FILE *)userp; - size *= nitems; - - rembuff=url->buffer_len - url->buffer_pos; /* remaining space in buffer */ - - if(size > rembuff) { - /* not enough space in buffer */ - newbuff=(char*)realloc(url->buffer,url->buffer_len + (size - rembuff)); - if(newbuff==NULL) { - fprintf(stderr,"callback buffer grow failed\n"); - size=rembuff; - } else { - /* realloc suceeded increase buffer size*/ - url->buffer_len+=size - rembuff; - url->buffer=newbuff; - } - } - - memcpy(&url->buffer[url->buffer_pos], buffer, size); - url->buffer_pos += size; - - return size; + +const std::map URLImpl::getInHeaderFields() { + if (!_isDownloaded) { + download(true); + } + + std::map headerFields; + std::string line; + while (std::getline(_inHeader, line)) { + size_t colon = line.find_first_of(":"); + size_t newline = line.find_first_of("\r\n"); + if (newline == std::string::npos) + newline = line.size(); + + if (colon == std::string::npos) { + if (headerFields.size() == 0) { + // put http status in a key that can never occur otherwise + headerFields["status:"] = line.substr(0, newline); + } else { + headerFields[line.substr(0, newline)] = line.substr(0, newline); // this should never happen + } + } else { + std::string key = line.substr(0, colon); + size_t firstChar = line.find_first_not_of(": ", colon, 2); + if (firstChar == std::string::npos) { + // nothing but spaces? + headerFields[line.substr(0, newline)] = ""; + } else { + std::string value = line.substr(firstChar, newline - firstChar); + headerFields[key] = value; + } + } + } + + return headerFields; } -/* use to attempt to fill the read buffer up to requested number of bytes */ -static int fill_buffer(URL_FILE *file, size_t want) { - fd_set fdread; - fd_set fdwrite; - fd_set fdexcep; - struct timeval timeout; - int rc; - - /* only attempt to fill buffer if transactions still running and buffer - * doesnt exceed required size already - */ - if((!file->still_running) || (file->buffer_pos > want)) - return 0; - - /* attempt to fill buffer */ - do { - int maxfd = -1; - long curl_timeo = -1; - - FD_ZERO(&fdread); - FD_ZERO(&fdwrite); - FD_ZERO(&fdexcep); - - /* set a suitable timeout to fail on */ - timeout.tv_sec = 60; /* 1 minute */ - timeout.tv_usec = 0; - - curl_multi_timeout(multi_handle, &curl_timeo); - if(curl_timeo >= 0) { - timeout.tv_sec = curl_timeo / 1000; - if(timeout.tv_sec > 1) - timeout.tv_sec = 1; - else - timeout.tv_usec = (curl_timeo % 1000) * 1000; - } - - /* get file descriptors from the transfers */ - curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); - - /* In a real-world program you OF COURSE check the return code of the - function calls. On success, the value of maxfd is guaranteed to be - greater or equal than -1. We call select(maxfd + 1, ...), specially - in case of (maxfd == -1), we call select(0, ...), which is basically - equal to sleep. */ - - rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout); - - switch(rc) { - case -1: - /* select error */ - break; - - case 0: - default: - /* timeout or readable/writable sockets */ - curl_multi_perform(multi_handle, &file->still_running); - break; - } - } while(file->still_running && (file->buffer_pos < want)); - return 1; +void URLImpl::setRequestType(const std::string& requestType) { + _requestType = requestType; } -/* use to remove want bytes from the front of a files buffer */ -static int use_buffer(URL_FILE *file,int want) { - /* sort out buffer */ - if((file->buffer_pos - want) <=0) { - /* ditch buffer - write will recreate */ - if(file->buffer) - free(file->buffer); - - file->buffer=NULL; - file->buffer_pos=0; - file->buffer_len=0; - } else { - /* move rest down make it available for later */ - memmove(file->buffer, - &file->buffer[want], - (file->buffer_pos - want)); - - file->buffer_pos -= want; - } - return 0; +void URLImpl::setOutContent(const std::string& content) { + _outContent = content; } -URL_FILE *url_fopen(const char *url,const char *operation) { - /* this code could check for URLs or types in the 'url' and - basicly use the real fopen() for standard files */ - - URL_FILE *file; - (void)operation; - - file = (URL_FILE*)malloc(sizeof(URL_FILE)); - if(!file) - return NULL; - - memset(file, 0, sizeof(URL_FILE)); - - if((file->handle.file=fopen(url,operation))) - file->type = CFTYPE_FILE; /* marked as URL */ - - else { - file->type = CFTYPE_CURL; /* marked as URL */ - file->handle.curl = curl_easy_init(); - - curl_easy_setopt(file->handle.curl, CURLOPT_URL, url); - curl_easy_setopt(file->handle.curl, CURLOPT_WRITEDATA, file); - curl_easy_setopt(file->handle.curl, CURLOPT_VERBOSE, 0L); - curl_easy_setopt(file->handle.curl, CURLOPT_WRITEFUNCTION, write_callback); - - if(!multi_handle) - multi_handle = curl_multi_init(); - - curl_multi_add_handle(multi_handle, file->handle.curl); - - /* lets start the fetch */ - curl_multi_perform(multi_handle, &file->still_running); - - if((file->buffer_pos == 0) && (!file->still_running)) { - /* if still_running is 0 now, we should return NULL */ - - /* make sure the easy handle is not in the multi handle anymore */ - curl_multi_remove_handle(multi_handle, file->handle.curl); - - /* cleanup */ - curl_easy_cleanup(file->handle.curl); - - free(file); - - file = NULL; - } - } - return file; +const std::string URLImpl::getInContent(bool forceReload) { + if (!_isDownloaded) { + download(true); + } + return _inContent.str(); } -int url_fclose(URL_FILE *file) { - int ret=0;/* default is good return */ - - switch(file->type) { - case CFTYPE_FILE: - ret=fclose(file->handle.file); /* passthrough */ - break; - - case CFTYPE_CURL: - /* make sure the easy handle is not in the multi handle anymore */ - curl_multi_remove_handle(multi_handle, file->handle.curl); - - /* cleanup */ - curl_easy_cleanup(file->handle.curl); - break; - - default: /* unknown or supported type - oh dear */ - ret=EOF; - errno=EBADF; - break; - } - - if(file->buffer) - free(file->buffer);/* free any allocated buffer space */ - - free(file); - - return ret; +const void URLImpl::download(bool blocking) { + tthread::lock_guard lock(_mutex); + + if (_isDownloaded) + return; + + URL url(shared_from_this()); + URLFetcher::fetchURL(url); + + if (blocking) { + while(!_isDownloaded && !_hasFailed) { + _condVar.wait(_mutex); // wait for notification + } + } } -int url_feof(URL_FILE *file) { - int ret=0; - - switch(file->type) { - case CFTYPE_FILE: - ret=feof(file->handle.file); - break; - - case CFTYPE_CURL: - if((file->buffer_pos == 0) && (!file->still_running)) - ret = 1; - break; - - default: /* unknown or supported type - oh dear */ - ret=-1; - errno=EBADF; - break; - } - return ret; +const bool URLImpl::toAbsoluteCwd() { + char currPath[FILENAME_MAX]; + if (!getcwd(currPath, sizeof(currPath))) { + return false; + } + currPath[sizeof(currPath) - 1] = '\0'; /* not really required */ + return toAbsolute(std::string("file://" + std::string(currPath) + "/")); } -size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file) { - size_t want; - - switch(file->type) { - case CFTYPE_FILE: - want=fread(ptr,size,nmemb,file->handle.file); - break; - - case CFTYPE_CURL: - want = nmemb * size; - - fill_buffer(file,want); - - /* check if theres data in the buffer - if not fill_buffer() - * either errored or EOF */ - if(!file->buffer_pos) - return 0; - - /* ensure only available data is considered */ - if(file->buffer_pos < want) - want = file->buffer_pos; - - /* xfer data to caller */ - memcpy(ptr, file->buffer, want); - - use_buffer(file,want); - - want = want / size; /* number of items */ - break; - - default: /* unknown or supported type - oh dear */ - want=0; - errno=EBADF; - break; - - } - return want; +std::string URLImpl::getLocalFilename(const std::string& suffix) { + if (_localFile.length() > 0) + return _localFile; + + if (_uri.scheme().compare("file") == 0) + return _uri.path(); + + // try hard to find a temporary directory + const char* tmpDir = NULL; + if (tmpDir == NULL) + tmpDir = getenv("TMPDIR"); + if (tmpDir == NULL) + tmpDir = getenv("TMP"); + if (tmpDir == NULL) + tmpDir = getenv("TEMP"); + if (tmpDir == NULL) + tmpDir = getenv("USERPROFILE"); + if (tmpDir == NULL) + tmpDir = "/tmp/"; + + char* tmpl = (char*)malloc(strlen(tmpDir) + 11 + suffix.length()); + char* writePtr = tmpl; + memcpy(writePtr, tmpDir, strlen(tmpDir)); + writePtr += strlen(tmpDir); + memcpy(writePtr, "scxmlXXXXXX", 11); + writePtr += 11; + memcpy(writePtr, suffix.c_str(), suffix.length()); + writePtr += suffix.length(); + tmpl[writePtr - tmpl] = 0; + +#ifdef _WIN32 + _mktemp_s(tmpl, strlen(tmpl) + 1); + int fd = _open(tmpl, _O_CREAT, _S_IREAD | _S_IWRITE); +#else + int fd = mkstemps(tmpl, suffix.length()); +#endif + if (fd < 0) { + LOG(ERROR) << "mkstemp " << tmpl << ": " << strerror(errno) << std::endl; + return ""; + } +#ifdef WIN32 + _close(fd); +#else + close(fd); +#endif + return std::string(tmpl); } -char *url_fgets(char *ptr, size_t size, URL_FILE *file) { - size_t want = size - 1;/* always need to leave room for zero termination */ - size_t loop; - - switch(file->type) { - case CFTYPE_FILE: - ptr = fgets(ptr,size,file->handle.file); - break; - - case CFTYPE_CURL: - fill_buffer(file,want); - - /* check if theres data in the buffer - if not fill either errored or - * EOF */ - if(!file->buffer_pos) - return NULL; - - /* ensure only available data is considered */ - if(file->buffer_pos < want) - want = file->buffer_pos; - - /*buffer contains data */ - /* look for newline or eof */ - for(loop=0; loop < want; loop++) { - if(file->buffer[loop] == '\n') { - want=loop+1;/* include newline */ - break; - } - } - - /* xfer data to caller */ - memcpy(ptr, file->buffer, want); - ptr[want]=0;/* allways null terminate */ - - use_buffer(file,want); - - break; +const bool URLImpl::toAbsolute(const std::string& baseUrl) { + if (_uri.is_absolute()) + return true; + _uri = Arabica::io::URI(baseUrl, _uri.as_string()); + if (!_uri.is_absolute()) + return false; + return true; +} - default: /* unknown or supported type - oh dear */ - ptr=NULL; - errno=EBADF; - break; - } +boost::shared_ptr URLImpl::toLocalFile(const std::string& content, const std::string& suffix) { + boost::shared_ptr urlImpl = boost::shared_ptr(new URLImpl()); + urlImpl->_localFile = urlImpl->getLocalFilename(suffix); + urlImpl->_uri = std::string("file://") + urlImpl->_localFile; + + std::ofstream file(urlImpl->_localFile.c_str(), std::ios_base::out); + if(file.is_open()) { + file << content; + file.close(); + } else { + return boost::shared_ptr(); + } + + return urlImpl; +} + +const std::string URLImpl::asLocalFile(const std::string& suffix, bool reload) { + // this is already a local file + if (_uri.scheme().compare("file") == 0) + return _uri.path(); + + if (_localFile.length() > 0 && !reload) + return _localFile; + + if (_localFile.length() > 0) + remove(_localFile.c_str()); + + _localFile = getLocalFilename(suffix); + + std::ofstream file(_localFile.c_str(), std::ios_base::out); + if(file.is_open()) { + file << URL(this->shared_from_this()); + file.close(); + } else { + _localFile = ""; + } + + return _localFile; +} - return ptr;/*success */ +std::ostream & operator<<(std::ostream & stream, const URL& url) { + URL nonConstUrl = url; // this is a hack + stream << nonConstUrl.getInContent(); + return stream; } -void url_rewind(URL_FILE *file) { - switch(file->type) { - case CFTYPE_FILE: - rewind(file->handle.file); /* passthrough */ - break; +URLFetcher::URLFetcher() { + _isStarted = false; + _multiHandle = curl_multi_init(); + start(); +} + +URLFetcher::~URLFetcher() { + stop(); + curl_multi_cleanup(_multiHandle); +} + +void URLFetcher::fetchURL(URL& url) { + URLFetcher* instance = getInstance(); + tthread::lock_guard lock(instance->_mutex); + + assert(url._impl->_handle != NULL); + if (url._impl->_handle == NULL) + return; + + if (instance->_handlesToURLs.find(url._impl->_handle) == instance->_handlesToURLs.end()) { + CURLcode curlError; + CURL* handle = url._impl->_handle; + + (curlError = curl_easy_setopt(handle, CURLOPT_URL, url.asString().c_str())) == CURLE_OK || + LOG(ERROR) << "Cannot set url to " << url.asString() << ": " << curl_easy_strerror(curlError); + + (curlError = curl_easy_setopt(handle, CURLOPT_WRITEDATA, url._impl.get())) == CURLE_OK || + LOG(ERROR) << "Cannot register this as write userdata: " << curl_easy_strerror(curlError); + + (curlError = curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, URLImpl::writeHandler)) == CURLE_OK || + LOG(ERROR) << "Cannot set write callback: " << curl_easy_strerror(curlError); + + (curlError = curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, URLImpl::headerHandler)) == CURLE_OK || + LOG(ERROR) << "Cannot request header from curl: " << curl_easy_strerror(curlError); + + (curlError = curl_easy_setopt(handle, CURLOPT_HEADERDATA, url._impl.get())) == CURLE_OK || + LOG(ERROR) << "Cannot register this as header userdata: " << curl_easy_strerror(curlError); + + + if (boost::iequals(url._impl->_requestType, "post")) { + + (curlError = curl_easy_setopt(handle, CURLOPT_POST, 1)) == CURLE_OK || + LOG(ERROR) << "Cannot set request type to post for " << url.asString() << ": " << curl_easy_strerror(curlError); + + (curlError = curl_easy_setopt(handle, CURLOPT_COPYPOSTFIELDS, url._impl->_outContent.c_str())) == CURLE_OK || + LOG(ERROR) << "Cannot set post data " << url.asString() << ": " << curl_easy_strerror(curlError); + + struct curl_slist* headers = NULL; + std::map::iterator paramIter = url._impl->_outHeader.begin(); + while(paramIter != url._impl->_outHeader.end()) { + char* key = curl_easy_escape(handle, paramIter->first.c_str(), paramIter->first.length()); + char* value = curl_easy_escape(handle, paramIter->second.c_str(), paramIter->second.length()); + + char* header = (char*)malloc(paramIter->first.size() + strlen(value) + 3); + sprintf(header,"%s: %s", paramIter->first.c_str(), value); + headers = curl_slist_append(headers, header); + + curl_free(key); + curl_free(value); + paramIter++; + } + (curlError = curl_easy_setopt(handle, CURLOPT_HTTPHEADER, headers)) == CURLE_OK || + LOG(ERROR) << "Cannot headers for " << url.asString() << ": " << curl_easy_strerror(curlError); + + //curl_slist_free_all(headers); + + + } else if (boost::iequals(url._impl->_requestType, "get")) { + (curlError = curl_easy_setopt(handle, CURLOPT_HTTPGET, 1)) == CURLE_OK || + LOG(ERROR) << "Cannot set request type to get for " << url.asString() << ": " << curl_easy_strerror(curlError); + } + + url.downloadStarted(); + instance->_handlesToURLs[handle] = url; + assert(instance->_handlesToURLs.size() > 0); + + curl_multi_add_handle(instance->_multiHandle, handle); + instance->_condVar.notify_all(); + } +} - case CFTYPE_CURL: - /* halt transaction */ - curl_multi_remove_handle(multi_handle, file->handle.curl); +void URLFetcher::breakURL(URL& url) { + URLFetcher* instance = getInstance(); + CURL* handle = url._impl->_handle; - /* restart */ - curl_multi_add_handle(multi_handle, file->handle.curl); + tthread::lock_guard lock(instance->_mutex); + if (instance->_handlesToURLs.find(handle) != instance->_handlesToURLs.end()) { + url.downloadFailed(0); + curl_multi_remove_handle(instance->_multiHandle, handle); + instance->_handlesToURLs.erase(handle); + } +} - /* ditch buffer - write will recreate - resets stream pos*/ - if(file->buffer) - free(file->buffer); +void URLFetcher::start() { + tthread::lock_guard lock(_mutex); + if (!_isStarted) { + _isStarted = true; + _thread = new tthread::thread(URLFetcher::run, this); + } +} + +void URLFetcher::stop() { + tthread::lock_guard lock(_mutex); + if (_isStarted) { + _isStarted = false; + _thread->join(); + delete _thread; + } +} - file->buffer=NULL; - file->buffer_pos=0; - file->buffer_len=0; +void URLFetcher::run(void* instance) { + URLFetcher* fetcher = (URLFetcher*)instance; + while(fetcher->_isStarted) { + fetcher->perform(); + } + LOG(ERROR) << "URLFetcher thread stopped!"; +} + +void URLFetcher::perform() { + + CURLMsg *msg; /* for picking up messages with the transfer status */ + int msgsLeft; /* how many messages are left */ + int stillRunning; + + { + tthread::lock_guard lock(_mutex); + if (_handlesToURLs.empty()) { + std::cout << "Waiting for work" << std::endl; + _condVar.wait(_mutex); + } + curl_multi_perform(_multiHandle, &stillRunning); + } + + do { + struct timeval timeout; + int rc; /* select() return code */ + + fd_set fdread, fdwrite, fdexcep; + FD_ZERO(&fdread); FD_ZERO(&fdwrite); FD_ZERO(&fdexcep); + + int maxfd = -1; + long curlTimeOut = -1; + + /* set a suitable timeout to play around with */ + timeout.tv_sec = 1; + timeout.tv_usec = 0; + + { + tthread::lock_guard lock(_mutex); + curl_multi_timeout(_multiHandle, &curlTimeOut); + } + + if(curlTimeOut >= 0) { + timeout.tv_sec = curlTimeOut / 1000; + if(timeout.tv_sec > 1) + timeout.tv_sec = 1; + else + timeout.tv_usec = (curlTimeOut % 1000) * 1000; + } + + /* get file descriptors from the transfers */ + { + tthread::lock_guard lock(_mutex); + curl_multi_fdset(_multiHandle, &fdread, &fdwrite, &fdexcep, &maxfd); + } + + rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout); + + switch(rc) { + case -1: + /* select error */ + break; + case 0: /* timeout */ + default: /* action */ + { + tthread::lock_guard lock(_mutex); + curl_multi_perform(_multiHandle, &stillRunning); + } + break; + } + + { + tthread::lock_guard lock(_mutex); + while ((msg = curl_multi_info_read(_multiHandle, &msgsLeft))) { + if (msg->msg == CURLMSG_DONE) { + switch (msg->data.result) { + case CURLM_OK: + _handlesToURLs[msg->easy_handle].downloadCompleted(); + curl_multi_remove_handle(_multiHandle, msg->easy_handle); + _handlesToURLs.erase(msg->easy_handle); + break; + case CURLM_BAD_HANDLE: + case CURLM_BAD_EASY_HANDLE: + case CURLM_OUT_OF_MEMORY: + case CURLM_INTERNAL_ERROR: + case CURLM_BAD_SOCKET: + case CURLM_UNKNOWN_OPTION: + case CURLM_LAST: + _handlesToURLs[msg->easy_handle].downloadFailed(msg->data.result); + curl_multi_remove_handle(_multiHandle, msg->easy_handle); + _handlesToURLs.erase(msg->easy_handle); + default: + break; + } + } else { + LOG(ERROR) << "Curl reports info on unfinished download?!"; + } + } + } + } while(stillRunning && _isStarted); +} - break; +URLFetcher* URLFetcher::_instance = NULL; - default: /* unknown or supported type - oh dear */ - break; +URLFetcher* URLFetcher::getInstance() { + if (_instance == NULL) { + _instance = new URLFetcher(); } + return _instance; } } \ No newline at end of file diff --git a/src/uscxml/URL.cpp.old b/src/uscxml/URL.cpp.old new file mode 100644 index 0000000..20c9a18 --- /dev/null +++ b/src/uscxml/URL.cpp.old @@ -0,0 +1,519 @@ +#include +#include +#include +#include + +#include +#include + +#include +#include +#ifndef WIN32 +#include +#endif +#include +#include + +#include "uscxml/Common.h" +#include "URL.h" + +#include "uscxml/config.h" + +#include /* defines FILENAME_MAX */ +#ifdef _WIN32 +#include +#include +#include +#include +#include +#define getcwd _getcwd +#else +#include +#endif + +#include // mkstemp +#ifdef HAS_UNISTD_H +#include // mkstemp legacy +#endif + +namespace uscxml { + +URLImpl::~URLImpl() { + if (_localFile.length() > 0) + remove(_localFile.c_str()); +} + +const bool URLImpl::toAbsoluteCwd() { + char currPath[FILENAME_MAX]; + if (!getcwd(currPath, sizeof(currPath))) { + return false; + } + currPath[sizeof(currPath) - 1] = '\0'; /* not really required */ + return toAbsolute(std::string("file://" + std::string(currPath) + "/")); +} + +std::string URLImpl::getLocalFilename(const std::string& suffix) { + if (_localFile.length() > 0) + return _localFile; + + if (_uri.scheme().compare("file") == 0) + return _uri.path(); + + // try hard to find a temporary directory + const char* tmpDir = NULL; + if (tmpDir == NULL) + tmpDir = getenv("TMPDIR"); + if (tmpDir == NULL) + tmpDir = getenv("TMP"); + if (tmpDir == NULL) + tmpDir = getenv("TEMP"); + if (tmpDir == NULL) + tmpDir = getenv("USERPROFILE"); + if (tmpDir == NULL) + tmpDir = "/tmp"; + + char* tmpl = (char*)malloc(strlen(tmpDir) + 11 + suffix.length()); + char* writePtr = tmpl; + memcpy(writePtr, tmpDir, strlen(tmpDir)); + writePtr += strlen(tmpDir); + memcpy(writePtr, "scxmlXXXXXX", 11); + writePtr += 11; + memcpy(writePtr, suffix.c_str(), suffix.length()); + writePtr += suffix.length(); + tmpl[writePtr - tmpl] = 0; + +#ifdef _WIN32 + _mktemp_s(tmpl, strlen(tmpl) + 1); + int fd = _open(tmpl, _O_CREAT, _S_IREAD | _S_IWRITE); +#else + int fd = mkstemps(tmpl, suffix.length()); +#endif + if (fd < 0) { + LOG(ERROR) << "mkstemp " << tmpl << ": " << strerror(errno) << std::endl; + return ""; + } +#ifdef WIN32 + _close(fd); +#else + close(fd); +#endif + return std::string(tmpl); +} + +boost::shared_ptr URLImpl::toLocalFile(const std::string& content, const std::string& suffix) { + boost::shared_ptr urlImpl = boost::shared_ptr(new URLImpl()); + urlImpl->_localFile = urlImpl->getLocalFilename(suffix); + urlImpl->_uri = std::string("file://") + urlImpl->_localFile; + + std::ofstream file(urlImpl->_localFile.c_str(), std::ios_base::out); + if(file.is_open()) { + file << content; + file.close(); + } else { + return boost::shared_ptr(); + } + + return urlImpl; +} + +const bool URLImpl::toAbsolute(const std::string& baseUrl) { + if (_uri.is_absolute()) + return true; + _uri = Arabica::io::URI(baseUrl, _uri.as_string()); + if (!_uri.is_absolute()) + return false; + return true; +} + +const std::string URLImpl::asLocalFile(const std::string& suffix, bool reload) { + // this is already a local file + if (_uri.scheme().compare("file") == 0) + return _uri.path(); + + if (_localFile.length() > 0 && !reload) + return _localFile; + + if (_localFile.length() > 0) + remove(_localFile.c_str()); + + _localFile = getLocalFilename(suffix); + + std::ofstream file(_localFile.c_str(), std::ios_base::out); + if(file.is_open()) { + file << URL(this->shared_from_this()); + file.close(); + } else { + _localFile = ""; + } + + return _localFile; +} + +std::ostream & operator<<(std::ostream & stream, const URL& url) { + + std::string urlString = url.asString(); + std::string fileURL = "file://"; + + // strip file:// to support relative filenames + if(urlString.substr(0, fileURL.size()) == fileURL) { + urlString = urlString.substr(fileURL.size()); +#ifdef _WIN32 + urlString = urlString.substr(0,1) + ":" + urlString.substr(1); +// std::replace( urlString.begin(), urlString.end(), '/', '\\'); +#endif + } +// LOG(ERROR) << "Trying to open " << urlString; + URL_FILE *handle = url_fopen(urlString.c_str(), "r"); + + if(!handle) { + LOG(ERROR) << "Cannot open URL " << url.asString(); + return stream; + } + + int nread; + char buffer[256]; + + do { + nread = url_fread(buffer, 1,sizeof(buffer), handle); + stream.write(buffer, nread); + } while(nread); + + url_fclose(handle); + return stream; +} + +/* we use a global one for convenience */ +CURLM *multi_handle; + +/* curl calls this routine to get more data */ +static size_t write_callback(char *buffer, + size_t size, + size_t nitems, + void *userp) { + char *newbuff; + size_t rembuff; + + URL_FILE *url = (URL_FILE *)userp; + size *= nitems; + + rembuff=url->buffer_len - url->buffer_pos; /* remaining space in buffer */ + + if(size > rembuff) { + /* not enough space in buffer */ + newbuff=(char*)realloc(url->buffer,url->buffer_len + (size - rembuff)); + if(newbuff==NULL) { + fprintf(stderr,"callback buffer grow failed\n"); + size=rembuff; + } else { + /* realloc suceeded increase buffer size*/ + url->buffer_len+=size - rembuff; + url->buffer=newbuff; + } + } + + memcpy(&url->buffer[url->buffer_pos], buffer, size); + url->buffer_pos += size; + + return size; +} + +/* use to attempt to fill the read buffer up to requested number of bytes */ +static int fill_buffer(URL_FILE *file, size_t want) { + fd_set fdread; + fd_set fdwrite; + fd_set fdexcep; + struct timeval timeout; + int rc; + + /* only attempt to fill buffer if transactions still running and buffer + * doesnt exceed required size already + */ + if((!file->still_running) || (file->buffer_pos > want)) + return 0; + + /* attempt to fill buffer */ + do { + int maxfd = -1; + long curl_timeo = -1; + + FD_ZERO(&fdread); + FD_ZERO(&fdwrite); + FD_ZERO(&fdexcep); + + /* set a suitable timeout to fail on */ + timeout.tv_sec = 60; /* 1 minute */ + timeout.tv_usec = 0; + + curl_multi_timeout(multi_handle, &curl_timeo); + if(curl_timeo >= 0) { + timeout.tv_sec = curl_timeo / 1000; + if(timeout.tv_sec > 1) + timeout.tv_sec = 1; + else + timeout.tv_usec = (curl_timeo % 1000) * 1000; + } + + /* get file descriptors from the transfers */ + curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); + + /* In a real-world program you OF COURSE check the return code of the + function calls. On success, the value of maxfd is guaranteed to be + greater or equal than -1. We call select(maxfd + 1, ...), specially + in case of (maxfd == -1), we call select(0, ...), which is basically + equal to sleep. */ + + rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout); + + switch(rc) { + case -1: + /* select error */ + break; + + case 0: + default: + /* timeout or readable/writable sockets */ + curl_multi_perform(multi_handle, &file->still_running); + break; + } + } while(file->still_running && (file->buffer_pos < want)); + return 1; +} + +/* use to remove want bytes from the front of a files buffer */ +static int use_buffer(URL_FILE *file,int want) { + /* sort out buffer */ + if((file->buffer_pos - want) <=0) { + /* ditch buffer - write will recreate */ + if(file->buffer) + free(file->buffer); + + file->buffer=NULL; + file->buffer_pos=0; + file->buffer_len=0; + } else { + /* move rest down make it available for later */ + memmove(file->buffer, + &file->buffer[want], + (file->buffer_pos - want)); + + file->buffer_pos -= want; + } + return 0; +} + +URL_FILE *url_fopen(const char *url,const char *operation) { + /* this code could check for URLs or types in the 'url' and + basicly use the real fopen() for standard files */ + + URL_FILE *file; + (void)operation; + + file = (URL_FILE*)malloc(sizeof(URL_FILE)); + if(!file) + return NULL; + + memset(file, 0, sizeof(URL_FILE)); + + if((file->handle.file=fopen(url,operation))) + file->type = CFTYPE_FILE; /* marked as URL */ + + else { + file->type = CFTYPE_CURL; /* marked as URL */ + file->handle.curl = curl_easy_init(); + + curl_easy_setopt(file->handle.curl, CURLOPT_URL, url); + curl_easy_setopt(file->handle.curl, CURLOPT_WRITEDATA, file); + curl_easy_setopt(file->handle.curl, CURLOPT_VERBOSE, 0L); + curl_easy_setopt(file->handle.curl, CURLOPT_WRITEFUNCTION, write_callback); + + if(!multi_handle) + multi_handle = curl_multi_init(); + + curl_multi_add_handle(multi_handle, file->handle.curl); + + /* lets start the fetch */ + curl_multi_perform(multi_handle, &file->still_running); + + if((file->buffer_pos == 0) && (!file->still_running)) { + /* if still_running is 0 now, we should return NULL */ + + /* make sure the easy handle is not in the multi handle anymore */ + curl_multi_remove_handle(multi_handle, file->handle.curl); + + /* cleanup */ + curl_easy_cleanup(file->handle.curl); + + free(file); + + file = NULL; + } + } + return file; +} + +int url_fclose(URL_FILE *file) { + int ret=0;/* default is good return */ + + switch(file->type) { + case CFTYPE_FILE: + ret=fclose(file->handle.file); /* passthrough */ + break; + + case CFTYPE_CURL: + /* make sure the easy handle is not in the multi handle anymore */ + curl_multi_remove_handle(multi_handle, file->handle.curl); + + /* cleanup */ + curl_easy_cleanup(file->handle.curl); + break; + + default: /* unknown or supported type - oh dear */ + ret=EOF; + errno=EBADF; + break; + } + + if(file->buffer) + free(file->buffer);/* free any allocated buffer space */ + + free(file); + + return ret; +} + +int url_feof(URL_FILE *file) { + int ret=0; + + switch(file->type) { + case CFTYPE_FILE: + ret=feof(file->handle.file); + break; + + case CFTYPE_CURL: + if((file->buffer_pos == 0) && (!file->still_running)) + ret = 1; + break; + + default: /* unknown or supported type - oh dear */ + ret=-1; + errno=EBADF; + break; + } + return ret; +} + +size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file) { + size_t want; + + switch(file->type) { + case CFTYPE_FILE: + want=fread(ptr,size,nmemb,file->handle.file); + break; + + case CFTYPE_CURL: + want = nmemb * size; + + fill_buffer(file,want); + + /* check if theres data in the buffer - if not fill_buffer() + * either errored or EOF */ + if(!file->buffer_pos) + return 0; + + /* ensure only available data is considered */ + if(file->buffer_pos < want) + want = file->buffer_pos; + + /* xfer data to caller */ + memcpy(ptr, file->buffer, want); + + use_buffer(file,want); + + want = want / size; /* number of items */ + break; + + default: /* unknown or supported type - oh dear */ + want=0; + errno=EBADF; + break; + + } + return want; +} + +char *url_fgets(char *ptr, size_t size, URL_FILE *file) { + size_t want = size - 1;/* always need to leave room for zero termination */ + size_t loop; + + switch(file->type) { + case CFTYPE_FILE: + ptr = fgets(ptr,size,file->handle.file); + break; + + case CFTYPE_CURL: + fill_buffer(file,want); + + /* check if theres data in the buffer - if not fill either errored or + * EOF */ + if(!file->buffer_pos) + return NULL; + + /* ensure only available data is considered */ + if(file->buffer_pos < want) + want = file->buffer_pos; + + /*buffer contains data */ + /* look for newline or eof */ + for(loop=0; loop < want; loop++) { + if(file->buffer[loop] == '\n') { + want=loop+1;/* include newline */ + break; + } + } + + /* xfer data to caller */ + memcpy(ptr, file->buffer, want); + ptr[want]=0;/* allways null terminate */ + + use_buffer(file,want); + + break; + + default: /* unknown or supported type - oh dear */ + ptr=NULL; + errno=EBADF; + break; + } + + return ptr;/*success */ +} + +void url_rewind(URL_FILE *file) { + switch(file->type) { + case CFTYPE_FILE: + rewind(file->handle.file); /* passthrough */ + break; + + case CFTYPE_CURL: + /* halt transaction */ + curl_multi_remove_handle(multi_handle, file->handle.curl); + + /* restart */ + curl_multi_add_handle(multi_handle, file->handle.curl); + + /* ditch buffer - write will recreate - resets stream pos*/ + if(file->buffer) + free(file->buffer); + + file->buffer=NULL; + file->buffer_pos=0; + file->buffer_len=0; + + break; + + default: /* unknown or supported type - oh dear */ + break; + } +} + +} \ No newline at end of file diff --git a/src/uscxml/URL.h b/src/uscxml/URL.h index 9ff24c5..0858626 100644 --- a/src/uscxml/URL.h +++ b/src/uscxml/URL.h @@ -1,77 +1,106 @@ -#ifndef URL_H_27HPRH76 -#define URL_H_27HPRH76 +#ifndef URL_H_9DAEGSMV +#define URL_H_9DAEGSMV +#include #include +#include #include -#include +#include +#include +#include +#include + +#include "uscxml/concurrency/tinythread.h" // use arabica URL parser #include -#include -#include - namespace uscxml { +class URL; + +class URLMonitor { +public: + virtual void downloadStarted(const URL& url) {}; + virtual void downloadCompleted(const URL& url) {}; + virtual void downloadFailed(const URL& url, int errorCode) {}; + virtual void headerChunkReceived(const URL& url, const std::string& headerChunk) {}; + virtual void contentChunkReceived(const URL& url, const std::string& contentChunk) {}; +}; + class URLImpl : public boost::enable_shared_from_this { public: - URLImpl() {} - URLImpl(const std::string uri) : _uri(uri) {} - virtual ~URLImpl(); - const bool toAbsoluteCwd(); + URLImpl(const std::string& url); + ~URLImpl(); + static boost::shared_ptr toLocalFile(const std::string& content, const std::string& suffix); + + static size_t writeHandler(void *ptr, size_t size, size_t nmemb, void *userdata); + static size_t headerHandler(void *ptr, size_t size, size_t nmemb, void *userdata); + + void addMonitor(URLMonitor* monitor) { _monitors.insert(monitor); } + void removeMonitor(URLMonitor* monitor) { _monitors.erase(monitor); } + + const bool isAbsolute() const { return _uri.is_absolute(); } + const std::string scheme() const { return _uri.scheme(); } + const std::string host() const { return _uri.host(); } + const std::string port() const { return _uri.port(); } + const std::string path() const { return _uri.path(); } + const std::string asString() const { return _uri.as_string(); } + + const bool toAbsoluteCwd(); const bool toAbsolute(const std::string& baseUrl); const std::string asLocalFile(const std::string& suffix, bool reload = false); - static boost::shared_ptr toLocalFile(const std::string& content, const std::string& suffix); + void addOutHeader(const std::string& key, const std::string& value) { _outHeader[key] = value; } + void setOutContent(const std::string& content); + void setRequestType(const std::string& requestType); + + const std::map getInHeaderFields(); + const std::string getInContent(bool forceReload = false); + const void download(bool blocking = false); + + void downloadStarted(); + void downloadCompleted(); + void downloadFailed(int errorCode); - const bool isAbsolute() const { - return _uri.is_absolute(); - } - const std::string scheme() const { - return _uri.scheme(); - } - const std::string host() const { - return _uri.host(); - } - const std::string port() const { - return _uri.port(); - } - const std::string path() const { - return _uri.path(); - } - const std::string asString() const { - return _uri.as_string(); - } + friend class URLFetcher; -private: +protected: + URLImpl() : _handle(NULL), _isDownloaded(false), _hasFailed(false) {} std::string getLocalFilename(const std::string& suffix); - Arabica::io::URI _uri; - std::string _localFile; + std::string _outContent; + std::map _outHeader; + std::string _requestType; + + CURL* _handle; + std::stringstream _inContent; + std::stringstream _inHeader; + + Arabica::io::URI _uri; + bool _isDownloaded; + bool _hasFailed; + + std::string _localFile; + + tthread::condition_variable _condVar; + tthread::recursive_mutex _mutex; + + std::set _monitors; + typedef std::set::iterator monIter_t; }; class URL { -public: +public: URL() : _impl() {} - URL(const std::string uri) : _impl(new URLImpl(uri)) {} + URL(const std::string url) : _impl(new URLImpl(url)) {} URL(boost::shared_ptr const impl) : _impl(impl) { } URL(const URL& other) : _impl(other._impl) { } virtual ~URL() {}; - - static URL toLocalFile(const std::string& content, const std::string& suffix) { - boost::shared_ptr impl = URLImpl::toLocalFile(content, suffix); - return URL(impl); - } - - operator bool() const { - return _impl; - } - bool operator< (const URL& other) const { - return _impl < other._impl; - } - bool operator==(const URL& other) const { - return _impl == other._impl; - } + + operator bool() const { return _impl; } + bool operator< (const URL& other) const { return _impl < other._impl; } + bool operator==(const URL& other) const { return _impl == other._impl; } bool operator!=(const URL& other) const { return _impl != other._impl; } @@ -80,75 +109,72 @@ public: return *this; } - const bool toAbsoluteCwd() { - return _impl->toAbsoluteCwd(); - } - const bool toAbsolute(const std::string& baseUrl) { - return _impl->toAbsolute(baseUrl); - } - const bool toAbsolute(const URL& baseUrl) { - return _impl->toAbsolute(baseUrl.asString()); - } - const std::string asLocalFile(const std::string& suffix, bool reload = false) { - return _impl->asLocalFile(suffix, reload); - } - - const bool isAbsolute() const { - return _impl->isAbsolute(); - } - const std::string scheme() const { - return _impl->scheme(); - } - const std::string host() const { - return _impl->host(); - } - const std::string port() const { - return _impl->port(); - } - const std::string path() const { - return _impl->path(); - } - const std::string asString() const { - return _impl->asString(); - } - + const std::map getInHeaderFields() const { return _impl->getInHeaderFields(); } + const std::string getInContent() const { return _impl->getInContent(); } + const void download(bool blocking = false) const { return _impl->download(blocking); } + + void addOutHeader(const std::string& key, const std::string& value) { _impl->addOutHeader(key, value); } + void setRequestType(const std::string& requestType) { _impl->setRequestType(requestType); } + void setOutContent(const std::string& content) { _impl->setOutContent(content); } + + const bool toAbsoluteCwd() { return _impl->toAbsoluteCwd(); } + const bool toAbsolute(const std::string& baseUrl) { return _impl->toAbsolute(baseUrl); } + const bool toAbsolute(const URL& baseUrl) { return _impl->toAbsolute(baseUrl.asString()); } + const std::string asLocalFile(const std::string& suffix, bool reload = false) { return _impl->asLocalFile(suffix, reload); } + + static URL toLocalFile(const std::string& content, const std::string& suffix) { + boost::shared_ptr impl = URLImpl::toLocalFile(content, suffix); + return URL(impl); + } + + void addMonitor(URLMonitor* monitor) { _impl->addMonitor(monitor); } + void removeMonitor(URLMonitor* monitor) { _impl->removeMonitor(monitor); } + + const bool isAbsolute() const { return _impl->isAbsolute(); } + const std::string scheme() const { return _impl->scheme(); } + const std::string host() const { return _impl->host(); } + const std::string port() const { return _impl->port(); } + const std::string path() const { return _impl->path(); } + const std::string asString() const { return _impl->asString(); } + + friend class URLFetcher; friend std::ostream & operator<<(std::ostream &stream, const URL& p); protected: - boost::shared_ptr _impl; -}; - -enum fcurl_type_e { - CFTYPE_NONE=0, - CFTYPE_FILE=1, - CFTYPE_CURL=2 -}; + void downloadStarted() { return _impl->downloadStarted(); } + void downloadCompleted() { return _impl->downloadCompleted(); } + void downloadFailed(int errorCode) { return _impl->downloadFailed(errorCode); } -struct fcurl_data { - enum fcurl_type_e type; /* type of handle */ - union { - CURL *curl; - FILE *file; - } handle; /* handle */ - - char *buffer; /* buffer to store cached data*/ - size_t buffer_len; /* currently allocated buffers length */ - size_t buffer_pos; /* end of data in buffer*/ - int still_running; /* Is background url fetch still in progress */ + boost::shared_ptr _impl; }; -typedef struct fcurl_data URL_FILE; +class URLFetcher { +public: + URLFetcher(); + ~URLFetcher(); + + static void fetchURL(URL& url); + static void breakURL(URL& url); -URL_FILE *url_fopen(const char *url,const char *operation); -int url_fclose(URL_FILE *file); -int url_feof(URL_FILE *file); -size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file); -char * url_fgets(char *ptr, size_t size, URL_FILE *file); -void url_rewind(URL_FILE *file); + void start(); + void stop(); -std::ostream & operator<<(std::ostream &stream, const URL& url); +protected: + static URLFetcher* _instance; + static URLFetcher* getInstance(); + + static void run(void* instance); + void perform(); + + tthread::thread* _thread; + tthread::condition_variable _condVar; + tthread::recursive_mutex _mutex; + bool _isStarted; + + std::map _handlesToURLs; + CURLM* _multiHandle; +}; } - -#endif /* end of include guard: URL_H_27HPRH76 */ +#endif /* end of include guard: URL_H_9DAEGSMV */ diff --git a/src/uscxml/URL.h.old b/src/uscxml/URL.h.old new file mode 100644 index 0000000..9ff24c5 --- /dev/null +++ b/src/uscxml/URL.h.old @@ -0,0 +1,154 @@ +#ifndef URL_H_27HPRH76 +#define URL_H_27HPRH76 + +#include +#include +#include + +// use arabica URL parser +#include + +#include +#include + +namespace uscxml { + +class URLImpl : public boost::enable_shared_from_this { +public: + URLImpl() {} + URLImpl(const std::string uri) : _uri(uri) {} + virtual ~URLImpl(); + const bool toAbsoluteCwd(); + const bool toAbsolute(const std::string& baseUrl); + const std::string asLocalFile(const std::string& suffix, bool reload = false); + + static boost::shared_ptr toLocalFile(const std::string& content, const std::string& suffix); + + const bool isAbsolute() const { + return _uri.is_absolute(); + } + const std::string scheme() const { + return _uri.scheme(); + } + const std::string host() const { + return _uri.host(); + } + const std::string port() const { + return _uri.port(); + } + const std::string path() const { + return _uri.path(); + } + const std::string asString() const { + return _uri.as_string(); + } + +private: + std::string getLocalFilename(const std::string& suffix); + + Arabica::io::URI _uri; + std::string _localFile; +}; + +class URL { +public: + URL() : _impl() {} + URL(const std::string uri) : _impl(new URLImpl(uri)) {} + URL(boost::shared_ptr const impl) : _impl(impl) { } + URL(const URL& other) : _impl(other._impl) { } + virtual ~URL() {}; + + static URL toLocalFile(const std::string& content, const std::string& suffix) { + boost::shared_ptr impl = URLImpl::toLocalFile(content, suffix); + return URL(impl); + } + + operator bool() const { + return _impl; + } + bool operator< (const URL& other) const { + return _impl < other._impl; + } + bool operator==(const URL& other) const { + return _impl == other._impl; + } + bool operator!=(const URL& other) const { + return _impl != other._impl; + } + URL& operator= (const URL& other) { + _impl = other._impl; + return *this; + } + + const bool toAbsoluteCwd() { + return _impl->toAbsoluteCwd(); + } + const bool toAbsolute(const std::string& baseUrl) { + return _impl->toAbsolute(baseUrl); + } + const bool toAbsolute(const URL& baseUrl) { + return _impl->toAbsolute(baseUrl.asString()); + } + const std::string asLocalFile(const std::string& suffix, bool reload = false) { + return _impl->asLocalFile(suffix, reload); + } + + const bool isAbsolute() const { + return _impl->isAbsolute(); + } + const std::string scheme() const { + return _impl->scheme(); + } + const std::string host() const { + return _impl->host(); + } + const std::string port() const { + return _impl->port(); + } + const std::string path() const { + return _impl->path(); + } + const std::string asString() const { + return _impl->asString(); + } + + friend std::ostream & operator<<(std::ostream &stream, const URL& p); + +protected: + boost::shared_ptr _impl; +}; + +enum fcurl_type_e { + CFTYPE_NONE=0, + CFTYPE_FILE=1, + CFTYPE_CURL=2 +}; + +struct fcurl_data { + enum fcurl_type_e type; /* type of handle */ + union { + CURL *curl; + FILE *file; + } handle; /* handle */ + + char *buffer; /* buffer to store cached data*/ + size_t buffer_len; /* currently allocated buffers length */ + size_t buffer_pos; /* end of data in buffer*/ + int still_running; /* Is background url fetch still in progress */ +}; + +typedef struct fcurl_data URL_FILE; + +URL_FILE *url_fopen(const char *url,const char *operation); +int url_fclose(URL_FILE *file); +int url_feof(URL_FILE *file); +size_t url_fread(void *ptr, size_t size, size_t nmemb, URL_FILE *file); +char * url_fgets(char *ptr, size_t size, URL_FILE *file); +void url_rewind(URL_FILE *file); + +std::ostream & operator<<(std::ostream &stream, const URL& url); + +} + + +#endif /* end of include guard: URL_H_27HPRH76 */ diff --git a/src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp b/src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp index 4390927..e0b5a8d 100644 --- a/src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp +++ b/src/uscxml/concurrency/eventqueue/DelayedEventQueue.cpp @@ -17,7 +17,7 @@ DelayedEventQueue::DelayedEventQueue() { DelayedEventQueue::~DelayedEventQueue() { // std::cout << "Deleting DelayedEventQueue" << std::endl; stop(); - if (_thread) + if (_thread && _isStarted) _thread->join(); if(_eventLoop) event_base_free(_eventLoop); @@ -66,6 +66,7 @@ void DelayedEventQueue::cancelEvent(std::string eventId) { void DelayedEventQueue::start() { _isStarted = true; _thread = new tthread::thread(DelayedEventQueue::run, this); + _isStarted = false; } void DelayedEventQueue::stop() { diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp index d8a3c8d..c190e3b 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.cpp @@ -105,21 +105,21 @@ void V8DataModel::initialize() { } void V8DataModel::setEvent(const Event& event) { - _event = event; v8::Locker locker; v8::HandleScope handleScope; v8::Context::Scope contextScope(_contexts.front()); v8::Handle global = _contexts.front()->Global(); v8::Handle eventCtor = Arabica::DOM::V8SCXMLEvent::getTmpl()->GetFunction(); - v8::Handle eventObj = eventCtor->NewInstance(); + v8::Persistent eventObj = v8::Persistent::New(eventCtor->NewInstance()); Arabica::DOM::V8SCXMLEvent::V8SCXMLEventPrivate* privData = new Arabica::DOM::V8SCXMLEvent::V8SCXMLEventPrivate(); - privData->nativeObj = &_event; + privData->nativeObj = new Event(event); privData->dom = _dom; eventObj->SetInternalField(0, Arabica::DOM::V8DOM::toExternal(privData)); + eventObj.MakeWeak(0, Arabica::DOM::V8SCXMLEvent::jsDestructor); - eventObj->Set(v8::String::New("data"), getDataAsValue(event)); // set data part of _event + eventObj->Set(v8::String::New("data"), getDataAsValue(event.data)); // set data part of _event global->Set(v8::String::New("_event"), eventObj); } @@ -312,20 +312,20 @@ v8::Handle V8DataModel::evalAsValue(const std::string& expr) { exceptionEvent.name = "error.execution"; std::string exceptionString(*v8::String::AsciiValue(tryCatch.Exception())); - exceptionEvent.compound["exception"] = Data(exceptionString, Data::VERBATIM);; + exceptionEvent.data.compound["exception"] = Data(exceptionString, Data::VERBATIM);; v8::Handle message = tryCatch.Message(); if (!message.IsEmpty()) { std::string filename(*v8::String::AsciiValue(message->GetScriptResourceName())); - exceptionEvent.compound["filename"] = Data(filename, Data::VERBATIM); + exceptionEvent.data.compound["filename"] = Data(filename, Data::VERBATIM); std::string sourceLine(*v8::String::AsciiValue(message->GetSourceLine())); - exceptionEvent.compound["sourceline"] = Data(sourceLine, Data::VERBATIM); + exceptionEvent.data.compound["sourceline"] = Data(sourceLine, Data::VERBATIM); std::stringstream ssLineNumber; int lineNumber = message->GetLineNumber(); ssLineNumber << lineNumber; - exceptionEvent.compound["linenumber"] = Data(ssLineNumber.str()); + exceptionEvent.data.compound["linenumber"] = Data(ssLineNumber.str()); int startColumn = message->GetStartColumn(); int endColumn = message->GetEndColumn(); @@ -334,10 +334,10 @@ v8::Handle V8DataModel::evalAsValue(const std::string& expr) { ssUnderline << " "; for (int i = startColumn; i < endColumn; i++) ssUnderline << "^"; - exceptionEvent.compound["sourcemark"] = Data(ssUnderline.str(), Data::VERBATIM); + exceptionEvent.data.compound["sourcemark"] = Data(ssUnderline.str(), Data::VERBATIM); std::string stackTrace(*v8::String::AsciiValue(tryCatch.StackTrace())); - exceptionEvent.compound["stacktrace"] = Data(stackTrace, Data::VERBATIM); + exceptionEvent.data.compound["stacktrace"] = Data(stackTrace, Data::VERBATIM); } diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h index b99392f..18e1ea4 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h @@ -59,7 +59,6 @@ public: protected: std::list > _contexts; - Event _event; Arabica::DOM::V8DOM* _dom; v8::Handle evalAsValue(const std::string& expr); diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp index bee6042..d16f81b 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.cpp @@ -5,59 +5,59 @@ namespace Arabica { namespace DOM { -v8::Persistent V8Attr::Tmpl; + v8::Persistent V8Attr::Tmpl; -v8::Handle V8Attr::nameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Attr::nameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getName().c_str()); -} + return v8::String::New(privData->nativeObj->getName().c_str()); + } -v8::Handle V8Attr::specifiedAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Attr::specifiedAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Boolean::New(privData->nativeObj->getSpecified()); -} + return v8::Boolean::New(privData->nativeObj->getSpecified()); + } -v8::Handle V8Attr::valueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Attr::valueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getValue().c_str()); -} + return v8::String::New(privData->nativeObj->getValue().c_str()); + } -void V8Attr::valueAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localValue(value); - privData->nativeObj->setValue(*localValue); -} + void V8Attr::valueAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localValue(value); + privData->nativeObj->setValue(*localValue); + } -v8::Handle V8Attr::ownerElementAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Attr::ownerElementAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8AttrPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - if (!privData->nativeObj->getOwnerElement()) return v8::Undefined(); - Arabica::DOM::Element* arbaicaRet = new Arabica::DOM::Element(privData->nativeObj->getOwnerElement()); + if (!privData->nativeObj->getOwnerElement()) return v8::Undefined(); + Arabica::DOM::Element* arbaicaRet = new Arabica::DOM::Element(privData->nativeObj->getOwnerElement()); - v8::Handle arbaicaRetCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + v8::Handle arbaicaRetCtor = V8Element::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); - struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Element::jsDestructor); + return arbaicaRetObj; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Element::jsDestructor); - return arbaicaRetObj; + } + bool V8Attr::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -bool V8Attr::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} - -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h index e290415..e317698 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Attr.h @@ -21,8 +21,10 @@ #ifndef V8Attr_h #define V8Attr_h +#include #include "DOM/Node.hpp" #include "V8Node.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,48 +33,50 @@ namespace DOM { class V8Attr { public: - struct V8AttrPrivate { - V8DOM* dom; - Arabica::DOM::Attr* nativeObj; - }; - - V8_DESTRUCTOR(V8AttrPrivate); - static bool hasInstance(v8::Handle); - - - static v8::Handle nameAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle specifiedAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle valueAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static void valueAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info); - static v8::Handle ownerElementAttrGetter(v8::Local property, const v8::AccessorInfo& info); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("Attr")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("name"), V8Attr::nameAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("specified"), V8Attr::specifiedAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("value"), V8Attr::valueAttrGetter, V8Attr::valueAttrSetter, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("ownerElement"), V8Attr::ownerElementAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + struct V8AttrPrivate { + V8DOM* dom; + Arabica::DOM::Attr* nativeObj; + }; + + V8_DESTRUCTOR(V8AttrPrivate); + static bool hasInstance(v8::Handle); + + + static v8::Handle nameAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle specifiedAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle valueAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static void valueAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info); + static v8::Handle ownerElementAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Attr")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("name"), V8Attr::nameAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("specified"), V8Attr::specifiedAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("value"), V8Attr::valueAttrGetter, V8Attr::valueAttrSetter, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("ownerElement"), V8Attr::ownerElementAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + + + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.cpp index a9e5ac9..90495f4 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.cpp @@ -4,11 +4,11 @@ namespace Arabica { namespace DOM { -v8::Persistent V8CDATASection::Tmpl; + v8::Persistent V8CDATASection::Tmpl; -bool V8CDATASection::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + bool V8CDATASection::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h index a0b5ced..f9767a0 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CDATASection.h @@ -21,8 +21,10 @@ #ifndef V8CDATASection_h #define V8CDATASection_h +#include #include "DOM/Node.hpp" #include "V8Text.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,35 +33,37 @@ namespace DOM { class V8CDATASection { public: - struct V8CDATASectionPrivate { - V8DOM* dom; - Arabica::DOM::CDATASection* nativeObj; - }; + struct V8CDATASectionPrivate { + V8DOM* dom; + Arabica::DOM::CDATASection* nativeObj; + }; - V8_DESTRUCTOR(V8CDATASectionPrivate); - static bool hasInstance(v8::Handle); + V8_DESTRUCTOR(V8CDATASectionPrivate); + static bool hasInstance(v8::Handle); - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("CDATASection")); - tmpl->ReadOnlyPrototype(); + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("CDATASection")); + tmpl->ReadOnlyPrototype(); - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - tmpl->Inherit(V8Text::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8Text::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp index 459cf96..74c80ea 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.cpp @@ -4,102 +4,102 @@ namespace Arabica { namespace DOM { -v8::Persistent V8CharacterData::Tmpl; + v8::Persistent V8CharacterData::Tmpl; -v8::Handle V8CharacterData::dataAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8CharacterData::dataAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getData().c_str()); -} + return v8::String::New(privData->nativeObj->getData().c_str()); + } -void V8CharacterData::dataAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localData(value); - privData->nativeObj->setData(*localData); -} + void V8CharacterData::dataAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localData(value); + privData->nativeObj->setData(*localData); + } -v8::Handle V8CharacterData::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8CharacterData::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Integer::New(privData->nativeObj->getLength()); -} -v8::Handle V8CharacterData::substringDataCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in substringData"); + return v8::Integer::New(privData->nativeObj->getLength()); + } + v8::Handle V8CharacterData::substringDataCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in substringData"); - v8::Local self = args.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); - unsigned long localCount = args[1]->ToNumber()->Uint32Value(); + v8::Local self = args.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); + unsigned long localCount = args[1]->ToNumber()->Uint32Value(); - std::string retVal = privData->nativeObj->substringData(localOffset, localCount); + std::string retVal = privData->nativeObj->substringData(localOffset, localCount); - return v8::String::New(retVal.c_str()); -} + return v8::String::New(retVal.c_str()); + } -v8::Handle V8CharacterData::appendDataCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in appendData"); + v8::Handle V8CharacterData::appendDataCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in appendData"); - v8::Local self = args.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localArg(args[0]); + v8::Local self = args.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localArg(args[0]); - privData->nativeObj->appendData(*localArg); + privData->nativeObj->appendData(*localArg); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle V8CharacterData::insertDataCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in insertData"); + v8::Handle V8CharacterData::insertDataCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in insertData"); - v8::Local self = args.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); - v8::String::AsciiValue localArg(args[1]); + v8::Local self = args.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); + v8::String::AsciiValue localArg(args[1]); - privData->nativeObj->insertData(localOffset, *localArg); + privData->nativeObj->insertData(localOffset, *localArg); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle V8CharacterData::deleteDataCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in deleteData"); + v8::Handle V8CharacterData::deleteDataCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in deleteData"); - v8::Local self = args.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); - unsigned long localCount = args[1]->ToNumber()->Uint32Value(); + v8::Local self = args.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); + unsigned long localCount = args[1]->ToNumber()->Uint32Value(); - privData->nativeObj->deleteData(localOffset, localCount); + privData->nativeObj->deleteData(localOffset, localCount); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle V8CharacterData::replaceDataCallback(const v8::Arguments& args) { - if (args.Length() < 3) - throw V8Exception("Wrong number of arguments in replaceData"); + v8::Handle V8CharacterData::replaceDataCallback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in replaceData"); - v8::Local self = args.Holder(); - struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); - unsigned long localCount = args[1]->ToNumber()->Uint32Value(); - v8::String::AsciiValue localArg(args[2]); + v8::Local self = args.Holder(); + struct V8CharacterDataPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); + unsigned long localCount = args[1]->ToNumber()->Uint32Value(); + v8::String::AsciiValue localArg(args[2]); - privData->nativeObj->replaceData(localOffset, localCount, *localArg); + privData->nativeObj->replaceData(localOffset, localCount, *localArg); - return v8::Undefined(); -} + return v8::Undefined(); + } -bool V8CharacterData::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + bool V8CharacterData::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h index a86519b..fe93896 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8CharacterData.h @@ -21,8 +21,10 @@ #ifndef V8CharacterData_h #define V8CharacterData_h +#include #include "DOM/Node.hpp" #include "V8Node.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,57 +33,59 @@ namespace DOM { class V8CharacterData { public: - struct V8CharacterDataPrivate { - V8DOM* dom; - Arabica::DOM::CharacterData* nativeObj; - }; - - V8_DESTRUCTOR(V8CharacterDataPrivate); - static bool hasInstance(v8::Handle); - - static v8::Handle substringDataCallback(const v8::Arguments&); - static v8::Handle appendDataCallback(const v8::Arguments&); - static v8::Handle insertDataCallback(const v8::Arguments&); - static v8::Handle deleteDataCallback(const v8::Arguments&); - static v8::Handle replaceDataCallback(const v8::Arguments&); - - static v8::Handle dataAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static void dataAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info); - static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("CharacterData")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("data"), V8CharacterData::dataAttrGetter, V8CharacterData::dataAttrSetter, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("length"), V8CharacterData::lengthAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - prototype->Set(v8::String::NewSymbol("substringData"), - v8::FunctionTemplate::New(V8CharacterData::substringDataCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("appendData"), - v8::FunctionTemplate::New(V8CharacterData::appendDataCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("insertData"), - v8::FunctionTemplate::New(V8CharacterData::insertDataCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("deleteData"), - v8::FunctionTemplate::New(V8CharacterData::deleteDataCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("replaceData"), - v8::FunctionTemplate::New(V8CharacterData::replaceDataCallback, v8::Undefined()), static_cast(v8::DontDelete)); - - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + struct V8CharacterDataPrivate { + V8DOM* dom; + Arabica::DOM::CharacterData* nativeObj; + }; + + V8_DESTRUCTOR(V8CharacterDataPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle substringDataCallback(const v8::Arguments&); + static v8::Handle appendDataCallback(const v8::Arguments&); + static v8::Handle insertDataCallback(const v8::Arguments&); + static v8::Handle deleteDataCallback(const v8::Arguments&); + static v8::Handle replaceDataCallback(const v8::Arguments&); + + static v8::Handle dataAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static void dataAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info); + static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("CharacterData")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("data"), V8CharacterData::dataAttrGetter, V8CharacterData::dataAttrSetter, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("length"), V8CharacterData::lengthAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("substringData"), + v8::FunctionTemplate::New(V8CharacterData::substringDataCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("appendData"), + v8::FunctionTemplate::New(V8CharacterData::appendDataCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("insertData"), + v8::FunctionTemplate::New(V8CharacterData::insertDataCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("deleteData"), + v8::FunctionTemplate::New(V8CharacterData::deleteDataCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("replaceData"), + v8::FunctionTemplate::New(V8CharacterData::replaceDataCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.cpp index f754ea7..e470a70 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.cpp @@ -4,11 +4,11 @@ namespace Arabica { namespace DOM { -v8::Persistent V8Comment::Tmpl; + v8::Persistent V8Comment::Tmpl; -bool V8Comment::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + bool V8Comment::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h index b07bf19..c659150 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Comment.h @@ -21,8 +21,10 @@ #ifndef V8Comment_h #define V8Comment_h +#include #include "DOM/Node.hpp" #include "V8CharacterData.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,35 +33,37 @@ namespace DOM { class V8Comment { public: - struct V8CommentPrivate { - V8DOM* dom; - Arabica::DOM::Comment* nativeObj; - }; + struct V8CommentPrivate { + V8DOM* dom; + Arabica::DOM::Comment* nativeObj; + }; - V8_DESTRUCTOR(V8CommentPrivate); - static bool hasInstance(v8::Handle); + V8_DESTRUCTOR(V8CommentPrivate); + static bool hasInstance(v8::Handle); - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("Comment")); - tmpl->ReadOnlyPrototype(); + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Comment")); + tmpl->ReadOnlyPrototype(); - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - tmpl->Inherit(V8CharacterData::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8CharacterData::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp index f7a7575..0f81958 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.cpp @@ -5,77 +5,77 @@ namespace Arabica { namespace DOM { -v8::Persistent V8DOMImplementation::Tmpl; + v8::Persistent V8DOMImplementation::Tmpl; -v8::Handle V8DOMImplementation::hasFeatureCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in hasFeature"); + v8::Handle V8DOMImplementation::hasFeatureCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in hasFeature"); - v8::Local self = args.Holder(); - struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localFeature(args[0]); - v8::String::AsciiValue localVersion(args[1]); + v8::Local self = args.Holder(); + struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localFeature(args[0]); + v8::String::AsciiValue localVersion(args[1]); - bool retVal = privData->nativeObj->hasFeature(*localFeature, *localVersion); + bool retVal = privData->nativeObj->hasFeature(*localFeature, *localVersion); - return v8::Boolean::New(retVal); -} + return v8::Boolean::New(retVal); + } -v8::Handle V8DOMImplementation::createDocumentTypeCallback(const v8::Arguments& args) { - if (args.Length() < 3) - throw V8Exception("Wrong number of arguments in createDocumentType"); + v8::Handle V8DOMImplementation::createDocumentTypeCallback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in createDocumentType"); - v8::Local self = args.Holder(); - struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localQualifiedName(args[0]); - v8::String::AsciiValue localPublicId(args[1]); - v8::String::AsciiValue localSystemId(args[2]); + v8::Local self = args.Holder(); + struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localQualifiedName(args[0]); + v8::String::AsciiValue localPublicId(args[1]); + v8::String::AsciiValue localSystemId(args[2]); - Arabica::DOM::DocumentType* retVal = new Arabica::DOM::DocumentType(privData->nativeObj->createDocumentType(*localQualifiedName, *localPublicId, *localSystemId)); - v8::Handle retCtor = V8DocumentType::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::DocumentType* retVal = new Arabica::DOM::DocumentType(privData->nativeObj->createDocumentType(*localQualifiedName, *localPublicId, *localSystemId)); + v8::Handle retCtor = V8DocumentType::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8DocumentType::V8DocumentTypePrivate* retPrivData = new V8DocumentType::V8DocumentTypePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8DocumentType::V8DocumentTypePrivate* retPrivData = new V8DocumentType::V8DocumentTypePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8DocumentType::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8DocumentType::jsDestructor); + return retObj; -} + } -v8::Handle V8DOMImplementation::createDocumentCallback(const v8::Arguments& args) { - if (args.Length() < 3) - throw V8Exception("Wrong number of arguments in createDocument"); - if (!(V8DocumentType::hasInstance(args[2]))) - throw V8Exception("Parameter mismatch while calling createDocument"); + v8::Handle V8DOMImplementation::createDocumentCallback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in createDocument"); + if (!(V8DocumentType::hasInstance(args[2]))) + throw V8Exception("Parameter mismatch while calling createDocument"); - v8::Local self = args.Holder(); - struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localQualifiedName(args[1]); - Arabica::DOM::DocumentType* localDoctype = V8DOM::toClassPtr(args[2]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local self = args.Holder(); + struct V8DOMImplementationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localQualifiedName(args[1]); + Arabica::DOM::DocumentType* localDoctype = V8DOM::toClassPtr(args[2]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Document* retVal = new Arabica::DOM::Document(privData->nativeObj->createDocument(*localNamespaceURI, *localQualifiedName, *localDoctype)); - v8::Handle retCtor = V8Document::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Document* retVal = new Arabica::DOM::Document(privData->nativeObj->createDocument(*localNamespaceURI, *localQualifiedName, *localDoctype)); + v8::Handle retCtor = V8Document::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Document::V8DocumentPrivate* retPrivData = new V8Document::V8DocumentPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Document::V8DocumentPrivate* retPrivData = new V8Document::V8DocumentPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Document::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Document::jsDestructor); + return retObj; -} + } -bool V8DOMImplementation::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + bool V8DOMImplementation::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h index 5a4c9d3..6fb8c7e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOMImplementation.h @@ -21,7 +21,9 @@ #ifndef V8DOMImplementation_h #define V8DOMImplementation_h +#include #include "DOM/Node.hpp" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -30,43 +32,45 @@ namespace DOM { class V8DOMImplementation { public: - struct V8DOMImplementationPrivate { - V8DOM* dom; - Arabica::DOM::DOMImplementation* nativeObj; - }; + struct V8DOMImplementationPrivate { + V8DOM* dom; + Arabica::DOM::DOMImplementation* nativeObj; + }; - V8_DESTRUCTOR(V8DOMImplementationPrivate); - static bool hasInstance(v8::Handle); + V8_DESTRUCTOR(V8DOMImplementationPrivate); + static bool hasInstance(v8::Handle); - static v8::Handle hasFeatureCallback(const v8::Arguments&); - static v8::Handle createDocumentTypeCallback(const v8::Arguments&); - static v8::Handle createDocumentCallback(const v8::Arguments&); + static v8::Handle hasFeatureCallback(const v8::Arguments&); + static v8::Handle createDocumentTypeCallback(const v8::Arguments&); + static v8::Handle createDocumentCallback(const v8::Arguments&); - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("DOMImplementation")); - tmpl->ReadOnlyPrototype(); + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("DOMImplementation")); + tmpl->ReadOnlyPrototype(); - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - prototype->Set(v8::String::NewSymbol("hasFeature"), - v8::FunctionTemplate::New(V8DOMImplementation::hasFeatureCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createDocumentType"), - v8::FunctionTemplate::New(V8DOMImplementation::createDocumentTypeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createDocument"), - v8::FunctionTemplate::New(V8DOMImplementation::createDocumentCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("hasFeature"), + v8::FunctionTemplate::New(V8DOMImplementation::hasFeatureCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createDocumentType"), + v8::FunctionTemplate::New(V8DOMImplementation::createDocumentTypeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createDocument"), + v8::FunctionTemplate::New(V8DOMImplementation::createDocumentCallback, v8::Undefined()), static_cast(v8::DontDelete)); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp index 06191ea..d9d123a 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.cpp @@ -15,397 +15,397 @@ namespace Arabica { namespace DOM { -v8::Persistent V8Document::Tmpl; + v8::Persistent V8Document::Tmpl; -v8::Handle V8Document::doctypeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Document::doctypeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - if (!privData->nativeObj->getDoctype()) return v8::Undefined(); - Arabica::DOM::DocumentType* arbaicaRet = new Arabica::DOM::DocumentType(privData->nativeObj->getDoctype()); + if (!privData->nativeObj->getDoctype()) return v8::Undefined(); + Arabica::DOM::DocumentType* arbaicaRet = new Arabica::DOM::DocumentType(privData->nativeObj->getDoctype()); - v8::Handle arbaicaRetCtor = V8DocumentType::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + v8::Handle arbaicaRetCtor = V8DocumentType::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); - struct V8DocumentType::V8DocumentTypePrivate* retPrivData = new V8DocumentType::V8DocumentTypePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + struct V8DocumentType::V8DocumentTypePrivate* retPrivData = new V8DocumentType::V8DocumentTypePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8DocumentType::jsDestructor); + return arbaicaRetObj; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8DocumentType::jsDestructor); - return arbaicaRetObj; + } -} + v8::Handle V8Document::implementationAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); -v8::Handle V8Document::implementationAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + if (!privData->nativeObj->getImplementation()) return v8::Undefined(); + Arabica::DOM::DOMImplementation* arbaicaRet = new Arabica::DOM::DOMImplementation(privData->nativeObj->getImplementation()); - if (!privData->nativeObj->getImplementation()) return v8::Undefined(); - Arabica::DOM::DOMImplementation* arbaicaRet = new Arabica::DOM::DOMImplementation(privData->nativeObj->getImplementation()); + v8::Handle arbaicaRetCtor = V8DOMImplementation::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); - v8::Handle arbaicaRetCtor = V8DOMImplementation::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + struct V8DOMImplementation::V8DOMImplementationPrivate* retPrivData = new V8DOMImplementation::V8DOMImplementationPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8DOMImplementation::jsDestructor); + return arbaicaRetObj; - struct V8DOMImplementation::V8DOMImplementationPrivate* retPrivData = new V8DOMImplementation::V8DOMImplementationPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + } - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8DOMImplementation::jsDestructor); - return arbaicaRetObj; + v8::Handle V8Document::documentElementAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); -} + if (!privData->nativeObj->getDocumentElement()) return v8::Undefined(); + Arabica::DOM::Element* arbaicaRet = new Arabica::DOM::Element(privData->nativeObj->getDocumentElement()); -v8::Handle V8Document::documentElementAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle arbaicaRetCtor = V8Element::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); - if (!privData->nativeObj->getDocumentElement()) return v8::Undefined(); - Arabica::DOM::Element* arbaicaRet = new Arabica::DOM::Element(privData->nativeObj->getDocumentElement()); + struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Element::jsDestructor); + return arbaicaRetObj; - v8::Handle arbaicaRetCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + } + v8::Handle V8Document::createElementCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in createElement"); - struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localTagName(args[0]); - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Element::jsDestructor); - return arbaicaRetObj; + Arabica::DOM::Element* retVal = new Arabica::DOM::Element(privData->nativeObj->createElement(*localTagName)); + v8::Handle retCtor = V8Element::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -} -v8::Handle V8Document::createElementCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in createElement"); + struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localTagName(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Element* retVal = new Arabica::DOM::Element(privData->nativeObj->createElement(*localTagName)); - v8::Handle retCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Element::jsDestructor); + return retObj; - struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::createDocumentFragmentCallback(const v8::Arguments& args) { - retObj.MakeWeak(0, V8Element::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); -} + Arabica::DOM::DocumentFragment* retVal = new Arabica::DOM::DocumentFragment(privData->nativeObj->createDocumentFragment()); + v8::Handle retCtor = V8DocumentFragment::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::createDocumentFragmentCallback(const v8::Arguments& args) { + struct V8DocumentFragment::V8DocumentFragmentPrivate* retPrivData = new V8DocumentFragment::V8DocumentFragmentPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::DocumentFragment* retVal = new Arabica::DOM::DocumentFragment(privData->nativeObj->createDocumentFragment()); - v8::Handle retCtor = V8DocumentFragment::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8DocumentFragment::jsDestructor); + return retObj; - struct V8DocumentFragment::V8DocumentFragmentPrivate* retPrivData = new V8DocumentFragment::V8DocumentFragmentPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::createTextNodeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in createTextNode"); - retObj.MakeWeak(0, V8DocumentFragment::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localData(args[0]); -} + Arabica::DOM::Text* retVal = new Arabica::DOM::Text(privData->nativeObj->createTextNode(*localData)); + v8::Handle retCtor = V8Text::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::createTextNodeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in createTextNode"); + struct V8Text::V8TextPrivate* retPrivData = new V8Text::V8TextPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localData(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Text* retVal = new Arabica::DOM::Text(privData->nativeObj->createTextNode(*localData)); - v8::Handle retCtor = V8Text::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Text::jsDestructor); + return retObj; - struct V8Text::V8TextPrivate* retPrivData = new V8Text::V8TextPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::createCommentCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in createComment"); - retObj.MakeWeak(0, V8Text::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localData(args[0]); -} + Arabica::DOM::Comment* retVal = new Arabica::DOM::Comment(privData->nativeObj->createComment(*localData)); + v8::Handle retCtor = V8Comment::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::createCommentCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in createComment"); + struct V8Comment::V8CommentPrivate* retPrivData = new V8Comment::V8CommentPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localData(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Comment* retVal = new Arabica::DOM::Comment(privData->nativeObj->createComment(*localData)); - v8::Handle retCtor = V8Comment::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Comment::jsDestructor); + return retObj; - struct V8Comment::V8CommentPrivate* retPrivData = new V8Comment::V8CommentPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::createCDATASectionCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in createCDATASection"); - retObj.MakeWeak(0, V8Comment::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localData(args[0]); -} + Arabica::DOM::CDATASection* retVal = new Arabica::DOM::CDATASection(privData->nativeObj->createCDATASection(*localData)); + v8::Handle retCtor = V8CDATASection::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::createCDATASectionCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in createCDATASection"); + struct V8CDATASection::V8CDATASectionPrivate* retPrivData = new V8CDATASection::V8CDATASectionPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localData(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::CDATASection* retVal = new Arabica::DOM::CDATASection(privData->nativeObj->createCDATASection(*localData)); - v8::Handle retCtor = V8CDATASection::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8CDATASection::jsDestructor); + return retObj; - struct V8CDATASection::V8CDATASectionPrivate* retPrivData = new V8CDATASection::V8CDATASectionPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::createProcessingInstructionCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in createProcessingInstruction"); - retObj.MakeWeak(0, V8CDATASection::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localTarget(args[0]); + v8::String::AsciiValue localData(args[1]); -} + Arabica::DOM::ProcessingInstruction* retVal = new Arabica::DOM::ProcessingInstruction(privData->nativeObj->createProcessingInstruction(*localTarget, *localData)); + v8::Handle retCtor = V8ProcessingInstruction::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::createProcessingInstructionCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in createProcessingInstruction"); + struct V8ProcessingInstruction::V8ProcessingInstructionPrivate* retPrivData = new V8ProcessingInstruction::V8ProcessingInstructionPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localTarget(args[0]); - v8::String::AsciiValue localData(args[1]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::ProcessingInstruction* retVal = new Arabica::DOM::ProcessingInstruction(privData->nativeObj->createProcessingInstruction(*localTarget, *localData)); - v8::Handle retCtor = V8ProcessingInstruction::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8ProcessingInstruction::jsDestructor); + return retObj; - struct V8ProcessingInstruction::V8ProcessingInstructionPrivate* retPrivData = new V8ProcessingInstruction::V8ProcessingInstructionPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::createAttributeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in createAttribute"); - retObj.MakeWeak(0, V8ProcessingInstruction::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); -} + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->createAttribute(*localName)); + v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::createAttributeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in createAttribute"); + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->createAttribute(*localName)); - v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::createEntityReferenceCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in createEntityReference"); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); -} + Arabica::DOM::EntityReference* retVal = new Arabica::DOM::EntityReference(privData->nativeObj->createEntityReference(*localName)); + v8::Handle retCtor = V8EntityReference::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::createEntityReferenceCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in createEntityReference"); + struct V8EntityReference::V8EntityReferencePrivate* retPrivData = new V8EntityReference::V8EntityReferencePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::EntityReference* retVal = new Arabica::DOM::EntityReference(privData->nativeObj->createEntityReference(*localName)); - v8::Handle retCtor = V8EntityReference::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8EntityReference::jsDestructor); + return retObj; - struct V8EntityReference::V8EntityReferencePrivate* retPrivData = new V8EntityReference::V8EntityReferencePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::getElementsByTagNameCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getElementsByTagName"); - retObj.MakeWeak(0, V8EntityReference::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localTagname(args[0]); -} + Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->nativeObj->getElementsByTagName(*localTagname)); + v8::Handle retCtor = V8NodeList::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::getElementsByTagNameCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getElementsByTagName"); + struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localTagname(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->nativeObj->getElementsByTagName(*localTagname)); - v8::Handle retCtor = V8NodeList::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8NodeList::jsDestructor); + return retObj; - struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::importNodeCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in importNode"); + if (!(V8Node::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling importNode"); - retObj.MakeWeak(0, V8NodeList::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + Arabica::DOM::Node* localImportedNode = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; + bool localDeep = args[1]->ToBoolean()->BooleanValue(); -} + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->importNode(*localImportedNode, localDeep)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::importNodeCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in importNode"); - if (!(V8Node::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling importNode"); + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localImportedNode = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - bool localDeep = args[1]->ToBoolean()->BooleanValue(); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->importNode(*localImportedNode, localDeep)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::createElementNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in createElementNS"); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localQualifiedName(args[1]); -} + Arabica::DOM::Element* retVal = new Arabica::DOM::Element(privData->nativeObj->createElementNS(*localNamespaceURI, *localQualifiedName)); + v8::Handle retCtor = V8Element::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::createElementNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in createElementNS"); + struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localQualifiedName(args[1]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Element* retVal = new Arabica::DOM::Element(privData->nativeObj->createElementNS(*localNamespaceURI, *localQualifiedName)); - v8::Handle retCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Element::jsDestructor); + return retObj; - struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::createAttributeNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in createAttributeNS"); - retObj.MakeWeak(0, V8Element::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localQualifiedName(args[1]); -} + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->createAttributeNS(*localNamespaceURI, *localQualifiedName)); + v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::createAttributeNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in createAttributeNS"); + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localQualifiedName(args[1]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->createAttributeNS(*localNamespaceURI, *localQualifiedName)); - v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::getElementsByTagNameNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getElementsByTagNameNS"); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); -} + Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->nativeObj->getElementsByTagNameNS(*localNamespaceURI, *localLocalName)); + v8::Handle retCtor = V8NodeList::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::getElementsByTagNameNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in getElementsByTagNameNS"); + struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->nativeObj->getElementsByTagNameNS(*localNamespaceURI, *localLocalName)); - v8::Handle retCtor = V8NodeList::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8NodeList::jsDestructor); + return retObj; - struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Document::getElementByIdCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getElementById"); - retObj.MakeWeak(0, V8NodeList::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localElementId(args[0]); -} + Arabica::DOM::Element* retVal = new Arabica::DOM::Element(privData->nativeObj->getElementById(*localElementId)); + v8::Handle retCtor = V8Element::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Document::getElementByIdCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getElementById"); + struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8DocumentPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localElementId(args[0]); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Element* retVal = new Arabica::DOM::Element(privData->nativeObj->getElementById(*localElementId)); - v8::Handle retCtor = V8Element::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Element::jsDestructor); + return retObj; - struct V8Element::V8ElementPrivate* retPrivData = new V8Element::V8ElementPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + bool V8Document::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } - retObj.MakeWeak(0, V8Element::jsDestructor); - return retObj; - -} - -bool V8Document::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} - -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h index da61876..c12e0dc 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Document.h @@ -21,8 +21,10 @@ #ifndef V8Document_h #define V8Document_h +#include #include "DOM/Node.hpp" #include "V8Node.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,89 +33,91 @@ namespace DOM { class V8Document { public: - struct V8DocumentPrivate { - V8DOM* dom; - Arabica::DOM::Document* nativeObj; - }; - - V8_DESTRUCTOR(V8DocumentPrivate); - static bool hasInstance(v8::Handle); - - static v8::Handle createElementCallback(const v8::Arguments&); - static v8::Handle createDocumentFragmentCallback(const v8::Arguments&); - static v8::Handle createTextNodeCallback(const v8::Arguments&); - static v8::Handle createCommentCallback(const v8::Arguments&); - static v8::Handle createCDATASectionCallback(const v8::Arguments&); - static v8::Handle createProcessingInstructionCallback(const v8::Arguments&); - static v8::Handle createAttributeCallback(const v8::Arguments&); - static v8::Handle createEntityReferenceCallback(const v8::Arguments&); - static v8::Handle getElementsByTagNameCallback(const v8::Arguments&); - static v8::Handle importNodeCallback(const v8::Arguments&); - static v8::Handle createElementNSCallback(const v8::Arguments&); - static v8::Handle createAttributeNSCallback(const v8::Arguments&); - static v8::Handle getElementsByTagNameNSCallback(const v8::Arguments&); - static v8::Handle getElementByIdCallback(const v8::Arguments&); - static v8::Handle evaluateCustomCallback(const v8::Arguments&); - - static v8::Handle doctypeAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle implementationAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle documentElementAttrGetter(v8::Local property, const v8::AccessorInfo& info); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("Document")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("doctype"), V8Document::doctypeAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("implementation"), V8Document::implementationAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("documentElement"), V8Document::documentElementAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - prototype->Set(v8::String::NewSymbol("createElement"), - v8::FunctionTemplate::New(V8Document::createElementCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createDocumentFragment"), - v8::FunctionTemplate::New(V8Document::createDocumentFragmentCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createTextNode"), - v8::FunctionTemplate::New(V8Document::createTextNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createComment"), - v8::FunctionTemplate::New(V8Document::createCommentCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createCDATASection"), - v8::FunctionTemplate::New(V8Document::createCDATASectionCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createProcessingInstruction"), - v8::FunctionTemplate::New(V8Document::createProcessingInstructionCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createAttribute"), - v8::FunctionTemplate::New(V8Document::createAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createEntityReference"), - v8::FunctionTemplate::New(V8Document::createEntityReferenceCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getElementsByTagName"), - v8::FunctionTemplate::New(V8Document::getElementsByTagNameCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("importNode"), - v8::FunctionTemplate::New(V8Document::importNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createElementNS"), - v8::FunctionTemplate::New(V8Document::createElementNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("createAttributeNS"), - v8::FunctionTemplate::New(V8Document::createAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getElementsByTagNameNS"), - v8::FunctionTemplate::New(V8Document::getElementsByTagNameNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getElementById"), - v8::FunctionTemplate::New(V8Document::getElementByIdCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("evaluate"), - v8::FunctionTemplate::New(V8Document::evaluateCustomCallback, v8::Undefined()), static_cast(v8::DontDelete)); - - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + struct V8DocumentPrivate { + V8DOM* dom; + Arabica::DOM::Document* nativeObj; + }; + + V8_DESTRUCTOR(V8DocumentPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle createElementCallback(const v8::Arguments&); + static v8::Handle createDocumentFragmentCallback(const v8::Arguments&); + static v8::Handle createTextNodeCallback(const v8::Arguments&); + static v8::Handle createCommentCallback(const v8::Arguments&); + static v8::Handle createCDATASectionCallback(const v8::Arguments&); + static v8::Handle createProcessingInstructionCallback(const v8::Arguments&); + static v8::Handle createAttributeCallback(const v8::Arguments&); + static v8::Handle createEntityReferenceCallback(const v8::Arguments&); + static v8::Handle getElementsByTagNameCallback(const v8::Arguments&); + static v8::Handle importNodeCallback(const v8::Arguments&); + static v8::Handle createElementNSCallback(const v8::Arguments&); + static v8::Handle createAttributeNSCallback(const v8::Arguments&); + static v8::Handle getElementsByTagNameNSCallback(const v8::Arguments&); + static v8::Handle getElementByIdCallback(const v8::Arguments&); + static v8::Handle evaluateCustomCallback(const v8::Arguments&); + + static v8::Handle doctypeAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle implementationAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle documentElementAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Document")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("doctype"), V8Document::doctypeAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("implementation"), V8Document::implementationAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("documentElement"), V8Document::documentElementAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("createElement"), + v8::FunctionTemplate::New(V8Document::createElementCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createDocumentFragment"), + v8::FunctionTemplate::New(V8Document::createDocumentFragmentCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createTextNode"), + v8::FunctionTemplate::New(V8Document::createTextNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createComment"), + v8::FunctionTemplate::New(V8Document::createCommentCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createCDATASection"), + v8::FunctionTemplate::New(V8Document::createCDATASectionCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createProcessingInstruction"), + v8::FunctionTemplate::New(V8Document::createProcessingInstructionCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createAttribute"), + v8::FunctionTemplate::New(V8Document::createAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createEntityReference"), + v8::FunctionTemplate::New(V8Document::createEntityReferenceCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getElementsByTagName"), + v8::FunctionTemplate::New(V8Document::getElementsByTagNameCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("importNode"), + v8::FunctionTemplate::New(V8Document::importNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createElementNS"), + v8::FunctionTemplate::New(V8Document::createElementNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("createAttributeNS"), + v8::FunctionTemplate::New(V8Document::createAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getElementsByTagNameNS"), + v8::FunctionTemplate::New(V8Document::getElementsByTagNameNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getElementById"), + v8::FunctionTemplate::New(V8Document::getElementByIdCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("evaluate"), + v8::FunctionTemplate::New(V8Document::evaluateCustomCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.cpp index 1403574..e6bec84 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.cpp @@ -4,11 +4,11 @@ namespace Arabica { namespace DOM { -v8::Persistent V8DocumentFragment::Tmpl; + v8::Persistent V8DocumentFragment::Tmpl; -bool V8DocumentFragment::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + bool V8DocumentFragment::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h index 62dc58d..cf7f6ba 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentFragment.h @@ -21,8 +21,10 @@ #ifndef V8DocumentFragment_h #define V8DocumentFragment_h +#include #include "DOM/Node.hpp" #include "V8Node.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,35 +33,37 @@ namespace DOM { class V8DocumentFragment { public: - struct V8DocumentFragmentPrivate { - V8DOM* dom; - Arabica::DOM::DocumentFragment* nativeObj; - }; + struct V8DocumentFragmentPrivate { + V8DOM* dom; + Arabica::DOM::DocumentFragment* nativeObj; + }; - V8_DESTRUCTOR(V8DocumentFragmentPrivate); - static bool hasInstance(v8::Handle); + V8_DESTRUCTOR(V8DocumentFragmentPrivate); + static bool hasInstance(v8::Handle); - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("DocumentFragment")); - tmpl->ReadOnlyPrototype(); + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("DocumentFragment")); + tmpl->ReadOnlyPrototype(); - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp index 6b9a7b0..a2098f2 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.cpp @@ -5,79 +5,79 @@ namespace Arabica { namespace DOM { -v8::Persistent V8DocumentType::Tmpl; + v8::Persistent V8DocumentType::Tmpl; -v8::Handle V8DocumentType::nameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8DocumentType::nameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getName().c_str()); -} + return v8::String::New(privData->nativeObj->getName().c_str()); + } -v8::Handle V8DocumentType::entitiesAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8DocumentType::entitiesAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->nativeObj->getEntities()); - Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->nativeObj->getEntities()); + v8::Handle arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); - v8::Handle arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); + return arbaicaRetObj; - struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + } - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); - return arbaicaRetObj; + v8::Handle V8DocumentType::notationsAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); -} + + Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->nativeObj->getNotations()); -v8::Handle V8DocumentType::notationsAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); + return arbaicaRetObj; - Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->nativeObj->getNotations()); + } - v8::Handle arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + v8::Handle V8DocumentType::publicIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + return v8::String::New(privData->nativeObj->getPublicId().c_str()); + } - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); - return arbaicaRetObj; + v8::Handle V8DocumentType::systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); -} + return v8::String::New(privData->nativeObj->getSystemId().c_str()); + } -v8::Handle V8DocumentType::publicIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8DocumentType::internalSubsetAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getPublicId().c_str()); -} + return v8::String::New(privData->nativeObj->getInternalSubset().c_str()); + } + bool V8DocumentType::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -v8::Handle V8DocumentType::systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - - return v8::String::New(privData->nativeObj->getSystemId().c_str()); -} - -v8::Handle V8DocumentType::internalSubsetAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8DocumentTypePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - - return v8::String::New(privData->nativeObj->getInternalSubset().c_str()); -} -bool V8DocumentType::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} - -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h index f4d0c15..65ce30c 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8DocumentType.h @@ -21,8 +21,10 @@ #ifndef V8DocumentType_h #define V8DocumentType_h +#include #include "DOM/Node.hpp" #include "V8Node.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,53 +33,55 @@ namespace DOM { class V8DocumentType { public: - struct V8DocumentTypePrivate { - V8DOM* dom; - Arabica::DOM::DocumentType* nativeObj; - }; - - V8_DESTRUCTOR(V8DocumentTypePrivate); - static bool hasInstance(v8::Handle); - - - static v8::Handle nameAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle entitiesAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle notationsAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle publicIdAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle internalSubsetAttrGetter(v8::Local property, const v8::AccessorInfo& info); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("DocumentType")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("name"), V8DocumentType::nameAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("entities"), V8DocumentType::entitiesAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("notations"), V8DocumentType::notationsAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("publicId"), V8DocumentType::publicIdAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("systemId"), V8DocumentType::systemIdAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("internalSubset"), V8DocumentType::internalSubsetAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + struct V8DocumentTypePrivate { + V8DOM* dom; + Arabica::DOM::DocumentType* nativeObj; + }; + + V8_DESTRUCTOR(V8DocumentTypePrivate); + static bool hasInstance(v8::Handle); + + + static v8::Handle nameAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle entitiesAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle notationsAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle publicIdAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle internalSubsetAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("DocumentType")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("name"), V8DocumentType::nameAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("entities"), V8DocumentType::entitiesAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("notations"), V8DocumentType::notationsAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("publicId"), V8DocumentType::publicIdAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("systemId"), V8DocumentType::systemIdAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("internalSubset"), V8DocumentType::internalSubsetAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + + + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp index 680dd5e..d476daa 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.cpp @@ -6,297 +6,297 @@ namespace Arabica { namespace DOM { -v8::Persistent V8Element::Tmpl; + v8::Persistent V8Element::Tmpl; -v8::Handle V8Element::tagNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Element::tagNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getTagName().c_str()); -} -v8::Handle V8Element::getAttributeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getAttribute"); + return v8::String::New(privData->nativeObj->getTagName().c_str()); + } + v8::Handle V8Element::getAttributeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getAttribute"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); - std::string retVal = privData->nativeObj->getAttribute(*localName); + std::string retVal = privData->nativeObj->getAttribute(*localName); - return v8::String::New(retVal.c_str()); -} + return v8::String::New(retVal.c_str()); + } -v8::Handle V8Element::setAttributeCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in setAttribute"); + v8::Handle V8Element::setAttributeCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in setAttribute"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); - v8::String::AsciiValue localValue(args[1]); + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); + v8::String::AsciiValue localValue(args[1]); - privData->nativeObj->setAttribute(*localName, *localValue); + privData->nativeObj->setAttribute(*localName, *localValue); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle V8Element::removeAttributeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in removeAttribute"); + v8::Handle V8Element::removeAttributeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in removeAttribute"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); - privData->nativeObj->removeAttribute(*localName); + privData->nativeObj->removeAttribute(*localName); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle V8Element::getAttributeNodeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getAttributeNode"); + v8::Handle V8Element::getAttributeNodeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getAttributeNode"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->getAttributeNode(*localName)); - v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->getAttributeNode(*localName)); + v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; -} + } -v8::Handle V8Element::setAttributeNodeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in setAttributeNode"); - if (!(V8Attr::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling setAttributeNode"); + v8::Handle V8Element::setAttributeNodeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in setAttributeNode"); + if (!(V8Attr::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling setAttributeNode"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Attr* localNewAttr = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + Arabica::DOM::Attr* localNewAttr = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->setAttributeNode(*localNewAttr)); - v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->setAttributeNode(*localNewAttr)); + v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; -} + } -v8::Handle V8Element::removeAttributeNodeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in removeAttributeNode"); - if (!(V8Attr::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling removeAttributeNode"); + v8::Handle V8Element::removeAttributeNodeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in removeAttributeNode"); + if (!(V8Attr::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling removeAttributeNode"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Attr* localOldAttr = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + Arabica::DOM::Attr* localOldAttr = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->removeAttributeNode(*localOldAttr)); - v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->removeAttributeNode(*localOldAttr)); + v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; -} + } -v8::Handle V8Element::getElementsByTagNameCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getElementsByTagName"); + v8::Handle V8Element::getElementsByTagNameCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getElementsByTagName"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); - Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->nativeObj->getElementsByTagName(*localName)); - v8::Handle retCtor = V8NodeList::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->nativeObj->getElementsByTagName(*localName)); + v8::Handle retCtor = V8NodeList::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8NodeList::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8NodeList::jsDestructor); + return retObj; -} + } -v8::Handle V8Element::getAttributeNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in getAttributeNS"); + v8::Handle V8Element::getAttributeNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getAttributeNS"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); - std::string retVal = privData->nativeObj->getAttributeNS(*localNamespaceURI, *localLocalName); + std::string retVal = privData->nativeObj->getAttributeNS(*localNamespaceURI, *localLocalName); - return v8::String::New(retVal.c_str()); -} + return v8::String::New(retVal.c_str()); + } -v8::Handle V8Element::setAttributeNSCallback(const v8::Arguments& args) { - if (args.Length() < 3) - throw V8Exception("Wrong number of arguments in setAttributeNS"); + v8::Handle V8Element::setAttributeNSCallback(const v8::Arguments& args) { + if (args.Length() < 3) + throw V8Exception("Wrong number of arguments in setAttributeNS"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localQualifiedName(args[1]); - v8::String::AsciiValue localValue(args[2]); + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localQualifiedName(args[1]); + v8::String::AsciiValue localValue(args[2]); - privData->nativeObj->setAttributeNS(*localNamespaceURI, *localQualifiedName, *localValue); + privData->nativeObj->setAttributeNS(*localNamespaceURI, *localQualifiedName, *localValue); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle V8Element::removeAttributeNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in removeAttributeNS"); + v8::Handle V8Element::removeAttributeNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in removeAttributeNS"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); - privData->nativeObj->removeAttributeNS(*localNamespaceURI, *localLocalName); + privData->nativeObj->removeAttributeNS(*localNamespaceURI, *localLocalName); - return v8::Undefined(); -} + return v8::Undefined(); + } -v8::Handle V8Element::getAttributeNodeNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in getAttributeNodeNS"); + v8::Handle V8Element::getAttributeNodeNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getAttributeNodeNS"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->getAttributeNodeNS(*localNamespaceURI, *localLocalName)); - v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->getAttributeNodeNS(*localNamespaceURI, *localLocalName)); + v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; -} + } -v8::Handle V8Element::setAttributeNodeNSCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in setAttributeNodeNS"); - if (!(V8Attr::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling setAttributeNodeNS"); + v8::Handle V8Element::setAttributeNodeNSCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in setAttributeNodeNS"); + if (!(V8Attr::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling setAttributeNodeNS"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Attr* localNewAttr = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + Arabica::DOM::Attr* localNewAttr = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->setAttributeNodeNS(*localNewAttr)); - v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Attr* retVal = new Arabica::DOM::Attr(privData->nativeObj->setAttributeNodeNS(*localNewAttr)); + v8::Handle retCtor = V8Attr::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Attr::V8AttrPrivate* retPrivData = new V8Attr::V8AttrPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Attr::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Attr::jsDestructor); + return retObj; -} + } -v8::Handle V8Element::getElementsByTagNameNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in getElementsByTagNameNS"); + v8::Handle V8Element::getElementsByTagNameNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getElementsByTagNameNS"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); - Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->nativeObj->getElementsByTagNameNS(*localNamespaceURI, *localLocalName)); - v8::Handle retCtor = V8NodeList::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::NodeList* retVal = new Arabica::DOM::NodeList(privData->nativeObj->getElementsByTagNameNS(*localNamespaceURI, *localLocalName)); + v8::Handle retCtor = V8NodeList::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8NodeList::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8NodeList::jsDestructor); + return retObj; -} + } -v8::Handle V8Element::hasAttributeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in hasAttribute"); + v8::Handle V8Element::hasAttributeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in hasAttribute"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); - bool retVal = privData->nativeObj->hasAttribute(*localName); + bool retVal = privData->nativeObj->hasAttribute(*localName); - return v8::Boolean::New(retVal); -} + return v8::Boolean::New(retVal); + } -v8::Handle V8Element::hasAttributeNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in hasAttributeNS"); + v8::Handle V8Element::hasAttributeNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in hasAttributeNS"); - v8::Local self = args.Holder(); - struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local self = args.Holder(); + struct V8ElementPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); - bool retVal = privData->nativeObj->hasAttributeNS(*localNamespaceURI, *localLocalName); + bool retVal = privData->nativeObj->hasAttributeNS(*localNamespaceURI, *localLocalName); - return v8::Boolean::New(retVal); -} + return v8::Boolean::New(retVal); + } -bool V8Element::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + bool V8Element::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h index 338c249..499ae0e 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Element.h @@ -21,8 +21,10 @@ #ifndef V8Element_h #define V8Element_h +#include #include "DOM/Node.hpp" #include "V8Node.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,83 +33,85 @@ namespace DOM { class V8Element { public: - struct V8ElementPrivate { - V8DOM* dom; - Arabica::DOM::Element* nativeObj; - }; - - V8_DESTRUCTOR(V8ElementPrivate); - static bool hasInstance(v8::Handle); - - static v8::Handle getAttributeCallback(const v8::Arguments&); - static v8::Handle setAttributeCallback(const v8::Arguments&); - static v8::Handle removeAttributeCallback(const v8::Arguments&); - static v8::Handle getAttributeNodeCallback(const v8::Arguments&); - static v8::Handle setAttributeNodeCallback(const v8::Arguments&); - static v8::Handle removeAttributeNodeCallback(const v8::Arguments&); - static v8::Handle getElementsByTagNameCallback(const v8::Arguments&); - static v8::Handle getAttributeNSCallback(const v8::Arguments&); - static v8::Handle setAttributeNSCallback(const v8::Arguments&); - static v8::Handle removeAttributeNSCallback(const v8::Arguments&); - static v8::Handle getAttributeNodeNSCallback(const v8::Arguments&); - static v8::Handle setAttributeNodeNSCallback(const v8::Arguments&); - static v8::Handle getElementsByTagNameNSCallback(const v8::Arguments&); - static v8::Handle hasAttributeCallback(const v8::Arguments&); - static v8::Handle hasAttributeNSCallback(const v8::Arguments&); - - static v8::Handle tagNameAttrGetter(v8::Local property, const v8::AccessorInfo& info); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("Element")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("tagName"), V8Element::tagNameAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - prototype->Set(v8::String::NewSymbol("getAttribute"), - v8::FunctionTemplate::New(V8Element::getAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setAttribute"), - v8::FunctionTemplate::New(V8Element::setAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeAttribute"), - v8::FunctionTemplate::New(V8Element::removeAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getAttributeNode"), - v8::FunctionTemplate::New(V8Element::getAttributeNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setAttributeNode"), - v8::FunctionTemplate::New(V8Element::setAttributeNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeAttributeNode"), - v8::FunctionTemplate::New(V8Element::removeAttributeNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getElementsByTagName"), - v8::FunctionTemplate::New(V8Element::getElementsByTagNameCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getAttributeNS"), - v8::FunctionTemplate::New(V8Element::getAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setAttributeNS"), - v8::FunctionTemplate::New(V8Element::setAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeAttributeNS"), - v8::FunctionTemplate::New(V8Element::removeAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getAttributeNodeNS"), - v8::FunctionTemplate::New(V8Element::getAttributeNodeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setAttributeNodeNS"), - v8::FunctionTemplate::New(V8Element::setAttributeNodeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getElementsByTagNameNS"), - v8::FunctionTemplate::New(V8Element::getElementsByTagNameNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasAttribute"), - v8::FunctionTemplate::New(V8Element::hasAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasAttributeNS"), - v8::FunctionTemplate::New(V8Element::hasAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + struct V8ElementPrivate { + V8DOM* dom; + Arabica::DOM::Element* nativeObj; + }; + + V8_DESTRUCTOR(V8ElementPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle getAttributeCallback(const v8::Arguments&); + static v8::Handle setAttributeCallback(const v8::Arguments&); + static v8::Handle removeAttributeCallback(const v8::Arguments&); + static v8::Handle getAttributeNodeCallback(const v8::Arguments&); + static v8::Handle setAttributeNodeCallback(const v8::Arguments&); + static v8::Handle removeAttributeNodeCallback(const v8::Arguments&); + static v8::Handle getElementsByTagNameCallback(const v8::Arguments&); + static v8::Handle getAttributeNSCallback(const v8::Arguments&); + static v8::Handle setAttributeNSCallback(const v8::Arguments&); + static v8::Handle removeAttributeNSCallback(const v8::Arguments&); + static v8::Handle getAttributeNodeNSCallback(const v8::Arguments&); + static v8::Handle setAttributeNodeNSCallback(const v8::Arguments&); + static v8::Handle getElementsByTagNameNSCallback(const v8::Arguments&); + static v8::Handle hasAttributeCallback(const v8::Arguments&); + static v8::Handle hasAttributeNSCallback(const v8::Arguments&); + + static v8::Handle tagNameAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Element")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("tagName"), V8Element::tagNameAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("getAttribute"), + v8::FunctionTemplate::New(V8Element::getAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setAttribute"), + v8::FunctionTemplate::New(V8Element::setAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("removeAttribute"), + v8::FunctionTemplate::New(V8Element::removeAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getAttributeNode"), + v8::FunctionTemplate::New(V8Element::getAttributeNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setAttributeNode"), + v8::FunctionTemplate::New(V8Element::setAttributeNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("removeAttributeNode"), + v8::FunctionTemplate::New(V8Element::removeAttributeNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getElementsByTagName"), + v8::FunctionTemplate::New(V8Element::getElementsByTagNameCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getAttributeNS"), + v8::FunctionTemplate::New(V8Element::getAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setAttributeNS"), + v8::FunctionTemplate::New(V8Element::setAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("removeAttributeNS"), + v8::FunctionTemplate::New(V8Element::removeAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getAttributeNodeNS"), + v8::FunctionTemplate::New(V8Element::getAttributeNodeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setAttributeNodeNS"), + v8::FunctionTemplate::New(V8Element::setAttributeNodeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getElementsByTagNameNS"), + v8::FunctionTemplate::New(V8Element::getElementsByTagNameNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("hasAttribute"), + v8::FunctionTemplate::New(V8Element::hasAttributeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("hasAttributeNS"), + v8::FunctionTemplate::New(V8Element::hasAttributeNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp index f3ce21d..6db7b15 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.cpp @@ -4,32 +4,32 @@ namespace Arabica { namespace DOM { -v8::Persistent V8Entity::Tmpl; + v8::Persistent V8Entity::Tmpl; -v8::Handle V8Entity::publicIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8EntityPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Entity::publicIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8EntityPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getPublicId().c_str()); -} + return v8::String::New(privData->nativeObj->getPublicId().c_str()); + } -v8::Handle V8Entity::systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8EntityPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Entity::systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8EntityPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getSystemId().c_str()); -} + return v8::String::New(privData->nativeObj->getSystemId().c_str()); + } -v8::Handle V8Entity::notationNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8EntityPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Entity::notationNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8EntityPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getNotationName().c_str()); -} -bool V8Entity::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + return v8::String::New(privData->nativeObj->getNotationName().c_str()); + } + bool V8Entity::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h index c8e0eaf..acea6ea 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Entity.h @@ -21,8 +21,10 @@ #ifndef V8Entity_h #define V8Entity_h +#include #include "DOM/Node.hpp" #include "V8Node.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,44 +33,46 @@ namespace DOM { class V8Entity { public: - struct V8EntityPrivate { - V8DOM* dom; - Arabica::DOM::Entity* nativeObj; - }; - - V8_DESTRUCTOR(V8EntityPrivate); - static bool hasInstance(v8::Handle); - - - static v8::Handle publicIdAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle notationNameAttrGetter(v8::Local property, const v8::AccessorInfo& info); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("Entity")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("publicId"), V8Entity::publicIdAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("systemId"), V8Entity::systemIdAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("notationName"), V8Entity::notationNameAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - - - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + struct V8EntityPrivate { + V8DOM* dom; + Arabica::DOM::Entity* nativeObj; + }; + + V8_DESTRUCTOR(V8EntityPrivate); + static bool hasInstance(v8::Handle); + + + static v8::Handle publicIdAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle notationNameAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Entity")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("publicId"), V8Entity::publicIdAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("systemId"), V8Entity::systemIdAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("notationName"), V8Entity::notationNameAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + + + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.cpp index 197fadd..95ceee8 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.cpp @@ -4,11 +4,11 @@ namespace Arabica { namespace DOM { -v8::Persistent V8EntityReference::Tmpl; + v8::Persistent V8EntityReference::Tmpl; -bool V8EntityReference::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + bool V8EntityReference::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h index 85cc7cc..9bfb86d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8EntityReference.h @@ -21,8 +21,10 @@ #ifndef V8EntityReference_h #define V8EntityReference_h +#include #include "DOM/Node.hpp" #include "V8Node.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,35 +33,37 @@ namespace DOM { class V8EntityReference { public: - struct V8EntityReferencePrivate { - V8DOM* dom; - Arabica::DOM::EntityReference* nativeObj; - }; + struct V8EntityReferencePrivate { + V8DOM* dom; + Arabica::DOM::EntityReference* nativeObj; + }; - V8_DESTRUCTOR(V8EntityReferencePrivate); - static bool hasInstance(v8::Handle); + V8_DESTRUCTOR(V8EntityReferencePrivate); + static bool hasInstance(v8::Handle); - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("EntityReference")); - tmpl->ReadOnlyPrototype(); + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("EntityReference")); + tmpl->ReadOnlyPrototype(); - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp index 037d651..e09bbb8 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.cpp @@ -4,185 +4,185 @@ namespace Arabica { namespace DOM { -v8::Persistent V8NamedNodeMap::Tmpl; + v8::Persistent V8NamedNodeMap::Tmpl; -v8::Handle V8NamedNodeMap::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8NamedNodeMap::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Integer::New(privData->nativeObj->getLength()); -} -v8::Handle V8NamedNodeMap::getNamedItemCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in getNamedItem"); + return v8::Integer::New(privData->nativeObj->getLength()); + } + v8::Handle V8NamedNodeMap::getNamedItemCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in getNamedItem"); - v8::Local self = args.Holder(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local self = args.Holder(); + struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->getNamedItem(*localName)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->getNamedItem(*localName)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; -} + } -v8::Handle V8NamedNodeMap::setNamedItemCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in setNamedItem"); - if (!(V8Node::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling setNamedItem"); + v8::Handle V8NamedNodeMap::setNamedItemCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in setNamedItem"); + if (!(V8Node::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling setNamedItem"); - v8::Local self = args.Holder(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localArg = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local self = args.Holder(); + struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + Arabica::DOM::Node* localArg = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->setNamedItem(*localArg)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->setNamedItem(*localArg)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; -} + } -v8::Handle V8NamedNodeMap::removeNamedItemCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in removeNamedItem"); + v8::Handle V8NamedNodeMap::removeNamedItemCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in removeNamedItem"); - v8::Local self = args.Holder(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localName(args[0]); + v8::Local self = args.Holder(); + struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localName(args[0]); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->removeNamedItem(*localName)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->removeNamedItem(*localName)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; -} + } -v8::Handle V8NamedNodeMap::itemCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in item"); + v8::Handle V8NamedNodeMap::itemCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in item"); - v8::Local self = args.Holder(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + v8::Local self = args.Holder(); + struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->item(localIndex)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->item(localIndex)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; -} + } -v8::Handle V8NamedNodeMap::getNamedItemNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in getNamedItemNS"); + v8::Handle V8NamedNodeMap::getNamedItemNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in getNamedItemNS"); - v8::Local self = args.Holder(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local self = args.Holder(); + struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->getNamedItemNS(*localNamespaceURI, *localLocalName)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->getNamedItemNS(*localNamespaceURI, *localLocalName)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; -} + } -v8::Handle V8NamedNodeMap::setNamedItemNSCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in setNamedItemNS"); - if (!(V8Node::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling setNamedItemNS"); + v8::Handle V8NamedNodeMap::setNamedItemNSCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in setNamedItemNS"); + if (!(V8Node::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling setNamedItemNS"); - v8::Local self = args.Holder(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localArg = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local self = args.Holder(); + struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + Arabica::DOM::Node* localArg = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->setNamedItemNS(*localArg)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->setNamedItemNS(*localArg)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; -} + } -v8::Handle V8NamedNodeMap::removeNamedItemNSCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in removeNamedItemNS"); + v8::Handle V8NamedNodeMap::removeNamedItemNSCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in removeNamedItemNS"); - v8::Local self = args.Holder(); - struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNamespaceURI(args[0]); - v8::String::AsciiValue localLocalName(args[1]); + v8::Local self = args.Holder(); + struct V8NamedNodeMapPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNamespaceURI(args[0]); + v8::String::AsciiValue localLocalName(args[1]); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->removeNamedItemNS(*localNamespaceURI, *localLocalName)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->removeNamedItemNS(*localNamespaceURI, *localLocalName)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; -} + } -bool V8NamedNodeMap::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + bool V8NamedNodeMap::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h index b8bc873..a98c5ee 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NamedNodeMap.h @@ -21,7 +21,9 @@ #ifndef V8NamedNodeMap_h #define V8NamedNodeMap_h +#include #include "DOM/Node.hpp" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -30,58 +32,60 @@ namespace DOM { class V8NamedNodeMap { public: - struct V8NamedNodeMapPrivate { - V8DOM* dom; - Arabica::DOM::NamedNodeMap* nativeObj; - }; - - V8_DESTRUCTOR(V8NamedNodeMapPrivate); - static bool hasInstance(v8::Handle); - - static v8::Handle getNamedItemCallback(const v8::Arguments&); - static v8::Handle setNamedItemCallback(const v8::Arguments&); - static v8::Handle removeNamedItemCallback(const v8::Arguments&); - static v8::Handle itemCallback(const v8::Arguments&); - static v8::Handle getNamedItemNSCallback(const v8::Arguments&); - static v8::Handle setNamedItemNSCallback(const v8::Arguments&); - static v8::Handle removeNamedItemNSCallback(const v8::Arguments&); - - static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("NamedNodeMap")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("length"), V8NamedNodeMap::lengthAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - prototype->Set(v8::String::NewSymbol("getNamedItem"), - v8::FunctionTemplate::New(V8NamedNodeMap::getNamedItemCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setNamedItem"), - v8::FunctionTemplate::New(V8NamedNodeMap::setNamedItemCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeNamedItem"), - v8::FunctionTemplate::New(V8NamedNodeMap::removeNamedItemCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("item"), - v8::FunctionTemplate::New(V8NamedNodeMap::itemCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("getNamedItemNS"), - v8::FunctionTemplate::New(V8NamedNodeMap::getNamedItemNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("setNamedItemNS"), - v8::FunctionTemplate::New(V8NamedNodeMap::setNamedItemNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeNamedItemNS"), - v8::FunctionTemplate::New(V8NamedNodeMap::removeNamedItemNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); - - - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + struct V8NamedNodeMapPrivate { + V8DOM* dom; + Arabica::DOM::NamedNodeMap* nativeObj; + }; + + V8_DESTRUCTOR(V8NamedNodeMapPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle getNamedItemCallback(const v8::Arguments&); + static v8::Handle setNamedItemCallback(const v8::Arguments&); + static v8::Handle removeNamedItemCallback(const v8::Arguments&); + static v8::Handle itemCallback(const v8::Arguments&); + static v8::Handle getNamedItemNSCallback(const v8::Arguments&); + static v8::Handle setNamedItemNSCallback(const v8::Arguments&); + static v8::Handle removeNamedItemNSCallback(const v8::Arguments&); + + static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("NamedNodeMap")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("length"), V8NamedNodeMap::lengthAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("getNamedItem"), + v8::FunctionTemplate::New(V8NamedNodeMap::getNamedItemCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setNamedItem"), + v8::FunctionTemplate::New(V8NamedNodeMap::setNamedItemCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("removeNamedItem"), + v8::FunctionTemplate::New(V8NamedNodeMap::removeNamedItemCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("item"), + v8::FunctionTemplate::New(V8NamedNodeMap::itemCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("getNamedItemNS"), + v8::FunctionTemplate::New(V8NamedNodeMap::getNamedItemNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("setNamedItemNS"), + v8::FunctionTemplate::New(V8NamedNodeMap::setNamedItemNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("removeNamedItemNS"), + v8::FunctionTemplate::New(V8NamedNodeMap::removeNamedItemNSCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp index b77f38e..7de50f6 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.cpp @@ -6,396 +6,396 @@ namespace Arabica { namespace DOM { -v8::Persistent V8Node::Tmpl; + v8::Persistent V8Node::Tmpl; -v8::Handle V8Node::nodeNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Node::nodeNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getNodeName().c_str()); -} + return v8::String::New(privData->nativeObj->getNodeName().c_str()); + } -v8::Handle V8Node::nodeValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Node::nodeValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getNodeValue().c_str()); -} + return v8::String::New(privData->nativeObj->getNodeValue().c_str()); + } -void V8Node::nodeValueAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localNodeValue(value); - privData->nativeObj->setNodeValue(*localNodeValue); -} + void V8Node::nodeValueAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localNodeValue(value); + privData->nativeObj->setNodeValue(*localNodeValue); + } -v8::Handle V8Node::nodeTypeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Node::nodeTypeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Integer::New(privData->nativeObj->getNodeType()); -} + return v8::Integer::New(privData->nativeObj->getNodeType()); + } -v8::Handle V8Node::parentNodeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Node::parentNodeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - if (!privData->nativeObj->getParentNode()) return v8::Undefined(); - Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getParentNode()); + if (!privData->nativeObj->getParentNode()) return v8::Undefined(); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getParentNode()); - v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); - return arbaicaRetObj; + } -} + v8::Handle V8Node::childNodesAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); -v8::Handle V8Node::childNodesAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + Arabica::DOM::NodeList* arbaicaRet = new Arabica::DOM::NodeList(privData->nativeObj->getChildNodes()); + v8::Handle arbaicaRetCtor = V8NodeList::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); - Arabica::DOM::NodeList* arbaicaRet = new Arabica::DOM::NodeList(privData->nativeObj->getChildNodes()); + struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8NodeList::jsDestructor); + return arbaicaRetObj; - v8::Handle arbaicaRetCtor = V8NodeList::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + } - struct V8NodeList::V8NodeListPrivate* retPrivData = new V8NodeList::V8NodeListPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + v8::Handle V8Node::firstChildAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8NodeList::jsDestructor); - return arbaicaRetObj; + if (!privData->nativeObj->getFirstChild()) return v8::Undefined(); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getFirstChild()); -} + v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); -v8::Handle V8Node::firstChildAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; - if (!privData->nativeObj->getFirstChild()) return v8::Undefined(); - Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getFirstChild()); + } - v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + v8::Handle V8Node::lastChildAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + if (!privData->nativeObj->getLastChild()) return v8::Undefined(); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getLastChild()); - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); - return arbaicaRetObj; + v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); -} + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; -v8::Handle V8Node::lastChildAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + } + + v8::Handle V8Node::previousSiblingAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + if (!privData->nativeObj->getPreviousSibling()) return v8::Undefined(); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getPreviousSibling()); + + v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; + + } + + v8::Handle V8Node::nextSiblingAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + + if (!privData->nativeObj->getNextSibling()) return v8::Undefined(); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getNextSibling()); + + v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; - if (!privData->nativeObj->getLastChild()) return v8::Undefined(); - Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getLastChild()); + } - v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + v8::Handle V8Node::attributesAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + + Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->nativeObj->getAttributes()); + + v8::Handle arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + + struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); + return arbaicaRetObj; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); - return arbaicaRetObj; + } -} + v8::Handle V8Node::ownerDocumentAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); -v8::Handle V8Node::previousSiblingAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + if (!privData->nativeObj->getOwnerDocument()) return v8::Undefined(); + Arabica::DOM::Document* arbaicaRet = new Arabica::DOM::Document(privData->nativeObj->getOwnerDocument()); - if (!privData->nativeObj->getPreviousSibling()) return v8::Undefined(); - Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getPreviousSibling()); + v8::Handle arbaicaRetCtor = V8Document::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); - v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + struct V8Document::V8DocumentPrivate* retPrivData = new V8Document::V8DocumentPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Document::jsDestructor); + return arbaicaRetObj; - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + } - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); - return arbaicaRetObj; + v8::Handle V8Node::namespaceURIAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); -} + return v8::String::New(privData->nativeObj->getNamespaceURI().c_str()); + } -v8::Handle V8Node::nextSiblingAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Node::prefixAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - if (!privData->nativeObj->getNextSibling()) return v8::Undefined(); - Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->getNextSibling()); + return v8::String::New(privData->nativeObj->getPrefix().c_str()); + } - v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + void V8Node::prefixAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localPrefix(value); + privData->nativeObj->setPrefix(*localPrefix); + } - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + v8::Handle V8Node::localNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); - return arbaicaRetObj; + return v8::String::New(privData->nativeObj->getLocalName().c_str()); + } + v8::Handle V8Node::insertBeforeCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in insertBefore"); + if (!((V8Node::hasInstance(args[0])) && (V8Node::hasInstance(args[1])))) + throw V8Exception("Parameter mismatch while calling insertBefore"); -} + v8::Local self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + Arabica::DOM::Node* localNewChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; + Arabica::DOM::Node* localRefChild = V8DOM::toClassPtr(args[1]->ToObject()->GetInternalField(0))->nativeObj; -v8::Handle V8Node::attributesAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->insertBefore(*localNewChild, *localRefChild)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - Arabica::DOM::NamedNodeMap* arbaicaRet = new Arabica::DOM::NamedNodeMap(privData->nativeObj->getAttributes()); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - v8::Handle arbaicaRetCtor = V8NamedNodeMap::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; - struct V8NamedNodeMap::V8NamedNodeMapPrivate* retPrivData = new V8NamedNodeMap::V8NamedNodeMapPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + } - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8NamedNodeMap::jsDestructor); - return arbaicaRetObj; + v8::Handle V8Node::replaceChildCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in replaceChild"); + if (!((V8Node::hasInstance(args[0])) && (V8Node::hasInstance(args[1])))) + throw V8Exception("Parameter mismatch while calling replaceChild"); -} + v8::Local self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + Arabica::DOM::Node* localNewChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; + Arabica::DOM::Node* localOldChild = V8DOM::toClassPtr(args[1]->ToObject()->GetInternalField(0))->nativeObj; -v8::Handle V8Node::ownerDocumentAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->replaceChild(*localNewChild, *localOldChild)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - if (!privData->nativeObj->getOwnerDocument()) return v8::Undefined(); - Arabica::DOM::Document* arbaicaRet = new Arabica::DOM::Document(privData->nativeObj->getOwnerDocument()); + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Handle arbaicaRetCtor = V8Document::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - struct V8Document::V8DocumentPrivate* retPrivData = new V8Document::V8DocumentPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Document::jsDestructor); - return arbaicaRetObj; + } -} + v8::Handle V8Node::removeChildCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in removeChild"); + if (!(V8Node::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling removeChild"); -v8::Handle V8Node::namespaceURIAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Local self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + Arabica::DOM::Node* localOldChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - return v8::String::New(privData->nativeObj->getNamespaceURI().c_str()); -} + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->removeChild(*localOldChild)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Node::prefixAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - return v8::String::New(privData->nativeObj->getPrefix().c_str()); -} + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); -void V8Node::prefixAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localPrefix(value); - privData->nativeObj->setPrefix(*localPrefix); -} + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; -v8::Handle V8Node::localNameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + } - return v8::String::New(privData->nativeObj->getLocalName().c_str()); -} -v8::Handle V8Node::insertBeforeCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in insertBefore"); - if (!((V8Node::hasInstance(args[0])) && (V8Node::hasInstance(args[1])))) - throw V8Exception("Parameter mismatch while calling insertBefore"); + v8::Handle V8Node::appendChildCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in appendChild"); + if (!(V8Node::hasInstance(args[0]))) + throw V8Exception("Parameter mismatch while calling appendChild"); - v8::Local self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localNewChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node* localRefChild = V8DOM::toClassPtr(args[1]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + Arabica::DOM::Node* localNewChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->insertBefore(*localNewChild, *localRefChild)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->appendChild(*localNewChild)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; -} + } -v8::Handle V8Node::replaceChildCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in replaceChild"); - if (!((V8Node::hasInstance(args[0])) && (V8Node::hasInstance(args[1])))) - throw V8Exception("Parameter mismatch while calling replaceChild"); + v8::Handle V8Node::hasChildNodesCallback(const v8::Arguments& args) { - v8::Local self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localNewChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; - Arabica::DOM::Node* localOldChild = V8DOM::toClassPtr(args[1]->ToObject()->GetInternalField(0))->nativeObj; + v8::Local self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->replaceChild(*localNewChild, *localOldChild)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + bool retVal = privData->nativeObj->hasChildNodes(); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + return v8::Boolean::New(retVal); + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Node::cloneNodeCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in cloneNode"); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + bool localDeep = args[0]->ToBoolean()->BooleanValue(); -} + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->cloneNode(localDeep)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); -v8::Handle V8Node::removeChildCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in removeChild"); - if (!(V8Node::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling removeChild"); + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - v8::Local self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localOldChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->removeChild(*localOldChild)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + } - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + v8::Handle V8Node::normalizeCallback(const v8::Arguments& args) { - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + v8::Local self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); -} + privData->nativeObj->normalize(); -v8::Handle V8Node::appendChildCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in appendChild"); - if (!(V8Node::hasInstance(args[0]))) - throw V8Exception("Parameter mismatch while calling appendChild"); + return v8::Undefined(); + } - v8::Local self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::DOM::Node* localNewChild = V8DOM::toClassPtr(args[0]->ToObject()->GetInternalField(0))->nativeObj; + v8::Handle V8Node::isSupportedCallback(const v8::Arguments& args) { + if (args.Length() < 2) + throw V8Exception("Wrong number of arguments in isSupported"); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->appendChild(*localNewChild)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + v8::Local self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localFeature(args[0]); + v8::String::AsciiValue localVersion(args[1]); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + bool retVal = privData->nativeObj->isSupported(*localFeature, *localVersion); - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + return v8::Boolean::New(retVal); + } - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + v8::Handle V8Node::hasAttributesCallback(const v8::Arguments& args) { -} + v8::Local self = args.Holder(); + struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); -v8::Handle V8Node::hasChildNodesCallback(const v8::Arguments& args) { + bool retVal = privData->nativeObj->hasAttributes(); - v8::Local self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + return v8::Boolean::New(retVal); + } - bool retVal = privData->nativeObj->hasChildNodes(); + bool V8Node::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } - return v8::Boolean::New(retVal); -} - -v8::Handle V8Node::cloneNodeCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in cloneNode"); - - v8::Local self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - bool localDeep = args[0]->ToBoolean()->BooleanValue(); - - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->cloneNode(localDeep)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; - - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; - -} - -v8::Handle V8Node::normalizeCallback(const v8::Arguments& args) { - - v8::Local self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - - privData->nativeObj->normalize(); - - return v8::Undefined(); -} - -v8::Handle V8Node::isSupportedCallback(const v8::Arguments& args) { - if (args.Length() < 2) - throw V8Exception("Wrong number of arguments in isSupported"); - - v8::Local self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localFeature(args[0]); - v8::String::AsciiValue localVersion(args[1]); - - bool retVal = privData->nativeObj->isSupported(*localFeature, *localVersion); - - return v8::Boolean::New(retVal); -} - -v8::Handle V8Node::hasAttributesCallback(const v8::Arguments& args) { - - v8::Local self = args.Holder(); - struct V8NodePrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - - bool retVal = privData->nativeObj->hasAttributes(); - - return v8::Boolean::New(retVal); -} - -bool V8Node::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} - -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h index a15a676..cd427e5 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Node.h @@ -21,7 +21,9 @@ #ifndef V8Node_h #define V8Node_h +#include #include "DOM/Node.hpp" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -30,129 +32,131 @@ namespace DOM { class V8Node { public: - struct V8NodePrivate { - V8DOM* dom; - Arabica::DOM::Node* nativeObj; - }; - - V8_DESTRUCTOR(V8NodePrivate); - static bool hasInstance(v8::Handle); - - static v8::Handle insertBeforeCallback(const v8::Arguments&); - static v8::Handle replaceChildCallback(const v8::Arguments&); - static v8::Handle removeChildCallback(const v8::Arguments&); - static v8::Handle appendChildCallback(const v8::Arguments&); - static v8::Handle hasChildNodesCallback(const v8::Arguments&); - static v8::Handle cloneNodeCallback(const v8::Arguments&); - static v8::Handle normalizeCallback(const v8::Arguments&); - static v8::Handle isSupportedCallback(const v8::Arguments&); - static v8::Handle hasAttributesCallback(const v8::Arguments&); - - static v8::Handle nodeNameAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle nodeValueAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static void nodeValueAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info); - static v8::Handle nodeTypeAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle parentNodeAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle childNodesAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle firstChildAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle lastChildAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle previousSiblingAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle nextSiblingAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle attributesAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle ownerDocumentAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle namespaceURIAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle prefixAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static void prefixAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info); - static v8::Handle localNameAttrGetter(v8::Local property, const v8::AccessorInfo& info); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("Node")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("nodeName"), V8Node::nodeNameAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("nodeValue"), V8Node::nodeValueAttrGetter, V8Node::nodeValueAttrSetter, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("nodeType"), V8Node::nodeTypeAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("parentNode"), V8Node::parentNodeAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("childNodes"), V8Node::childNodesAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("firstChild"), V8Node::firstChildAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("lastChild"), V8Node::lastChildAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("previousSibling"), V8Node::previousSiblingAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("nextSibling"), V8Node::nextSiblingAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("attributes"), V8Node::attributesAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("ownerDocument"), V8Node::ownerDocumentAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("namespaceURI"), V8Node::namespaceURIAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("prefix"), V8Node::prefixAttrGetter, V8Node::prefixAttrSetter, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("localName"), V8Node::localNameAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - prototype->Set(v8::String::NewSymbol("insertBefore"), - v8::FunctionTemplate::New(V8Node::insertBeforeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("replaceChild"), - v8::FunctionTemplate::New(V8Node::replaceChildCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("removeChild"), - v8::FunctionTemplate::New(V8Node::removeChildCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("appendChild"), - v8::FunctionTemplate::New(V8Node::appendChildCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasChildNodes"), - v8::FunctionTemplate::New(V8Node::hasChildNodesCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("cloneNode"), - v8::FunctionTemplate::New(V8Node::cloneNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("normalize"), - v8::FunctionTemplate::New(V8Node::normalizeCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("isSupported"), - v8::FunctionTemplate::New(V8Node::isSupportedCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("hasAttributes"), - v8::FunctionTemplate::New(V8Node::hasAttributesCallback, v8::Undefined()), static_cast(v8::DontDelete)); - - tmpl->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(3), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(3), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(4), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(4), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(5), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(5), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(6), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(6), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(7), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(7), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(8), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(8), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(9), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(9), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(10), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(10), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(11), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(11), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(12), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(12), static_cast(v8::ReadOnly | v8::DontEnum)); - - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + struct V8NodePrivate { + V8DOM* dom; + Arabica::DOM::Node* nativeObj; + }; + + V8_DESTRUCTOR(V8NodePrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle insertBeforeCallback(const v8::Arguments&); + static v8::Handle replaceChildCallback(const v8::Arguments&); + static v8::Handle removeChildCallback(const v8::Arguments&); + static v8::Handle appendChildCallback(const v8::Arguments&); + static v8::Handle hasChildNodesCallback(const v8::Arguments&); + static v8::Handle cloneNodeCallback(const v8::Arguments&); + static v8::Handle normalizeCallback(const v8::Arguments&); + static v8::Handle isSupportedCallback(const v8::Arguments&); + static v8::Handle hasAttributesCallback(const v8::Arguments&); + + static v8::Handle nodeNameAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle nodeValueAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static void nodeValueAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info); + static v8::Handle nodeTypeAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle parentNodeAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle childNodesAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle firstChildAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle lastChildAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle previousSiblingAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle nextSiblingAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle attributesAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle ownerDocumentAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle namespaceURIAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle prefixAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static void prefixAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info); + static v8::Handle localNameAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Node")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("nodeName"), V8Node::nodeNameAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("nodeValue"), V8Node::nodeValueAttrGetter, V8Node::nodeValueAttrSetter, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("nodeType"), V8Node::nodeTypeAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("parentNode"), V8Node::parentNodeAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("childNodes"), V8Node::childNodesAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("firstChild"), V8Node::firstChildAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("lastChild"), V8Node::lastChildAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("previousSibling"), V8Node::previousSiblingAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("nextSibling"), V8Node::nextSiblingAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("attributes"), V8Node::attributesAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("ownerDocument"), V8Node::ownerDocumentAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("namespaceURI"), V8Node::namespaceURIAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("prefix"), V8Node::prefixAttrGetter, V8Node::prefixAttrSetter, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("localName"), V8Node::localNameAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("insertBefore"), + v8::FunctionTemplate::New(V8Node::insertBeforeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("replaceChild"), + v8::FunctionTemplate::New(V8Node::replaceChildCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("removeChild"), + v8::FunctionTemplate::New(V8Node::removeChildCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("appendChild"), + v8::FunctionTemplate::New(V8Node::appendChildCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("hasChildNodes"), + v8::FunctionTemplate::New(V8Node::hasChildNodesCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("cloneNode"), + v8::FunctionTemplate::New(V8Node::cloneNodeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("normalize"), + v8::FunctionTemplate::New(V8Node::normalizeCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("isSupported"), + v8::FunctionTemplate::New(V8Node::isSupportedCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("hasAttributes"), + v8::FunctionTemplate::New(V8Node::hasAttributesCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + tmpl->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("ELEMENT_NODE"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("ATTRIBUTE_NODE"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(3), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("TEXT_NODE"), v8::Integer::New(3), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(4), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("CDATA_SECTION_NODE"), v8::Integer::New(4), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(5), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("ENTITY_REFERENCE_NODE"), v8::Integer::New(5), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(6), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("ENTITY_NODE"), v8::Integer::New(6), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(7), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("PROCESSING_INSTRUCTION_NODE"), v8::Integer::New(7), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(8), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("COMMENT_NODE"), v8::Integer::New(8), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(9), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("DOCUMENT_NODE"), v8::Integer::New(9), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(10), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("DOCUMENT_TYPE_NODE"), v8::Integer::New(10), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(11), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("DOCUMENT_FRAGMENT_NODE"), v8::Integer::New(11), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(12), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("NOTATION_NODE"), v8::Integer::New(12), static_cast(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp index bee706e..bc2afb5 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.cpp @@ -4,41 +4,41 @@ namespace Arabica { namespace DOM { -v8::Persistent V8NodeList::Tmpl; + v8::Persistent V8NodeList::Tmpl; -v8::Handle V8NodeList::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodeListPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8NodeList::lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodeListPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Integer::New(privData->nativeObj->getLength()); -} -v8::Handle V8NodeList::itemCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in item"); + return v8::Integer::New(privData->nativeObj->getLength()); + } + v8::Handle V8NodeList::itemCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in item"); - v8::Local self = args.Holder(); - struct V8NodeListPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); + v8::Local self = args.Holder(); + struct V8NodeListPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localIndex = args[0]->ToNumber()->Uint32Value(); - Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->item(localIndex)); - v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Node* retVal = new Arabica::DOM::Node(privData->nativeObj->item(localIndex)); + v8::Handle retCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Node::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Node::jsDestructor); + return retObj; -} + } -bool V8NodeList::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + bool V8NodeList::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h index 771d82c..667af40 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeList.h @@ -21,7 +21,9 @@ #ifndef V8NodeList_h #define V8NodeList_h +#include #include "DOM/Node.hpp" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -30,40 +32,42 @@ namespace DOM { class V8NodeList { public: - struct V8NodeListPrivate { - V8DOM* dom; - Arabica::DOM::NodeList* nativeObj; - }; + struct V8NodeListPrivate { + V8DOM* dom; + Arabica::DOM::NodeList* nativeObj; + }; - V8_DESTRUCTOR(V8NodeListPrivate); - static bool hasInstance(v8::Handle); + V8_DESTRUCTOR(V8NodeListPrivate); + static bool hasInstance(v8::Handle); - static v8::Handle itemCallback(const v8::Arguments&); + static v8::Handle itemCallback(const v8::Arguments&); - static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle lengthAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("NodeList")); - tmpl->ReadOnlyPrototype(); + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("NodeList")); + tmpl->ReadOnlyPrototype(); - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - instance->SetAccessor(v8::String::NewSymbol("length"), V8NodeList::lengthAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("length"), V8NodeList::lengthAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - prototype->Set(v8::String::NewSymbol("item"), - v8::FunctionTemplate::New(V8NodeList::itemCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("item"), + v8::FunctionTemplate::New(V8NodeList::itemCallback, v8::Undefined()), static_cast(v8::DontDelete)); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp index fade729..6f59a90 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.cpp @@ -3,35 +3,35 @@ namespace Arabica { namespace DOM { -v8::Persistent V8NodeSet::Tmpl; + v8::Persistent V8NodeSet::Tmpl; -v8::Handle V8NodeSet::sizeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodeSetPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8NodeSet::sizeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodeSetPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Integer::New(privData->nativeObj->size()); -} + return v8::Integer::New(privData->nativeObj->size()); + } -v8::Handle V8NodeSet::emptyAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NodeSetPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8NodeSet::emptyAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NodeSetPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Boolean::New(privData->nativeObj->empty()); -} -v8::Handle V8NodeSet::toDocumentOrderCallback(const v8::Arguments& args) { + return v8::Boolean::New(privData->nativeObj->empty()); + } + v8::Handle V8NodeSet::toDocumentOrderCallback(const v8::Arguments& args) { - v8::Local self = args.Holder(); - struct V8NodeSetPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Local self = args.Holder(); + struct V8NodeSetPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - privData->nativeObj->to_document_order(); + privData->nativeObj->to_document_order(); - return v8::Undefined(); -} + return v8::Undefined(); + } -bool V8NodeSet::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + bool V8NodeSet::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h index 294d851..78e4410 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8NodeSet.h @@ -21,7 +21,9 @@ #ifndef V8NodeSet_h #define V8NodeSet_h +#include #include "DOM/Node.hpp" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -30,45 +32,47 @@ namespace DOM { class V8NodeSet { public: - struct V8NodeSetPrivate { - V8DOM* dom; - Arabica::XPath::NodeSet* nativeObj; - }; - - V8_DESTRUCTOR(V8NodeSetPrivate); - static bool hasInstance(v8::Handle); - - static v8::Handle toDocumentOrderCallback(const v8::Arguments&); - - static v8::Handle sizeAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle emptyAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle indexedPropertyCustomGetter(uint32_t, const v8::AccessorInfo&); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("NodeSet")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("size"), V8NodeSet::sizeAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("empty"), V8NodeSet::emptyAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - instance->SetIndexedPropertyHandler(V8NodeSet::indexedPropertyCustomGetter, 0); - prototype->Set(v8::String::NewSymbol("toDocumentOrder"), - v8::FunctionTemplate::New(V8NodeSet::toDocumentOrderCallback, v8::Undefined()), static_cast(v8::DontDelete)); - - - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + struct V8NodeSetPrivate { + V8DOM* dom; + Arabica::XPath::NodeSet* nativeObj; + }; + + V8_DESTRUCTOR(V8NodeSetPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle toDocumentOrderCallback(const v8::Arguments&); + + static v8::Handle sizeAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle emptyAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle indexedPropertyCustomGetter(uint32_t, const v8::AccessorInfo&); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("NodeSet")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("size"), V8NodeSet::sizeAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("empty"), V8NodeSet::emptyAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + instance->SetIndexedPropertyHandler(V8NodeSet::indexedPropertyCustomGetter, 0); + prototype->Set(v8::String::NewSymbol("toDocumentOrder"), + v8::FunctionTemplate::New(V8NodeSet::toDocumentOrderCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp index 129563d..5ecdd10 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.cpp @@ -4,25 +4,25 @@ namespace Arabica { namespace DOM { -v8::Persistent V8Notation::Tmpl; + v8::Persistent V8Notation::Tmpl; -v8::Handle V8Notation::publicIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NotationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Notation::publicIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NotationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getPublicId().c_str()); -} + return v8::String::New(privData->nativeObj->getPublicId().c_str()); + } -v8::Handle V8Notation::systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8NotationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8Notation::systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8NotationPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getSystemId().c_str()); -} -bool V8Notation::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + return v8::String::New(privData->nativeObj->getSystemId().c_str()); + } + bool V8Notation::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h index ba90056..2102a24 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Notation.h @@ -21,8 +21,10 @@ #ifndef V8Notation_h #define V8Notation_h +#include #include "DOM/Node.hpp" #include "V8Node.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,41 +33,43 @@ namespace DOM { class V8Notation { public: - struct V8NotationPrivate { - V8DOM* dom; - Arabica::DOM::Notation* nativeObj; - }; + struct V8NotationPrivate { + V8DOM* dom; + Arabica::DOM::Notation* nativeObj; + }; - V8_DESTRUCTOR(V8NotationPrivate); - static bool hasInstance(v8::Handle); + V8_DESTRUCTOR(V8NotationPrivate); + static bool hasInstance(v8::Handle); - static v8::Handle publicIdAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle publicIdAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle systemIdAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("Notation")); - tmpl->ReadOnlyPrototype(); + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Notation")); + tmpl->ReadOnlyPrototype(); - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - instance->SetAccessor(v8::String::NewSymbol("publicId"), V8Notation::publicIdAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("systemId"), V8Notation::systemIdAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("publicId"), V8Notation::publicIdAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("systemId"), V8Notation::systemIdAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp index c6d2b28..f28a56d 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.cpp @@ -4,32 +4,32 @@ namespace Arabica { namespace DOM { -v8::Persistent V8ProcessingInstruction::Tmpl; + v8::Persistent V8ProcessingInstruction::Tmpl; -v8::Handle V8ProcessingInstruction::targetAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8ProcessingInstruction::targetAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getTarget().c_str()); -} + return v8::String::New(privData->nativeObj->getTarget().c_str()); + } -v8::Handle V8ProcessingInstruction::dataAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8ProcessingInstruction::dataAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->getData().c_str()); -} + return v8::String::New(privData->nativeObj->getData().c_str()); + } -void V8ProcessingInstruction::dataAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - v8::String::AsciiValue localData(value); - privData->nativeObj->setData(*localData); -} -bool V8ProcessingInstruction::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + void V8ProcessingInstruction::dataAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8ProcessingInstructionPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::String::AsciiValue localData(value); + privData->nativeObj->setData(*localData); + } + bool V8ProcessingInstruction::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h index 995d066..a588b1f 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8ProcessingInstruction.h @@ -21,8 +21,10 @@ #ifndef V8ProcessingInstruction_h #define V8ProcessingInstruction_h +#include #include "DOM/Node.hpp" #include "V8Node.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,42 +33,44 @@ namespace DOM { class V8ProcessingInstruction { public: - struct V8ProcessingInstructionPrivate { - V8DOM* dom; - Arabica::DOM::ProcessingInstruction* nativeObj; - }; + struct V8ProcessingInstructionPrivate { + V8DOM* dom; + Arabica::DOM::ProcessingInstruction* nativeObj; + }; - V8_DESTRUCTOR(V8ProcessingInstructionPrivate); - static bool hasInstance(v8::Handle); + V8_DESTRUCTOR(V8ProcessingInstructionPrivate); + static bool hasInstance(v8::Handle); - static v8::Handle targetAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle dataAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static void dataAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info); + static v8::Handle targetAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle dataAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static void dataAttrSetter(v8::Local property, v8::Local value, const v8::AccessorInfo& info); - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("ProcessingInstruction")); - tmpl->ReadOnlyPrototype(); + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("ProcessingInstruction")); + tmpl->ReadOnlyPrototype(); - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - instance->SetAccessor(v8::String::NewSymbol("target"), V8ProcessingInstruction::targetAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("data"), V8ProcessingInstruction::dataAttrGetter, V8ProcessingInstruction::dataAttrSetter, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("target"), V8ProcessingInstruction::targetAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("data"), V8ProcessingInstruction::dataAttrGetter, V8ProcessingInstruction::dataAttrSetter, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - tmpl->Inherit(V8Node::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8Node::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp index ed6133a..72c0651 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.cpp @@ -4,73 +4,73 @@ namespace Arabica { namespace DOM { -v8::Persistent V8SCXMLEvent::Tmpl; + v8::Persistent V8SCXMLEvent::Tmpl; -v8::Handle V8SCXMLEvent::typeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8SCXMLEvent::typeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Integer::New(privData->nativeObj->type); -} + return v8::Integer::New(privData->nativeObj->type); + } -v8::Handle V8SCXMLEvent::nameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8SCXMLEvent::nameAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->name.c_str()); -} + return v8::String::New(privData->nativeObj->name.c_str()); + } -v8::Handle V8SCXMLEvent::originAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8SCXMLEvent::originAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->origin.c_str()); -} + return v8::String::New(privData->nativeObj->origin.c_str()); + } -v8::Handle V8SCXMLEvent::origintypeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8SCXMLEvent::origintypeAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->origintype.c_str()); -} + return v8::String::New(privData->nativeObj->origintype.c_str()); + } -v8::Handle V8SCXMLEvent::domAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8SCXMLEvent::domAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - if (!privData->nativeObj->dom) return v8::Undefined(); - Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->dom); + if (!privData->nativeObj->dom) return v8::Undefined(); + Arabica::DOM::Node* arbaicaRet = new Arabica::DOM::Node(privData->nativeObj->dom); - v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); - v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); + v8::Handle arbaicaRetCtor = V8Node::getTmpl()->GetFunction(); + v8::Persistent arbaicaRetObj = v8::Persistent::New(arbaicaRetCtor->NewInstance()); - struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = arbaicaRet; + struct V8Node::V8NodePrivate* retPrivData = new V8Node::V8NodePrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = arbaicaRet; + + arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); + return arbaicaRetObj; - arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - arbaicaRetObj.MakeWeak(0, V8Node::jsDestructor); - return arbaicaRetObj; + } -} + v8::Handle V8SCXMLEvent::sendidAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); -v8::Handle V8SCXMLEvent::sendidAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + return v8::String::New(privData->nativeObj->sendid.c_str()); + } - return v8::String::New(privData->nativeObj->sendid.c_str()); -} + v8::Handle V8SCXMLEvent::invokeidAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); -v8::Handle V8SCXMLEvent::invokeidAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8SCXMLEventPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + return v8::String::New(privData->nativeObj->invokeid.c_str()); + } + bool V8SCXMLEvent::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } - return v8::String::New(privData->nativeObj->invokeid.c_str()); -} -bool V8SCXMLEvent::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} - -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h index 26ac8b6..a1c76c1 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8SCXMLEvent.h @@ -21,7 +21,9 @@ #ifndef V8SCXMLEvent_h #define V8SCXMLEvent_h +#include #include "DOM/Node.hpp" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -30,61 +32,63 @@ namespace DOM { class V8SCXMLEvent { public: - struct V8SCXMLEventPrivate { - V8DOM* dom; - uscxml::Event* nativeObj; - }; - - V8_DESTRUCTOR_KEEP_WRAPPED(V8SCXMLEventPrivate); - static bool hasInstance(v8::Handle); - - - static v8::Handle typeAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle nameAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle originAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle origintypeAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle domAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle sendidAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle invokeidAttrGetter(v8::Local property, const v8::AccessorInfo& info); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("SCXMLEvent")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("type"), V8SCXMLEvent::typeAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("name"), V8SCXMLEvent::nameAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("origin"), V8SCXMLEvent::originAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("origintype"), V8SCXMLEvent::origintypeAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("dom"), V8SCXMLEvent::domAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("sendid"), V8SCXMLEvent::sendidAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("invokeid"), V8SCXMLEvent::invokeidAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - - tmpl->Set(v8::String::NewSymbol("INTERNAL"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("INTERNAL"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("EXTERNAL"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("EXTERNAL"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); - tmpl->Set(v8::String::NewSymbol("PLATFORM"), v8::Integer::New(3), static_cast(v8::ReadOnly | v8::DontEnum)); - prototype->Set(v8::String::NewSymbol("PLATFORM"), v8::Integer::New(3), static_cast(v8::ReadOnly | v8::DontEnum)); - - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + struct V8SCXMLEventPrivate { + V8DOM* dom; + uscxml::Event* nativeObj; + }; + + V8_DESTRUCTOR(V8SCXMLEventPrivate); + static bool hasInstance(v8::Handle); + + + static v8::Handle typeAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle nameAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle originAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle origintypeAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle domAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle sendidAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle invokeidAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("SCXMLEvent")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("type"), V8SCXMLEvent::typeAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("name"), V8SCXMLEvent::nameAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("origin"), V8SCXMLEvent::originAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("origintype"), V8SCXMLEvent::origintypeAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("dom"), V8SCXMLEvent::domAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("sendid"), V8SCXMLEvent::sendidAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("invokeid"), V8SCXMLEvent::invokeidAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + + tmpl->Set(v8::String::NewSymbol("INTERNAL"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("INTERNAL"), v8::Integer::New(1), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("EXTERNAL"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("EXTERNAL"), v8::Integer::New(2), static_cast(v8::ReadOnly | v8::DontEnum)); + tmpl->Set(v8::String::NewSymbol("PLATFORM"), v8::Integer::New(3), static_cast(v8::ReadOnly | v8::DontEnum)); + prototype->Set(v8::String::NewSymbol("PLATFORM"), v8::Integer::New(3), static_cast(v8::ReadOnly | v8::DontEnum)); + + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp index 42b298a..fb027d5 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.cpp @@ -4,34 +4,34 @@ namespace Arabica { namespace DOM { -v8::Persistent V8Text::Tmpl; + v8::Persistent V8Text::Tmpl; -v8::Handle V8Text::splitTextCallback(const v8::Arguments& args) { - if (args.Length() < 1) - throw V8Exception("Wrong number of arguments in splitText"); + v8::Handle V8Text::splitTextCallback(const v8::Arguments& args) { + if (args.Length() < 1) + throw V8Exception("Wrong number of arguments in splitText"); - v8::Local self = args.Holder(); - struct V8TextPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); + v8::Local self = args.Holder(); + struct V8TextPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + unsigned long localOffset = args[0]->ToNumber()->Uint32Value(); - Arabica::DOM::Text* retVal = new Arabica::DOM::Text(privData->nativeObj->splitText(localOffset)); - v8::Handle retCtor = V8Text::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::DOM::Text* retVal = new Arabica::DOM::Text(privData->nativeObj->splitText(localOffset)); + v8::Handle retCtor = V8Text::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8Text::V8TextPrivate* retPrivData = new V8Text::V8TextPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8Text::V8TextPrivate* retPrivData = new V8Text::V8TextPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8Text::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8Text::jsDestructor); + return retObj; -} + } -bool V8Text::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + bool V8Text::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h index 4861dc8..bbf2577 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8Text.h @@ -21,8 +21,10 @@ #ifndef V8Text_h #define V8Text_h +#include #include "DOM/Node.hpp" #include "V8CharacterData.h" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -31,38 +33,40 @@ namespace DOM { class V8Text { public: - struct V8TextPrivate { - V8DOM* dom; - Arabica::DOM::Text* nativeObj; - }; + struct V8TextPrivate { + V8DOM* dom; + Arabica::DOM::Text* nativeObj; + }; - V8_DESTRUCTOR(V8TextPrivate); - static bool hasInstance(v8::Handle); + V8_DESTRUCTOR(V8TextPrivate); + static bool hasInstance(v8::Handle); - static v8::Handle splitTextCallback(const v8::Arguments&); + static v8::Handle splitTextCallback(const v8::Arguments&); - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("Text")); - tmpl->ReadOnlyPrototype(); + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("Text")); + tmpl->ReadOnlyPrototype(); - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); - prototype->Set(v8::String::NewSymbol("splitText"), - v8::FunctionTemplate::New(V8Text::splitTextCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("splitText"), + v8::FunctionTemplate::New(V8Text::splitTextCallback, v8::Undefined()), static_cast(v8::DontDelete)); - tmpl->Inherit(V8CharacterData::getTmpl()); - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + tmpl->Inherit(V8CharacterData::getTmpl()); + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp index 968e53d..38f69ae 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.cpp @@ -4,82 +4,82 @@ namespace Arabica { namespace DOM { -v8::Persistent V8XPathResult::Tmpl; + v8::Persistent V8XPathResult::Tmpl; -v8::Handle V8XPathResult::numberValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8XPathResult::numberValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Number::New(privData->nativeObj->asNumber()); -} + return v8::Number::New(privData->nativeObj->asNumber()); + } -v8::Handle V8XPathResult::stringValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8XPathResult::stringValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::String::New(privData->nativeObj->asString().c_str()); -} + return v8::String::New(privData->nativeObj->asString().c_str()); + } -v8::Handle V8XPathResult::booleanValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { - v8::Local self = info.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Handle V8XPathResult::booleanValueAttrGetter(v8::Local property, const v8::AccessorInfo& info) { + v8::Local self = info.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - return v8::Boolean::New(privData->nativeObj->asBool()); -} -v8::Handle V8XPathResult::asNodeSetCallback(const v8::Arguments& args) { + return v8::Boolean::New(privData->nativeObj->asBool()); + } + v8::Handle V8XPathResult::asNodeSetCallback(const v8::Arguments& args) { - v8::Local self = args.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Local self = args.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - Arabica::XPath::NodeSet* retVal = new Arabica::XPath::NodeSet(privData->nativeObj->asNodeSet()); - v8::Handle retCtor = V8NodeSet::getTmpl()->GetFunction(); - v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); + Arabica::XPath::NodeSet* retVal = new Arabica::XPath::NodeSet(privData->nativeObj->asNodeSet()); + v8::Handle retCtor = V8NodeSet::getTmpl()->GetFunction(); + v8::Persistent retObj = v8::Persistent::New(retCtor->NewInstance()); - struct V8NodeSet::V8NodeSetPrivate* retPrivData = new V8NodeSet::V8NodeSetPrivate(); - retPrivData->dom = privData->dom; - retPrivData->nativeObj = retVal; + struct V8NodeSet::V8NodeSetPrivate* retPrivData = new V8NodeSet::V8NodeSetPrivate(); + retPrivData->dom = privData->dom; + retPrivData->nativeObj = retVal; - retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); + retObj->SetInternalField(0, V8DOM::toExternal(retPrivData)); - retObj.MakeWeak(0, V8NodeSet::jsDestructor); - return retObj; + retObj.MakeWeak(0, V8NodeSet::jsDestructor); + return retObj; -} + } -v8::Handle V8XPathResult::asBoolCallback(const v8::Arguments& args) { + v8::Handle V8XPathResult::asBoolCallback(const v8::Arguments& args) { - v8::Local self = args.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Local self = args.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - bool retVal = privData->nativeObj->asBool(); + bool retVal = privData->nativeObj->asBool(); - return v8::Boolean::New(retVal); -} + return v8::Boolean::New(retVal); + } -v8::Handle V8XPathResult::asStringCallback(const v8::Arguments& args) { + v8::Handle V8XPathResult::asStringCallback(const v8::Arguments& args) { - v8::Local self = args.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Local self = args.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - std::string retVal = privData->nativeObj->asString(); + std::string retVal = privData->nativeObj->asString(); - return v8::String::New(retVal.c_str()); -} + return v8::String::New(retVal.c_str()); + } -v8::Handle V8XPathResult::asNumberCallback(const v8::Arguments& args) { + v8::Handle V8XPathResult::asNumberCallback(const v8::Arguments& args) { - v8::Local self = args.Holder(); - struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); + v8::Local self = args.Holder(); + struct V8XPathResultPrivate* privData = V8DOM::toClassPtr(self->GetInternalField(0)); - double retVal = privData->nativeObj->asNumber(); + double retVal = privData->nativeObj->asNumber(); - return v8::Number::New(retVal); -} + return v8::Number::New(retVal); + } -bool V8XPathResult::hasInstance(v8::Handle value) { - return getTmpl()->HasInstance(value); -} + bool V8XPathResult::hasInstance(v8::Handle value) { + return getTmpl()->HasInstance(value); + } -} -} +} +} diff --git a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h index 9a3bf4d..1fae618 100644 --- a/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h +++ b/src/uscxml/plugins/datamodel/ecmascript/v8/dom/V8XPathResult.h @@ -21,7 +21,9 @@ #ifndef V8XPathResult_h #define V8XPathResult_h +#include #include "DOM/Node.hpp" +#include "string" #include "uscxml/plugins/datamodel/ecmascript/v8/dom/V8DOM.h" #include @@ -30,58 +32,60 @@ namespace DOM { class V8XPathResult { public: - struct V8XPathResultPrivate { - V8DOM* dom; - Arabica::XPath::XPathValue* nativeObj; - }; - - V8_DESTRUCTOR(V8XPathResultPrivate); - static bool hasInstance(v8::Handle); - - static v8::Handle asNodeSetCallback(const v8::Arguments&); - static v8::Handle asBoolCallback(const v8::Arguments&); - static v8::Handle asStringCallback(const v8::Arguments&); - static v8::Handle asNumberCallback(const v8::Arguments&); - - static v8::Handle numberValueAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle stringValueAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle booleanValueAttrGetter(v8::Local property, const v8::AccessorInfo& info); - static v8::Handle singleNodeValueCustomAttrGetter(v8::Local property, const v8::AccessorInfo& info); - - static v8::Persistent Tmpl; - static v8::Handle getTmpl() { - if (Tmpl.IsEmpty()) { - v8::Handle tmpl = v8::FunctionTemplate::New(); - tmpl->SetClassName(v8::String::New("XPathResult")); - tmpl->ReadOnlyPrototype(); - - v8::Local instance = tmpl->InstanceTemplate(); - v8::Local prototype = tmpl->PrototypeTemplate(); - instance->SetInternalFieldCount(1); - - instance->SetAccessor(v8::String::NewSymbol("numberValue"), V8XPathResult::numberValueAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("stringValue"), V8XPathResult::stringValueAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("booleanValue"), V8XPathResult::booleanValueAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - instance->SetAccessor(v8::String::NewSymbol("singleNodeValue"), V8XPathResult::singleNodeValueCustomAttrGetter, 0, - v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); - - prototype->Set(v8::String::NewSymbol("asNodeSet"), - v8::FunctionTemplate::New(V8XPathResult::asNodeSetCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("asBool"), - v8::FunctionTemplate::New(V8XPathResult::asBoolCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("asString"), - v8::FunctionTemplate::New(V8XPathResult::asStringCallback, v8::Undefined()), static_cast(v8::DontDelete)); - prototype->Set(v8::String::NewSymbol("asNumber"), - v8::FunctionTemplate::New(V8XPathResult::asNumberCallback, v8::Undefined()), static_cast(v8::DontDelete)); - - - Tmpl = v8::Persistent::New(tmpl); - } - return Tmpl; - } + struct V8XPathResultPrivate { + V8DOM* dom; + Arabica::XPath::XPathValue* nativeObj; + }; + + V8_DESTRUCTOR(V8XPathResultPrivate); + static bool hasInstance(v8::Handle); + + static v8::Handle asNodeSetCallback(const v8::Arguments&); + static v8::Handle asBoolCallback(const v8::Arguments&); + static v8::Handle asStringCallback(const v8::Arguments&); + static v8::Handle asNumberCallback(const v8::Arguments&); + + static v8::Handle numberValueAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle stringValueAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle booleanValueAttrGetter(v8::Local property, const v8::AccessorInfo& info); + static v8::Handle singleNodeValueCustomAttrGetter(v8::Local property, const v8::AccessorInfo& info); + + static v8::Persistent Tmpl; + static v8::Handle getTmpl() { + if (Tmpl.IsEmpty()) { + v8::Handle tmpl = v8::FunctionTemplate::New(); + tmpl->SetClassName(v8::String::New("XPathResult")); + tmpl->ReadOnlyPrototype(); + + v8::Local instance = tmpl->InstanceTemplate(); + v8::Local prototype = tmpl->PrototypeTemplate(); + (void)prototype; // surpress unused warnings + + instance->SetInternalFieldCount(1); + + instance->SetAccessor(v8::String::NewSymbol("numberValue"), V8XPathResult::numberValueAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("stringValue"), V8XPathResult::stringValueAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("booleanValue"), V8XPathResult::booleanValueAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + instance->SetAccessor(v8::String::NewSymbol("singleNodeValue"), V8XPathResult::singleNodeValueCustomAttrGetter, 0, + v8::External::New(0), static_cast(v8::DEFAULT), static_cast(v8::None)); + + prototype->Set(v8::String::NewSymbol("asNodeSet"), + v8::FunctionTemplate::New(V8XPathResult::asNodeSetCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("asBool"), + v8::FunctionTemplate::New(V8XPathResult::asBoolCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("asString"), + v8::FunctionTemplate::New(V8XPathResult::asStringCallback, v8::Undefined()), static_cast(v8::DontDelete)); + prototype->Set(v8::String::NewSymbol("asNumber"), + v8::FunctionTemplate::New(V8XPathResult::asNumberCallback, v8::Undefined()), static_cast(v8::DontDelete)); + + + Tmpl = v8::Persistent::New(tmpl); + } + return Tmpl; + } }; diff --git a/src/uscxml/plugins/element/fetch/FetchElement.cpp b/src/uscxml/plugins/element/fetch/FetchElement.cpp new file mode 100644 index 0000000..33cb76e --- /dev/null +++ b/src/uscxml/plugins/element/fetch/FetchElement.cpp @@ -0,0 +1,108 @@ +#include "FetchElement.h" +#include + +#include +#include + +#ifdef BUILD_AS_PLUGINS +#include +#endif + +namespace uscxml { + +#ifdef BUILD_AS_PLUGINS +PLUMA_CONNECTOR +bool connect(pluma::Host& host) { + host.add( new FetchElementProvider() ); + return true; +} +#endif + +boost::shared_ptr FetchElement::create(Interpreter* interpreter) { + boost::shared_ptr invoker = boost::shared_ptr(new FetchElement()); + invoker->_interpreter = interpreter; + return invoker; +} + +FetchElement::~FetchElement() { + URLFetcher::breakURL(_targetUrl); +} + +void FetchElement::downloadCompleted(const URL& url) { + Event event; + event.name = _callback; + + std::string content = url.getInContent(); + std::map headerFields = url.getInHeaderFields(); + + if (false) { + } else if (boost::iequals(_type, "text")) { + event.data.atom = content; + event.data.type = Data::VERBATIM; + } else if (boost::iequals(_type, "url")) { + } else if (boost::iequals(_type, "json")) { + event.data = Data::fromJSON(content); + } else if (boost::iequals(_type, "xml")) { + event = Event::fromXML(content); + } + + _interpreter->receive(event); + +} + +void FetchElement::downloadFailed(const URL& url, int errorCode) { + Event event; + event.name = _callback + ".failed"; + + _interpreter->receive(event); + +} + +void FetchElement::enterElement(const Arabica::DOM::Node& node) { + if (!HAS_ATTR(node, "target") && !HAS_ATTR(node, "targetexpr")) { + LOG(ERROR) << "Fetch element requires target or targetexpr"; + return; + } + if (HAS_ATTR(node, "targetexpr") && !_interpreter->getDataModel()) { + LOG(ERROR) << "Fetch element with targetexpr requires datamodel"; + return; + } + _target = (HAS_ATTR(node, "target") ? ATTR(node, "target") : _interpreter->getDataModel().evalAsString(ATTR(node, "targetexpr"))); + + if (!HAS_ATTR(node, "callback") && !HAS_ATTR(node, "callbackexpr")) { + LOG(ERROR) << "Fetch element requires callback or callbackexpr"; + return; + } + if (HAS_ATTR(node, "callbackexpr") && !_interpreter->getDataModel()) { + LOG(ERROR) << "Fetch element with callbackexpr requires datamodel"; + return; + } + _callback = (HAS_ATTR(node, "callback") ? ATTR(node, "callback") : _interpreter->getDataModel().evalAsString(ATTR(node, "callbackexpr"))); + + _type = (HAS_ATTR(node, "type") ? ATTR(node, "type") : "text"); + if (!boost::iequals(_type, "text") && + !boost::iequals(_type, "url") && + !boost::iequals(_type, "json") && + !boost::iequals(_type, "xml")) { + LOG(ERROR) << "Fetch element type attribute not one of text, url, json, xml."; + return; + } + + _targetUrl = URL(_target); + if (!_targetUrl.isAbsolute()) { + if (!_interpreter->toAbsoluteURI(_targetUrl)) { + LOG(ERROR) << "Cannot transform " << _target << " into absolute URL"; + return; + } + } + + _targetUrl.addMonitor(this); + URLFetcher::fetchURL(_targetUrl); + +} + +void FetchElement::exitElement(const Arabica::DOM::Node& node) { + +} + +} \ No newline at end of file diff --git a/src/uscxml/plugins/element/fetch/FetchElement.h b/src/uscxml/plugins/element/fetch/FetchElement.h new file mode 100644 index 0000000..0229048 --- /dev/null +++ b/src/uscxml/plugins/element/fetch/FetchElement.h @@ -0,0 +1,48 @@ +#ifndef FETCHELEMENT_H_R6GH94FV +#define FETCHELEMENT_H_R6GH94FV + +#include + +#ifdef BUILD_AS_PLUGINS +#include "uscxml/plugins/Plugins.h" +#endif + +namespace uscxml { + +class FetchElement : public ExecutableContentImpl, public URLMonitor { +public: + FetchElement() {} + virtual ~FetchElement(); + boost::shared_ptr create(Interpreter* interpreter); + + std::string getLocalName() { + return "fetch"; + } + + std::string getNamespace() { + return "http://www.w3.org/2005/07/scxml"; + } + + bool processChildren() { + return false; + } + + void enterElement(const Arabica::DOM::Node& node); + void exitElement(const Arabica::DOM::Node& node); + void downloadCompleted(const URL& url); + void downloadFailed(const URL& url, int errorCode); + +protected: + URL _targetUrl; + std::string _target; + std::string _callback; + std::string _type; +}; + +#ifdef BUILD_AS_PLUGINS +PLUMA_INHERIT_PROVIDER(FetchElement, Element); +#endif + +} + +#endif /* end of include guard: FETCHELEMENT_H_R6GH94FV */ diff --git a/src/uscxml/plugins/element/response/ResponseElement.cpp b/src/uscxml/plugins/element/response/ResponseElement.cpp new file mode 100644 index 0000000..ce25036 --- /dev/null +++ b/src/uscxml/plugins/element/response/ResponseElement.cpp @@ -0,0 +1,68 @@ +#include "ResponseElement.h" +#include "uscxml/plugins/invoker/http/HTTPServletInvoker.h" +#include + +#ifdef BUILD_AS_PLUGINS +#include +#endif + +namespace uscxml { + +#ifdef BUILD_AS_PLUGINS +PLUMA_CONNECTOR +bool connect(pluma::Host& host) { + host.add( new ResponseElementProvider() ); + return true; +} +#endif + +boost::shared_ptr ResponseElement::create(Interpreter* interpreter) { + boost::shared_ptr invoker = boost::shared_ptr(new ResponseElement()); + invoker->_interpreter = interpreter; + return invoker; +} + +void ResponseElement::enterElement(const Arabica::DOM::Node& node) { + if (!HAS_ATTR(node, "request") && !HAS_ATTR(node, "requestexpr")) { + LOG(ERROR) << "Response element requires request or requestexpr"; + return; + } + if (HAS_ATTR(node, "requestexpr") && !_interpreter->getDataModel()) { + LOG(ERROR) << "Response element with requestexpr requires datamodel"; + return; + } + if (HAS_ATTR(node, "close")) { + + } + + std::string requestId = (HAS_ATTR(node, "request") ? ATTR(node, "request") : _interpreter->getDataModel().evalAsString(ATTR(node, "requestexpr"))); + + HTTPServletInvoker* servlet = _interpreter->getHTTPServlet(); + tthread::lock_guard lock(servlet->getMutex()); + + if (servlet->getRequests().find(requestId) == servlet->getRequests().end()) { + LOG(ERROR) << "No matching HTTP request for response element"; + return; + } + + std::string statusStr = (HAS_ATTR(node, "status") ? ATTR(node, "status") : "200"); + if (!isNumeric(statusStr.c_str(), 10)) { + LOG(ERROR) << "Response element with non-numeric status " << statusStr; + return; + } + int status = strTo(statusStr); + + HTTPServer::Request httpReq = servlet->getRequests()[requestId]; + + HTTPServer::Reply httpReply(httpReq); + httpReply.status = status; + + HTTPServer::reply(httpReply); + servlet->getRequests().erase(requestId); +} + +void ResponseElement::exitElement(const Arabica::DOM::Node& node) { + +} + +} \ No newline at end of file diff --git a/src/uscxml/plugins/element/response/ResponseElement.h b/src/uscxml/plugins/element/response/ResponseElement.h new file mode 100644 index 0000000..97ff9db --- /dev/null +++ b/src/uscxml/plugins/element/response/ResponseElement.h @@ -0,0 +1,42 @@ +#ifndef RESPONSEELEMENT_H_I11KQ39Q +#define RESPONSEELEMENT_H_I11KQ39Q + +#include + +#ifdef BUILD_AS_PLUGINS +#include "uscxml/plugins/Plugins.h" +#endif + +namespace uscxml { + +class ResponseElement : public ExecutableContentImpl { +public: + ResponseElement() {} + virtual ~ResponseElement() {} + boost::shared_ptr create(Interpreter* interpreter); + + std::string getLocalName() { + return "response"; + } + + std::string getNamespace() { + return "http://www.w3.org/2005/07/scxml"; + } + + bool processChildren() { + return false; + } + + void enterElement(const Arabica::DOM::Node& node); + void exitElement(const Arabica::DOM::Node& node); + +}; + +#ifdef BUILD_AS_PLUGINS +PLUMA_INHERIT_PROVIDER(ResponseElement, Element); +#endif + +} + + +#endif /* end of include guard: RESPONSEELEMENT_H_I11KQ39Q */ diff --git a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp index 8489d1d..2d308ce 100644 --- a/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp +++ b/src/uscxml/plugins/invoker/filesystem/dirmon/DirMonInvoker.cpp @@ -116,13 +116,13 @@ void DirMonInvoker::handleFileAction(FW::WatchID watchid, const FW::String& dir, break; } - event.compound["file"].compound["name"] = Data(filename, Data::VERBATIM); - event.compound["file"].compound["dir"] = Data(dir, Data::VERBATIM); + event.data.compound["file"].compound["name"] = Data(filename, Data::VERBATIM); + event.data.compound["file"].compound["dir"] = Data(dir, Data::VERBATIM); - event.compound["file"].compound["mtime"] = toStr(fileStat.st_mtime); - event.compound["file"].compound["ctime"] = toStr(fileStat.st_ctime); - event.compound["file"].compound["atime"] = toStr(fileStat.st_atime); - event.compound["file"].compound["size"] = toStr(fileStat.st_size); + event.data.compound["file"].compound["mtime"] = toStr(fileStat.st_mtime); + event.data.compound["file"].compound["ctime"] = toStr(fileStat.st_ctime); + event.data.compound["file"].compound["atime"] = toStr(fileStat.st_atime); + event.data.compound["file"].compound["size"] = toStr(fileStat.st_size); returnEvent(event); } @@ -158,8 +158,8 @@ void DirMonInvoker::reportExistingIn(const std::string dir, FW::WatchID watchid) if (boost::iequals(dname, ".") || boost::iequals(dname, "..")) continue; - char* filename; - asprintf(&filename, "%s/%s", dir.c_str(), dname.c_str()); + char* filename = (char*)malloc(dir.size() + dname.size() + 2); + sprintf(filename, "%s/%s", dir.c_str(), dname.c_str()); struct stat fileStat; if (stat(filename, &fileStat) != 0) { diff --git a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp new file mode 100644 index 0000000..40f8b66 --- /dev/null +++ b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.cpp @@ -0,0 +1,147 @@ +#include "HTTPServletInvoker.h" +#include + +#ifdef BUILD_AS_PLUGINS +#include +#endif + +namespace uscxml { + +#ifdef BUILD_AS_PLUGINS +PLUMA_CONNECTOR +bool connect(pluma::Host& host) { + host.add( new HTTPServletInvokerProvider() ); + return true; +} +#endif + +HTTPServletInvoker::HTTPServletInvoker() { + _isInterpreterGlobal = false; +} + +HTTPServletInvoker::HTTPServletInvoker(Interpreter* interpreter) { + _isInterpreterGlobal = true; + _interpreter = interpreter; + std::stringstream path; + path << _interpreter->getName(); + int i = 2; + while(!HTTPServer::registerServlet(path.str(), this)) { + path.clear(); + path.str(); + path << _interpreter->getName() << toStr(i++); + } +} + +HTTPServletInvoker::~HTTPServletInvoker() { + HTTPServer::unregisterServlet(this); + +}; + +boost::shared_ptr HTTPServletInvoker::create(Interpreter* interpreter) { + boost::shared_ptr invoker = boost::shared_ptr(new HTTPServletInvoker()); + invoker->_interpreter = interpreter; + return invoker; +} + +Data HTTPServletInvoker::getDataModelVariables() { + Data data; + assert(_url.length() > 0); + data.compound["location"] = Data(_url, Data::VERBATIM); + return data; +} + +void HTTPServletInvoker::send(const SendRequest& req) { + assert(!_isInterpreterGlobal); + + if (req.name.find("reply.", 0, req.name.length())) { + // this is a reply + const std::string requestId = req.name.substr(6); + if (_requests.find(requestId) == _requests.end()) { + LOG(ERROR) << "Replying to non existing request " << requestId; + return; + } + + HTTPServer::Request httpRequest = _requests[requestId]; + HTTPServer::Reply httpReply(httpRequest); + httpReply.content = req.content; + + std::map::const_iterator nameListIter = req.namelist.begin(); + while(nameListIter != req.namelist.end()) { + httpReply.headers[nameListIter->first] = nameListIter->second; + nameListIter++; + } + + std::multimap::const_iterator paramIter = req.params.begin(); + while(paramIter != req.params.end()) { + httpReply.headers[paramIter->first] = paramIter->second; + paramIter++; + } + + HTTPServer::reply(httpReply); + return; + } +} + +void HTTPServletInvoker::cancel(const std::string sendId) { + assert(!_isInterpreterGlobal); +} + +void HTTPServletInvoker::invoke(const InvokeRequest& req) { + assert(!_isInterpreterGlobal); + + _invokeId = req.invokeid; + if (req.params.find("path") == req.params.end()) { + LOG(ERROR) << "Path parameter required with httpserver"; + } + _path = (*req.params.find("path")).second; + + if (req.params.find("callback") != req.params.end()) { + _callback = (*req.params.find("callback")).second; + } else { + _callback = _path; + std::replace(_callback.begin(), _callback.end(), '/', '.'); + } + + if (!HTTPServer::registerServlet(_path, this)) { + LOG(ERROR) << "Cannot register http servlet at " << _path << ": " << " already taken"; + } +} + +/** + * Receive a request and deliver it to the interpreter + */ +void HTTPServletInvoker::httpRecvRequest(const HTTPServer::Request& req) { + tthread::lock_guard lock(_mutex); + +// evhttp_request_own(req.curlReq); + + _requests[toStr((uintptr_t)req.curlReq)] = req; + + Event event; + + if (_isInterpreterGlobal) { + event.name = "http." + req.type; + event.origin = toStr((uintptr_t)req.curlReq); + } else { + event.name = _callback; + event.data.compound["reqId"] = Data(toStr((uintptr_t)req.curlReq), Data::VERBATIM); + } + + std::map::const_iterator headerIter = req.headers.begin(); + while(headerIter != req.headers.end()) { + event.data.compound["headers"].compound[headerIter->first] = Data(headerIter->second, Data::VERBATIM); + headerIter++; + } + + event.data.compound["content"] = Data(req.content, Data::VERBATIM); + event.data.compound["type"] = Data(req.type, Data::VERBATIM); + + returnEvent(event); + +} + +std::string HTTPServletInvoker::getPath() { + return _path; +} + +} \ No newline at end of file diff --git a/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h new file mode 100644 index 0000000..1d667de --- /dev/null +++ b/src/uscxml/plugins/invoker/http/HTTPServletInvoker.h @@ -0,0 +1,55 @@ +#ifndef HTTPSERVERINVOKER_H_OAAWX8NF +#define HTTPSERVERINVOKER_H_OAAWX8NF + +#include +#include + +#ifdef BUILD_AS_PLUGINS +#include "uscxml/plugins/Plugins.h" +#endif + +namespace uscxml { + +class HTTPServletInvoker : public InvokerImpl, public HTTPServlet { +public: + HTTPServletInvoker(); + HTTPServletInvoker(Interpreter* interpreter); + virtual ~HTTPServletInvoker(); + virtual boost::shared_ptr create(Interpreter* interpreter); + + virtual std::set getNames() { + std::set names; + names.insert("httpserver"); + names.insert("http://uscxml.tk.informatik.tu-darmstadt.de/#httpserver"); + return names; + } + + virtual Data getDataModelVariables(); + virtual void send(const SendRequest& req); + virtual void cancel(const std::string sendId); + virtual void invoke(const InvokeRequest& req); + + // HTTPServlet + virtual void httpRecvRequest(const HTTPServer::Request& req); + virtual std::string getPath(); + virtual void setURL(const std::string& url) { _url = url; } + + tthread::recursive_mutex& getMutex() { return _mutex; } + std::map& getRequests() { return _requests; } + +protected: + tthread::recursive_mutex _mutex; + std::map _requests; + std::string _path; + std::string _callback; + std::string _url; + bool _isInterpreterGlobal; +}; + +#ifdef BUILD_AS_PLUGINS +PLUMA_INHERIT_PROVIDER(HTTPServletInvoker, Invoker); +#endif + +} + +#endif /* end of include guard: HTTPSERVERINVOKER_H_OAAWX8NF */ diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp index 1e15865..4005d03 100644 --- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp +++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.cpp @@ -77,7 +77,7 @@ void UmundoInvoker::send(const SendRequest& req) { Event event; void* rv = NULL; stub->callStubMethod(req.name, pbMsg, type, rv, ""); - protobufToData(event, *(const google::protobuf::Message*)rv); + protobufToData(event.data, *(const google::protobuf::Message*)rv); event.name = _invokeId + ".reply." + req.name; event.origin = msg->getMeta("um.channel"); @@ -162,9 +162,9 @@ void UmundoInvoker::invoke(const InvokeRequest& req) { } else if (serviceName.length() > 0) { // use umundo to access services - _svcFilter = umundo::ServiceFilter(serviceName); - _node->connect(&_svcMgr); - _svcMgr.startQuery(_svcFilter, this); + _svcFilter = new umundo::ServiceFilter(serviceName); + _node->connect(_svcMgr); + _svcMgr->startQuery(*_svcFilter, this); } } @@ -185,13 +185,13 @@ void UmundoInvoker::receive(void* object, umundo::Message* msg) { // event.compound["class"] = msg->getMeta("um.s11n.type"); if (object != NULL) - protobufToData(event, *(const google::protobuf::Message*)object); + protobufToData(event.data, *(const google::protobuf::Message*)object); // get meta fields into event std::map::const_iterator metaIter = msg->getMeta().begin(); while(metaIter != msg->getMeta().end()) { if (metaIter->first.substr(0,3).compare("um.") != 0) - event.compound[metaIter->first] = Data(metaIter->second, Data::VERBATIM); + event.data.compound[metaIter->first] = Data(metaIter->second, Data::VERBATIM); metaIter++; } @@ -213,7 +213,7 @@ void UmundoInvoker::added(umundo::ServiceDescription desc) { std::map::const_iterator propIter = desc.getProperties().begin(); while(propIter != desc.getProperties().end()) { - addedEvent.compound[propIter->first] = Data(propIter->second, Data::VERBATIM); + addedEvent.data.compound[propIter->first] = Data(propIter->second, Data::VERBATIM); propIter++; } @@ -239,7 +239,7 @@ void UmundoInvoker::removed(umundo::ServiceDescription desc) { std::map::const_iterator propIter = desc.getProperties().begin(); while(propIter != desc.getProperties().end()) { - addedEvent.compound[propIter->first] = Data(propIter->second, Data::VERBATIM); + addedEvent.data.compound[propIter->first] = Data(propIter->second, Data::VERBATIM); propIter++; } diff --git a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h index f03006b..a7f45f1 100644 --- a/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h +++ b/src/uscxml/plugins/invoker/umundo/UmundoInvoker.h @@ -1,12 +1,12 @@ #ifndef UMUNDOINVOKER_H_77YXQGU7 #define UMUNDOINVOKER_H_77YXQGU7 +#include +#include #include #include #include #include -#include -#include #ifdef BUILD_AS_PLUGINS #include "uscxml/plugins/Plugins.h" @@ -51,8 +51,8 @@ protected: umundo::TypedPublisher* _pub; umundo::TypedSubscriber* _sub; - umundo::ServiceFilter _svcFilter; - umundo::ServiceManager _svcMgr; + umundo::ServiceFilter* _svcFilter; + umundo::ServiceManager* _svcMgr; std::map _svcs; static std::multimap > _nodes; diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp index 98d08b3..ed51ef8 100644 --- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp +++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.cpp @@ -40,32 +40,25 @@ EventIOProcessor::EventIOProcessor() { } EventIOProcessor::~EventIOProcessor() { - _asyncQueue.stop(); - evdns_base_free(_dns, 1); - EventIOServer* httpServer = EventIOServer::getInstance(); - httpServer->unregisterProcessor(this); + HTTPServer* httpServer = HTTPServer::getInstance(); + httpServer->unregisterServlet(this); } + boost::shared_ptr EventIOProcessor::create(Interpreter* interpreter) { boost::shared_ptr io = boost::shared_ptr(new EventIOProcessor()); io->_interpreter = interpreter; - io->_dns = evdns_base_new(io->_asyncQueue._eventLoop, 1); - assert(io->_dns); - assert(evdns_base_count_nameservers(io->_dns) > 0); - // register at http server - EventIOServer* httpServer = EventIOServer::getInstance(); - httpServer->registerProcessor(io.get()); + std::string path = interpreter->getName(); + path += "/basichttp"; + if (!HTTPServer::registerServlet(path, io.get())) { + LOG(ERROR) << "Cannot register basichttp ioprocessor at " << path << ": " << " already taken"; + } - io->start(); return io; } -void EventIOProcessor::start() { - _asyncQueue.start(); -} - Data EventIOProcessor::getDataModelVariables() { Data data; assert(_url.length() > 0); @@ -73,335 +66,107 @@ Data EventIOProcessor::getDataModelVariables() { return data; } - -void EventIOProcessor::send(const SendRequest& req) { - - _sendData[req.sendid] = new SendData(); - _sendData[req.sendid]->scxmlReq = req; - _sendData[req.sendid]->ioProcessor = this; - - int err = 0; - char uriBuf[1024]; - - struct evhttp_uri* targetURI = evhttp_uri_parse(_sendData[req.sendid]->scxmlReq.target.c_str()); - if (evhttp_uri_get_port(targetURI) < 0) - evhttp_uri_set_port(targetURI, 80); - const char* hostName = evhttp_uri_get_host(targetURI); - - // use synchronous dns resolving for multicast dns - if(hostName && strlen(hostName) >= strlen(".local")) { - if(strcmp(hostName + strlen(hostName) - strlen(".local"), ".local") == 0) { - evhttp_uri_set_host(targetURI, EventIOServer::syncResolve(hostName).c_str()) && LOG(ERROR) << "evhttp_uri_set_host: " << strerror(errno); - } +void EventIOProcessor::httpRecvRequest(const HTTPServer::Request& req) { + Event reqEvent; + reqEvent.type = Event::EXTERNAL; + bool scxmlStructFound = false; + + std::map::const_iterator headerIter = req.headers.begin(); + while(headerIter != req.headers.end()) { + if (boost::iequals("_scxmleventstruct", headerIter->first)) { + reqEvent = Event::fromXML(evhttp_decode_uri(headerIter->second.c_str())); + scxmlStructFound = true; + break; + } else if (boost::iequals("_scxmleventname", headerIter->first)) { + reqEvent.name = evhttp_decode_uri(headerIter->second.c_str()); + } else { + reqEvent.data.compound[headerIter->first] = Data(evhttp_decode_uri(headerIter->second.c_str()), Data::VERBATIM); + } + headerIter++; + } + + if (reqEvent.name.length() == 0) + reqEvent.name = req.type; + + if (!scxmlStructFound) { + // get content into event + reqEvent.data.compound["content"] = Data(req.content, Data::VERBATIM); } - evhttp_uri_join(targetURI, uriBuf, 1024) || LOG(ERROR) << "evhttp_uri_join: " << strerror(errno); - LOG(INFO) << "URI for send request: " << uriBuf << std::endl; - - int port = evhttp_uri_get_port(targetURI); - if (port <= 0) - port = 80; - - std::stringstream ssEndPoint; - ssEndPoint << evhttp_uri_get_host(targetURI) << ":" << port; - std::string endPoint = ssEndPoint.str(); - - std::stringstream ssLocalURI; - ssLocalURI << evhttp_uri_get_path(targetURI) << evhttp_uri_get_fragment(targetURI); - std::string localURI = ssLocalURI.str(); + + returnEvent(reqEvent); + evhttp_send_reply(req.curlReq, 200, "OK", NULL); +} - if (_httpConnections.find(endPoint) == _httpConnections.end()) { - struct evhttp_connection* conn = evhttp_connection_base_new(_asyncQueue._eventLoop, _dns, evhttp_uri_get_host(targetURI), evhttp_uri_get_port(targetURI)); - evhttp_connection_set_retries(conn, 3); - _httpConnections[endPoint] = conn; - } +void EventIOProcessor::send(const SendRequest& req) { - struct evhttp_connection* httpConn = _httpConnections[endPoint]; - struct evhttp_request* httpReq = evhttp_request_new(EventIOServer::httpSendReqDoneCallback, _sendData[req.sendid]); + std::string target = req.target; + URL targetURL(target); - // event name + // event name if (req.name.size() > 0) { - evhttp_add_header(evhttp_request_get_output_headers(httpReq), "_scxmleventname", evhttp_encode_uri(req.name.c_str())) && LOG(ERROR) << "evhttp_add_header: " << strerror(errno); + targetURL.addOutHeader("_scxmleventname", evhttp_encode_uri(req.name.c_str())); } - // event namelist + // event namelist if (req.namelist.size() > 0) { std::map::const_iterator namelistIter = req.namelist.begin(); while (namelistIter != req.namelist.end()) { - evhttp_add_header(evhttp_request_get_output_headers(httpReq), - namelistIter->first.c_str(), - evhttp_encode_uri(namelistIter->second.c_str())) - && LOG(ERROR) << "evhttp_add_header: " << strerror(errno); + targetURL.addOutHeader(namelistIter->first, namelistIter->second); namelistIter++; } } - // event params + // event params if (req.params.size() > 0) { std::multimap::const_iterator paramIter = req.params.begin(); while (paramIter != req.params.end()) { -// LOG(INFO) << paramIter->first << " = " << paramIter->second << std::endl; - evhttp_add_header(evhttp_request_get_output_headers(httpReq), - paramIter->first.c_str(), - evhttp_encode_uri(paramIter->second.c_str())) - && LOG(ERROR) << "evhttp_add_header: " << strerror(errno); + targetURL.addOutHeader(paramIter->first, paramIter->second); paramIter++; } } - + // content if (req.content.size() > 0) - evbuffer_add(evhttp_request_get_output_buffer(httpReq), req.content.c_str(), req.content.size()) && LOG(ERROR) << "evbuffer_add: " << strerror(errno); - -#if 0 - evhttp_add_header(evhttp_request_get_output_headers(httpReq), "_scxmleventstruct", evhttp_encode_uri(req.toXMLString().c_str())); -#endif - // required as per http 1.1 RFC2616 section 14.23 - evhttp_add_header(evhttp_request_get_output_headers(httpReq), "Host", evhttp_uri_get_host(targetURI)) && LOG(ERROR) << "evhttp_add_header: " << strerror(errno); - - _httpRequests[req.sendid] = httpReq; - err = evhttp_make_request(httpConn, - httpReq, - EVHTTP_REQ_POST, localURI.c_str()); - if (err) { - LOG(ERROR) << "Could not make http request to " << req.target; - } -} + targetURL.setOutContent(req.content); -void EventIOProcessor::httpSendReqDone(struct SendData* sendData) { - if (sendData->httpReq == NULL || evhttp_request_get_response_code(sendData->httpReq) != 200) { - Event failureEvent; - failureEvent.name = "error.communication"; - sendData->ioProcessor->returnEvent(failureEvent); + targetURL.setRequestType("post"); + targetURL.addMonitor(this); + + _sendRequests[req.sendid] = std::make_pair(targetURL, req); + URLFetcher::fetchURL(targetURL); +} + +void EventIOProcessor::downloadStarted(const URL& url) {} + +void EventIOProcessor::downloadCompleted(const URL& url) { + std::map >::iterator reqIter = _sendRequests.begin(); + while(reqIter != _sendRequests.end()) { + if (reqIter->second.first == url) { + _sendRequests.erase(reqIter); + return; + } + reqIter++; } - delete _sendData[sendData->scxmlReq.sendid]; -} - -void EventIOProcessor::httpRecvReq(struct evhttp_request *req) { - - const char *cmdtype; - struct evkeyvalq *headers; - struct evkeyval *header; - struct evbuffer *buf; - - switch (evhttp_request_get_command(req)) { - case EVHTTP_REQ_GET: - cmdtype = "GET"; - break; - case EVHTTP_REQ_POST: - cmdtype = "POST"; - break; - case EVHTTP_REQ_HEAD: - cmdtype = "HEAD"; - break; - case EVHTTP_REQ_PUT: - cmdtype = "PUT"; - break; - case EVHTTP_REQ_DELETE: - cmdtype = "DELETE"; - break; - case EVHTTP_REQ_OPTIONS: - cmdtype = "OPTIONS"; - break; - case EVHTTP_REQ_TRACE: - cmdtype = "TRACE"; - break; - case EVHTTP_REQ_CONNECT: - cmdtype = "CONNECT"; - break; - case EVHTTP_REQ_PATCH: - cmdtype = "PATCH"; - break; - default: - cmdtype = "unknown"; - break; - } - - Event reqEvent; - reqEvent.type = Event::EXTERNAL; - bool scxmlStructFound = false; - - // map headers to event structure - headers = evhttp_request_get_input_headers(req); - for (header = headers->tqh_first; header; - header = header->next.tqe_next) { -// std::cout << "Header: " << header->key << std::endl; -// std::cout << "Value: " << evhttp_decode_uri(header->value) << std::endl; - if (boost::iequals("_scxmleventstruct", header->key)) { - reqEvent = Event::fromXML(evhttp_decode_uri(header->value)); - scxmlStructFound = true; - break; - } else if (boost::iequals("_scxmleventname", header->key)) { - reqEvent.name = evhttp_decode_uri(header->value); - } else { - reqEvent.compound[header->key] = Data(evhttp_decode_uri(header->value), Data::VERBATIM); - } - } - - if (reqEvent.name.length() == 0) - reqEvent.name = cmdtype; - - if (!scxmlStructFound) { - // get content into event - std::string content; - buf = evhttp_request_get_input_buffer(req); - while (evbuffer_get_length(buf)) { - int n; - char cbuf[128]; - n = evbuffer_remove(buf, cbuf, sizeof(buf)-1); - if (n > 0) { - content.append(cbuf, n); - } - } - reqEvent.compound["content"] = Data(content, Data::VERBATIM); - } - - returnEvent(reqEvent); - evhttp_send_reply(req, 200, "OK", NULL); -} - -EventIOServer::EventIOServer(unsigned short port) { - _port = port; - _base = event_base_new(); - _http = evhttp_new(_base); - _handle = NULL; - while((_handle = evhttp_bind_socket_with_handle(_http, INADDR_ANY, _port)) == NULL) { - _port++; - } - determineAddress(); -} - -EventIOServer::~EventIOServer() { + assert(false); } -EventIOServer* EventIOServer::_instance = NULL; -tthread::recursive_mutex EventIOServer::_instanceMutex; - -EventIOServer* EventIOServer::getInstance() { - tthread::lock_guard lock(_instanceMutex); - if (_instance == NULL) { - _instance = new EventIOServer(8080); - _instance->start(); - } - return _instance; -} - -void EventIOServer::registerProcessor(EventIOProcessor* processor) { - EventIOServer* INSTANCE = getInstance(); - tthread::lock_guard lock(INSTANCE->_mutex); - - /** - * Determine path for interpreter. - * - * If the interpreter has a name and it is not yet taken, choose it as the path - * for requests. If the interpreters name path is already taken, append digits - * until we have an available path. - * - * If the interpreter does not specify a name, take its sessionid. - */ - - std::string path = processor->getPath(); - if (path.size() == 0) { - path = processor->_interpreter->getSessionId(); - } - assert(path.size() > 0); - - std::stringstream actualPath(path); - int i = 1; - while(INSTANCE->_processors.find(actualPath.str()) != INSTANCE->_processors.end()) { - actualPath.str(std::string()); - actualPath.clear(); - actualPath << path << ++i; - } - - std::stringstream processorURL; - processorURL << "http://" << INSTANCE->_address << ":" << INSTANCE->_port << "/" << actualPath.str(); - - INSTANCE->_processors[actualPath.str()] = processor; - processor->setURL(processorURL.str()); - - LOG(INFO) << "SCXML listening at: " << processorURL.str() << std::endl; - - evhttp_set_cb(INSTANCE->_http, ("/" + actualPath.str()).c_str(), EventIOServer::httpRecvReqCallback, processor); +void EventIOProcessor::downloadFailed(const URL& url, int errorCode) { -// evhttp_set_cb(THIS->_http, "/", EventIOProcessor::httpRecvReq, processor); -// evhttp_set_gencb(THIS->_http, EventIOProcessor::httpRecvReq, NULL); -} - -void EventIOServer::unregisterProcessor(EventIOProcessor* processor) { - EventIOServer* INSTANCE = getInstance(); - tthread::lock_guard lock(INSTANCE->_mutex); - evhttp_del_cb(INSTANCE->_http, processor->_url.c_str()); -} - -void EventIOServer::start() { - _isRunning = true; - _thread = new tthread::thread(EventIOServer::run, this); -} - -void EventIOServer::run(void* instance) { - EventIOServer* INSTANCE = (EventIOServer*)instance; - while(INSTANCE->_isRunning) { - event_base_dispatch(INSTANCE->_base); - } - LOG(INFO) << "HTTP Server stopped" << std::endl; -} - -std::string EventIOServer::syncResolve(const std::string& hostname) { - struct hostent *he; - struct in_addr **addr_list; - int i; + std::map >::iterator reqIter = _sendRequests.begin(); + while(reqIter != _sendRequests.end()) { + if (reqIter->second.first == url) { + Event failEvent; + failEvent.name = "error.communication"; + returnEvent(failEvent); + + _sendRequests.erase(reqIter); + return; + } + reqIter++; + } + assert(false); - if ( (he = gethostbyname( hostname.c_str() ) ) != NULL) { - addr_list = (struct in_addr **) he->h_addr_list; - for(i = 0; addr_list[i] != NULL; i++) { - return std::string(inet_ntoa(*addr_list[i])); - } - } - return ""; } -void EventIOServer::determineAddress() { - - char hostname[1024]; - gethostname(hostname, 1024); - _address = std::string(hostname); - -#if 0 - struct sockaddr_storage ss; - evutil_socket_t fd; - ev_socklen_t socklen = sizeof(ss); - char addrbuf[128]; - - void *inaddr; - const char *addr; - int got_port = -1; - fd = evhttp_bound_socket_get_fd(_handle); - memset(&ss, 0, sizeof(ss)); - if (getsockname(fd, (struct sockaddr *)&ss, &socklen)) { - perror("getsockname() failed"); - return; - } - - if (ss.ss_family == AF_INET) { - got_port = ntohs(((struct sockaddr_in*)&ss)->sin_port); - inaddr = &((struct sockaddr_in*)&ss)->sin_addr; - } else if (ss.ss_family == AF_INET6) { - got_port = ntohs(((struct sockaddr_in6*)&ss)->sin6_port); - inaddr = &((struct sockaddr_in6*)&ss)->sin6_addr; - } else { - fprintf(stderr, "Weird address family %d\n", - ss.ss_family); - return; - } - addr = evutil_inet_ntop(ss.ss_family, inaddr, addrbuf, - sizeof(addrbuf)); - if (addr) { - _address = std::string(addr); - } else { - fprintf(stderr, "evutil_inet_ntop failed\n"); - return; - } -#endif -} } \ No newline at end of file diff --git a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h index 7dd1c41..416761f 100644 --- a/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h +++ b/src/uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h @@ -2,6 +2,7 @@ #define EVENTIOPROCESSOR_H_2CUY93KU #include "uscxml/concurrency/eventqueue/DelayedEventQueue.h" +#include "uscxml/server/HTTPServer.h" #include "uscxml/Interpreter.h" #include "uscxml/Factory.h" #ifndef _WIN32 @@ -19,14 +20,8 @@ namespace uscxml { class EventIOServer; -class EventIOProcessor : public IOProcessorImpl { +class EventIOProcessor : public IOProcessorImpl, public HTTPServlet, public URLMonitor { public: - struct SendData { - EventIOProcessor* ioProcessor; - uscxml::SendRequest scxmlReq; - evhttp_request* httpReq; - }; - EventIOProcessor(); virtual ~EventIOProcessor(); virtual boost::shared_ptr create(uscxml::Interpreter* interpreter); @@ -41,73 +36,19 @@ public: virtual void send(const SendRequest& req); Data getDataModelVariables(); - void setURL(const std::string& url) { - _url = url; - } - void start(); - static void run(void* instance); + /// HTTPServlet + void httpRecvRequest(const HTTPServer::Request& req); + void setURL(const std::string& url) { _url = url; } - virtual std::string getPath() { return _interpreter->getName(); } - virtual void httpSendReqDone(struct SendData* sendData); - virtual void httpRecvReq(struct evhttp_request *req); + // URLMonitor + void downloadStarted(const URL& url); + void downloadCompleted(const URL& url); + void downloadFailed(const URL& url, int errorCode); protected: - std::map _sendData; - std::string _url; - - uscxml::DelayedEventQueue _asyncQueue; - std::map _httpConnections; - std::map _httpRequests; - struct evdns_base* _dns; - - friend class EventIOServer; -}; - -class EventIOServer { -public: - static EventIOServer* getInstance(); - - static void registerProcessor(EventIOProcessor* processor); - static void unregisterProcessor(EventIOProcessor* processor); - -private: - EventIOServer(unsigned short port); - ~EventIOServer(); - - void start(); - void stop(); - static void run(void* instance); - - void determineAddress(); - static std::string syncResolve(const std::string& hostname); - - static void httpSendReqDoneCallback(struct evhttp_request *req, void *cb_arg) { - EventIOProcessor::SendData* sendData = (EventIOProcessor::SendData*)cb_arg; - sendData->httpReq = req; - sendData->ioProcessor->httpSendReqDone(sendData); - } - static void httpRecvReqCallback(struct evhttp_request *req, void *cb_arg) { - ((EventIOProcessor*)cb_arg)->httpRecvReq(req); - } - - std::map _processors; - - struct event_base* _base; - struct evhttp* _http; - struct evhttp_bound_socket* _handle; - - unsigned short _port; - std::string _address; - - static EventIOServer* _instance; - static tthread::recursive_mutex _instanceMutex; - tthread::thread* _thread; - tthread::recursive_mutex _mutex; - bool _isRunning; - - friend class EventIOProcessor; + std::map > _sendRequests; }; #ifdef BUILD_AS_PLUGINS diff --git a/src/uscxml/server/HTTPServer.cpp b/src/uscxml/server/HTTPServer.cpp new file mode 100644 index 0000000..e151f9e --- /dev/null +++ b/src/uscxml/server/HTTPServer.cpp @@ -0,0 +1,223 @@ +#ifdef _WIN32 +#include +#include +#endif + +#include "uscxml/server/HTTPServer.h" +#include "uscxml/Message.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#ifndef _WIN32 +#include +#include +#endif + +#ifdef BUILD_AS_PLUGINS +#include +#endif + +namespace uscxml { + +HTTPServer::HTTPServer(unsigned short port) { + _port = port; + _base = event_base_new(); + _http = evhttp_new(_base); + _handle = NULL; + while((_handle = evhttp_bind_socket_with_handle(_http, INADDR_ANY, _port)) == NULL) { + _port++; + } + determineAddress(); +} + +HTTPServer::~HTTPServer() { +} + +HTTPServer* HTTPServer::_instance = NULL; +tthread::recursive_mutex HTTPServer::_instanceMutex; + +HTTPServer* HTTPServer::getInstance(int port) { + tthread::lock_guard lock(_instanceMutex); + if (_instance == NULL) { +#ifndef _WIN32 + evthread_use_pthreads(); +#else + evthread_use_windows_threads(); +#endif + _instance = new HTTPServer(port); + _instance->start(); + } + return _instance; +} + +void HTTPServer::httpRecvReqCallback(struct evhttp_request *req, void *callbackData) { +// std::cout << (uintptr_t)req << ": Replying" << std::endl; +// evhttp_send_reply(req, 200, NULL, NULL); +// return; + + Request request; + request.curlReq = req; + + switch (evhttp_request_get_command(req)) { + case EVHTTP_REQ_GET: + request.type = "GET"; + break; + case EVHTTP_REQ_POST: + request.type = "POST"; + break; + case EVHTTP_REQ_HEAD: + request.type = "HEAD"; + break; + case EVHTTP_REQ_PUT: + request.type = "PUT"; + break; + case EVHTTP_REQ_DELETE: + request.type = "DELETE"; + break; + case EVHTTP_REQ_OPTIONS: + request.type = "OPTIONS"; + break; + case EVHTTP_REQ_TRACE: + request.type = "TRACE"; + break; + case EVHTTP_REQ_CONNECT: + request.type = "CONNECT"; + break; + case EVHTTP_REQ_PATCH: + request.type = "PATCH"; + break; + default: + request.type = "unknown"; + break; + } + + struct evkeyvalq *headers; + struct evkeyval *header; + struct evbuffer *buf; + + // map headers to event structure + headers = evhttp_request_get_input_headers(req); + for (header = headers->tqh_first; header; header = header->next.tqe_next) { + request.headers[header->key] = header->value; + } + + request.remoteHost = req->remote_host; + request.remotePort = req->remote_port; + request.httpMajor = req->major; + request.httpMinor = req->minor; + request.uri = req->uri; + + // get content + buf = evhttp_request_get_input_buffer(req); + while (evbuffer_get_length(buf)) { + int n; + char cbuf[1024]; + n = evbuffer_remove(buf, cbuf, sizeof(buf)-1); + if (n > 0) { + request.content.append(cbuf, n); + } + } + + ((HTTPServlet*)callbackData)->httpRecvRequest(request); +} + +void HTTPServer::reply(const Reply& reply) { + struct evbuffer *evb = evbuffer_new(); + + std::map::const_iterator headerIter = reply.headers.begin(); + while(headerIter != reply.headers.end()) { + evhttp_add_header(evhttp_request_get_output_headers(reply.curlReq), headerIter->first.c_str(), headerIter->second.c_str()); + headerIter++; + } + + if (!boost::iequals(reply.type, "HEAD")) + evbuffer_add(evb, reply.content.data(), reply.content.size()); + + evhttp_send_reply(reply.curlReq, reply.status, NULL, evb); + evbuffer_free(evb); +// evhttp_request_free(reply.curlReq); + +} + +bool HTTPServer::registerServlet(const std::string& path, HTTPServlet* servlet) { + HTTPServer* INSTANCE = getInstance(); + tthread::lock_guard lock(INSTANCE->_mutex); + + /** + * Determine path for interpreter. + * + * If the interpreter has a name and it is not yet taken, choose it as the path + * for requests. If the interpreters name path is already taken, append digits + * until we have an available path. + * + * If the interpreter does not specify a name, take its sessionid. + * + * Responsibility moved to individual servlets. + */ + + if(INSTANCE->_servlets.find(path) != INSTANCE->_servlets.end()) { + return false; + } + + std::stringstream servletURL; + servletURL << "http://" << INSTANCE->_address << ":" << INSTANCE->_port << "/" << path; + servlet->setURL(servletURL.str()); + + INSTANCE->_servlets[path] = servlet; + + LOG(INFO) << "HTTP Servlet listening at: " << servletURL.str() << std::endl; + + // register callback + evhttp_set_cb(INSTANCE->_http, ("/" + path).c_str(), HTTPServer::httpRecvReqCallback, servlet); + + return true; + // generic callback +// evhttp_set_cb(THIS->_http, "/", EventIOProcessor::httpRecvReq, processor); +// evhttp_set_gencb(THIS->_http, EventIOProcessor::httpRecvReq, NULL); +} + +void HTTPServer::unregisterServlet(HTTPServlet* servlet) { + HTTPServer* INSTANCE = getInstance(); + tthread::lock_guard lock(INSTANCE->_mutex); + servlet_iter_t servletIter = INSTANCE->_servlets.begin(); + while(servletIter != INSTANCE->_servlets.end()) { + if (servletIter->second == servlet) { + evhttp_del_cb(INSTANCE->_http, std::string("/" + servletIter->first).c_str()); + INSTANCE->_servlets.erase(servletIter); + break; + } + servletIter++; + } +} + +void HTTPServer::start() { + _isRunning = true; + _thread = new tthread::thread(HTTPServer::run, this); +} + +void HTTPServer::run(void* instance) { + HTTPServer* INSTANCE = (HTTPServer*)instance; + while(INSTANCE->_isRunning) { + event_base_dispatch(INSTANCE->_base); + } + LOG(INFO) << "HTTP Server stopped" << std::endl; +} + +void HTTPServer::determineAddress() { + char hostname[1024]; + gethostname(hostname, 1024); + _address = std::string(hostname); +} + +} \ No newline at end of file diff --git a/src/uscxml/server/HTTPServer.h b/src/uscxml/server/HTTPServer.h new file mode 100644 index 0000000..597c749 --- /dev/null +++ b/src/uscxml/server/HTTPServer.h @@ -0,0 +1,92 @@ +#ifndef HTTPSERVER_H_AIH108EG +#define HTTPSERVER_H_AIH108EG + +#include +#include + +#include + +#include "uscxml/concurrency/tinythread.h" + +namespace uscxml { + +class HTTPServlet; + +class HTTPServer { +public: + class Request { + public: + Request() : curlReq(NULL) {} + std::string type; + std::map headers; + std::string content; + std::string remoteHost; + unsigned short remotePort; + std::string httpMajor; + std::string httpMinor; + std::string uri; + struct evhttp_request* curlReq; + }; + + class Reply { + public: + Reply(Request req) : status(200), type(req.type), curlReq(req.curlReq) {} + int status; + std::string type; + std::map headers; + std::string content; + struct evhttp_request* curlReq; + }; + + struct CallbackData { + HTTPServlet* servlet; + evhttp_request* httpReq; + }; + + static HTTPServer* getInstance(int port = 8080); + static void reply(const Reply& reply); + + static bool registerServlet(const std::string& path, HTTPServlet* servlet); ///< Register a servlet, returns false if path is already taken + static void unregisterServlet(HTTPServlet* servlet); + +private: + HTTPServer(unsigned short port); + ~HTTPServer(); + + void start(); + void stop(); + static void run(void* instance); + + void determineAddress(); + + static void httpRecvReqCallback(struct evhttp_request *req, void *callbackData); + + std::map _servlets; + typedef std::map::iterator servlet_iter_t; + + struct event_base* _base; + struct evhttp* _http; + struct evhttp_bound_socket* _handle; + + unsigned short _port; + std::string _address; + + static HTTPServer* _instance; + + static tthread::recursive_mutex _instanceMutex; + tthread::thread* _thread; + tthread::recursive_mutex _mutex; + bool _isRunning; + + friend class HTTPServlet; +}; + +class HTTPServlet { +public: + virtual void httpRecvRequest(const HTTPServer::Request& request) = 0; + virtual void setURL(const std::string& url) = 0; /// Called by the server with the actual URL +}; + +} + +#endif /* end of include guard: HTTPSERVER_H_AIH108EG */ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 88d10e9..b6cbdc0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,36 +1,25 @@ -find_program(XMLLINT xmllint) -if (XMLLINT) - file(GLOB SCXML_FILES samples/uscxml/*.scxml) - -endif() - -add_executable(test-predicates src/test-predicates.cpp) -target_link_libraries(test-predicates uscxml) -add_test(test-predicates ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-predicates ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-predicates.scxml) -set_target_properties(test-predicates PROPERTIES FOLDER "Tests") +# find_program(XMLLINT xmllint) +# if (XMLLINT) +# file(GLOB SCXML_FILES samples/uscxml/*.scxml) +# endif() -add_executable(test-execution src/test-execution.cpp) -target_link_libraries(test-execution uscxml) -add_test(test-execution ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-execution ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-execution.scxml) -set_target_properties(test-execution PROPERTIES FOLDER "Tests") +if (NOT WIN32) + add_executable(test-predicates src/test-predicates.cpp) + target_link_libraries(test-predicates uscxml) + add_test(test-predicates ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-predicates ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-predicates.scxml) + set_target_properties(test-predicates PROPERTIES FOLDER "Tests") +endif() -# add_executable(test-apache-commons src/test-apache-commons.cpp) -# target_link_libraries(test-apache-commons uscxml) -# add_test(test-apache-commons ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-apache-commons ${CMAKE_SOURCE_DIR}/test/samples/apache) -# set_target_properties(test-apache-commons PROPERTIES FOLDER "Tests") - -# if (V8_FOUND) -# add_executable(test-ecmascript-v8 src/test-ecmascript-v8.cpp) -# target_link_libraries(test-ecmascript-v8 uscxml) -# add_test(test-ecmascript-v8 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-ecmascript-v8 ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-ecmascript.scxml) -# set_target_properties(test-ecmascript-v8 PROPERTIES FOLDER "Tests") -# endif() +add_test(test-execution ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/mmi-browser ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-execution.scxml) +add_test(test-communication ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/mmi-browser ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-communication.scxml) +add_test(test-done-data ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/mmi-browser ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-donedata.scxml) if (SWI_FOUND) - add_executable(test-prolog-swi src/test-prolog-swi.cpp) - target_link_libraries(test-prolog-swi uscxml) - add_test(test-prolog-swi ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-prolog-swi ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-prolog.scxml) - set_target_properties(test-prolog-swi PROPERTIES FOLDER "Tests") + add_test(test-prolog-swi ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/mmi-browser ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-prolog.scxml) +endif() + +if (V8_FOUND) + add_test(test-ecmascript ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/mmi-browser ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-ecmascript.scxml) endif() if (OPENSCENEGRAPH_FOUND) @@ -39,21 +28,11 @@ if (OPENSCENEGRAPH_FOUND) set_target_properties(test-osg PROPERTIES FOLDER "Tests") endif() -add_executable(test-communication src/test-communication.cpp) -target_link_libraries(test-communication uscxml) -add_test(test-communication ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-communication ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-communication.scxml) -set_target_properties(test-communication PROPERTIES FOLDER "Tests") - add_executable(test-eventdelay src/test-eventdelay.cpp) target_link_libraries(test-eventdelay uscxml) add_test(test-eventdelay ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-eventdelay) set_target_properties(test-eventdelay PROPERTIES FOLDER "Tests") -add_executable(test-completion src/test-completion.cpp) -target_link_libraries(test-completion uscxml) -add_test(test-completion ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-completion ${CMAKE_SOURCE_DIR}/test/samples/uscxml/test-donedata.scxml) -set_target_properties(test-completion PROPERTIES FOLDER "Tests") - if (NOT WIN32) add_executable(test-arabica-events src/test-arabica-events.cpp) target_link_libraries(test-arabica-events uscxml) @@ -67,8 +46,11 @@ add_test(test-url ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-url) set_target_properties(test-url PROPERTIES FOLDER "Tests") add_executable(scxml-test-framework-client - ${PROJECT_SOURCE_DIR}/contrib/src/jsmn/jsmn.c src/scxml-test-framework-client.cpp) -target_link_libraries(scxml-test-framework-client uscxml) + target_link_libraries(scxml-test-framework-client uscxml) set_target_properties(scxml-test-framework-client PROPERTIES FOLDER "Tests") +# add_executable(test-curl-multi-api src/test-curl-multi-api.cpp) +# target_link_libraries(test-curl-multi-api uscxml) +# add_test(test-curl-multi-api ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-completion) +# set_target_properties(test-curl-multi-api PROPERTIES FOLDER "Tests") diff --git a/test/run-scxml-test-framework.sh b/test/run-scxml-test-framework.sh index e20afe9..83cb403 100755 --- a/test/run-scxml-test-framework.sh +++ b/test/run-scxml-test-framework.sh @@ -100,7 +100,7 @@ TESTS="" # TESTS="${TESTS} scxml-test-framework/test/multiple-events-per-transition/test1.scxml" # passed # TESTS="${TESTS} scxml-test-framework/test/parallel/test0.scxml" # passed -# TESTS="${TESTS} scxml-test-framework/test/parallel/test1.scxml" # passed +# TESTS="${TESTS} scxml-test-framework/test/parallel/test1.scxml" # failed # TESTS="${TESTS} scxml-test-framework/test/parallel/test2.scxml" # passed # TESTS="${TESTS} scxml-test-framework/test/parallel/test3.scxml" # passed @@ -142,7 +142,7 @@ TESTS="" # TESTS="${TESTS} scxml-test-framework/test/script/test2.scxml" # getData not defined # TESTS="${TESTS} scxml-test-framework/test/script-src/test0.scxml" # getData not defined # TESTS="${TESTS} scxml-test-framework/test/script-src/test1.scxml" # getData not defined -# TESTS="${TESTS} scxml-test-framework/test/script-src/test2.scxml" # getData not defined +#TESTS="${TESTS} scxml-test-framework/test/script-src/test2.scxml" # getData not defined # TESTS="${TESTS} scxml-test-framework/test/script-src/test3.scxml" # getData not defined # TESTS="${TESTS} scxml-test-framework/test/scxml-prefix-event-name-matching/star0.scxml" # passed @@ -155,8 +155,9 @@ TESTS="" # TESTS="${TESTS} scxml-test-framework/test/targetless-transition/test0.scxml" # passed # TESTS="${TESTS} scxml-test-framework/test/targetless-transition/test1.scxml" # passed # TESTS="${TESTS} scxml-test-framework/test/targetless-transition/test2.scxml" # passed -TESTS="${TESTS} scxml-test-framework/test/targetless-transition/test3.scxml" # failed +# TESTS="${TESTS} scxml-test-framework/test/targetless-transition/test3.scxml" # failed +TESTS="${TESTS} scxml-test-framework/test/*/*.scxml" #trap 'killall ${SCXML_TEST_FRAMEWORK_NAME}' 0 #$SCXML_TEST_FRAMEWORK_FULL & diff --git a/test/samples/uscxml/test-custom-executable-content.scxml b/test/samples/uscxml/test-custom-executable-content.scxml new file mode 100644 index 0000000..a40af93 --- /dev/null +++ b/test/samples/uscxml/test-custom-executable-content.scxml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/test/samples/uscxml/test-ecmascript.scxml b/test/samples/uscxml/test-ecmascript.scxml index aa88f17..7dfd94c 100644 --- a/test/samples/uscxml/test-ecmascript.scxml +++ b/test/samples/uscxml/test-ecmascript.scxml @@ -77,13 +77,7 @@ - - - - - - - + diff --git a/test/samples/uscxml/test-http-servlet.scxml b/test/samples/uscxml/test-http-servlet.scxml new file mode 100644 index 0000000..8836b76 --- /dev/null +++ b/test/samples/uscxml/test-http-servlet.scxml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/samples/uscxml/test-response-element.scxml b/test/samples/uscxml/test-response-element.scxml new file mode 100644 index 0000000..d3d3c53 --- /dev/null +++ b/test/samples/uscxml/test-response-element.scxml @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file diff --git a/test/scxml-test-framework/test-ext/node/require/require.json b/test/scxml-test-framework/test-ext/node/require/require.json deleted file mode 100644 index 1d2faec..0000000 --- a/test/scxml-test-framework/test-ext/node/require/require.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] -} - - - diff --git a/test/scxml-test-framework/test-ext/node/require/require.scxml b/test/scxml-test-framework/test-ext/node/require/require.scxml deleted file mode 100644 index 221ad81..0000000 --- a/test/scxml-test-framework/test-ext/node/require/require.scxml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - + + + + + - - - + + + - + - + - - - - diff --git a/test/scxml-test-framework/test/assign-current-small-step/test1.json b/test/scxml-test-framework/test/assign-current-small-step/test1.json index 8424ef5..0e49c49 100644 --- a/test/scxml-test-framework/test/assign-current-small-step/test1.json +++ b/test/scxml-test-framework/test/assign-current-small-step/test1.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c"] + } + ] } diff --git a/test/scxml-test-framework/test/assign-current-small-step/test1.scxml b/test/scxml-test-framework/test/assign-current-small-step/test1.scxml index 632d1f0..21e8777 100644 --- a/test/scxml-test-framework/test/assign-current-small-step/test1.scxml +++ b/test/scxml-test-framework/test/assign-current-small-step/test1.scxml @@ -18,32 +18,27 @@ This test illustrates how possibly infinite loops may be created. Here, without the counter and the cond, the big-step would never complete. --> - - - - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/assign-current-small-step/test2.json b/test/scxml-test-framework/test/assign-current-small-step/test2.json index 6769dfe..36628bc 100644 --- a/test/scxml-test-framework/test/assign-current-small-step/test2.json +++ b/test/scxml-test-framework/test/assign-current-small-step/test2.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["e"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["e"] + } + ] } diff --git a/test/scxml-test-framework/test/assign-current-small-step/test2.scxml b/test/scxml-test-framework/test/assign-current-small-step/test2.scxml index b5a5828..05cf13b 100644 --- a/test/scxml-test-framework/test/assign-current-small-step/test2.scxml +++ b/test/scxml-test-framework/test/assign-current-small-step/test2.scxml @@ -18,53 +18,48 @@ This is another test that illustrates how possibly infinite loops may be created. Here, without the counter and the cond, the big-step would never complete. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + - - - + + + + + - - - - - + - + + + + + - - - - - + + + + + - - - - - + + + + - - - - + + + + - - - - + - - - + diff --git a/test/scxml-test-framework/test/assign-current-small-step/test3.json b/test/scxml-test-framework/test/assign-current-small-step/test3.json index d31828b..58b5b14 100644 --- a/test/scxml-test-framework/test/assign-current-small-step/test3.json +++ b/test/scxml-test-framework/test/assign-current-small-step/test3.json @@ -1,19 +1,19 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b1","c1"] - }, - { - "event" : { "name" : "t2" }, - "nextConfiguration" : ["b2","c2"] - }, - { - "event" : { "name" : "t3" }, - "nextConfiguration" : ["d"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b1","c1"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["b2","c2"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["d"] + } + ] } diff --git a/test/scxml-test-framework/test/assign-current-small-step/test3.scxml b/test/scxml-test-framework/test/assign-current-small-step/test3.scxml index 431717e..203ed43 100644 --- a/test/scxml-test-framework/test/assign-current-small-step/test3.scxml +++ b/test/scxml-test-framework/test/assign-current-small-step/test3.scxml @@ -18,57 +18,52 @@ This test demonstrates the way the memory model semantics interact with transition order and concurrency semantics. Here, transitions originating from c1 and b1 will be taken in the same small-step, however i will not be updated until the end of that small step. The transitions actions are evaluated in document order, though, so the outcome is deterministic, so the assignment action on the transition originating from c1 will win. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + - - - + + + + + - - - - - + - + + + + + + - - - - - - + + + - - - + + + + + + - - - - - - + + + - - - + + + - - - + - - - + diff --git a/test/scxml-test-framework/test/assign-current-small-step/test4.json b/test/scxml-test-framework/test/assign-current-small-step/test4.json index ce82511..d616eb4 100644 --- a/test/scxml-test-framework/test/assign-current-small-step/test4.json +++ b/test/scxml-test-framework/test/assign-current-small-step/test4.json @@ -1,9 +1,9 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c"] + } + ] } diff --git a/test/scxml-test-framework/test/assign-current-small-step/test4.scxml b/test/scxml-test-framework/test/assign-current-small-step/test4.scxml index 856f943..64a8a8b 100644 --- a/test/scxml-test-framework/test/assign-current-small-step/test4.scxml +++ b/test/scxml-test-framework/test/assign-current-small-step/test4.scxml @@ -15,28 +15,27 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + - - - - + + + + - - + + - - - - - + + + + + @@ -52,12 +51,12 @@ - - - + + + - + - + diff --git a/test/scxml-test-framework/test/assign-next-small-step/test0.json b/test/scxml-test-framework/test/assign-next-small-step/test0.json deleted file mode 100644 index 1d2faec..0000000 --- a/test/scxml-test-framework/test/assign-next-small-step/test0.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] -} - - - diff --git a/test/scxml-test-framework/test/assign-next-small-step/test0.scxml b/test/scxml-test-framework/test/assign-next-small-step/test0.scxml deleted file mode 100644 index b7ffdfe..0000000 --- a/test/scxml-test-framework/test/assign-next-small-step/test0.scxml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/scxml-test-framework/test/assign-next-small-step/test1.json b/test/scxml-test-framework/test/assign-next-small-step/test1.json deleted file mode 100644 index 8424ef5..0000000 --- a/test/scxml-test-framework/test/assign-next-small-step/test1.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c"] - } - ] -} - - - diff --git a/test/scxml-test-framework/test/assign-next-small-step/test1.scxml b/test/scxml-test-framework/test/assign-next-small-step/test1.scxml deleted file mode 100644 index bc7074e..0000000 --- a/test/scxml-test-framework/test/assign-next-small-step/test1.scxml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/scxml-test-framework/test/assign-next-small-step/test2.json b/test/scxml-test-framework/test/assign-next-small-step/test2.json deleted file mode 100644 index 6769dfe..0000000 --- a/test/scxml-test-framework/test/assign-next-small-step/test2.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["e"] - } - ] -} - - - - diff --git a/test/scxml-test-framework/test/assign-next-small-step/test2.scxml b/test/scxml-test-framework/test/assign-next-small-step/test2.scxml deleted file mode 100644 index 1448d70..0000000 --- a/test/scxml-test-framework/test/assign-next-small-step/test2.scxml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/scxml-test-framework/test/assign-next-small-step/test3.json b/test/scxml-test-framework/test/assign-next-small-step/test3.json deleted file mode 100644 index d31828b..0000000 --- a/test/scxml-test-framework/test/assign-next-small-step/test3.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b1","c1"] - }, - { - "event" : { "name" : "t2" }, - "nextConfiguration" : ["b2","c2"] - }, - { - "event" : { "name" : "t3" }, - "nextConfiguration" : ["d"] - } - ] -} - - - - - diff --git a/test/scxml-test-framework/test/assign-next-small-step/test3.scxml b/test/scxml-test-framework/test/assign-next-small-step/test3.scxml deleted file mode 100644 index d30be88..0000000 --- a/test/scxml-test-framework/test/assign-next-small-step/test3.scxml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/scxml-test-framework/test/atom3-basic-tests/m0.json b/test/scxml-test-framework/test/atom3-basic-tests/m0.json index 66fe90f..2121cdd 100644 --- a/test/scxml-test-framework/test/atom3-basic-tests/m0.json +++ b/test/scxml-test-framework/test/atom3-basic-tests/m0.json @@ -1,13 +1,13 @@ { - "initialConfiguration" : ["A"], - "events" : [ - { - "event" : { "name" : "e1" }, - "nextConfiguration" : ["B"] - }, - { - "event" : { "name" : "e2" }, - "nextConfiguration" : ["A"] - } - ] + "initialConfiguration" : ["A"], + "events" : [ + { + "event" : { "name" : "e1" }, + "nextConfiguration" : ["B"] + }, + { + "event" : { "name" : "e2" }, + "nextConfiguration" : ["A"] + } + ] } diff --git a/test/scxml-test-framework/test/atom3-basic-tests/m0.scxml b/test/scxml-test-framework/test/atom3-basic-tests/m0.scxml index 99bdc23..32026af 100644 --- a/test/scxml-test-framework/test/atom3-basic-tests/m0.scxml +++ b/test/scxml-test-framework/test/atom3-basic-tests/m0.scxml @@ -1,19 +1,18 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/atom3-basic-tests/m1.json b/test/scxml-test-framework/test/atom3-basic-tests/m1.json index dfb2ca4..eb25138 100644 --- a/test/scxml-test-framework/test/atom3-basic-tests/m1.json +++ b/test/scxml-test-framework/test/atom3-basic-tests/m1.json @@ -1,14 +1,14 @@ { - "initialConfiguration" : ["A"], - "events" : [ - { - "event" : { "name" : "e1" }, - "nextConfiguration" : ["B"] - }, - { - "event" : { "name" : "e2" }, - "nextConfiguration" : ["A"] - } - ] + "initialConfiguration" : ["A"], + "events" : [ + { + "event" : { "name" : "e1" }, + "nextConfiguration" : ["B"] + }, + { + "event" : { "name" : "e2" }, + "nextConfiguration" : ["A"] + } + ] } diff --git a/test/scxml-test-framework/test/atom3-basic-tests/m1.scxml b/test/scxml-test-framework/test/atom3-basic-tests/m1.scxml index e233f2c..6d8a01f 100644 --- a/test/scxml-test-framework/test/atom3-basic-tests/m1.scxml +++ b/test/scxml-test-framework/test/atom3-basic-tests/m1.scxml @@ -1,4 +1,6 @@ - + @@ -10,9 +12,6 @@ - - - diff --git a/test/scxml-test-framework/test/atom3-basic-tests/m2.json b/test/scxml-test-framework/test/atom3-basic-tests/m2.json index 7c0f278..3ac5a1a 100644 --- a/test/scxml-test-framework/test/atom3-basic-tests/m2.json +++ b/test/scxml-test-framework/test/atom3-basic-tests/m2.json @@ -1,15 +1,15 @@ { - "initialConfiguration" : ["A"], - "events" : [ - { - "event" : { "name" : "e1" }, - "nextConfiguration" : ["B"] - }, - { - "event" : { "name" : "e2" }, - "nextConfiguration" : ["A"] - } - ] + "initialConfiguration" : ["A"], + "events" : [ + { + "event" : { "name" : "e1" }, + "nextConfiguration" : ["B"] + }, + { + "event" : { "name" : "e2" }, + "nextConfiguration" : ["A"] + } + ] } diff --git a/test/scxml-test-framework/test/atom3-basic-tests/m2.scxml b/test/scxml-test-framework/test/atom3-basic-tests/m2.scxml index 750d263..eb959b9 100644 --- a/test/scxml-test-framework/test/atom3-basic-tests/m2.scxml +++ b/test/scxml-test-framework/test/atom3-basic-tests/m2.scxml @@ -1,4 +1,6 @@ - + @@ -20,7 +22,4 @@ - - - diff --git a/test/scxml-test-framework/test/atom3-basic-tests/m3.json b/test/scxml-test-framework/test/atom3-basic-tests/m3.json index 981ac5f..7a3414f 100644 --- a/test/scxml-test-framework/test/atom3-basic-tests/m3.json +++ b/test/scxml-test-framework/test/atom3-basic-tests/m3.json @@ -1,23 +1,23 @@ { - "initialConfiguration" : ["A"], - "events" : [ - { - "event" : { "name" : "e1" }, - "nextConfiguration" : ["B"] - }, - { - "event" : { "name" : "e2" }, - "nextConfiguration" : ["A"] - }, - { - "event" : { "name" : "e1" }, - "nextConfiguration" : ["B"] - }, - { - "event" : { "name" : "e1" }, - "nextConfiguration" : ["C"] - } - ] + "initialConfiguration" : ["A"], + "events" : [ + { + "event" : { "name" : "e1" }, + "nextConfiguration" : ["B"] + }, + { + "event" : { "name" : "e2" }, + "nextConfiguration" : ["A"] + }, + { + "event" : { "name" : "e1" }, + "nextConfiguration" : ["B"] + }, + { + "event" : { "name" : "e1" }, + "nextConfiguration" : ["C"] + } + ] } diff --git a/test/scxml-test-framework/test/atom3-basic-tests/m3.scxml b/test/scxml-test-framework/test/atom3-basic-tests/m3.scxml index ddef66c..a2ceb34 100644 --- a/test/scxml-test-framework/test/atom3-basic-tests/m3.scxml +++ b/test/scxml-test-framework/test/atom3-basic-tests/m3.scxml @@ -1,4 +1,6 @@ - + @@ -21,9 +23,6 @@ - - - diff --git a/test/scxml-test-framework/test/basic/basic0.json b/test/scxml-test-framework/test/basic/basic0.json index 871e757..0df730d 100644 --- a/test/scxml-test-framework/test/basic/basic0.json +++ b/test/scxml-test-framework/test/basic/basic0.json @@ -1,6 +1,6 @@ { - "initialConfiguration" : ["a"], - "events" : [] + "initialConfiguration" : ["a"], + "events" : [] } diff --git a/test/scxml-test-framework/test/basic/basic0.scxml b/test/scxml-test-framework/test/basic/basic0.scxml index 926495f..23eff63 100644 --- a/test/scxml-test-framework/test/basic/basic0.scxml +++ b/test/scxml-test-framework/test/basic/basic0.scxml @@ -15,13 +15,12 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> - + diff --git a/test/scxml-test-framework/test/basic/basic1.json b/test/scxml-test-framework/test/basic/basic1.json index 1d2faec..c27c2fd 100644 --- a/test/scxml-test-framework/test/basic/basic1.json +++ b/test/scxml-test-framework/test/basic/basic1.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + } + ] } diff --git a/test/scxml-test-framework/test/basic/basic1.scxml b/test/scxml-test-framework/test/basic/basic1.scxml index d12b092..304efbc 100644 --- a/test/scxml-test-framework/test/basic/basic1.scxml +++ b/test/scxml-test-framework/test/basic/basic1.scxml @@ -15,19 +15,14 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + - - - - - + diff --git a/test/scxml-test-framework/test/basic/basic2.json b/test/scxml-test-framework/test/basic/basic2.json index 3fa286e..9eac7e9 100644 --- a/test/scxml-test-framework/test/basic/basic2.json +++ b/test/scxml-test-framework/test/basic/basic2.json @@ -1,15 +1,15 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - }, - { - "event" : { "name" : "t2" }, - "nextConfiguration" : ["c"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["c"] + } + ] } diff --git a/test/scxml-test-framework/test/basic/basic2.scxml b/test/scxml-test-framework/test/basic/basic2.scxml index 66364c3..68057fd 100644 --- a/test/scxml-test-framework/test/basic/basic2.scxml +++ b/test/scxml-test-framework/test/basic/basic2.scxml @@ -15,24 +15,18 @@ limitations under the License. --> + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + - - - + + + - - - - - + diff --git a/test/scxml-test-framework/test/cond-js/TestConditionalTransition.json b/test/scxml-test-framework/test/cond-js/TestConditionalTransition.json index b586923..2806be0 100644 --- a/test/scxml-test-framework/test/cond-js/TestConditionalTransition.json +++ b/test/scxml-test-framework/test/cond-js/TestConditionalTransition.json @@ -1,31 +1,31 @@ { - "initialConfiguration" : ["b"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["d1"] - }, - { - "event" : { "name" : "t2" }, - "nextConfiguration" : ["e1"] - }, - { - "event" : { "name" : "t3" }, - "nextConfiguration" : ["f2"] - }, - { - "event" : { "name" : "t4" }, - "nextConfiguration" : ["h"] - }, - { - "event" : { "name" : "t5" }, - "nextConfiguration" : ["i"] - }, - { - "event" : { "name" : "t5" }, - "nextConfiguration" : ["last"] - } - ] + "initialConfiguration" : ["b"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["d1"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["e1"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["f2"] + }, + { + "event" : { "name" : "t4" }, + "nextConfiguration" : ["h"] + }, + { + "event" : { "name" : "t5" }, + "nextConfiguration" : ["i"] + }, + { + "event" : { "name" : "t5" }, + "nextConfiguration" : ["last"] + } + ] } diff --git a/test/scxml-test-framework/test/cond-js/TestConditionalTransition.scxml b/test/scxml-test-framework/test/cond-js/TestConditionalTransition.scxml index ed4b733..5d541be 100644 --- a/test/scxml-test-framework/test/cond-js/TestConditionalTransition.scxml +++ b/test/scxml-test-framework/test/cond-js/TestConditionalTransition.scxml @@ -20,84 +20,80 @@ This is to test transitions with guard conditions, and multiple transitions originating from the same state. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + name="root"> - - - + + + + - - - - + + + + - - - - + + + + + - - - - - + + + + + - - - - - + - + + + + + - - - - - + - + - + + + + + + - - - - - - + - + - + - + + + - - - + + + + - - - - + + + + - - - - + - + + - - - - + diff --git a/test/scxml-test-framework/test/cond-js/test0.json b/test/scxml-test-framework/test/cond-js/test0.json index 1d2faec..c27c2fd 100644 --- a/test/scxml-test-framework/test/cond-js/test0.json +++ b/test/scxml-test-framework/test/cond-js/test0.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + } + ] } diff --git a/test/scxml-test-framework/test/cond-js/test0.scxml b/test/scxml-test-framework/test/cond-js/test0.scxml index 11d6a3b..696f55b 100644 --- a/test/scxml-test-framework/test/cond-js/test0.scxml +++ b/test/scxml-test-framework/test/cond-js/test0.scxml @@ -15,20 +15,15 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + - - - - - + diff --git a/test/scxml-test-framework/test/cond-js/test1.json b/test/scxml-test-framework/test/cond-js/test1.json index 1d2faec..c27c2fd 100644 --- a/test/scxml-test-framework/test/cond-js/test1.json +++ b/test/scxml-test-framework/test/cond-js/test1.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + } + ] } diff --git a/test/scxml-test-framework/test/cond-js/test1.scxml b/test/scxml-test-framework/test/cond-js/test1.scxml index a25535b..84fe1fa 100644 --- a/test/scxml-test-framework/test/cond-js/test1.scxml +++ b/test/scxml-test-framework/test/cond-js/test1.scxml @@ -15,23 +15,18 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + + - - - - + - - - + diff --git a/test/scxml-test-framework/test/cond-js/test2.json b/test/scxml-test-framework/test/cond-js/test2.json index 1d2faec..c27c2fd 100644 --- a/test/scxml-test-framework/test/cond-js/test2.json +++ b/test/scxml-test-framework/test/cond-js/test2.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + } + ] } diff --git a/test/scxml-test-framework/test/cond-js/test2.scxml b/test/scxml-test-framework/test/cond-js/test2.scxml index 11d6a3b..696f55b 100644 --- a/test/scxml-test-framework/test/cond-js/test2.scxml +++ b/test/scxml-test-framework/test/cond-js/test2.scxml @@ -15,20 +15,15 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + - - - - - + diff --git a/test/scxml-test-framework/test/default-initial-state/initial1.json b/test/scxml-test-framework/test/default-initial-state/initial1.json index 1d2faec..c27c2fd 100644 --- a/test/scxml-test-framework/test/default-initial-state/initial1.json +++ b/test/scxml-test-framework/test/default-initial-state/initial1.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + } + ] } diff --git a/test/scxml-test-framework/test/default-initial-state/initial1.scxml b/test/scxml-test-framework/test/default-initial-state/initial1.scxml index 0e28f5a..76634c2 100644 --- a/test/scxml-test-framework/test/default-initial-state/initial1.scxml +++ b/test/scxml-test-framework/test/default-initial-state/initial1.scxml @@ -15,15 +15,15 @@ limitations under the License. --> - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + - - - + + + - + diff --git a/test/scxml-test-framework/test/default-initial-state/initial2.json b/test/scxml-test-framework/test/default-initial-state/initial2.json index 12656c3..6c8bd47 100644 --- a/test/scxml-test-framework/test/default-initial-state/initial2.json +++ b/test/scxml-test-framework/test/default-initial-state/initial2.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + } + ] } diff --git a/test/scxml-test-framework/test/default-initial-state/initial2.scxml b/test/scxml-test-framework/test/default-initial-state/initial2.scxml index da3aa62..0fc28b9 100644 --- a/test/scxml-test-framework/test/default-initial-state/initial2.scxml +++ b/test/scxml-test-framework/test/default-initial-state/initial2.scxml @@ -15,16 +15,16 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> - - - + + + - + diff --git a/test/scxml-test-framework/test/default-initial-state/initial3.json b/test/scxml-test-framework/test/default-initial-state/initial3.json deleted file mode 100644 index 510b8b6..0000000 --- a/test/scxml-test-framework/test/default-initial-state/initial3.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] -} - - - - - diff --git a/test/scxml-test-framework/test/default-initial-state/initial3.scxml b/test/scxml-test-framework/test/default-initial-state/initial3.scxml deleted file mode 100644 index 2517fb3..0000000 --- a/test/scxml-test-framework/test/default-initial-state/initial3.scxml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/test/scxml-test-framework/test/delayedSend/send1.json b/test/scxml-test-framework/test/delayedSend/send1.json index b219e13..2c1cda6 100644 --- a/test/scxml-test-framework/test/delayedSend/send1.json +++ b/test/scxml-test-framework/test/delayedSend/send1.json @@ -1,16 +1,16 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b"] - }, - { - "after" : 100, - "event" : { "name" : "t2" }, - "nextConfiguration" : ["d"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b"] + }, + { + "after" : 100, + "event" : { "name" : "t2" }, + "nextConfiguration" : ["d"] + } + ] } diff --git a/test/scxml-test-framework/test/delayedSend/send1.scxml b/test/scxml-test-framework/test/delayedSend/send1.scxml index 5e9b83d..de2d401 100644 --- a/test/scxml-test-framework/test/delayedSend/send1.scxml +++ b/test/scxml-test-framework/test/delayedSend/send1.scxml @@ -15,30 +15,25 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/delayedSend/send2.json b/test/scxml-test-framework/test/delayedSend/send2.json index b219e13..2c1cda6 100644 --- a/test/scxml-test-framework/test/delayedSend/send2.json +++ b/test/scxml-test-framework/test/delayedSend/send2.json @@ -1,16 +1,16 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b"] - }, - { - "after" : 100, - "event" : { "name" : "t2" }, - "nextConfiguration" : ["d"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b"] + }, + { + "after" : 100, + "event" : { "name" : "t2" }, + "nextConfiguration" : ["d"] + } + ] } diff --git a/test/scxml-test-framework/test/delayedSend/send2.scxml b/test/scxml-test-framework/test/delayedSend/send2.scxml index b88e127..c16064a 100644 --- a/test/scxml-test-framework/test/delayedSend/send2.scxml +++ b/test/scxml-test-framework/test/delayedSend/send2.scxml @@ -15,33 +15,28 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + + - - - - + + + - - - + + + - - - + + + - - - - - + diff --git a/test/scxml-test-framework/test/delayedSend/send3.json b/test/scxml-test-framework/test/delayedSend/send3.json index b219e13..2c1cda6 100644 --- a/test/scxml-test-framework/test/delayedSend/send3.json +++ b/test/scxml-test-framework/test/delayedSend/send3.json @@ -1,16 +1,16 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b"] - }, - { - "after" : 100, - "event" : { "name" : "t2" }, - "nextConfiguration" : ["d"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b"] + }, + { + "after" : 100, + "event" : { "name" : "t2" }, + "nextConfiguration" : ["d"] + } + ] } diff --git a/test/scxml-test-framework/test/delayedSend/send3.scxml b/test/scxml-test-framework/test/delayedSend/send3.scxml index efcbc3b..6c2fcc9 100644 --- a/test/scxml-test-framework/test/delayedSend/send3.scxml +++ b/test/scxml-test-framework/test/delayedSend/send3.scxml @@ -15,33 +15,28 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + + - - - - + + + + - - - - + + - - + + + - - - - - + diff --git a/test/scxml-test-framework/test/documentOrder/documentOrder0.json b/test/scxml-test-framework/test/documentOrder/documentOrder0.json index 1d2faec..c27c2fd 100644 --- a/test/scxml-test-framework/test/documentOrder/documentOrder0.json +++ b/test/scxml-test-framework/test/documentOrder/documentOrder0.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + } + ] } diff --git a/test/scxml-test-framework/test/documentOrder/documentOrder0.scxml b/test/scxml-test-framework/test/documentOrder/documentOrder0.scxml index 21d25e7..530a981 100644 --- a/test/scxml-test-framework/test/documentOrder/documentOrder0.scxml +++ b/test/scxml-test-framework/test/documentOrder/documentOrder0.scxml @@ -15,23 +15,18 @@ limitations under the License. --> - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + diff --git a/test/scxml-test-framework/test/foreach/test1.json b/test/scxml-test-framework/test/foreach/test1.json index 8424ef5..0e49c49 100644 --- a/test/scxml-test-framework/test/foreach/test1.json +++ b/test/scxml-test-framework/test/foreach/test1.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c"] + } + ] } diff --git a/test/scxml-test-framework/test/foreach/test1.scxml b/test/scxml-test-framework/test/foreach/test1.scxml index 80762da..6b7f87e 100644 --- a/test/scxml-test-framework/test/foreach/test1.scxml +++ b/test/scxml-test-framework/test/foreach/test1.scxml @@ -18,34 +18,33 @@ This test illustrates how possibly infinite loops may be created. Here, without the counter and the cond, the big-step would never complete. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - - - - - + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + diff --git a/test/scxml-test-framework/test/hierarchy+documentOrder/test0.json b/test/scxml-test-framework/test/hierarchy+documentOrder/test0.json index 883bfd9..116f26c 100644 --- a/test/scxml-test-framework/test/hierarchy+documentOrder/test0.json +++ b/test/scxml-test-framework/test/hierarchy+documentOrder/test0.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a2"] - } - ] + "initialConfiguration" : ["a1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a2"] + } + ] } diff --git a/test/scxml-test-framework/test/hierarchy+documentOrder/test0.scxml b/test/scxml-test-framework/test/hierarchy+documentOrder/test0.scxml index 6b48a10..540c944 100644 --- a/test/scxml-test-framework/test/hierarchy+documentOrder/test0.scxml +++ b/test/scxml-test-framework/test/hierarchy+documentOrder/test0.scxml @@ -15,30 +15,25 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/hierarchy+documentOrder/test1.json b/test/scxml-test-framework/test/hierarchy+documentOrder/test1.json index 12390fe..7fd2206 100644 --- a/test/scxml-test-framework/test/hierarchy+documentOrder/test1.json +++ b/test/scxml-test-framework/test/hierarchy+documentOrder/test1.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] + "initialConfiguration" : ["a1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + } + ] } diff --git a/test/scxml-test-framework/test/hierarchy+documentOrder/test1.scxml b/test/scxml-test-framework/test/hierarchy+documentOrder/test1.scxml index d8b23f0..7f29543 100644 --- a/test/scxml-test-framework/test/hierarchy+documentOrder/test1.scxml +++ b/test/scxml-test-framework/test/hierarchy+documentOrder/test1.scxml @@ -15,30 +15,25 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/hierarchy/hier0.json b/test/scxml-test-framework/test/hierarchy/hier0.json index 883bfd9..116f26c 100644 --- a/test/scxml-test-framework/test/hierarchy/hier0.json +++ b/test/scxml-test-framework/test/hierarchy/hier0.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a2"] - } - ] + "initialConfiguration" : ["a1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a2"] + } + ] } diff --git a/test/scxml-test-framework/test/hierarchy/hier0.scxml b/test/scxml-test-framework/test/hierarchy/hier0.scxml index 1c45ba7..dad78a3 100644 --- a/test/scxml-test-framework/test/hierarchy/hier0.scxml +++ b/test/scxml-test-framework/test/hierarchy/hier0.scxml @@ -15,23 +15,18 @@ limitations under the License. --> - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + diff --git a/test/scxml-test-framework/test/hierarchy/hier1.json b/test/scxml-test-framework/test/hierarchy/hier1.json index 883bfd9..116f26c 100644 --- a/test/scxml-test-framework/test/hierarchy/hier1.json +++ b/test/scxml-test-framework/test/hierarchy/hier1.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a2"] - } - ] + "initialConfiguration" : ["a1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a2"] + } + ] } diff --git a/test/scxml-test-framework/test/hierarchy/hier1.scxml b/test/scxml-test-framework/test/hierarchy/hier1.scxml index 654994d..c4d76ee 100644 --- a/test/scxml-test-framework/test/hierarchy/hier1.scxml +++ b/test/scxml-test-framework/test/hierarchy/hier1.scxml @@ -15,27 +15,22 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + + - - - - + + - - + + - - - - + diff --git a/test/scxml-test-framework/test/hierarchy/hier2.json b/test/scxml-test-framework/test/hierarchy/hier2.json index 12390fe..7fd2206 100644 --- a/test/scxml-test-framework/test/hierarchy/hier2.json +++ b/test/scxml-test-framework/test/hierarchy/hier2.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] + "initialConfiguration" : ["a1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + } + ] } diff --git a/test/scxml-test-framework/test/hierarchy/hier2.scxml b/test/scxml-test-framework/test/hierarchy/hier2.scxml index e1c3bb1..d0405f6 100644 --- a/test/scxml-test-framework/test/hierarchy/hier2.scxml +++ b/test/scxml-test-framework/test/hierarchy/hier2.scxml @@ -15,27 +15,22 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + + - - - - + + - - + + - - - - + diff --git a/test/scxml-test-framework/test/history/history0.json b/test/scxml-test-framework/test/history/history0.json index b614a61..cba3ae5 100644 --- a/test/scxml-test-framework/test/history/history0.json +++ b/test/scxml-test-framework/test/history/history0.json @@ -1,23 +1,23 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b2"] - }, - { - "event" : { "name" : "t2" }, - "nextConfiguration" : ["b3"] - }, - { - "event" : { "name" : "t3" }, - "nextConfiguration" : ["a"] - }, - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b3"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b2"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["b3"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["a"] + }, + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b3"] + } + ] } diff --git a/test/scxml-test-framework/test/history/history0.scxml b/test/scxml-test-framework/test/history/history0.scxml index 1473049..0dbd622 100644 --- a/test/scxml-test-framework/test/history/history0.scxml +++ b/test/scxml-test-framework/test/history/history0.scxml @@ -15,32 +15,31 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> - - - + + + - + - - - + + + - + - - - + + + - - - - + + + + diff --git a/test/scxml-test-framework/test/history/history1.json b/test/scxml-test-framework/test/history/history1.json index 02eb502..1dfeb82 100644 --- a/test/scxml-test-framework/test/history/history1.json +++ b/test/scxml-test-framework/test/history/history1.json @@ -1,23 +1,23 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b1.2"] - }, - { - "event" : { "name" : "t2" }, - "nextConfiguration" : ["b1.3"] - }, - { - "event" : { "name" : "t3" }, - "nextConfiguration" : ["a"] - }, - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b1.3"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b1.2"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["b1.3"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["a"] + }, + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b1.3"] + } + ] } diff --git a/test/scxml-test-framework/test/history/history1.scxml b/test/scxml-test-framework/test/history/history1.scxml index 4dd5aec..6d2235f 100644 --- a/test/scxml-test-framework/test/history/history1.scxml +++ b/test/scxml-test-framework/test/history/history1.scxml @@ -15,36 +15,35 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> - - - + + + - + - - - + + + - - + + - - - + + + - - - - + + + + - + diff --git a/test/scxml-test-framework/test/history/history2.json b/test/scxml-test-framework/test/history/history2.json index 3bbcac1..4cc3ee4 100644 --- a/test/scxml-test-framework/test/history/history2.json +++ b/test/scxml-test-framework/test/history/history2.json @@ -1,23 +1,23 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b1.2"] - }, - { - "event" : { "name" : "t2" }, - "nextConfiguration" : ["b1.3"] - }, - { - "event" : { "name" : "t3" }, - "nextConfiguration" : ["a"] - }, - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b1.1"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b1.2"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["b1.3"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["a"] + }, + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b1.1"] + } + ] } diff --git a/test/scxml-test-framework/test/history/history2.scxml b/test/scxml-test-framework/test/history/history2.scxml index 9c691cb..2a2ab95 100644 --- a/test/scxml-test-framework/test/history/history2.scxml +++ b/test/scxml-test-framework/test/history/history2.scxml @@ -15,36 +15,35 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> - - - + + + - + - - - + + + - - + + - - - + + + - - - - + + + + - + diff --git a/test/scxml-test-framework/test/history/history3.json b/test/scxml-test-framework/test/history/history3.json index d7b3593..4786e3a 100644 --- a/test/scxml-test-framework/test/history/history3.json +++ b/test/scxml-test-framework/test/history/history3.json @@ -1,23 +1,23 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b1","c1"] - }, - { - "event" : { "name" : "t2" }, - "nextConfiguration" : ["b2","c2"] - }, - { - "event" : { "name" : "t3" }, - "nextConfiguration" : ["a"] - }, - { - "event" : { "name" : "t4" }, - "nextConfiguration" : ["b2","c2"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b1","c1"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["b2","c2"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["a"] + }, + { + "event" : { "name" : "t4" }, + "nextConfiguration" : ["b2","c2"] + } + ] } diff --git a/test/scxml-test-framework/test/history/history3.scxml b/test/scxml-test-framework/test/history/history3.scxml index 0723031..6fd4de1 100644 --- a/test/scxml-test-framework/test/history/history3.scxml +++ b/test/scxml-test-framework/test/history/history3.scxml @@ -15,39 +15,40 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/history/history4.json b/test/scxml-test-framework/test/history/history4.json index 094701b..e5bbc31 100644 --- a/test/scxml-test-framework/test/history/history4.json +++ b/test/scxml-test-framework/test/history/history4.json @@ -1,43 +1,43 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b1.1","c1.1"] - }, - { - "event" : { "name" : "t2" }, - "nextConfiguration" : ["b1.2","c1.2"] - }, - { - "event" : { "name" : "t3" }, - "nextConfiguration" : ["b2.1","c2.1"] - }, - { - "event" : { "name" : "t4" }, - "nextConfiguration" : ["b2.2","c2.2"] - }, - { - "event" : { "name" : "t5" }, - "nextConfiguration" : ["a"] - }, - { - "event" : { "name" : "t6" }, - "nextConfiguration" : ["b2.2","c2.1"] - }, - { - "event" : { "name" : "t7" }, - "nextConfiguration" : ["b2.2","c2.2"] - }, - { - "event" : { "name" : "t8" }, - "nextConfiguration" : ["a"] - }, - { - "event" : { "name" : "t9" }, - "nextConfiguration" : ["b2.2","c2.2"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b1.1","c1.1"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["b1.2","c1.2"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["b2.1","c2.1"] + }, + { + "event" : { "name" : "t4" }, + "nextConfiguration" : ["b2.2","c2.2"] + }, + { + "event" : { "name" : "t5" }, + "nextConfiguration" : ["a"] + }, + { + "event" : { "name" : "t6" }, + "nextConfiguration" : ["b2.2","c2.1"] + }, + { + "event" : { "name" : "t7" }, + "nextConfiguration" : ["b2.2","c2.2"] + }, + { + "event" : { "name" : "t8" }, + "nextConfiguration" : ["a"] + }, + { + "event" : { "name" : "t9" }, + "nextConfiguration" : ["b2.2","c2.2"] + } + ] } diff --git a/test/scxml-test-framework/test/history/history4.scxml b/test/scxml-test-framework/test/history/history4.scxml index 4296c8a..4c59e17 100644 --- a/test/scxml-test-framework/test/history/history4.scxml +++ b/test/scxml-test-framework/test/history/history4.scxml @@ -18,77 +18,78 @@ illustrates both deep and shallow history, working in both AND and OR states --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/history/history5.json b/test/scxml-test-framework/test/history/history5.json index a6c52a7..fcd1cb6 100644 --- a/test/scxml-test-framework/test/history/history5.json +++ b/test/scxml-test-framework/test/history/history5.json @@ -1,19 +1,19 @@ { - "initialConfiguration" : ["i1","j","h","g","f1","k"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["i2","j","h","g","f2","k"] - }, - { - "event" : { "name" : "t2" }, - "nextConfiguration" : ["l"] - }, - { - "event" : { "name" : "t3" }, - "nextConfiguration" : ["i2","j","h","g","f2","k"] - } + "initialConfiguration" : ["i1","j","h","g","f1","k"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["i2","j","h","g","f2","k"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["l"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["i2","j","h","g","f2","k"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/history/history5.scxml b/test/scxml-test-framework/test/history/history5.scxml index c2f497d..0b97e26 100644 --- a/test/scxml-test-framework/test/history/history5.scxml +++ b/test/scxml-test-framework/test/history/history5.scxml @@ -18,55 +18,56 @@ illustrates deep history with many parallel states --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/history/history6.json b/test/scxml-test-framework/test/history/history6.json index 2face8d..ff5c582 100644 --- a/test/scxml-test-framework/test/history/history6.json +++ b/test/scxml-test-framework/test/history/history6.json @@ -1,27 +1,27 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b2"] - }, - { - "event" : { "name" : "t2" }, - "nextConfiguration" : ["b3"] - }, - { - "event" : { "name" : "t3" }, - "nextConfiguration" : ["a"] - }, - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b3"] - }, - { - "event" : { "name" : "t4" }, - "nextConfiguration" : ["success"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b2"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["b3"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["a"] + }, + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b3"] + }, + { + "event" : { "name" : "t4" }, + "nextConfiguration" : ["success"] + } + ] } diff --git a/test/scxml-test-framework/test/history/history6.scxml b/test/scxml-test-framework/test/history/history6.scxml index b726427..48cfd9a 100644 --- a/test/scxml-test-framework/test/history/history6.scxml +++ b/test/scxml-test-framework/test/history/history6.scxml @@ -15,56 +15,55 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> - + - - - + + + - - - - - + + + + + - - - + + + - + - + - - + + - + - - + + - - - - - - + + + + + + diff --git a/test/scxml-test-framework/test/if-else/test0.json b/test/scxml-test-framework/test/if-else/test0.json index 8424ef5..0e49c49 100644 --- a/test/scxml-test-framework/test/if-else/test0.json +++ b/test/scxml-test-framework/test/if-else/test0.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c"] + } + ] } diff --git a/test/scxml-test-framework/test/if-else/test0.scxml b/test/scxml-test-framework/test/if-else/test0.scxml index 369222b..3dfc1a5 100644 --- a/test/scxml-test-framework/test/if-else/test0.scxml +++ b/test/scxml-test-framework/test/if-else/test0.scxml @@ -15,93 +15,92 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - + - - - + + + - + - + - - + + - - - + + + - + - + diff --git a/test/scxml-test-framework/test/in/TestInPredicate.json b/test/scxml-test-framework/test/in/TestInPredicate.json index 5ef98f1..861374e 100644 --- a/test/scxml-test-framework/test/in/TestInPredicate.json +++ b/test/scxml-test-framework/test/in/TestInPredicate.json @@ -1,47 +1,47 @@ { - "initialConfiguration" : ["a1","a2"], - "events" : [ - { - "event" : { "name" : "t1" }, - "nextConfiguration" : ["b1","a2"] - }, - { - "event" : { "name" : "t2" }, - "nextConfiguration" : ["c1","a2"] - }, - { - "event" : { "name" : "t3" }, - "nextConfiguration" : ["d1","a2"] - }, - { - "event" : { "name" : "t4" }, - "nextConfiguration" : ["e1","a2"] - }, - { - "event" : { "name" : "t5" }, - "nextConfiguration" : ["f1","a2"] - }, - { - "event" : { "name" : "t6" }, - "nextConfiguration" : ["g1","b2"] - }, - { - "event" : { "name" : "t7" }, - "nextConfiguration" : ["h1","d2"] - }, - { - "event" : { "name" : "t8" }, - "nextConfiguration" : ["i1","d2"] - }, - { - "event" : { "name" : "t9" }, - "nextConfiguration" : ["j1","e2"] - }, - { - "event" : { "name" : "t10" }, - "nextConfiguration" : ["k1","e2"] - } - ] + "initialConfiguration" : ["a1","a2"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["b1","a2"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["c1","a2"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["d1","a2"] + }, + { + "event" : { "name" : "t4" }, + "nextConfiguration" : ["e1","a2"] + }, + { + "event" : { "name" : "t5" }, + "nextConfiguration" : ["f1","a2"] + }, + { + "event" : { "name" : "t6" }, + "nextConfiguration" : ["g1","b2"] + }, + { + "event" : { "name" : "t7" }, + "nextConfiguration" : ["h1","d2"] + }, + { + "event" : { "name" : "t8" }, + "nextConfiguration" : ["i1","d2"] + }, + { + "event" : { "name" : "t9" }, + "nextConfiguration" : ["j1","e2"] + }, + { + "event" : { "name" : "t10" }, + "nextConfiguration" : ["k1","e2"] + } + ] } diff --git a/test/scxml-test-framework/test/in/TestInPredicate.scxml b/test/scxml-test-framework/test/in/TestInPredicate.scxml index 4a6fedb..d89611b 100644 --- a/test/scxml-test-framework/test/in/TestInPredicate.scxml +++ b/test/scxml-test-framework/test/in/TestInPredicate.scxml @@ -19,94 +19,90 @@ This is to test the use of the In() predicate. --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + initial="p1" + version="1.0"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/internal-transitions/test0.json b/test/scxml-test-framework/test/internal-transitions/test0.json new file mode 100644 index 0000000..4808030 --- /dev/null +++ b/test/scxml-test-framework/test/internal-transitions/test0.json @@ -0,0 +1,17 @@ +{ + "initialConfiguration" : ["a1"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["a2"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["b"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["c"] + } + ] +} diff --git a/test/scxml-test-framework/test/internal-transitions/test0.scxml b/test/scxml-test-framework/test/internal-transitions/test0.scxml new file mode 100644 index 0000000..f9a620d --- /dev/null +++ b/test/scxml-test-framework/test/internal-transitions/test0.scxml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/internal-transitions/test1.json b/test/scxml-test-framework/test/internal-transitions/test1.json new file mode 100644 index 0000000..d3e59ca --- /dev/null +++ b/test/scxml-test-framework/test/internal-transitions/test1.json @@ -0,0 +1,18 @@ +{ + "initialConfiguration" : ["a1", "b1"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["a2", "b1"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["c"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["d"] + } + ] +} + diff --git a/test/scxml-test-framework/test/internal-transitions/test1.scxml b/test/scxml-test-framework/test/internal-transitions/test1.scxml new file mode 100644 index 0000000..81e7cc3 --- /dev/null +++ b/test/scxml-test-framework/test/internal-transitions/test1.scxml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/more-parallel/test0.json b/test/scxml-test-framework/test/more-parallel/test0.json index 4de58d0..a316c55 100644 --- a/test/scxml-test-framework/test/more-parallel/test0.json +++ b/test/scxml-test-framework/test/more-parallel/test0.json @@ -1,10 +1,10 @@ { - "initialConfiguration" : ["a","b"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a","b"] - } + "initialConfiguration" : ["a","b"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a","b"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/more-parallel/test0.scxml b/test/scxml-test-framework/test/more-parallel/test0.scxml index 460143d..19ab416 100644 --- a/test/scxml-test-framework/test/more-parallel/test0.scxml +++ b/test/scxml-test-framework/test/more-parallel/test0.scxml @@ -15,17 +15,17 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - - + + + + - - + + diff --git a/test/scxml-test-framework/test/more-parallel/test1.json b/test/scxml-test-framework/test/more-parallel/test1.json index 29793c8..0fb5018 100644 --- a/test/scxml-test-framework/test/more-parallel/test1.json +++ b/test/scxml-test-framework/test/more-parallel/test1.json @@ -1,10 +1,10 @@ { - "initialConfiguration" : ["a1","b1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a1","b1"] - } + "initialConfiguration" : ["a1","b1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a1","b1"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/more-parallel/test1.scxml b/test/scxml-test-framework/test/more-parallel/test1.scxml index 94afb20..58eee87 100644 --- a/test/scxml-test-framework/test/more-parallel/test1.scxml +++ b/test/scxml-test-framework/test/more-parallel/test1.scxml @@ -15,28 +15,27 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - + + - + - - + + - + - + - - - + + + diff --git a/test/scxml-test-framework/test/more-parallel/test10.json b/test/scxml-test-framework/test/more-parallel/test10.json new file mode 100644 index 0000000..b02dc37 --- /dev/null +++ b/test/scxml-test-framework/test/more-parallel/test10.json @@ -0,0 +1,17 @@ +{ + "initialConfiguration" : ["a","b"], + "events" : [ + { + "event" : { "name" : "t1" }, + "nextConfiguration" : ["a","b"] + }, + { + "event" : { "name" : "t2" }, + "nextConfiguration" : ["c"] + }, + { + "event" : { "name" : "t3" }, + "nextConfiguration" : ["d"] + } + ] +} diff --git a/test/scxml-test-framework/test/more-parallel/test10.scxml b/test/scxml-test-framework/test/more-parallel/test10.scxml new file mode 100644 index 0000000..1d6f371 --- /dev/null +++ b/test/scxml-test-framework/test/more-parallel/test10.scxml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/more-parallel/test2.json b/test/scxml-test-framework/test/more-parallel/test2.json index f024462..afcef7a 100644 --- a/test/scxml-test-framework/test/more-parallel/test2.json +++ b/test/scxml-test-framework/test/more-parallel/test2.json @@ -1,10 +1,10 @@ { - "initialConfiguration" : ["a1","b1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a1","b2"] - } + "initialConfiguration" : ["a1","b1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a1","b2"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/more-parallel/test2.scxml b/test/scxml-test-framework/test/more-parallel/test2.scxml index 96d54fd..2adbb3b 100644 --- a/test/scxml-test-framework/test/more-parallel/test2.scxml +++ b/test/scxml-test-framework/test/more-parallel/test2.scxml @@ -15,30 +15,29 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - + + - + - - + + - + - - - + + + - - - + + + diff --git a/test/scxml-test-framework/test/more-parallel/test3.json b/test/scxml-test-framework/test/more-parallel/test3.json index c2277fa..bc31df4 100644 --- a/test/scxml-test-framework/test/more-parallel/test3.json +++ b/test/scxml-test-framework/test/more-parallel/test3.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a1","b1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a2","b2"] - } + "initialConfiguration" : ["a1","b1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a1","b2"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/more-parallel/test3.scxml b/test/scxml-test-framework/test/more-parallel/test3.scxml index e959293..14d613e 100644 --- a/test/scxml-test-framework/test/more-parallel/test3.scxml +++ b/test/scxml-test-framework/test/more-parallel/test3.scxml @@ -15,34 +15,29 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" > - - + + - + - - + + - + - - - + + + - - - + + + - - - - diff --git a/test/scxml-test-framework/test/more-parallel/test4.json b/test/scxml-test-framework/test/more-parallel/test4.json index 8335a57..3f05f83 100644 --- a/test/scxml-test-framework/test/more-parallel/test4.json +++ b/test/scxml-test-framework/test/more-parallel/test4.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["a1","b1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a1","b1"] - } + "initialConfiguration" : ["a1","b1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a1","b1"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/more-parallel/test4.scxml b/test/scxml-test-framework/test/more-parallel/test4.scxml index 3818e1b..b211cad 100644 --- a/test/scxml-test-framework/test/more-parallel/test4.scxml +++ b/test/scxml-test-framework/test/more-parallel/test4.scxml @@ -15,30 +15,29 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - + + - + - - + + - + - + - - - + + + diff --git a/test/scxml-test-framework/test/more-parallel/test5.json b/test/scxml-test-framework/test/more-parallel/test5.json index 16791aa..b07bacf 100644 --- a/test/scxml-test-framework/test/more-parallel/test5.json +++ b/test/scxml-test-framework/test/more-parallel/test5.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["a1","b1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a2","b2"] - } - - ] + "initialConfiguration" : ["a1","b1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a2","b1"] + } + + ] } diff --git a/test/scxml-test-framework/test/more-parallel/test5.scxml b/test/scxml-test-framework/test/more-parallel/test5.scxml index df2fc78..7f4c7ab 100644 --- a/test/scxml-test-framework/test/more-parallel/test5.scxml +++ b/test/scxml-test-framework/test/more-parallel/test5.scxml @@ -15,30 +15,29 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - + + - + - - + + - + - + - - - + + + diff --git a/test/scxml-test-framework/test/more-parallel/test6.json b/test/scxml-test-framework/test/more-parallel/test6.json index 17a169b..9e33fe5 100644 --- a/test/scxml-test-framework/test/more-parallel/test6.json +++ b/test/scxml-test-framework/test/more-parallel/test6.json @@ -1,10 +1,10 @@ { - "initialConfiguration" : ["a11","b11"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a22","b12"] - } + "initialConfiguration" : ["a11","b11"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a11","b12"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/more-parallel/test6.scxml b/test/scxml-test-framework/test/more-parallel/test6.scxml index 35be417..efe2442 100644 --- a/test/scxml-test-framework/test/more-parallel/test6.scxml +++ b/test/scxml-test-framework/test/more-parallel/test6.scxml @@ -15,42 +15,41 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - + + - - - - + + + + - - - - - + + + + + - + - - + + - - - - - - - - - - + + + + + + + + + + diff --git a/test/scxml-test-framework/test/more-parallel/test7.json b/test/scxml-test-framework/test/more-parallel/test7.json index 12c66d9..db9e53f 100644 --- a/test/scxml-test-framework/test/more-parallel/test7.json +++ b/test/scxml-test-framework/test/more-parallel/test7.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a11","b11"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a22","b22"] - } + "initialConfiguration" : ["a11","b11"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a22","b11"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/more-parallel/test7.scxml b/test/scxml-test-framework/test/more-parallel/test7.scxml index 6050d0e..dcaee1e 100644 --- a/test/scxml-test-framework/test/more-parallel/test7.scxml +++ b/test/scxml-test-framework/test/more-parallel/test7.scxml @@ -15,42 +15,41 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - + + - - - - + + + + - - - - - + + + + + - + - - - - - - - - - - - + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/more-parallel/test8.json b/test/scxml-test-framework/test/more-parallel/test8.json index 26269b8..d36bc3c 100644 --- a/test/scxml-test-framework/test/more-parallel/test8.json +++ b/test/scxml-test-framework/test/more-parallel/test8.json @@ -1,10 +1,10 @@ { - "initialConfiguration" : ["x"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a22","b11"] - } + "initialConfiguration" : ["x"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a22","b11"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/more-parallel/test8.scxml b/test/scxml-test-framework/test/more-parallel/test8.scxml index 03f492a..1c6f60c 100644 --- a/test/scxml-test-framework/test/more-parallel/test8.scxml +++ b/test/scxml-test-framework/test/more-parallel/test8.scxml @@ -15,39 +15,38 @@ limitations under the License. --> - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/more-parallel/test9.json b/test/scxml-test-framework/test/more-parallel/test9.json index b435564..142f1f7 100644 --- a/test/scxml-test-framework/test/more-parallel/test9.json +++ b/test/scxml-test-framework/test/more-parallel/test9.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["x"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a22","b22"] - } + "initialConfiguration" : ["x"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a22","b22"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/more-parallel/test9.scxml b/test/scxml-test-framework/test/more-parallel/test9.scxml index 9223c95..0e95f17 100644 --- a/test/scxml-test-framework/test/more-parallel/test9.scxml +++ b/test/scxml-test-framework/test/more-parallel/test9.scxml @@ -15,40 +15,39 @@ limitations under the License. --> - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/multiple-events-per-transition/test1.json b/test/scxml-test-framework/test/multiple-events-per-transition/test1.json index aa3a778..155aa6f 100644 --- a/test/scxml-test-framework/test/multiple-events-per-transition/test1.json +++ b/test/scxml-test-framework/test/multiple-events-per-transition/test1.json @@ -1,19 +1,19 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "foo" }, - "nextConfiguration" : ["b"] - }, - { - "event" : { "name" : "bar" }, - "nextConfiguration" : ["c"] - }, - { - "event" : { "name" : "bat" }, - "nextConfiguration" : ["d"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "foo" }, + "nextConfiguration" : ["b"] + }, + { + "event" : { "name" : "bar" }, + "nextConfiguration" : ["c"] + }, + { + "event" : { "name" : "bat" }, + "nextConfiguration" : ["d"] + } + ] } diff --git a/test/scxml-test-framework/test/multiple-events-per-transition/test1.scxml b/test/scxml-test-framework/test/multiple-events-per-transition/test1.scxml index fdea437..3ee5fa2 100644 --- a/test/scxml-test-framework/test/multiple-events-per-transition/test1.scxml +++ b/test/scxml-test-framework/test/multiple-events-per-transition/test1.scxml @@ -15,22 +15,22 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + - - - + + + - - - + + + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test0.json b/test/scxml-test-framework/test/parallel+interrupt/test0.json index f8c3982..95b109d 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test0.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test0.json @@ -1,10 +1,10 @@ { - "initialConfiguration" : ["c","d"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a1"] - } + "initialConfiguration" : ["c","d"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a1"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test0.scxml b/test/scxml-test-framework/test/parallel+interrupt/test0.scxml index 5684784..e8072f0 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test0.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test0.scxml @@ -19,26 +19,25 @@ orthogonal preemption - inner or states interrupt one-another in our semantics, source state is at the same level of hierarchy, so document order will resolve conflict. a1 will win. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - + + + + - - - + + + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test1.json b/test/scxml-test-framework/test/parallel+interrupt/test1.json index 09312a0..723901c 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test1.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test1.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["c1","d1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c2","d1"] - } + "initialConfiguration" : ["c1","d1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c2","d1"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test1.scxml b/test/scxml-test-framework/test/parallel+interrupt/test1.scxml index 8dd8661..83ad119 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test1.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test1.scxml @@ -19,29 +19,28 @@ orthogonal preemption - transition originating at inner OR state interrupts tran first OR state should win, as the transitions originate at the same level of hierarchy, and wins by document order --> - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test10.json b/test/scxml-test-framework/test/parallel+interrupt/test10.json index 4db82db..cc1a4ff 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test10.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test10.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["b1","b2"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c1","c2"] - } - - ] + "initialConfiguration" : ["b1","b2"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c1","c2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test10.scxml b/test/scxml-test-framework/test/parallel+interrupt/test10.scxml index bf84721..b68c38e 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test10.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test10.scxml @@ -20,32 +20,31 @@ initial: [b1,b2] after t: [c1,c2] --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> - + - + - - - + + + - - - + + + - - - + + + - - - - + + + + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test11.json b/test/scxml-test-framework/test/parallel+interrupt/test11.json index 3d4a03b..19f29fb 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test11.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test11.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["b1","b2"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["d"] - } - - ] + "initialConfiguration" : ["b1","b2"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["d"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test11.scxml b/test/scxml-test-framework/test/parallel+interrupt/test11.scxml index 0ba2be3..c098dc0 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test11.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test11.scxml @@ -4,35 +4,34 @@ initial: [b1,b2] after t: [d] --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> - + - - - - + + + + - - - + + + - + - - - + + + - - - + + + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test12.json b/test/scxml-test-framework/test/parallel+interrupt/test12.json index c1d01f4..93a1a43 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test12.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test12.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["b1","b2"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c1","c2"] - } - - ] + "initialConfiguration" : ["b1","b2"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c1","c2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test12.scxml b/test/scxml-test-framework/test/parallel+interrupt/test12.scxml index 8f7a66a..f7025a4 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test12.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test12.scxml @@ -19,35 +19,34 @@ initial: [b1,b2] after t: [c1,c2] --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> - - - - - + + + + + - - - + + + - + - - - + + + - - - + + + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test13.json b/test/scxml-test-framework/test/parallel+interrupt/test13.json index b97af4f..f84429c 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test13.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test13.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["b1","b2"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c1","c2"] - } - - ] + "initialConfiguration" : ["b1","b2"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c1","c2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test13.scxml b/test/scxml-test-framework/test/parallel+interrupt/test13.scxml index a0fcf54..5e87469 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test13.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test13.scxml @@ -19,37 +19,36 @@ initial: [b1,b2] after t: [c1,c2] --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> - + - - - - + + + + - - + + - + - + - - - + + + - - - + + + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test14.json b/test/scxml-test-framework/test/parallel+interrupt/test14.json index cd93b1d..f3c1994 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test14.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test14.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["i1","j","h","g","f1","k"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["l"] - } - - ] + "initialConfiguration" : ["i1","j","h","g","f1","k"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["l"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test14.scxml b/test/scxml-test-framework/test/parallel+interrupt/test14.scxml index 098ecf1..dead195 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test14.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test14.scxml @@ -19,50 +19,49 @@ initial: [i1,j,h,g,f1,i1,k] after t: [l] --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test15.json b/test/scxml-test-framework/test/parallel+interrupt/test15.json index 6737f6e..e3d8a56 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test15.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test15.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["i1","j","h","g","f1","k"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["i2","j","h","g","f1","k"] - } - - ] + "initialConfiguration" : ["i1","j","h","g","f1","k"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["i2","j","h","g","f1","k"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test15.scxml b/test/scxml-test-framework/test/parallel+interrupt/test15.scxml index d9bf6f8..2c2fc67 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test15.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test15.scxml @@ -19,48 +19,47 @@ initial: [i1,j,h,g,f1,i1,k] after t: ["i2","j","h","g","f1","k"] --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> - - - - - + + + + + - - - - + + + + - - - + + + - - + + - - + + - - + + - - - - + + + + - - - - + + + + - - + + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test16.json b/test/scxml-test-framework/test/parallel+interrupt/test16.json index 3e7a63f..b73fce9 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test16.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test16.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c","d"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a1"] - } - - ] + "initialConfiguration" : ["c","d"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a1"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test16.scxml b/test/scxml-test-framework/test/parallel+interrupt/test16.scxml index 3312fa8..d7ec9fc 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test16.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test16.scxml @@ -20,27 +20,26 @@ illustrates target interrupt in our semantics, source state is at the same level of hierarchy, so document order will resolve conflict. a1 will win. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - + + + + - - - + + + - + - - + + - - + + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test17.json b/test/scxml-test-framework/test/parallel+interrupt/test17.json index 586da7a..5b9f8af 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test17.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test17.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c","d"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a2"] - } - - ] + "initialConfiguration" : ["c","d"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test17.scxml b/test/scxml-test-framework/test/parallel+interrupt/test17.scxml index 944c2b0..4af40c5 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test17.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test17.scxml @@ -20,28 +20,27 @@ illustrates target interrupt in our semantics, source state is at the same level of hierarchy, so document order will resolve conflict. a1 will win. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - + + + + - - - + + + - + - - + + - - + + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test18.json b/test/scxml-test-framework/test/parallel+interrupt/test18.json index 46b284f..55abbba 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test18.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test18.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c","d"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a2"] - } - - ] + "initialConfiguration" : ["c","d"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test18.scxml b/test/scxml-test-framework/test/parallel+interrupt/test18.scxml index 2765d52..e0d14a8 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test18.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test18.scxml @@ -16,25 +16,24 @@ --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - + + - - - + + + - - + + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test19.json b/test/scxml-test-framework/test/parallel+interrupt/test19.json index e899562..9c0458f 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test19.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test19.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c1","d1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c2","d2"] - } - - ] + "initialConfiguration" : ["c1","d1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c2","d2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test19.scxml b/test/scxml-test-framework/test/parallel+interrupt/test19.scxml index 1eee200..d5c8967 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test19.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test19.scxml @@ -16,34 +16,33 @@ --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - - + + + + + - - + + - - - - + + + + - - + + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test2.json b/test/scxml-test-framework/test/parallel+interrupt/test2.json index 5d1076a..e3b3b9d 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test2.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test2.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c1","d1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a1"] - } + "initialConfiguration" : ["c1","d1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a1"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test2.scxml b/test/scxml-test-framework/test/parallel+interrupt/test2.scxml index 975431d..1c3757f 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test2.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test2.scxml @@ -19,34 +19,33 @@ orthogonal preemption - transition originating at inner OR state interrupts tran again, first OR state should win, as the transitions originate at the same level of hierarchy, and wins by document order --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - + - - - - + + + + - - + + - - - - + + + + - - + + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test20.json b/test/scxml-test-framework/test/parallel+interrupt/test20.json index c29b31d..470a986 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test20.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test20.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c1","d"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c2","d"] - } - - ] + "initialConfiguration" : ["c1","d"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c2","d"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test20.scxml b/test/scxml-test-framework/test/parallel+interrupt/test20.scxml index 1e2473c..2066be5 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test20.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test20.scxml @@ -18,32 +18,31 @@ here we have multiple interrupt conflicts, originating from d and a2. transition from c1 will win, for same reasons listed above --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - - + + + + + - - + + - - - + + + - + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test21.json b/test/scxml-test-framework/test/parallel+interrupt/test21.json index 99f729c..15fb75b 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test21.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test21.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c","d1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c","d2"] - } - - ] + "initialConfiguration" : ["c","d1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c","d2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test21.scxml b/test/scxml-test-framework/test/parallel+interrupt/test21.scxml index 55bdcdf..4e66fda 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test21.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test21.scxml @@ -18,31 +18,30 @@ here we have multiple interrupt conflicts, originating from d and a2. transition from d1 will win, for same reasons listed above --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - + - - - + + + - - - - + + + + - - + + - + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test22.json b/test/scxml-test-framework/test/parallel+interrupt/test22.json index d3434f7..4d7bf5a 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test22.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test22.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c1","d1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c2","d2"] - } - - ] + "initialConfiguration" : ["c1","d1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c2","d2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test22.scxml b/test/scxml-test-framework/test/parallel+interrupt/test22.scxml index b313fa5..2e71d50 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test22.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test22.scxml @@ -18,33 +18,32 @@ here we have multiple interrupt conflicts, originating from d and a2. transitions from c1 and d1 will win, for same reasons listed above --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - - + + + + + - - + + - - - - + + + + - - + + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test23.json b/test/scxml-test-framework/test/parallel+interrupt/test23.json index 7321890..db53da4 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test23.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test23.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c","d"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a2"] - } - - ] + "initialConfiguration" : ["c","d"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test23.scxml b/test/scxml-test-framework/test/parallel+interrupt/test23.scxml index e5b24e7..04245a6 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test23.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test23.scxml @@ -16,25 +16,24 @@ --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - + + - - - + + + - - + + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test24.json b/test/scxml-test-framework/test/parallel+interrupt/test24.json index 90c50b5..d1c8f8b 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test24.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test24.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c1","d1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c2","d2"] - } - - ] + "initialConfiguration" : ["c1","d1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c2","d2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test24.scxml b/test/scxml-test-framework/test/parallel+interrupt/test24.scxml index 1faa9ce..6534d68 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test24.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test24.scxml @@ -16,34 +16,33 @@ --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - - + + + + + - - + + - - - - + + + + - - + + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test25.json b/test/scxml-test-framework/test/parallel+interrupt/test25.json index 444f24e..7c380c8 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test25.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test25.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c1","d"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c2","d"] - } - - ] + "initialConfiguration" : ["c1","d"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c2","d"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test25.scxml b/test/scxml-test-framework/test/parallel+interrupt/test25.scxml index add7ebd..2084c90 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test25.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test25.scxml @@ -18,32 +18,31 @@ here we have multiple interrupt conflicts, originating from d and b. transition from c1 will win, for same reasons listed above --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - - + + + + + - - + + - - - + + + - + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test26.json b/test/scxml-test-framework/test/parallel+interrupt/test26.json index e6740f3..89e21a1 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test26.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test26.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c","d1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c","d2"] - } - - ] + "initialConfiguration" : ["c","d1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c","d2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test26.scxml b/test/scxml-test-framework/test/parallel+interrupt/test26.scxml index 1a5ab71..355e7f0 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test26.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test26.scxml @@ -3,33 +3,32 @@ here we have multiple interrupt conflicts, originating from d and a2. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - + - - - + + + - - - - + + + + - - + + - + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test27.json b/test/scxml-test-framework/test/parallel+interrupt/test27.json index 1bfe6bf..46de906 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test27.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test27.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c1","d1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c2","d2"] - } - - ] + "initialConfiguration" : ["c1","d1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c2","d2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test27.scxml b/test/scxml-test-framework/test/parallel+interrupt/test27.scxml index 6bf78b8..e5b7384 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test27.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test27.scxml @@ -18,34 +18,33 @@ here we have multiple interrupt conflicts, originating from d and a2. transitions from c1 and d1 will win, for same reasons listed above --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - - + + + + + - - + + - - - - + + + + - - + + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test28.json b/test/scxml-test-framework/test/parallel+interrupt/test28.json index 54a4859..ebb83a8 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test28.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test28.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c","d"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a2"] - } - - ] + "initialConfiguration" : ["c","d"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test28.scxml b/test/scxml-test-framework/test/parallel+interrupt/test28.scxml index a0ce570..724a023 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test28.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test28.scxml @@ -18,28 +18,27 @@ inner transition will have priority, so final state will be a2. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - + + - - - + + + - - + + - - + + - - + + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test29.json b/test/scxml-test-framework/test/parallel+interrupt/test29.json index cf79edb..744f5da 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test29.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test29.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c","d"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a1"] - } - - ] + "initialConfiguration" : ["c","d"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a1"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test29.scxml b/test/scxml-test-framework/test/parallel+interrupt/test29.scxml index 3e111d8..d6bc1f0 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test29.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test29.scxml @@ -18,28 +18,27 @@ inner transition will have priority, so final state will be a1. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - + + - - - + + + - - + + - - + + - - + + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test3.json b/test/scxml-test-framework/test/parallel+interrupt/test3.json index e2fcd8b..804186e 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test3.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test3.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["e","f","d"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a1"] - } - - ] + "initialConfiguration" : ["e","f","d"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a1"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test3.scxml b/test/scxml-test-framework/test/parallel+interrupt/test3.scxml index 84c8c78..a21a4e2 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test3.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test3.scxml @@ -4,37 +4,36 @@ orthogonal preemption - inner or states interrupt one-another in our semantics, source state is at the same level of hierarchy, so document order will resolve conflict. a1 will win. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - - + + + + + - - - + + + - - + + - - - + + + - + - + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test30.json b/test/scxml-test-framework/test/parallel+interrupt/test30.json index 4f2cf18..3730a94 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test30.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test30.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c1","d"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c2","d"] - } - - ] + "initialConfiguration" : ["c1","d"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c2","d"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test30.scxml b/test/scxml-test-framework/test/parallel+interrupt/test30.scxml index 6163338..b10720b 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test30.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test30.scxml @@ -19,34 +19,33 @@ here we have multiple interrupt conflicts, originating from d and a2. transition from c1 will win, for same reasons listed above. final state will be: c2 --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - - + + + + + - - + + - - - + + + - + - + - - + + - - + + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test31.json b/test/scxml-test-framework/test/parallel+interrupt/test31.json index 355a5b3..a66b39a 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test31.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test31.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c1","d1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a1"] - } - - ] + "initialConfiguration" : ["c1","d1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a1"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test31.scxml b/test/scxml-test-framework/test/parallel+interrupt/test31.scxml index c20d2d9..a90fe8f 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test31.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test31.scxml @@ -19,37 +19,36 @@ here we have multiple interrupt conflicts, originating from d and a2. transition from c1 will win, for same reasons listed above. final state will be: a1 --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - + - - - - - + + + + + - - - - + + + + - - + + - + - + - - + + - - + + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test4.json b/test/scxml-test-framework/test/parallel+interrupt/test4.json index bbdc56d..497debc 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test4.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test4.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["e","f","g"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a1"] - } - - ] + "initialConfiguration" : ["e","f","g"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a1"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test4.scxml b/test/scxml-test-framework/test/parallel+interrupt/test4.scxml index d705279..ca9d2bd 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test4.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test4.scxml @@ -18,43 +18,42 @@ orthogonal preemption - inner or states interrupt one-another --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - - + + + + + - - - + + + - - + + - - - - + + + + - - + + - + - + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test5.json b/test/scxml-test-framework/test/parallel+interrupt/test5.json index fd1c05f..117dc4d 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test5.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test5.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["e","f","g"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["e","f","h"] - } - - ] + "initialConfiguration" : ["e","f","g"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["e","f","h"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test5.scxml b/test/scxml-test-framework/test/parallel+interrupt/test5.scxml index f96d49e..2d853a4 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test5.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test5.scxml @@ -18,41 +18,40 @@ orthogonal preemption - inner or states interrupt one-another --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - - + + + + + - - + + - - - - + + + + - - - + + + - - - + + + - + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test6.json b/test/scxml-test-framework/test/parallel+interrupt/test6.json index 8cec47b..2876d0b 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test6.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test6.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["g","e1","f1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["h","e2","f2"] - } + "initialConfiguration" : ["g","e1","f1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["h","e2","f2"] + } - ] + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test6.scxml b/test/scxml-test-framework/test/parallel+interrupt/test6.scxml index e2640ba..5b5702a 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test6.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test6.scxml @@ -16,47 +16,46 @@ --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - - + + + + + - - + + - - - - - + + + + + - - + + - - - - + + + + - - + + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test7.json b/test/scxml-test-framework/test/parallel+interrupt/test7.json index 2c94f66..ec5e2b4 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test7.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test7.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["c","e1","f1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c","e2","f2"] - } - - ] + "initialConfiguration" : ["c","e1","f1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c","e2","f2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test7.scxml b/test/scxml-test-framework/test/parallel+interrupt/test7.scxml index b16c052..97a3513 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test7.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test7.scxml @@ -22,39 +22,38 @@ initial configuration: [c,e1,f1] given event t: [c,e2,f2] --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="b"> - - - - + + + + - - - - - + + + + + - - + + - - - - + + + + - - + + - + - + - + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test8.json b/test/scxml-test-framework/test/parallel+interrupt/test8.json index 95ce85e..dea59df 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test8.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test8.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["b1","b2"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c1","c2"] - } - - ] + "initialConfiguration" : ["b1","b2"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c1","c2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test8.scxml b/test/scxml-test-framework/test/parallel+interrupt/test8.scxml index a81b230..9068ff3 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test8.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test8.scxml @@ -20,31 +20,30 @@ initial: [b1,b2] after t: [c1,c2] --> - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/parallel+interrupt/test9.json b/test/scxml-test-framework/test/parallel+interrupt/test9.json index b7eb5cd..621ba48 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test9.json +++ b/test/scxml-test-framework/test/parallel+interrupt/test9.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["b1","b2"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c1","c2"] - } - - ] + "initialConfiguration" : ["b1","b2"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c1","c2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel+interrupt/test9.scxml b/test/scxml-test-framework/test/parallel+interrupt/test9.scxml index 0169ed4..65231e8 100644 --- a/test/scxml-test-framework/test/parallel+interrupt/test9.scxml +++ b/test/scxml-test-framework/test/parallel+interrupt/test9.scxml @@ -20,30 +20,29 @@ initial: [b1,b2] after t: [c1,c2] --> - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="a"> + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/parallel/test0.json b/test/scxml-test-framework/test/parallel/test0.json index 5eccd85..0150078 100644 --- a/test/scxml-test-framework/test/parallel/test0.json +++ b/test/scxml-test-framework/test/parallel/test0.json @@ -1,6 +1,6 @@ { - "initialConfiguration" : ["a","b"], - "events" : [ ] + "initialConfiguration" : ["a","b"], + "events" : [ ] } diff --git a/test/scxml-test-framework/test/parallel/test0.scxml b/test/scxml-test-framework/test/parallel/test0.scxml index 968b281..6ae0838 100644 --- a/test/scxml-test-framework/test/parallel/test0.scxml +++ b/test/scxml-test-framework/test/parallel/test0.scxml @@ -15,20 +15,15 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + - - - - - + + diff --git a/test/scxml-test-framework/test/parallel/test1.json b/test/scxml-test-framework/test/parallel/test1.json index 16791aa..6827a36 100644 --- a/test/scxml-test-framework/test/parallel/test1.json +++ b/test/scxml-test-framework/test/parallel/test1.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["a1","b1"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["a2","b2"] - } - - ] + "initialConfiguration" : ["a1","b1"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["a2","b2"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel/test1.scxml b/test/scxml-test-framework/test/parallel/test1.scxml deleted file mode 100644 index 8fb9fda..0000000 --- a/test/scxml-test-framework/test/parallel/test1.scxml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/scxml-test-framework/test/parallel/test1.scxml.fail b/test/scxml-test-framework/test/parallel/test1.scxml.fail new file mode 100644 index 0000000..1c0fc61 --- /dev/null +++ b/test/scxml-test-framework/test/parallel/test1.scxml.fail @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/parallel/test2.json b/test/scxml-test-framework/test/parallel/test2.json index 367322c..7e7f790 100644 --- a/test/scxml-test-framework/test/parallel/test2.json +++ b/test/scxml-test-framework/test/parallel/test2.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["s3","s4","s7","s8"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["s5","s6","s9","s10"] - } - - ] + "initialConfiguration" : ["s3","s4","s7","s8"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["s5","s6","s9","s10"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel/test2.scxml b/test/scxml-test-framework/test/parallel/test2.scxml index 2802842..c73d0dd 100644 --- a/test/scxml-test-framework/test/parallel/test2.scxml +++ b/test/scxml-test-framework/test/parallel/test2.scxml @@ -19,50 +19,45 @@ initial configuration: [s3,s4,s7,s8] after event t: [s5,s6,s9,s10] --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + + - - - - + - + + - - + + - - + + - - + - + + + - - - + - + + - - + + - - + + + - - - - - + diff --git a/test/scxml-test-framework/test/parallel/test3.json b/test/scxml-test-framework/test/parallel/test3.json index 99379fe..88737e1 100644 --- a/test/scxml-test-framework/test/parallel/test3.json +++ b/test/scxml-test-framework/test/parallel/test3.json @@ -1,12 +1,12 @@ { - "initialConfiguration" : ["s3.1","s4","s7","s8"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["s3.2","s4","s9","s10"] - } - - ] + "initialConfiguration" : ["s3.1","s4","s7","s8"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["s3.2","s4","s9","s10"] + } + + ] } diff --git a/test/scxml-test-framework/test/parallel/test3.scxml b/test/scxml-test-framework/test/parallel/test3.scxml index a0ab2ff..e143417 100644 --- a/test/scxml-test-framework/test/parallel/test3.scxml +++ b/test/scxml-test-framework/test/parallel/test3.scxml @@ -19,59 +19,58 @@ initial configuration: [s3.1,s4,s7,s8] after event t: [s3.2,s4,s9,s10] --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0" + initial="p1"> - - - - - - - + + + + + + + - - + + - - + + - + - - - + + + - - - + + + - + - - - - + + + + - - + + - - + + - - - + + + - - - - + + + + - + diff --git a/test/scxml-test-framework/test/script-src/script-0-0.js b/test/scxml-test-framework/test/script-src/script-0-0.js index 6a2b22f..062f555 100644 --- a/test/scxml-test-framework/test/script-src/script-0-0.js +++ b/test/scxml-test-framework/test/script-src/script-0-0.js @@ -1 +1 @@ -setData('a',100); +x = 100; diff --git a/test/scxml-test-framework/test/script-src/script-1-0.js b/test/scxml-test-framework/test/script-src/script-1-0.js index e93bc2c..226697f 100644 --- a/test/scxml-test-framework/test/script-src/script-1-0.js +++ b/test/scxml-test-framework/test/script-src/script-1-0.js @@ -1 +1 @@ -setData('i',0) +i = 0; diff --git a/test/scxml-test-framework/test/script-src/script-1-1.js b/test/scxml-test-framework/test/script-src/script-1-1.js index 5c7d88d..8dca7b1 100644 --- a/test/scxml-test-framework/test/script-src/script-1-1.js +++ b/test/scxml-test-framework/test/script-src/script-1-1.js @@ -1 +1 @@ -setData('i',getData('i') + 1) +i = i + 1; diff --git a/test/scxml-test-framework/test/script-src/script-2-0.js b/test/scxml-test-framework/test/script-src/script-2-0.js index e93bc2c..226697f 100644 --- a/test/scxml-test-framework/test/script-src/script-2-0.js +++ b/test/scxml-test-framework/test/script-src/script-2-0.js @@ -1 +1 @@ -setData('i',0) +i = 0; diff --git a/test/scxml-test-framework/test/script-src/script-2-1.js b/test/scxml-test-framework/test/script-src/script-2-1.js index 5c7d88d..8dca7b1 100644 --- a/test/scxml-test-framework/test/script-src/script-2-1.js +++ b/test/scxml-test-framework/test/script-src/script-2-1.js @@ -1 +1 @@ -setData('i',getData('i') + 1) +i = i + 1; diff --git a/test/scxml-test-framework/test/script-src/script-2-2.js b/test/scxml-test-framework/test/script-src/script-2-2.js index 5c7d88d..8dca7b1 100644 --- a/test/scxml-test-framework/test/script-src/script-2-2.js +++ b/test/scxml-test-framework/test/script-src/script-2-2.js @@ -1 +1 @@ -setData('i',getData('i') + 1) +i = i + 1; diff --git a/test/scxml-test-framework/test/script-src/script-2-3.js b/test/scxml-test-framework/test/script-src/script-2-3.js index d60b3c8..795c1f2 100644 --- a/test/scxml-test-framework/test/script-src/script-2-3.js +++ b/test/scxml-test-framework/test/script-src/script-2-3.js @@ -1 +1 @@ -setData('i',getData('i') * 2) +i = i * 2; diff --git a/test/scxml-test-framework/test/script-src/script-3-0.js b/test/scxml-test-framework/test/script-src/script-3-0.js index ccc8f7b..de469c4 100644 --- a/test/scxml-test-framework/test/script-src/script-3-0.js +++ b/test/scxml-test-framework/test/script-src/script-3-0.js @@ -1,3 +1,3 @@ function foo(){ - a = 100; + x = 100; } diff --git a/test/scxml-test-framework/test/script-src/test0.json b/test/scxml-test-framework/test/script-src/test0.json index 1d2faec..c27c2fd 100644 --- a/test/scxml-test-framework/test/script-src/test0.json +++ b/test/scxml-test-framework/test/script-src/test0.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + } + ] } diff --git a/test/scxml-test-framework/test/script-src/test0.scxml b/test/scxml-test-framework/test/script-src/test0.scxml index c2c12cd..358405c 100644 --- a/test/scxml-test-framework/test/script-src/test0.scxml +++ b/test/scxml-test-framework/test/script-src/test0.scxml @@ -15,29 +15,28 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - + - - - - - + + + + + - - - - + + + + - + - + diff --git a/test/scxml-test-framework/test/script/test0.json b/test/scxml-test-framework/test/script/test0.json index 1d2faec..c27c2fd 100644 --- a/test/scxml-test-framework/test/script/test0.json +++ b/test/scxml-test-framework/test/script/test0.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + } + ] } diff --git a/test/scxml-test-framework/test/script/test0.scxml b/test/scxml-test-framework/test/script/test0.scxml index 43d9e0b..21d911d 100644 --- a/test/scxml-test-framework/test/script/test0.scxml +++ b/test/scxml-test-framework/test/script/test0.scxml @@ -15,31 +15,30 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/script/test1.json b/test/scxml-test-framework/test/script/test1.json index 8424ef5..0e49c49 100644 --- a/test/scxml-test-framework/test/script/test1.json +++ b/test/scxml-test-framework/test/script/test1.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["c"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["c"] + } + ] } diff --git a/test/scxml-test-framework/test/script/test1.scxml b/test/scxml-test-framework/test/script/test1.scxml index 4646c2e..cd6b2e6 100644 --- a/test/scxml-test-framework/test/script/test1.scxml +++ b/test/scxml-test-framework/test/script/test1.scxml @@ -15,37 +15,31 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/script/test2.json b/test/scxml-test-framework/test/script/test2.json index 6769dfe..36628bc 100644 --- a/test/scxml-test-framework/test/script/test2.json +++ b/test/scxml-test-framework/test/script/test2.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["e"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["e"] + } + ] } diff --git a/test/scxml-test-framework/test/script/test2.scxml b/test/scxml-test-framework/test/script/test2.scxml index 9623cd6..f3b469e 100644 --- a/test/scxml-test-framework/test/script/test2.scxml +++ b/test/scxml-test-framework/test/script/test2.scxml @@ -15,61 +15,56 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/scxml-prefix-event-name-matching/star0.json b/test/scxml-test-framework/test/scxml-prefix-event-name-matching/star0.json index d5bb5f5..577a005 100644 --- a/test/scxml-test-framework/test/scxml-prefix-event-name-matching/star0.json +++ b/test/scxml-test-framework/test/scxml-prefix-event-name-matching/star0.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "foo" }, - "nextConfiguration" : ["b"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "foo" }, + "nextConfiguration" : ["b"] + } + ] } diff --git a/test/scxml-test-framework/test/scxml-prefix-event-name-matching/star0.scxml b/test/scxml-test-framework/test/scxml-prefix-event-name-matching/star0.scxml index 54a86d5..31345a8 100644 --- a/test/scxml-test-framework/test/scxml-prefix-event-name-matching/star0.scxml +++ b/test/scxml-test-framework/test/scxml-prefix-event-name-matching/star0.scxml @@ -15,20 +15,20 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - - - - - - + + + + + + + + - + diff --git a/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test0.json b/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test0.json index ec26a85..bf11b72 100644 --- a/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test0.json +++ b/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test0.json @@ -1,39 +1,39 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "foo" }, - "nextConfiguration" : ["b"] - }, - { - "event" : { "name" : "foo.bar" }, - "nextConfiguration" : ["c"] - }, - { - "event" : { "name" : "foo.bar.bat" }, - "nextConfiguration" : ["d"] - }, - { - "event" : { "name" : "foo.bar.bat" }, - "nextConfiguration" : ["e"] - }, - { - "event" : { "name" : "foo" }, - "nextConfiguration" : ["e"] - }, - { - "event" : { "name" : "foo.bar.bat" }, - "nextConfiguration" : ["f"] - }, - { - "event" : { "name" : "foobar" }, - "nextConfiguration" : ["f"] - }, - { - "event" : { "name" : "foo.bar.bat.bif" }, - "nextConfiguration" : ["g"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "foo" }, + "nextConfiguration" : ["b"] + }, + { + "event" : { "name" : "foo.bar" }, + "nextConfiguration" : ["c"] + }, + { + "event" : { "name" : "foo.bar.bat" }, + "nextConfiguration" : ["d"] + }, + { + "event" : { "name" : "foo.bar.bat" }, + "nextConfiguration" : ["e"] + }, + { + "event" : { "name" : "foo" }, + "nextConfiguration" : ["e"] + }, + { + "event" : { "name" : "foo.bar.bat" }, + "nextConfiguration" : ["f"] + }, + { + "event" : { "name" : "foobar" }, + "nextConfiguration" : ["f"] + }, + { + "event" : { "name" : "foo.bar.bat.bif" }, + "nextConfiguration" : ["g"] + } + ] } diff --git a/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test0.scxml b/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test0.scxml index 85c9a54..3d14125 100644 --- a/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test0.scxml +++ b/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test0.scxml @@ -15,34 +15,34 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - + diff --git a/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test1.json b/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test1.json index db698ba..c3c994c 100644 --- a/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test1.json +++ b/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test1.json @@ -1,39 +1,39 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "foo" }, - "nextConfiguration" : ["b"] - }, - { - "event" : { "name" : "foo.bar" }, - "nextConfiguration" : ["c"] - }, - { - "event" : { "name" : "foo.bar.bat" }, - "nextConfiguration" : ["d"] - }, - { - "event" : { "name" : "foo.bar.bat" }, - "nextConfiguration" : ["e"] - }, - { - "event" : { "name" : "foo" }, - "nextConfiguration" : ["e"] - }, - { - "event" : { "name" : "foo.bar.bat" }, - "nextConfiguration" : ["f"] - }, - { - "event" : { "name" : "foobar" }, - "nextConfiguration" : ["f"] - }, - { - "event" : { "name" : "foo.bar.bat.bif" }, - "nextConfiguration" : ["g"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "foo" }, + "nextConfiguration" : ["b"] + }, + { + "event" : { "name" : "foo.bar" }, + "nextConfiguration" : ["c"] + }, + { + "event" : { "name" : "foo.bar.bat" }, + "nextConfiguration" : ["d"] + }, + { + "event" : { "name" : "foo.bar.bat" }, + "nextConfiguration" : ["e"] + }, + { + "event" : { "name" : "foo" }, + "nextConfiguration" : ["e"] + }, + { + "event" : { "name" : "foo.bar.bat" }, + "nextConfiguration" : ["f"] + }, + { + "event" : { "name" : "foobar" }, + "nextConfiguration" : ["f"] + }, + { + "event" : { "name" : "foo.bar.bat.bif" }, + "nextConfiguration" : ["g"] + } + ] } diff --git a/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test1.scxml b/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test1.scxml index 9e7c4e3..4515b3a 100644 --- a/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test1.scxml +++ b/test/scxml-test-framework/test/scxml-prefix-event-name-matching/test1.scxml @@ -15,39 +15,39 @@ limitations under the License. --> + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> - - - + + + - - - + + + - - - + + + - - - - + + + + - - - - + + + + - - - - + + + + - + - + diff --git a/test/scxml-test-framework/test/send-data/send1.json b/test/scxml-test-framework/test/send-data/send1.json index 0f7f7f3..f21ee8b 100644 --- a/test/scxml-test-framework/test/send-data/send1.json +++ b/test/scxml-test-framework/test/send-data/send1.json @@ -1,14 +1,15 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["b"] - }, - { - "after" : 100, - "event" : { "name" : "t2" }, - "nextConfiguration" : ["e"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["b"] + }, + { + "after" : 100, + "event" : { "name" : "t2" }, + "nextConfiguration" : ["e"] + } + ] } + diff --git a/test/scxml-test-framework/test/send-data/send1.scxml b/test/scxml-test-framework/test/send-data/send1.scxml index d150ad5..c663ce3 100644 --- a/test/scxml-test-framework/test/send-data/send1.scxml +++ b/test/scxml-test-framework/test/send-data/send1.scxml @@ -15,57 +15,59 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - - More content. - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + + + + + + More content. + - - + + - - + + - - + + + + - - - + + + - + diff --git a/test/scxml-test-framework/test/send-internal/test0.json b/test/scxml-test-framework/test/send-internal/test0.json index 855e0ee..a7f8799 100644 --- a/test/scxml-test-framework/test/send-internal/test0.json +++ b/test/scxml-test-framework/test/send-internal/test0.json @@ -1,9 +1,9 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["d"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["d"] + } + ] } diff --git a/test/scxml-test-framework/test/send-internal/test0.scxml b/test/scxml-test-framework/test/send-internal/test0.scxml index 943322c..03ac96a 100644 --- a/test/scxml-test-framework/test/send-internal/test0.scxml +++ b/test/scxml-test-framework/test/send-internal/test0.scxml @@ -15,54 +15,54 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - - More content. - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + + + + + + More content. + - - + + - - + + - - - - + + + + - + - + diff --git a/test/scxml-test-framework/test/targetless-transition/test0.json b/test/scxml-test-framework/test/targetless-transition/test0.json index 91e35b6..43f1a91 100644 --- a/test/scxml-test-framework/test/targetless-transition/test0.json +++ b/test/scxml-test-framework/test/targetless-transition/test0.json @@ -1,11 +1,11 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "t" }, - "nextConfiguration" : ["done"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "t" }, + "nextConfiguration" : ["done"] + } + ] } diff --git a/test/scxml-test-framework/test/targetless-transition/test0.scxml b/test/scxml-test-framework/test/targetless-transition/test0.scxml index c1cd27d..5b95d73 100644 --- a/test/scxml-test-framework/test/targetless-transition/test0.scxml +++ b/test/scxml-test-framework/test/targetless-transition/test0.scxml @@ -15,25 +15,25 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/targetless-transition/test1.json b/test/scxml-test-framework/test/targetless-transition/test1.json index 4ebbbd4..f82edf4 100644 --- a/test/scxml-test-framework/test/targetless-transition/test1.json +++ b/test/scxml-test-framework/test/targetless-transition/test1.json @@ -1,15 +1,15 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "foo" }, - "nextConfiguration" : ["a"] - }, - { - "event" : { "name" : "bar" }, - "nextConfiguration" : ["done"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "foo" }, + "nextConfiguration" : ["a"] + }, + { + "event" : { "name" : "bar" }, + "nextConfiguration" : ["done"] + } + ] } diff --git a/test/scxml-test-framework/test/targetless-transition/test1.scxml b/test/scxml-test-framework/test/targetless-transition/test1.scxml index f8f9f9f..11520bf 100644 --- a/test/scxml-test-framework/test/targetless-transition/test1.scxml +++ b/test/scxml-test-framework/test/targetless-transition/test1.scxml @@ -15,29 +15,29 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/targetless-transition/test2.json b/test/scxml-test-framework/test/targetless-transition/test2.json index a37a4cc..f97a06f 100644 --- a/test/scxml-test-framework/test/targetless-transition/test2.json +++ b/test/scxml-test-framework/test/targetless-transition/test2.json @@ -1,15 +1,15 @@ { - "initialConfiguration" : ["a"], - "events" : [ - { - "event" : { "name" : "foo" }, - "nextConfiguration" : ["a"] - }, - { - "event" : { "name" : "bar" }, - "nextConfiguration" : ["done"] - } - ] + "initialConfiguration" : ["a"], + "events" : [ + { + "event" : { "name" : "foo" }, + "nextConfiguration" : ["a"] + }, + { + "event" : { "name" : "bar" }, + "nextConfiguration" : ["done"] + } + ] } diff --git a/test/scxml-test-framework/test/targetless-transition/test2.scxml b/test/scxml-test-framework/test/targetless-transition/test2.scxml index b6b3f5d..12609dd 100644 --- a/test/scxml-test-framework/test/targetless-transition/test2.scxml +++ b/test/scxml-test-framework/test/targetless-transition/test2.scxml @@ -15,32 +15,32 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/scxml-test-framework/test/targetless-transition/test3.json b/test/scxml-test-framework/test/targetless-transition/test3.json index a002827..f1300b1 100644 --- a/test/scxml-test-framework/test/targetless-transition/test3.json +++ b/test/scxml-test-framework/test/targetless-transition/test3.json @@ -1,15 +1,15 @@ { - "initialConfiguration" : ["a1","b1","c"], - "events" : [ - { - "event" : { "name" : "foo" }, - "nextConfiguration" : ["a2","b2","c"] - }, - { - "event" : { "name" : "bar" }, - "nextConfiguration" : ["done"] - } - ] + "initialConfiguration" : ["a1","b1","c"], + "events" : [ + { + "event" : { "name" : "foo" }, + "nextConfiguration" : ["a2","b2","c"] + }, + { + "event" : { "name" : "bar" }, + "nextConfiguration" : ["done"] + } + ] } diff --git a/test/scxml-test-framework/test/targetless-transition/test3.scxml b/test/scxml-test-framework/test/targetless-transition/test3.scxml index 9d3d630..3af50cc 100644 --- a/test/scxml-test-framework/test/targetless-transition/test3.scxml +++ b/test/scxml-test-framework/test/targetless-transition/test3.scxml @@ -15,57 +15,57 @@ limitations under the License. --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + datamodel="ecmascript" + xmlns="http://www.w3.org/2005/07/scxml" + version="1.0"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/src/scxml-test-framework-client.cpp b/test/src/scxml-test-framework-client.cpp index 841df0f..1eeab9c 100644 --- a/test/src/scxml-test-framework-client.cpp +++ b/test/src/scxml-test-framework-client.cpp @@ -1,5 +1,5 @@ #include "uscxml/Interpreter.h" -#include "uscxml/plugins/ioprocessor/basichttp/libevent/EventIOProcessor.h" +#include "uscxml/server/HTTPServer.h" #include extern "C" { @@ -20,40 +20,19 @@ extern "C" { {"load":"http://localhost:9999/scxml-test-framework/test/targetless-transition/test3.scxml"} */ -class TestIOProcessor : public uscxml::EventIOProcessor, public uscxml::InterpreterMonitor { +class TestIOProcessor : public uscxml::HTTPServlet, public uscxml::InterpreterMonitor { public: - static int lastToken; - static std::map > _interpreters; + static bool alreadyAnswered; // we need this for delayed events + static std::map > _interpreters; TestIOProcessor() {} - virtual void onStableConfiguration(uscxml::Interpreter* interpreter) { - Arabica::XPath::NodeSet configuration = interpreter->getConfiguration(); - - uscxml::Data reply; - reply.compound["sessionToken"] = uscxml::Data(interpreter->getName()); - std::string seperator; - for (size_t i = 0; i < configuration.size(); i++) { - if (uscxml::Interpreter::isAtomic(configuration[i])) - reply.compound["nextConfiguration"].array.push_back(uscxml::Data(ATTR(configuration[i], "id"), uscxml::Data::VERBATIM)); - } - - std::cout << "---- reply:" << std::endl; - std::cout << reply << std::endl; - - std::stringstream replyString; - replyString << reply; - - struct evbuffer *databuf = evbuffer_new(); - evbuffer_add(databuf, replyString.str().c_str(), replyString.str().length()); - evhttp_send_reply(_interpreters[interpreter->getName()].second, 200, "OK", databuf); - evbuffer_free(databuf); - + virtual void beforeCompletion(uscxml::Interpreter* interpreter) { + _interpreters[interpreter->getName()].second.curlReq = NULL; } - virtual void beforeCompletion(uscxml::Interpreter* interpreter) {} virtual void afterCompletion(uscxml::Interpreter* interpreter) {} virtual void beforeMicroStep(uscxml::Interpreter* interpreter) {} virtual void beforeTakingTransitions(uscxml::Interpreter* interpreter, const Arabica::XPath::NodeSet& transitions) {} @@ -65,6 +44,7 @@ public: } std::cout << std::endl; } + virtual void afterEnteringStates(uscxml::Interpreter* interpreter) { std::cout << "After entering states: "; for (int i = 0; i < interpreter->getConfiguration().size(); i++) { @@ -72,6 +52,7 @@ public: } std::cout << std::endl; } + virtual void beforeExitingStates(uscxml::Interpreter* interpreter, const Arabica::XPath::NodeSet& statesToExit) { std::cout << "Configuration: "; for (int i = 0; i < interpreter->getConfiguration().size(); i++) { @@ -84,6 +65,7 @@ public: } std::cout << std::endl; } + virtual void afterExitingStates(uscxml::Interpreter* interpreter) { std::cout << "After exiting states: "; for (int i = 0; i < interpreter->getConfiguration().size(); i++) { @@ -92,37 +74,46 @@ public: std::cout << std::endl; } - virtual void httpRecvReq(struct evhttp_request *req) { - - std::cout << "---- received:" << std::endl; - - if (evhttp_request_get_command(req) != EVHTTP_REQ_POST) + virtual void onStableConfiguration(uscxml::Interpreter* interpreter) { + if (alreadyAnswered) return; - evhttp_request_own(req); - - struct evkeyval *header; - struct evkeyvalq *headers; - headers = evhttp_request_get_input_headers(req); + Arabica::XPath::NodeSet configuration = interpreter->getConfiguration(); - for (header = headers->tqh_first; header; - header = header->next.tqe_next) { -// std::cout << header->key << ": " << header->value << std::endl; + uscxml::Data reply; + reply.compound["sessionToken"] = uscxml::Data(interpreter->getName()); + std::string seperator; + for (size_t i = 0; i < configuration.size(); i++) { + if (uscxml::Interpreter::isAtomic(configuration[i])) + reply.compound["nextConfiguration"].array.push_back(uscxml::Data(ATTR(configuration[i], "id"), uscxml::Data::VERBATIM)); } + + std::cout << "---- reply:" << std::endl; + std::cout << reply << std::endl; + + std::stringstream replyString; + replyString << reply; + + alreadyAnswered = true; + + uscxml::HTTPServer::Request httpRequest = _interpreters[interpreter->getName()].second; + uscxml::HTTPServer::Reply httpReply(httpRequest); + httpReply.content = replyString.str(); + uscxml::HTTPServer::reply(httpReply); + + } - std::string content; - struct evbuffer *buf; - buf = evhttp_request_get_input_buffer(req); - while (evbuffer_get_length(buf)) { - int n; - char cbuf[128]; - n = evbuffer_remove(buf, cbuf, sizeof(buf)-1); - if (n > 0) { - content.append(cbuf, n); - } - } + void httpRecvRequest(const uscxml::HTTPServer::Request& request) { + +// uscxml::HTTPServer::Reply httpReply(request); +// uscxml::HTTPServer::reply(httpReply); +// return; - uscxml::Data jsonReq = uscxml::Data::fromJSON(content); + std::cout << "---- received:" << std::endl; + evhttp_request_own(request.curlReq); + + std::cout << request.content << std::endl; + uscxml::Data jsonReq = uscxml::Data::fromJSON(request.content); std::cout << jsonReq << std::endl; @@ -130,6 +121,19 @@ public: if (jsonReq.compound.find("load") != jsonReq.compound.end()) { std::string filename = jsonReq.compound["load"].atom; std::cout << "Starting Interpreter with " << filename << std::endl; + alreadyAnswered = false; + + std::map >::iterator interpreterIter = _interpreters.begin(); + while(interpreterIter != _interpreters.end()) { +// if (interpreterIter->second.second.curlReq == NULL) { + delete interpreterIter->second.first; + _interpreters.erase(interpreterIter++); +// } else { +// interpreterIter++; +// } + } + + uscxml::Interpreter* interpreter = uscxml::Interpreter::fromURI(filename); if (interpreter) { std::string token = uscxml::toStr(lastToken++); @@ -137,7 +141,7 @@ public: interpreter->setName(token); interpreter->addMonitor(this); interpreter->start(); - _interpreters[token] = std::make_pair(interpreter, req); + _interpreters[token] = std::make_pair(interpreter, request); } return; } @@ -151,33 +155,27 @@ public: event.name = jsonReq.compound["event"].compound["name"].atom; std::cout << "Sending event " << event << std::endl; // evhttp_request_free(_interpreters[token].second); - _interpreters[token].second = req; + alreadyAnswered = false; + _interpreters[token].second = request; _interpreters[token].first->receive(event); } - - } - - std::string getPath() { - return "test"; + } - + void setURL(const std::string& url) { std::cout << "Listening at " << url << std::endl; - _url = url; } }; int TestIOProcessor::lastToken; -std::map > TestIOProcessor::_interpreters; +bool TestIOProcessor::alreadyAnswered; +std::map > TestIOProcessor::_interpreters; int main(int argc, char** argv) { TestIOProcessor* testServer = new TestIOProcessor(); - uscxml::EventIOServer::registerProcessor(testServer); + uscxml::HTTPServer::registerServlet("test", testServer); while(true) tthread::this_thread::sleep_for(tthread::chrono::milliseconds(20)); -// uscxml::Interpreter* interpreter = uscxml::Interpreter::fromURI(argv[1]); -// interpreter->dump(); -// interpreter->interpret(); } \ No newline at end of file diff --git a/test/src/test-communication.cpp b/test/src/test-communication.cpp deleted file mode 100644 index a0cdbbd..0000000 --- a/test/src/test-communication.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "uscxml/Interpreter.h" -#include - -int main(int argc, char** argv) { - if (argc != 2) { - std::cerr << "Expected path to test-communication.scxml" << std::endl; - exit(EXIT_FAILURE); - } - - - using namespace uscxml; - std::list _interpreters; - -// Event e; -// e.compound["foo"] = Data("bar", Data::VERBATIM); -// e.compound["foo2"] = Data("bar2", Data::VERBATIM); -// std::cout << e.toDocument() << std::endl; - - int nrInterpreters = 1; - for (int i = 0; i < nrInterpreters; i++) { - _interpreters.push_back(Interpreter::fromURI(argv[1])); - _interpreters.back()->start(); - } - - std::list::iterator interIter = _interpreters.begin(); - while(interIter != _interpreters.end()) { - (*interIter)->join(); - interIter++; - } - -} \ No newline at end of file diff --git a/test/src/test-communication.cpp.old b/test/src/test-communication.cpp.old new file mode 100644 index 0000000..a0cdbbd --- /dev/null +++ b/test/src/test-communication.cpp.old @@ -0,0 +1,31 @@ +#include "uscxml/Interpreter.h" +#include + +int main(int argc, char** argv) { + if (argc != 2) { + std::cerr << "Expected path to test-communication.scxml" << std::endl; + exit(EXIT_FAILURE); + } + + + using namespace uscxml; + std::list _interpreters; + +// Event e; +// e.compound["foo"] = Data("bar", Data::VERBATIM); +// e.compound["foo2"] = Data("bar2", Data::VERBATIM); +// std::cout << e.toDocument() << std::endl; + + int nrInterpreters = 1; + for (int i = 0; i < nrInterpreters; i++) { + _interpreters.push_back(Interpreter::fromURI(argv[1])); + _interpreters.back()->start(); + } + + std::list::iterator interIter = _interpreters.begin(); + while(interIter != _interpreters.end()) { + (*interIter)->join(); + interIter++; + } + +} \ No newline at end of file diff --git a/test/src/test-completion.cpp b/test/src/test-completion.cpp deleted file mode 100644 index 67d8708..0000000 --- a/test/src/test-completion.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "uscxml/Interpreter.h" -#include "uscxml/debug/SCXMLDotWriter.h" -#include - -int main(int argc, char** argv) { - if (argc != 2) { - std::cerr << "Expected path to scxml document" << std::endl; - exit(EXIT_FAILURE); - } - - using namespace uscxml; - - Interpreter* interpreter = Interpreter::fromURI(argv[1]); - //SCXMLDotWriter::toDot("output.dot", interpreter); - - interpreter->interpret(); - - - return EXIT_SUCCESS; -} \ No newline at end of file diff --git a/test/src/test-completion.cpp.old b/test/src/test-completion.cpp.old new file mode 100644 index 0000000..67d8708 --- /dev/null +++ b/test/src/test-completion.cpp.old @@ -0,0 +1,20 @@ +#include "uscxml/Interpreter.h" +#include "uscxml/debug/SCXMLDotWriter.h" +#include + +int main(int argc, char** argv) { + if (argc != 2) { + std::cerr << "Expected path to scxml document" << std::endl; + exit(EXIT_FAILURE); + } + + using namespace uscxml; + + Interpreter* interpreter = Interpreter::fromURI(argv[1]); + //SCXMLDotWriter::toDot("output.dot", interpreter); + + interpreter->interpret(); + + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/test/src/test-curl-multi-api.cpp b/test/src/test-curl-multi-api.cpp new file mode 100644 index 0000000..fac06dc --- /dev/null +++ b/test/src/test-curl-multi-api.cpp @@ -0,0 +1,347 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "uscxml/concurrency/tinythread.h" + +// use arabica URL parser +#include + +class URL; + +class URLMonitor { +public: + virtual void downloadStarted(const URL& url) {}; + virtual void downloadCompleted(const URL& url) {}; + virtual void downloadFailed(const URL& url, int errorCode) {}; + virtual void headerChunkReceived(const URL& url, const std::string& headerChunk) {}; + virtual void contentChunkReceived(const URL& url, const std::string& contentChunk) {}; +}; + +class URLImpl : public boost::enable_shared_from_this { +public: + URLImpl(const std::string& url) : _handle(NULL), _uri(url), _isDownloaded(false) { + _handle = curl_easy_init(); + if (_handle != NULL) { + CURLcode curlError; + curlError = curl_easy_setopt(_handle, CURLOPT_URL, _uri.as_string().c_str()); + if (curlError != CURLE_OK) + LOG(ERROR) << "Cannot set url to " << _uri.as_string() << ": " << curl_easy_strerror(curlError); + + curlError = curl_easy_setopt(_handle, CURLOPT_WRITEDATA, this); + if (curlError != CURLE_OK) + LOG(ERROR) << "Cannot register this as write userdata: " << curl_easy_strerror(curlError); + + curlError = curl_easy_setopt(_handle, CURLOPT_WRITEFUNCTION, URLImpl::writeHandler); + if (curlError != CURLE_OK) + LOG(ERROR) << "Cannot set write callback: " << curl_easy_strerror(curlError); + + curlError = curl_easy_setopt(_handle, CURLOPT_HEADERFUNCTION, URLImpl::headerHandler); + if (curlError != CURLE_OK) + LOG(ERROR) << "Cannot request header from curl: " << curl_easy_strerror(curlError); + + curlError = curl_easy_setopt(_handle, CURLOPT_HEADERDATA, this); + if (curlError != CURLE_OK) + LOG(ERROR) << "Cannot register this as header userdata: " << curl_easy_strerror(curlError); + } else { + LOG(ERROR) << "curl_easy_init returned NULL, this is bad!"; + } + } + + ~URLImpl() { + if (_handle != NULL) + curl_easy_cleanup(_handle); + } + + static size_t writeHandler(void *ptr, size_t size, size_t nmemb, void *userdata) { + URLImpl* url = (URLImpl*)userdata; + url->_content.write((char*)ptr, size * nmemb); + return size * nmemb; + } + + static size_t headerHandler(void *ptr, size_t size, size_t nmemb, void *userdata) { + URLImpl* url = (URLImpl*)userdata; + url->_header.write((char*)ptr, size * nmemb); + return size * nmemb; + } + + void addMonitor(URLMonitor* monitor) { _monitors.insert(monitor); } + void removeMonitor(URLMonitor* monitor) { _monitors.erase(monitor); } + + const bool isAbsolute() const { return _uri.is_absolute(); } + const std::string scheme() const { return _uri.scheme(); } + const std::string host() const { return _uri.host(); } + const std::string port() const { return _uri.port(); } + const std::string path() const { return _uri.path(); } + const std::string asString() const { return _uri.as_string(); } + + void downloadStarted() { + std::cout << "Starting download of " << asString() << std::endl; + _content.str(""); + _content.clear(); + _header.str(""); + _header.clear(); + monIter_t monIter = _monitors.begin(); + while(monIter != _monitors.end()) { +// (*monIter)->downloadStarted(URL(shared_from_this())); + monIter++; + } + } + + void downloadCompleted() { + std::cout << "Finished loading " << asString() << " with " << _content.str().size() << " bytes" << std::endl; + _isDownloaded = true; + } + + void downloadFailed(int errorCode) { + std::cout << "FAILED!" << strerror(errorCode) << std::endl; + } + + std::string getHeader(bool forceReload = false) { + return _header.str(); + } + + std::string getContent(bool forceReload = false) { + return _content.str(); + } + + std::stringstream _content; + std::stringstream _header; + CURL* _handle; + Arabica::io::URI _uri; + bool _isDownloaded; + + std::set _monitors; + typedef std::set::iterator monIter_t; +}; + +class URL { +public: + URL() : _impl() {} + URL(const std::string url) : _impl(new URLImpl(url)) {} + URL(boost::shared_ptr const impl) : _impl(impl) { } + URL(const URL& other) : _impl(other._impl) { } + virtual ~URL() {}; + + operator bool() const { return _impl; } + bool operator< (const URL& other) const { return _impl < other._impl; } + bool operator==(const URL& other) const { return _impl == other._impl; } + bool operator!=(const URL& other) const { + return _impl != other._impl; + } + URL& operator= (const URL& other) { + _impl = other._impl; + return *this; + } + + std::string getHeader() { return _impl->getHeader(); } + std::string getContent() { return _impl->getContent(); } + + const bool toAbsoluteCwd() { return _impl->toAbsoluteCwd(); } + const bool toAbsolute(const std::string& baseUrl) { return _impl->toAbsolute(baseUrl); } + const bool toAbsolute(const URL& baseUrl) { return _impl->toAbsolute(baseUrl.asString()); } + const std::string asLocalFile(const std::string& suffix, bool reload = false) { return _impl->asLocalFile(suffix, reload); } + + void addMonitor(URLMonitor* monitor) { _impl->addMonitor(monitor); } + void removeMonitor(URLMonitor* monitor) { _impl->removeMonitor(monitor); } + + const bool isAbsolute() const { return _impl->isAbsolute(); } + const std::string scheme() const { return _impl->scheme(); } + const std::string host() const { return _impl->host(); } + const std::string port() const { return _impl->port(); } + const std::string path() const { return _impl->path(); } + const std::string asString() const { return _impl->asString(); } + + friend class URLFetcher; + friend std::ostream & operator<<(std::ostream &stream, const URL& p); + +protected: + void downloadStarted() { return _impl->downloadStarted(); } + void downloadCompleted() { return _impl->downloadCompleted(); } + void downloadFailed(int errorCode) { return _impl->downloadFailed(errorCode); } + + boost::shared_ptr _impl; +}; + +class URLFetcher { +public: + URLFetcher() { + _multiHandle = curl_multi_init(); + start(); + } + + ~URLFetcher() { + curl_multi_cleanup(_multiHandle); + stop(); + } + + void fetchURL(URL& url) { + tthread::lock_guard lock(_mutex); + url.downloadStarted(); + _handlesToURLs[url._impl->_handle] = url; + curl_multi_add_handle(_multiHandle, url._impl->_handle); + _condVar.notify_all(); + } + + void breakURL(URL& url) { + tthread::lock_guard lock(_mutex); + if (_handlesToURLs.find(url._impl->_handle) != _handlesToURLs.end()) { + url.downloadFailed(0); + curl_multi_remove_handle(_multiHandle, url._impl->_handle); + _handlesToURLs.erase(url._impl->_handle); + } + } + + void start() { + tthread::lock_guard lock(_mutex); + if (!_isStarted) { + _isStarted = true; + _thread = new tthread::thread(URLFetcher::run, this); + } + } + + void stop() { + tthread::lock_guard lock(_mutex); + if (_isStarted) { + _isStarted = false; + _thread->join(); + delete _thread; + } + } + + static void run(void* instance) { + URLFetcher* THIS = (URLFetcher*)instance; + THIS->_mutex.lock(); + while(THIS->_isStarted) { + if(THIS->_handlesToURLs.size() > 0) { + THIS->_mutex.unlock(); + THIS->perform(); + THIS->_mutex.lock(); + } + THIS->_condVar.wait(THIS->_mutex); + } + THIS->_mutex.unlock(); + } + + void perform() { + + CURLMsg *msg; /* for picking up messages with the transfer status */ + int msgsLeft; /* how many messages are left */ + int stillRunning; + + { + tthread::lock_guard lock(_mutex); + curl_multi_perform(_multiHandle, &stillRunning); + } + + do { + struct timeval timeout; + int rc; /* select() return code */ + + fd_set fdread, fdwrite, fdexcep; + FD_ZERO(&fdread); FD_ZERO(&fdwrite); FD_ZERO(&fdexcep); + + int maxfd = -1; + long curlTimeOut = -1; + + /* set a suitable timeout to play around with */ + timeout.tv_sec = 1; + timeout.tv_usec = 0; + + { + tthread::lock_guard lock(_mutex); + curl_multi_timeout(_multiHandle, &curlTimeOut); + } + + if(curlTimeOut >= 0) { + timeout.tv_sec = curlTimeOut / 1000; + if(timeout.tv_sec > 1) + timeout.tv_sec = 1; + else + timeout.tv_usec = (curlTimeOut % 1000) * 1000; + } + + /* get file descriptors from the transfers */ + { + tthread::lock_guard lock(_mutex); + curl_multi_fdset(_multiHandle, &fdread, &fdwrite, &fdexcep, &maxfd); + } + + rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout); + + switch(rc) { + case -1: + /* select error */ + break; + case 0: /* timeout */ + default: /* action */ + { + tthread::lock_guard lock(_mutex); + curl_multi_perform(_multiHandle, &stillRunning); + } + break; + } + + { + tthread::lock_guard lock(_mutex); + while ((msg = curl_multi_info_read(_multiHandle, &msgsLeft))) { + if (msg->msg == CURLMSG_DONE) { + _handlesToURLs[msg->easy_handle].downloadCompleted(); + curl_multi_remove_handle(_multiHandle, msg->easy_handle); + _handlesToURLs.erase(msg->easy_handle); + } else { + switch (msg->data.result) { + case CURLM_OK: + break; + case CURLM_BAD_HANDLE: + case CURLM_BAD_EASY_HANDLE: + case CURLM_OUT_OF_MEMORY: + case CURLM_INTERNAL_ERROR: + case CURLM_BAD_SOCKET: + case CURLM_UNKNOWN_OPTION: + case CURLM_LAST: + _handlesToURLs[msg->easy_handle].downloadFailed(msg->data.result); + curl_multi_remove_handle(_multiHandle, msg->easy_handle); + _handlesToURLs.erase(msg->easy_handle); + default: + break; + } + } + } + } + } while(stillRunning && _isStarted); + + } + + tthread::condition_variable _condVar; + tthread::thread* _thread; + tthread::recursive_mutex _mutex; + bool _isStarted; + + std::map _handlesToURLs; + CURLM* _multiHandle; +}; + + +int main(int argc, char** argv) { + URLFetcher fetcher; + URL heise("http://www.heise.de"); + URL localFile("file:///Users/sradomski/Desktop/scxml.xsd"); + URL slashdot("http://slashdot.org"); + URL asdf("daf://localhost:234"); + URL bahn("http://www.bahn.de"); + + fetcher.fetchURL(heise); + fetcher.fetchURL(localFile); + fetcher.fetchURL(asdf); + fetcher.fetchURL(slashdot); + fetcher.fetchURL(bahn); + + while(1) {} +} \ No newline at end of file diff --git a/test/src/test-ecmascript-v8.cpp b/test/src/test-ecmascript-v8.cpp deleted file mode 100644 index 9ce39d9..0000000 --- a/test/src/test-ecmascript-v8.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "uscxml/Interpreter.h" -#include "uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h" - -int main(int argc, char** argv) { - if (argc != 2) { - std::cerr << "Expected path to test-ecmascript.scxml" << std::endl; - exit(EXIT_FAILURE); - } - - using namespace uscxml; - using namespace Arabica::DOM; - using namespace Arabica::XPath; - - Interpreter* scxml = Interpreter::fromURI(argv[1]); - scxml->start(); - scxml->waitForStabilization(); - - Event event1; - event1.name = "event1"; - scxml->receive(event1); - scxml->join(); - tthread::this_thread::sleep_for(tthread::chrono::milliseconds(500)); - -} \ No newline at end of file diff --git a/test/src/test-ecmascript-v8.cpp.old b/test/src/test-ecmascript-v8.cpp.old new file mode 100644 index 0000000..9ce39d9 --- /dev/null +++ b/test/src/test-ecmascript-v8.cpp.old @@ -0,0 +1,24 @@ +#include "uscxml/Interpreter.h" +#include "uscxml/plugins/datamodel/ecmascript/v8/V8DataModel.h" + +int main(int argc, char** argv) { + if (argc != 2) { + std::cerr << "Expected path to test-ecmascript.scxml" << std::endl; + exit(EXIT_FAILURE); + } + + using namespace uscxml; + using namespace Arabica::DOM; + using namespace Arabica::XPath; + + Interpreter* scxml = Interpreter::fromURI(argv[1]); + scxml->start(); + scxml->waitForStabilization(); + + Event event1; + event1.name = "event1"; + scxml->receive(event1); + scxml->join(); + tthread::this_thread::sleep_for(tthread::chrono::milliseconds(500)); + +} \ No newline at end of file diff --git a/test/src/test-execution.cpp b/test/src/test-execution.cpp deleted file mode 100644 index 272ce41..0000000 --- a/test/src/test-execution.cpp +++ /dev/null @@ -1,16 +0,0 @@ -#include "uscxml/Interpreter.h" - -int main(int argc, char** argv) { - if (argc != 2) { - std::cerr << "Expected path to test-execution.scxml" << std::endl; - exit(EXIT_FAILURE); - } - - using namespace uscxml; - using namespace Arabica::DOM; - using namespace Arabica::XPath; - - Interpreter* interpreter = Interpreter::fromURI(argv[1]); - interpreter->dump(); - interpreter->interpret(); -} \ No newline at end of file diff --git a/test/src/test-execution.cpp.old b/test/src/test-execution.cpp.old new file mode 100644 index 0000000..272ce41 --- /dev/null +++ b/test/src/test-execution.cpp.old @@ -0,0 +1,16 @@ +#include "uscxml/Interpreter.h" + +int main(int argc, char** argv) { + if (argc != 2) { + std::cerr << "Expected path to test-execution.scxml" << std::endl; + exit(EXIT_FAILURE); + } + + using namespace uscxml; + using namespace Arabica::DOM; + using namespace Arabica::XPath; + + Interpreter* interpreter = Interpreter::fromURI(argv[1]); + interpreter->dump(); + interpreter->interpret(); +} \ No newline at end of file diff --git a/test/src/test-prolog-swi.cpp b/test/src/test-prolog-swi.cpp deleted file mode 100644 index 9e44f12..0000000 --- a/test/src/test-prolog-swi.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include -#include -#include -#include "uscxml/config.h" - -using namespace std; - -int main(void) { - const char* swibin = getenv("SWI_BINARY"); - if (swibin == NULL) - swibin = SWI_BINARY; - - static char * av[] = { - (char*)swibin, -// "--quiet", -// "-s", -// "/Users/sradomski/Documents/TK/Code/pl-devel/demo/likes.pl", - NULL - }; - if( ! PL_initialise(1,av)) { - cout<<"error initializing"< 0) { -// std::cout << "Yes!" << std::endl; -// } else { -// std::cout << "No!" << std::endl; -// } - -// std::cout << compound.name() << std::endl; -// PlTermv filename("/Users/sradomski/Documents/TK/Code/pl-devel/demo/likes.pl"); -// PlQuery loadFiles("system", "load_files", filename); - -// predicate_t loadFiles = PL_predicate("load_files",1,"system"); -// term_t h0 = PL_new_term_refs(1); - -// int rval; -// const char * expression = "/Users/sradomski/Documents/TK/Code/pl-devel/demo/likes.pl"; -// PL_put_atom_chars(h0,expression); -// rval = PL_call_predicate(NULL, PL_Q_NORMAL, loadFiles, h0); - -// PL_halt( rval ? 0 : 1 ); - -// PL_close_foreign_frame(fid); - return 0; -} diff --git a/test/src/test-prolog-swi.cpp.old b/test/src/test-prolog-swi.cpp.old new file mode 100644 index 0000000..9e44f12 --- /dev/null +++ b/test/src/test-prolog-swi.cpp.old @@ -0,0 +1,93 @@ +#include +#include +#include +#include "uscxml/config.h" + +using namespace std; + +int main(void) { + const char* swibin = getenv("SWI_BINARY"); + if (swibin == NULL) + swibin = SWI_BINARY; + + static char * av[] = { + (char*)swibin, +// "--quiet", +// "-s", +// "/Users/sradomski/Documents/TK/Code/pl-devel/demo/likes.pl", + NULL + }; + if( ! PL_initialise(1,av)) { + cout<<"error initializing"< 0) { +// std::cout << "Yes!" << std::endl; +// } else { +// std::cout << "No!" << std::endl; +// } + +// std::cout << compound.name() << std::endl; +// PlTermv filename("/Users/sradomski/Documents/TK/Code/pl-devel/demo/likes.pl"); +// PlQuery loadFiles("system", "load_files", filename); + +// predicate_t loadFiles = PL_predicate("load_files",1,"system"); +// term_t h0 = PL_new_term_refs(1); + +// int rval; +// const char * expression = "/Users/sradomski/Documents/TK/Code/pl-devel/demo/likes.pl"; +// PL_put_atom_chars(h0,expression); +// rval = PL_call_predicate(NULL, PL_Q_NORMAL, loadFiles, h0); + +// PL_halt( rval ? 0 : 1 ); + +// PL_close_foreign_frame(fid); + return 0; +} -- cgit v0.12