From 36b5c7614cc896d043ddeebae1cdb4e8e94afe18 Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Tue, 8 Oct 2013 01:13:54 +0200 Subject: Reduced compile times - new commandline argument handling - compiles on windows again --- CMakeLists.txt | 18 + apps/samples/map/spoken-map-ticker.scxml | 2 +- apps/samples/miles/miles.js | 664 ++++ apps/samples/vrml/vrml-server.scxml | 2 +- apps/uscxml-browser.cpp | 146 +- config.h.in | 2 + contrib/cmake/FindEVENT.cmake | 27 + contrib/cmake/USCXMLMacros.cmake | 1 + contrib/cmake/cotire.cmake | 3239 ++++++++++++++++++++ contrib/src/getopt/getopt.c | 562 ++++ contrib/src/getopt/getopt.h | 95 + src/bindings/swig/php/uscxmlNativePHP.php | 68 +- src/uscxml/Interpreter.cpp | 167 +- src/uscxml/Interpreter.h | 47 +- .../concurrency/eventqueue/DelayedEventQueue.cpp | 12 +- .../concurrency/eventqueue/DelayedEventQueue.h | 6 +- src/uscxml/pch.h | 14 + src/uscxml/plugins/datamodel/CMakeLists.txt | 106 +- .../plugins/datamodel/ecmascript/TypedArray.h | 1 + src/uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h | 1 + src/uscxml/plugins/invoker/im/IMInvoker.cpp | 412 ++- src/uscxml/plugins/invoker/im/IMInvoker.h | 46 +- src/uscxml/server/HTTPServer.cpp | 162 +- src/uscxml/server/HTTPServer.h | 21 +- test/CMakeLists.txt | 11 + test/samples/uscxml/test-instant-messaging.scxml | 17 +- test/samples/uscxml/test-performance.scxml | 2 +- test/samples/uscxml/test-startup-time.scxml | 4 + test/src/test-arabica-events.cpp | 2 + test/src/test-arabica-parsing.cpp | 2 + test/src/test-arabica-xpath.cpp | 2 + test/src/test-cmdline-parsing.cpp | 109 + test/src/test-instant-messaging.cpp | 298 ++ 33 files changed, 5928 insertions(+), 340 deletions(-) create mode 100644 apps/samples/miles/miles.js create mode 100644 contrib/cmake/cotire.cmake create mode 100644 contrib/src/getopt/getopt.c create mode 100644 contrib/src/getopt/getopt.h create mode 100644 src/uscxml/pch.h create mode 100644 test/samples/uscxml/test-startup-time.scxml create mode 100644 test/src/test-cmdline-parsing.cpp create mode 100644 test/src/test-instant-messaging.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2921af0..dfd0a38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -493,6 +493,7 @@ include_directories(${Boost_INCLUDE_DIR}) find_package(EVENT REQUIRED) include_directories(${EVENT_INCLUDE_DIR}) list (APPEND USCXML_CORE_LIBS ${EVENT_LIBRARY}) +#set(EVENT_SSL_FOUND OFF) # deactivate for now ################################################# # Optional libraries @@ -527,6 +528,13 @@ else() endif() +find_package(OpenSSL) +if (OPENSSL_FOUND) + include_directories(${OPENSSL_INCLUDE_DIR}) + list (APPEND USCXML_OPT_LIBS ${OPENSSL_LIBRARIES}) +endif() + + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SHARED}) find_package(SWI) if (SWI_FOUND) @@ -729,6 +737,12 @@ foreach( FILE ${USCXML_FILES} ) endif() endforeach() +# add compile time reducer +# see https://github.com/sakra/cotire +if ((WIN32 OR UNIX) AND NOT APPLE) + include(cotire) +endif() + # build library if (BUILD_AS_PLUGINS) add_library(uscxml ${USCXML_FILES}) @@ -737,6 +751,10 @@ else() add_library(uscxml ${USCXML_FILES}) target_link_libraries(uscxml ${USCXML_OPT_LIBS} ${USCXML_CORE_LIBS}) endif() +if ((WIN32 OR UNIX) AND NOT APPLE) + set_target_properties(uscxml PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "src/uscxml/pch.h") + cotire(uscxml) +endif() if (NOT CMAKE_CROSSCOMPILING) add_executable(uscxml-browser apps/uscxml-browser.cpp ${PROJECT_SOURCE_DIR}/contrib/src/getopt/XGetopt.cpp) diff --git a/apps/samples/map/spoken-map-ticker.scxml b/apps/samples/map/spoken-map-ticker.scxml index 147f890..3955715 100644 --- a/apps/samples/map/spoken-map-ticker.scxml +++ b/apps/samples/map/spoken-map-ticker.scxml @@ -27,7 +27,7 @@ - + diff --git a/apps/samples/miles/miles.js b/apps/samples/miles/miles.js new file mode 100644 index 0000000..a3cdcae --- /dev/null +++ b/apps/samples/miles/miles.js @@ -0,0 +1,664 @@ +function Miles(element, params) { + + // private attributes + var self = this; + + // private instanceId + if (!Miles.instances) + Miles.instances = 0; + this.instanceId = Miles.instances++; + + // public attributes + this.reflectorURL = "127.0.0.1"; + this.params = params; + + // privileged public methods + this.foo = function() { + }; + + // privileged private methods + var bar = function(param1, param2) { + }; + + // start of actual class after we fetched all dojo thingies + require(["dojo/dom-construct", + "dojo/_base/xhr", + "dojo/dom", + "dojo/on", + "dojox/storage", + "dojo/store/Memory", + "dojo/store/Observable", + "dijit/tree/ObjectStoreModel", + "dijit/Tree", + "dijit/form/TextBox", + "dijit/form/Button", + "dojox/widget/Standby", + "dijit/form/DropDownButton", + "dijit/TooltipDialog", + "dojo/dnd/Moveable", + "dojo/ready", + "dojo/dnd/Source", + "dijit/form/HorizontalSlider", + "dijit/form/Select", + "dijit/form/NumberSpinner"], + function(domConst, + xhr, + dom, + on, + storage, + Memory, + Observable, + ObjectStoreModel, + Tree, + TextBox, + Button, + Standby, + DropDownButton, + TooltipDialog, + Moveable, + ready, + Source, + HorizontalSlider, + Selector, + NumberSpinner) { + + ready(function() { + + if (typeof(element) === 'string') { + element = dom.byId(element); + } + + self.element = element; + self.xhr = xhr; + self.localStorage = dojox.storage.manager.getProvider(); + self.localStorage.initialize(); + + // establish our dom + element.appendChild(domConst.toDom('\ + \ + \ + \ + \ + \ + \ + \ + \ +
\ +
\ + \ +
\ +
\ +
\ +
\ + \ + \ + \ + \ + \ +
\ +
\ + \ +
\ +
\ +
\ +
\ +
\ +
\ +
\ + \ + \ + \ + \ + \ +
\ +
\ +
\ +
\ +
\ +
\ + \ + \ + \ + \ + \ +
\ +
\ +
\ +
\ +
\ +
\ + \ + \ + \ + \ + \ +
\ +
\ +
\ +
\ +
\ +
\ + ')); + + // fetch special dom nodes for content + self.messageBox = dojo.query("div.messages", element)[0]; + self.imgElem = dojo.query("img.model", element)[0]; + + /** + * === POSE MANIPULATION AND RESET ==================== + */ + + self.resetButtonElem = dojo.query("button.resetButton", element)[0]; + self.progressElem = dojo.query("div.progress", element)[0]; + self.pitchRollHandlerElem = dojo.query(".pitchRollHandler", element)[0]; + self.yawZoomHandlerElem = dojo.query(".yawZoomHandler", element)[0]; + self.xyHandlerElem = dojo.query(".xyHandler", element)[0]; + + self.pitchRollHandler = new Moveable(self.pitchRollHandlerElem); + self.pitchRollHandler.onMoveStop = function(mover) { + var handlerImg = dojo.query("img.pitchRollHandlerImg", mover.node)[0]; + var pitchLabel = dojo.query("div.pitchLabel", mover.node)[0]; + var rollLabel = dojo.query("div.rollLabel", mover.node)[0]; + + pitchLabel.innerHTML = ''; + rollLabel.innerHTML = ''; + + self.updateScene(); + }; + self.pitchRollHandler.onMoving = function(mover) { + // mover.node.style.backgroundColor = "rgba(255,255,255,0.5)"; + // mover.node.style.borderRadius = "5px"; + // mover.node.style.mozBorderRadius = "5px"; + // mover.node.style.webkitBorderRadius = "5px"; + var handlerImg = dojo.query(".pitchRollHandlerImg", mover.node)[0]; + var pitchLabel = dojo.query(".pitchLabel", mover.node)[0]; + var rollLabel = dojo.query(".rollLabel", mover.node)[0]; + var offset = moverRelativeTo(handlerImg, self.element); + + offset.x += 30; + offset.y += 20; + + self.xyHandlerElem.style.zIndex = 1; + self.yawZoomHandlerElem.style.zIndex = 1; + self.pitchRollHandlerElem.style.zIndex = 2; + + // self.pose.pitch = self.pose.pitch % (2 * 3.14159); + // self.pose.roll = self.pose.roll % (2 * 3.14159); + self.pose.roll = offset.x / self.pose.width - 0.5; + self.pose.pitch = offset.y / self.pose.height - 0.5; + self.pose.pitch *= -1; + self.pose.roll *= 2 * 3.14159; + self.pose.pitch *= 2 * 3.14159; + self.pose.roll = Math.ceil((self.pose.roll) * 10) / 10; + self.pose.pitch = Math.ceil((self.pose.pitch) * 10) / 10; + pitchLabel.innerHTML = 'Pitch:' + self.pose.pitch; + rollLabel.innerHTML = 'Roll:' + self.pose.roll; + }; + + self.yawZoomHandler = new Moveable(self.yawZoomHandlerElem); + self.yawZoomHandler.onMoveStop = function(mover) { + var handlerImg = dojo.query("img.yawZoomHandlerImg", mover.node)[0]; + var yawLabel = dojo.query("div.yawLabel", mover.node)[0]; + var zoomLabel = dojo.query("div.zoomLabel", mover.node)[0]; + + yawLabel.innerHTML = ''; + zoomLabel.innerHTML = ''; + + self.updateScene(); + }; + self.yawZoomHandler.onMoving = function(mover) { + var handlerImg = dojo.query("img.yawZoomHandlerImg", mover.node)[0]; + var yawLabel = dojo.query("div.yawLabel", mover.node)[0]; + var zoomLabel = dojo.query("div.zoomLabel", mover.node)[0]; + var offset = moverRelativeTo(handlerImg, self.element); + + offset.x += 7; + offset.y += 9; + + self.xyHandlerElem.style.zIndex = 1; + self.yawZoomHandlerElem.style.zIndex = 2; + self.pitchRollHandlerElem.style.zIndex = 1; + + // self.pose.pitch = self.pose.pitch % (2 * 3.14159); + // self.pose.roll = self.pose.roll % (2 * 3.14159); + self.pose.yaw = (self.pose.width - offset.x) / self.pose.width - 0.5; + self.pose.zoom = offset.y / self.pose.height - 0.5; + self.pose.yaw *= 2 * 3.14159; + self.pose.zoom = self.pose.zoom * 3 + 1; + self.pose.zoom = Math.ceil((self.pose.zoom) * 10) / 10; + self.pose.yaw = Math.ceil((self.pose.yaw) * 10) / 10; + yawLabel.innerHTML = 'Yaw:' + self.pose.yaw; + zoomLabel.innerHTML = 'Zoom:' + self.pose.zoom; + }; + + self.xyHandler = new Moveable(self.xyHandlerElem); + self.xyHandler.onMoveStop = function(mover) { + var handlerImg = dojo.query("img.xyHandlerImg", mover.node)[0]; + var xLabel = dojo.query("div.xLabel", mover.node)[0]; + var yLabel = dojo.query("div.yLabel", mover.node)[0]; + + xLabel.innerHTML = ''; + yLabel.innerHTML = ''; + + self.updateScene(); + }; + self.xyHandler.onMoving = function(mover) { + var handlerImg = dojo.query("img.xyHandlerImg", mover.node)[0]; + var xLabel = dojo.query("div.xLabel", mover.node)[0]; + var yLabel = dojo.query("div.yLabel", mover.node)[0]; + var offset = moverRelativeTo(handlerImg, self.element); + + offset.x += 3; + offset.y += 13; + + self.xyHandlerElem.style.zIndex = 2; + self.yawZoomHandlerElem.style.zIndex = 1; + self.pitchRollHandlerElem.style.zIndex = 1; + + self.pose.x = offset.x / self.pose.width - 0.5; + self.pose.y = offset.y / self.pose.height - 0.5; + self.pose.x *= 100; + self.pose.y *= 100; + self.pose.y = Math.ceil((self.pose.y) * 10) / 10; + self.pose.x = Math.ceil((self.pose.x) * 10) / 10; + xLabel.innerHTML = 'X:' + self.pose.x; + yLabel.innerHTML = 'Y:' + self.pose.y; + }; + + /** + * === FILES DROPDOWN ==================== + */ + + self.filesDropDownElem = dojo.query("td.filesDropDown", element)[0]; + + self.createAvatar = function(item, mode) { + if (mode == 'avatar') { + // create your avatar if you want + var avatar = dojo.create( 'div', { innerHTML: item.data }); + var avatarPose = dojo.clone(self.pose); + avatarPose.width=60; + avatarPose.height=60; + var avatarImgUrl = urlSuffixForPose(avatarPose); + avatar.innerHTML = ' '; + item.srcEcc = "VRMLViewer"; + item.iconPoseUrl = self.imageURL + avatarImgUrl; + item.imageURL = self.imageURL; + item.serverURL = self.serverURL; + item.pose = avatarPose; + return {node: avatar, data: item, type: item.type}; + } + var handler = dojo.create( 'div', { innerHTML: '' }); + return {node: handler, data: item, type: item.type}; + }; + + self.dragHandler = new Source(dojo.query("td.dragHandler", element)[0], {copyOnly: true, creator: self.createAvatar}); + self.dragHandler.insertNodes(false, [ { } ]); + + // setup fileStore for tree list + self.fileStore = new Observable(new Memory({ + data: [ { id: 'root', name:'3D Models'} ], + getChildren: function(object){ + return this.query({parent: object.id}); + } + })); + self.fileTreeModel = new ObjectStoreModel({ + store: self.fileStore, + query: { id: "root" } + }); + + // setup actual tree dijit + self.fileList = new dijit.Tree({ + id: "fileList" + self.instanceId, + model: self.fileTreeModel, + persist: false, + showRoot: false, + style: "height: 300px;", + onClick: function(item){ + if ('url' in item) { + self.imageURL = item.url; + self.updateScene(); + } + }, + getIconClass: function(item, opened) { + return (!item || !('url' in item)) ? (opened ? "dijitFolderOpened" : "dijitFolderClosed") : "dijitLeaf"; + }, + getIconStyle: function(item, opened){ + if('url' in item) { + return { backgroundImage: "url('" + item.url + "?width=16&height=16')"}; + } + } + //return {backgroundImage: "url('" + item.url + "?width=16&height=16')"}; + + }); + + if (self.params && self.params.serverURL) + self.serverURL = self.params.serverURL; + var savedServerURL = self.localStorage.get("vrmlServer"); + if (savedServerURL && !self.serverURL) { + self.serverURL = savedServerURL; + self.refreshServer(savedServerURL); + } + + self.serverBox = new TextBox({ + name: "Server", + value: self.serverURL, + style: "width: 65%", + + onKeyUp: function(e) { + if (self.browseButton) { + if (this.get("value") !== self.serverURL) { + self.browseButton.setAttribute('label', 'Browse'); + } else { + self.browseButton.setAttribute('label', 'Refresh'); + } + } + }, + + onKeyDown: function(e) { + var code = e.keyCode || e.which; + if( code === 13 ) { + e.preventDefault(); + self.refreshServer(this.get("value")); + return false; + } + }, + }); + + self.browseButton = new Button({ + label: "Browse", + onClick: function(){ + self.refreshServer(self.serverBox.get("value")); + } + }); + + self.filesDropDownContent = domConst.toDom('
'); + self.filesDropDownContent.appendChild(self.serverBox.domNode); + self.filesDropDownContent.appendChild(self.browseButton.domNode); + self.filesDropDownContent.appendChild(self.fileList.domNode); + + self.filesToolTip = new TooltipDialog({ content:self.filesDropDownContent, style:"max-height:320px"}); + self.filesDropDown = new DropDownButton({ label: "Files", dropDown: self.filesToolTip }); + self.filesDropDownElem.appendChild(self.filesDropDown.domNode); + + self.fileStandby = new Standby({target: self.filesDropDownContent }); + self.filesDropDownContent.appendChild(self.fileStandby.domNode); + + /** + * === MOVIE DROPDOWN ==================== + */ + + self.movieDropDownElem = dojo.query("div.movieDropDown", element)[0]; + self.movieAddButtonElem = dojo.query("button.movieAddButton", element)[0]; + + self.movieDropDownContent = domConst.toDom( + '
\ +
\ +
\ +
' + ); + + self.movieFormatLengthRowElem = dojo.query("tr.movieFormatLengthRow", self.movieDropDownContent)[0]; + self.movieWidthHeightLengthRowElem = dojo.query("tr.movieWidthHeightLengthRow", self.movieDropDownContent)[0]; + self.movieDnDArea = dojo.query("div.dndArea", self.movieDropDownContent)[0]; + + self.createMovieThumb = function(item, mode) { + if (mode == 'avatar') { + // when dragged + var avatar = dojo.create( 'div', { innerHTML: item.data }); + var avatarPose = dojo.clone(self.pose); + avatarPose.width = 60; + avatarPose.height = 60; + var avatarImgUrl = urlSuffixForPose(avatarPose); + avatar.innerHTML = ' '; + item.srcEcc = "VRMLViewer"; + item.iconPoseUrl = self.imageURL + avatarImgUrl; + item.imageURL = self.imageURL; + item.serverURL = self.serverURL; + item.pose = avatarPose; + return {node: avatar, data: item, type: item.type}; + } else { + + // when added to list + var thumb = domConst.toDom("\ +
\ +
\ + \ + \ + \ + \ + \ + \ + \ + \ +
Frame:
Transition:
\ +
\ +
\ + "); + thumb = dojo.query("div", thumb)[0]; + + var thumbImgElem = dojo.query("img.movieThumb", thumb)[0]; + var removeImgElem = dojo.query("img.removeThumb", thumb)[0]; + var relFrameLengthElem = dojo.query("div.relFrameLength", thumb)[0]; + var relTransitionLengthElem = dojo.query("div.relTransitionLength", thumb)[0]; + var fillInSeriesElem = dojo.query("div.fillInSeries", thumb)[0]; + + item.getThisAndNeighborsFromDnD = function() { + var thisAndNeighbors = {}; + self.addToMovieHandler.forInItems(function(obj, key, ctx) { + if (obj.data === item) { + thisAndNeighbors.this = { key: key, obj: obj }; + } else { + thisAndNeighbors.before = { key: key, obj: obj }; + } + if (thisAndNeighbors.this) { + thisAndNeighbors.after = { key: key, obj: obj }; + return thisAndNeighbors; + } + }); + return thisAndNeighbors; + }; + + item.relFrameLengthSlider = new HorizontalSlider({ + value: 50, + title: "Relative Duration of Frame", + style: "width:150px;" + }, relFrameLengthElem); + + item.relTransitionLengthSlider = new HorizontalSlider({ + value: 100, + title: "Relative Duration of Transition", + style: "width:150px;" + }, relTransitionLengthElem); + + removeImgElem.onclick = function() { + var thisItem = item.getThisAndNeighborsFromDnD(); + if (thisItem.this) { + // haha - what a mess! + self.addToMovieHandler.selectNone(); + self.addToMovieHandler.selection[thisItem.this.key] = thisItem.this.obj; + self.addToMovieHandler.deleteSelectedNodes(); + } + // disable create button if this was the last one + if (!thisItem.after || !thisItem.before) { + self.movieCreateButton.setAttribute('disabled', true); + } + } + + item.fillInSeriesButton = new Button({ + label: "Insert Series", + style: "display: none;", + onClick: function(){ + alert("foo"); + } + }, fillInSeriesElem); + + removeImgElem.src = self.resRoot + "img/close.png"; + + var thumbPose = dojo.clone(self.pose); + thumbPose.width = self.pose.width / 10; + thumbPose.height = self.pose.height / 10; + var thumbImgUrl = urlSuffixForPose(thumbPose); + + thumbImgElem.src = self.imageURL + thumbImgUrl; + // removeImgElem.src = self.resRoot + 'img/close.png'; + + item.srcEcc = "VRMLViewer"; + item.iconPoseUrl = self.imageURL + thumbImgUrl; + item.imageURL = self.imageURL; + item.serverURL = self.serverURL; + item.pose = thumbPose; + + return {node: thumb, data: item, type: item.type}; + } + }; + + self.addToMovieHandler = new Source(self.movieDnDArea, {copyOnly: true, creator: self.createMovieThumb}); + + self.movieFormatSelection = new Selector({ + name: "movieFormat", + style: "width: 320px", + options: [] + }); + self.populateMovieCodecs(self.serverURL + '/movie/codecs', self.movieFormatSelection); + + self.movieFormatLengthRowElem.appendChild(dojo.create('td', { innerHTML: 'Format:'} )); + self.movieFormatLengthRowElem.appendChild(dojo.create('td', { colspan: "2"})); + self.movieFormatLengthRowElem.lastChild.appendChild(self.movieFormatSelection.domNode); + + self.movieHeightSpinner = new NumberSpinner({ + value: 400, + smallDelta: 1, + style: "width: 60px", + constraints: { min:40, places:0 }, + }); + + self.movieWidthSpinner = new NumberSpinner({ + value: 600, + smallDelta: 1, + style: "width: 60px", + constraints: { min:40, places:0 }, + }); + + self.movieCreateButton = new Button({ + label: "Create", + disabled: true, + onClick: function(){ + + var form = document.createElement("form"); + + form.setAttribute("method", "post"); + form.setAttribute("action", self.serverURL + "/movie"); + + var submitData = {}; + submitData.frames = []; + submitData.movieLength = self.movieDurationSpinner.value; + submitData.format = self.movieFormatSelection.value; + submitData.width = self.movieWidthSpinner.value; + submitData.height = self.movieHeightSpinner.value; + + self.addToMovieHandler.forInItems(function(obj, key, ctx) { + var jsonData = { + iconPoseUrl: obj.data.iconPoseUrl, + imageURL: obj.data.imageURL, + serverURL: obj.data.serverURL, + pose: obj.data.pose, + relFrameLength: obj.data.relFrameLengthSlider.value, + relTransitionLength: obj.data.relTransitionLengthSlider.value, + } + submitData.frames.push(jsonData); + }); + + var hiddenField = document.createElement("input"); + hiddenField.setAttribute("type", "hidden"); + hiddenField.setAttribute("name", "data"); + hiddenField.setAttribute("value", JSON.stringify(submitData)); + + form.appendChild(hiddenField); + + // this will not save the returned binary file + // self.xhr.post({ + // form: form, + // load: function(data){ + // alert("asd"); + // } + // }); + + document.body.appendChild(form); + form.submit(); + document.body.removeChild(form); + } + }); + + self.movieDurationSpinner = new NumberSpinner({ + value: 10, + smallDelta: 1, + style: "width: 40px", + constraints: { min:0, places:0 }, + }); + + // append format duration cell + self.movieWidthHeightLengthRowElem.appendChild(dojo.create('td', { innerHTML: 'Size:'} )); + var movieDimensionCell = dojo.create('td'); + movieDimensionCell.appendChild(self.movieWidthSpinner.domNode); + movieDimensionCell.appendChild(dojo.create('span', { innerHTML: "x"} )); + movieDimensionCell.appendChild(self.movieHeightSpinner.domNode); + movieDimensionCell.appendChild(self.movieDurationSpinner.domNode); + movieDimensionCell.appendChild(dojo.create('span', { innerHTML: "sec"} )); + self.movieWidthHeightLengthRowElem.appendChild(movieDimensionCell); + + self.movieWidthHeightLengthRowElem.appendChild(dojo.create('td', { align: "right"})); + self.movieWidthHeightLengthRowElem.lastChild.appendChild(self.movieCreateButton.domNode); + + + self.movieToolTip = new TooltipDialog({ content:self.movieDropDownContent }); + self.movieDropDown = new DropDownButton({ + label: "Movie", + style: "display: none;", + dropDown: self.movieToolTip }); + self.movieDropDownElem.appendChild(self.movieDropDown.domNode); + + self.movieAddButton = new Button({ + label: "+", + style: "margin-left: -10px; display: none;", + onClick: function(){ + if (self.movieFormatSelection.options.length == 0) { + self.populateMovieCodecs(self.serverURL + '/movie/codecs', self.movieFormatSelection); + } + // we could pass item.data here to creator + self.addToMovieHandler.insertNodes(false, [ { } ]); + self.movieCreateButton.setAttribute('disabled', false); + + } + }, self.movieAddButtonElem); + + + self.resetButton = new Button({ + label: "Reset", + onClick: function(){ + self.pose.x = 0; + self.pose.y = 0; + self.pose.pitch = 0; + self.pose.roll = 0; + self.pose.yaw = 0; + self.pose.zoom = 1; + + self.xyHandler.node.style.left = 0; + self.xyHandler.node.style.top = 0; + self.pitchRollHandler.node.style.left = 0; + self.pitchRollHandler.node.style.top = 0; + self.yawZoomHandler.node.style.left = 0; + self.yawZoomHandler.node.style.top = 0; + + self.updateScene(); + } + }, self.resetButtonElem); + + // do we have parameters for the initial pose? + if(self.params && self.params.pose) + self.setPose(self.params.imageURL, self.params.pose, self.params.serverURL); + + }); + }); + + +} diff --git a/apps/samples/vrml/vrml-server.scxml b/apps/samples/vrml/vrml-server.scxml index 5ee28dd..2f5c4ca 100644 --- a/apps/samples/vrml/vrml-server.scxml +++ b/apps/samples/vrml/vrml-server.scxml @@ -179,7 +179,7 @@ - + + - - - - Hey There! - + + + + + + Hey There! + + + \ No newline at end of file diff --git a/test/samples/uscxml/test-performance.scxml b/test/samples/uscxml/test-performance.scxml index a102a18..4d2d4c4 100644 --- a/test/samples/uscxml/test-performance.scxml +++ b/test/samples/uscxml/test-performance.scxml @@ -1,6 +1,6 @@ - 1000 + 10000 diff --git a/test/samples/uscxml/test-startup-time.scxml b/test/samples/uscxml/test-startup-time.scxml new file mode 100644 index 0000000..cc10f04 --- /dev/null +++ b/test/samples/uscxml/test-startup-time.scxml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/test/src/test-arabica-events.cpp b/test/src/test-arabica-events.cpp index 193b7ae..0cd45ee 100644 --- a/test/src/test-arabica-events.cpp +++ b/test/src/test-arabica-events.cpp @@ -1,3 +1,5 @@ +#include + #include "uscxml/config.h" #include "uscxml/Common.h" #include diff --git a/test/src/test-arabica-parsing.cpp b/test/src/test-arabica-parsing.cpp index 24c58ae..24275fc 100644 --- a/test/src/test-arabica-parsing.cpp +++ b/test/src/test-arabica-parsing.cpp @@ -1,3 +1,5 @@ +#include + #include "uscxml/config.h" #include "uscxml/Common.h" #include diff --git a/test/src/test-arabica-xpath.cpp b/test/src/test-arabica-xpath.cpp index 408cc2b..fe457f4 100644 --- a/test/src/test-arabica-xpath.cpp +++ b/test/src/test-arabica-xpath.cpp @@ -1,3 +1,5 @@ +#include + #include #include #include diff --git a/test/src/test-cmdline-parsing.cpp b/test/src/test-cmdline-parsing.cpp new file mode 100644 index 0000000..b0b909e --- /dev/null +++ b/test/src/test-cmdline-parsing.cpp @@ -0,0 +1,109 @@ +#include "uscxml/config.h" +#include "uscxml/Interpreter.h" +#include + +int main(int argc, char** argv) { + using namespace uscxml; + + if (true) { + int testArgc = 11; + const char* testArgv[] = { + "test-cmdline-parsing", + "--verbose", + "--dot", + "--port=80", + "--ssl-port=8080", + "--certificate=/foo/bar.pem", + "--private-key=/foo/bar.priv", + "--public-key=/foo/bar.pub", + "--plugin-path=/foo/plugins", + "--loglevel=10", + "--disable-http", + 0 + }; + InterpreterOptions options = InterpreterOptions::fromCmdLine(testArgc, (char **)testArgv); + assert(options.verbose); + assert(options.useDot); + assert(options.httpPort == 80); + assert(options.httpsPort == 8080); + assert(boost::equals(options.certificate, "/foo/bar.pem")); + assert(boost::equals(options.privateKey, "/foo/bar.priv")); + assert(boost::equals(options.publicKey, "/foo/bar.pub")); + assert(boost::equals(options.pluginPath, "/foo/plugins")); + assert(options.logLevel == 10); + assert(!options.withHTTP); + assert(!options); // invalid as no SCXML document is given + + optind = 0; + optreset = 1; + } + + if (true) { + int testArgc = 3; + const char* testArgv[] = { + "test-cmdline-parsing", + "--verbose", + "/foo/bar.scxml", + 0 + }; + InterpreterOptions options = InterpreterOptions::fromCmdLine(testArgc, (char **)testArgv); + assert(options); + assert(options.verbose); + assert(options.interpreters.size() == 1); + assert(options.interpreters.find("/foo/bar.scxml") != options.interpreters.end()); + + optind = 0; + optreset = 1; + } + + if (true) { + int testArgc = 7; + const char* testArgv[] = { + "test-cmdline-parsing", + "--port=80", + "/foo/bar1.scxml", + "--disable-http", + "/foo/bar2.scxml", + "/foo/bar3.scxml", + "--disable-http", + 0 + }; + InterpreterOptions options = InterpreterOptions::fromCmdLine(testArgc, (char **)testArgv); + assert(options); + assert(options.httpPort == 80); + assert(options.interpreters.size() == 3); + assert(options.interpreters.find("/foo/bar1.scxml") != options.interpreters.end()); + assert(options.interpreters.find("/foo/bar2.scxml") != options.interpreters.end()); + assert(options.interpreters.find("/foo/bar3.scxml") != options.interpreters.end()); + assert(!options.interpreters["/foo/bar1.scxml"]->withHTTP); + assert(options.interpreters["/foo/bar2.scxml"]->withHTTP); + assert(!options.interpreters["/foo/bar3.scxml"]->withHTTP); + + optind = 0; + optreset = 1; + } + + if (true) { + int testArgc = 5; + const char* testArgv[] = { + "test-cmdline-parsing", + "--port=80", + "/foo/bar1.scxml", + "--vrml-path=/foo/bar.test", + "--tmp-path=/foo/bar.test", + 0 + }; + InterpreterOptions options = InterpreterOptions::fromCmdLine(testArgc, (char **)testArgv); + assert(options); + assert(options.httpPort == 80); + assert(options.interpreters.size() == 1); + assert(options.interpreters.find("/foo/bar1.scxml") != options.interpreters.end()); + assert(options.interpreters["/foo/bar1.scxml"]->additionalParameters.find("vrml-path") != options.interpreters["/foo/bar1.scxml"]->additionalParameters.end()); + assert(options.interpreters["/foo/bar1.scxml"]->additionalParameters.find("tmp-path") != options.interpreters["/foo/bar1.scxml"]->additionalParameters.end()); + + optind = 0; + optreset = 1; + } + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/test/src/test-instant-messaging.cpp b/test/src/test-instant-messaging.cpp new file mode 100644 index 0000000..0bf2898 --- /dev/null +++ b/test/src/test-instant-messaging.cpp @@ -0,0 +1,298 @@ +/* + * pidgin + * + * Pidgin is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + * + */ + +#include "purple.h" + +#include + +#include +#include +#ifndef _WIN32 +#include +#else +#include "win32/win32dep.h" +#endif + +#define CUSTOM_USER_DIRECTORY "/dev/null" +#define CUSTOM_PLUGIN_PATH "" +#define PLUGIN_SAVE_PREF "/purple/nullclient/plugins/saved" +#define UI_ID "nullclient" + +/** + * The following eventloop functions are used in both pidgin and purple-text. If your + * application uses glib mainloop, you can safely use this verbatim. + */ +#define PURPLE_GLIB_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR) +#define PURPLE_GLIB_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL) + +typedef struct _PurpleGLibIOClosure { + PurpleInputFunction function; + guint result; + gpointer data; +} PurpleGLibIOClosure; + +static void purple_glib_io_destroy(gpointer data) +{ + g_free(data); +} + +static gboolean purple_glib_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data) +{ + PurpleGLibIOClosure *closure = (PurpleGLibIOClosure*)data; + int purple_cond = 0; + + if (condition & PURPLE_GLIB_READ_COND) + purple_cond |= PURPLE_INPUT_READ; + if (condition & PURPLE_GLIB_WRITE_COND) + purple_cond |= PURPLE_INPUT_WRITE; + + closure->function(closure->data, g_io_channel_unix_get_fd(source), + (PurpleInputCondition)purple_cond); + + return TRUE; +} + +static guint glib_input_add(gint fd, PurpleInputCondition condition, PurpleInputFunction function, + gpointer data) +{ + PurpleGLibIOClosure *closure = g_new0(PurpleGLibIOClosure, 1); + GIOChannel *channel; + int cond = 0; + + closure->function = function; + closure->data = data; + + if (condition & PURPLE_INPUT_READ) + cond |= PURPLE_GLIB_READ_COND; + if (condition & PURPLE_INPUT_WRITE) + cond |= PURPLE_GLIB_WRITE_COND; + +#if defined _WIN32 && !defined WINPIDGIN_USE_GLIB_IO_CHANNEL + channel = wpurple_g_io_channel_win32_new_socket(fd); +#else + channel = g_io_channel_unix_new(fd); +#endif + closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, (GIOCondition)cond, + purple_glib_io_invoke, closure, purple_glib_io_destroy); + + g_io_channel_unref(channel); + return closure->result; +} + +static PurpleEventLoopUiOps glib_eventloops = +{ + g_timeout_add, + g_source_remove, + glib_input_add, + g_source_remove, + NULL, + g_timeout_add_seconds, + + /* padding */ + NULL, + NULL, + NULL +}; +/*** End of the eventloop functions. ***/ + +/*** Conversation uiops ***/ +static void +null_write_conv(PurpleConversation *conv, const char *who, const char *alias, + const char *message, PurpleMessageFlags flags, time_t mtime) +{ + const char *name; + if (alias && *alias) + name = alias; + else if (who && *who) + name = who; + else + name = NULL; + + printf("(%s) %s %s: %s\n", purple_conversation_get_name(conv), + purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)), + name, message); +} + +static PurpleConversationUiOps null_conv_uiops = +{ + NULL, /* create_conversation */ + NULL, /* destroy_conversation */ + NULL, /* write_chat */ + NULL, /* write_im */ + null_write_conv, /* write_conv */ + NULL, /* chat_add_users */ + NULL, /* chat_rename_user */ + NULL, /* chat_remove_users */ + NULL, /* chat_update_user */ + NULL, /* present */ + NULL, /* has_focus */ + NULL, /* custom_smiley_add */ + NULL, /* custom_smiley_write */ + NULL, /* custom_smiley_close */ + NULL, /* send_confirm */ + NULL, + NULL, + NULL, + NULL +}; + +static void +null_ui_init(void) +{ + /** + * This should initialize the UI components for all the modules. Here we + * just initialize the UI for conversations. + */ + purple_conversations_set_ui_ops(&null_conv_uiops); +} + +static PurpleCoreUiOps null_core_uiops = +{ + NULL, + NULL, + null_ui_init, + NULL, + + /* padding */ + NULL, + NULL, + NULL, + NULL +}; + +static void +init_libpurple(void) +{ + /* Set a custom user directory (optional) */ + purple_util_set_user_dir(CUSTOM_USER_DIRECTORY); + + /* We do not want any debugging for now to keep the noise to a minimum. */ + purple_debug_set_enabled(FALSE); + + /* Set the core-uiops, which is used to + * - initialize the ui specific preferences. + * - initialize the debug ui. + * - initialize the ui components for all the modules. + * - uninitialize the ui components for all the modules when the core terminates. + */ + purple_core_set_ui_ops(&null_core_uiops); + + /* Set the uiops for the eventloop. If your client is glib-based, you can safely + * copy this verbatim. */ + purple_eventloop_set_ui_ops(&glib_eventloops); + + /* Set path to search for plugins. The core (libpurple) takes care of loading the + * core-plugins, which includes the protocol-plugins. So it is not essential to add + * any path here, but it might be desired, especially for ui-specific plugins. */ + purple_plugins_add_search_path(CUSTOM_PLUGIN_PATH); + + /* Now that all the essential stuff has been set, let's try to init the core. It's + * necessary to provide a non-NULL name for the current ui to the core. This name + * is used by stuff that depends on this ui, for example the ui-specific plugins. */ + if (!purple_core_init(UI_ID)) { + /* Initializing the core failed. Terminate. */ + fprintf(stderr, + "libpurple initialization failed. Dumping core.\n" + "Please report this!\n"); + abort(); + } + + /* Load the preferences. */ + purple_prefs_load(); + + /* Load the desired plugins. The client should save the list of loaded plugins in + * the preferences using purple_plugins_save_loaded(PLUGIN_SAVE_PREF) */ + purple_plugins_load_saved(PLUGIN_SAVE_PREF); +} + +static void +signed_on(PurpleConnection *gc, gpointer null) +{ + PurpleAccount *account = purple_connection_get_account(gc); + printf("Account connected: %s %s\n", purple_account_get_username(account), purple_account_get_protocol_id(account)); +} + +static void +buddy_signed_on(PurpleBuddy *buddy) { + PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy)); + PurplePlugin* prpl = purple_connection_get_prpl(gc); + PurplePluginProtocolInfo* prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); + + if (prpl_info->send_file && (prpl_info->can_receive_file && prpl_info->can_receive_file(gc, "sradomski@localhost"))) { + prpl_info->send_file(gc, "sradomski@localhost", "/Users/sradomski/Documents/W3C Standards.pdf"); + } + +} + +static void +connect_to_signals_for_demonstration_purposes_only(void) +{ + static int handle; + purple_signal_connect(purple_connections_get_handle(), "signed-on", &handle, + PURPLE_CALLBACK(signed_on), NULL); + purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on", &handle, + PURPLE_CALLBACK(buddy_signed_on), NULL); +} + +int main(int argc, char *argv[]) +{ + GList *iter; + GMainLoop *loop = g_main_loop_new(NULL, FALSE); + PurpleAccount *account; + PurpleSavedStatus *status; + +#ifndef _WIN32 + /* libpurple's built-in DNS resolution forks processes to perform + * blocking lookups without blocking the main process. It does not + * handle SIGCHLD itself, so if the UI does not you quickly get an army + * of zombie subprocesses marching around. + */ + signal(SIGCHLD, SIG_IGN); +#endif + + init_libpurple(); + + printf("libpurple initialized.\n"); + + iter = purple_plugins_get_protocols(); + + /* Create the account */ + account = purple_account_new("uscxml@localhost", "prpl-jabber"); + + /* Get the password for the account */ + purple_account_set_password(account, "password", NULL, NULL); + + /* It's necessary to enable the account first. */ + purple_account_set_enabled(account, UI_ID, TRUE); + + /* Now, to connect the account(s), create a status and activate it. */ + status = purple_savedstatus_new(NULL, PURPLE_STATUS_AVAILABLE); + purple_savedstatus_activate(status); + + connect_to_signals_for_demonstration_purposes_only(); + + g_main_loop_run(loop); + + return 0; +} + -- cgit v0.12