You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by jb...@apache.org on 2010/08/19 16:48:56 UTC
svn commit: r987173 - in /commons/sandbox/gsoc/2010/scxml-js/trunk: ./
lib/js/requirejs/require/ src/javascript/scxml/cgf/
src/javascript/scxml/cgf/backends/js/ src/javascript/scxml/cgf/build/
src/javascript/scxml/cgf/util/xsl/ src/xslt/backends/js/
Author: jbeard
Date: Thu Aug 19 14:48:56 2010
New Revision: 987173
URL: http://svn.apache.org/viewvc?rev=987173&view=rev
Log:
Added facilities for compiling compiler to Java bytecode.
Makefile includes tasks to:
- compile with RequireJS (and optionally closure compiler), to create a single js file.
- compile single js file to Java class file
- run Java class file against a file to see that it gives correct output.
Other changes in this check-in facilitate this build. These changes include:
- changing xml dependencies to text dependencies
- changing all xsl processor modules to accept XML documents as both parsed DOM and string forms
- changing SCXML compiler to use slightly clunkier code to accommodate RequireJS build
- modifying RequireJS text module to work under Rhino without needing to emulate XMLHttpRequest
- created build/rhino.js, a rhino-specific, build-friendly front-end, which accepts command-line arguments, and passes them to main module
Also, fixed small bug in AbstractStatechartGenrator.xsl which was breaking just-in-time compilation, state backend in Chrome.
All unit tests pass (rhino, ahead-of-time browser, and just-in-time browser). All demos seem to work.
Added:
commons/sandbox/gsoc/2010/scxml-js/trunk/Makefile (with props)
commons/sandbox/gsoc/2010/scxml-js/trunk/lib/js/requirejs/require/text.js (with props)
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/build/
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/build/rhino.js (with props)
Modified:
commons/sandbox/gsoc/2010/scxml-js/trunk/build.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/browser.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/ie.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/rhino.js
commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
Added: commons/sandbox/gsoc/2010/scxml-js/trunk/Makefile
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/Makefile?rev=987173&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/Makefile (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/Makefile Thu Aug 19 14:48:56 2010
@@ -0,0 +1,14 @@
+all: compile-with-closure compile-with-jsc run-compiled
+
+compile-with-closure:
+ lib/js/requirejs/build/build.sh name=src/javascript/scxml/cgf/build/rhino out=build/main-built.js baseUrl=. includeRequire=true inlineText=true optimize=none
+
+compile-with-jsc:
+ java -cp lib/java/js.jar org.mozilla.javascript.tools.jsc.Main build/main-built.js
+
+run-compiled:
+ java -cp lib/java/js.jar:lib/java/commons-cli.jar:lib/java/serializer.jar:lib/java/xalan.jar:lib/java/xercesImpl.jar:lib/java/xml-apis.jar:build/ main_built --backend state --beautify test/parallel/TestParallel.xml
+
+
+clean:
+ rm build/main-built.js build/main_built.class
Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/Makefile
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/build.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/build.js?rev=987173&r1=987172&r2=987173&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/build.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/build.js Thu Aug 19 14:48:56 2010
@@ -224,7 +224,8 @@ require.def("build",
stylesheetsToPreprocess.forEach(function({from:inDoc,to:to}){
print("Preprocessing " + inDoc + " to " + to );
var transform = [xmlUtil.parseFromPath(pathToPreprocessScript)];
- var xmlStr = Transformer(new java.io.File(inDoc),transform,null,"xml");
+ var outDoc = Transformer(new java.io.File(inDoc),transform,null,"xml");
+ var xmlStr = xmlUtil.serializeToString(outDoc);
utilFile.writeFile(xmlStr,to);
});
@@ -838,6 +839,7 @@ require.def("build",
<head>
<script src="../lib/js/requirejs/require.js" type="text/javascript">true;</script>
<script src="../lib/js/requirejs/require/xml.js" type="text/javascript">true;</script>
+ <script src="../lib/js/requirejs/require/text.js" type="text/javascript">true;</script>
<script djConfig="isDebug:true" src="../lib/test-js/dojo-release-1.4.2-src/dojo/dojo.js" type="text/javascript">true;</script>
<script type="text/javascript">
dojo.require("doh.runner");
@@ -857,16 +859,16 @@ require.def("build",
"xml!{modulePathToXMLTest}",
"{testScriptModulePath}"],
- require( [window.DOMParser ?
- "src/javascript/scxml/cgf/util/xsl/browser" :
- "src/javascript/scxml/cgf/util/xsl/ie"],
- function(transform){
+ function(compiler,documentToCompile,testScriptModule){
+ require( [window.DOMParser ?
+ "src/javascript/scxml/cgf/util/xsl/browser" :
+ "src/javascript/scxml/cgf/util/xsl/ie"],
+ function(transform){
- function(compiler,KitchenSink_executableContent,testScriptModule){
var compileLog = true;
compiler.compile({
- inFiles:[KitchenSink_executableContent],
+ inFiles:[documentToCompile],
backend:"{backendName}",
beautify:true,
verbose:false,
@@ -885,9 +887,8 @@ require.def("build",
dojo.require("doh.runner");
doh.run();
},transform);
- }
- }
- );
+ });
+ });
</script>
</head>
Added: commons/sandbox/gsoc/2010/scxml-js/trunk/lib/js/requirejs/require/text.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/lib/js/requirejs/require/text.js?rev=987173&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/lib/js/requirejs/require/text.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/lib/js/requirejs/require/text.js Thu Aug 19 14:48:56 2010
@@ -0,0 +1,206 @@
+/**
+ * @license RequireJS text Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
+ * Available via the MIT, GPL or new BSD license.
+ * see: http://github.com/jrburke/requirejs for details
+ */
+/*jslint regexp: false, nomen: false, plusplus: false */
+/*global require: false, XMLHttpRequest: false, ActiveXObject: false */
+
+//>>includeStart("useStrict", pragmas.useStrict);
+"use strict";
+//>>includeEnd("useStrict");
+
+(function () {
+ var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'],
+ xmlRegExp = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,
+ bodyRegExp = /<body[^>]*>\s*([\s\S]+)\s*<\/body>/im;
+
+ if (!require.textStrip) {
+ require.textStrip = function (text) {
+ //Strips <?xml ...?> declarations so that external SVG and XML
+ //documents can be added to a document without worry. Also, if the string
+ //is an HTML document, only the part inside the body tag is returned.
+ if (text) {
+ text = text.replace(xmlRegExp, "");
+ var matches = text.match(bodyRegExp);
+ if (matches) {
+ text = matches[1];
+ }
+ } else {
+ text = "";
+ }
+ return text;
+ };
+ }
+
+ //Upgrade require to add some methods for XHR handling. But it could be that
+ //this require is used in a non-browser env, so detect for existing method
+ //before attaching one.
+ if (!require.getXhr) {
+ require.getXhr = function () {
+ //Would love to dump the ActiveX crap in here. Need IE 6 to die first.
+ var xhr, i, progId;
+ if (typeof XMLHttpRequest !== "undefined") {
+ return new XMLHttpRequest();
+ } else {
+ for (i = 0; i < 3; i++) {
+ progId = progIds[i];
+ try {
+ xhr = new ActiveXObject(progId);
+ } catch (e) {}
+
+ if (xhr) {
+ progIds = [progId]; // so faster next time
+ break;
+ }
+ }
+ }
+
+ if (!xhr) {
+ throw new Error("require.getXhr(): XMLHttpRequest not available");
+ }
+
+ return xhr;
+ };
+ }
+
+ if (!require.fetchText) {
+ if(require.isBrowser){
+ require.fetchText = function (url, callback) {
+ var xhr = require.getXhr();
+ xhr.open('GET', url, true);
+ xhr.onreadystatechange = function (evt) {
+ //Do not explicitly handle errors, those should be
+ //visible via console output in the browser.
+ if (xhr.readyState === 4) {
+ callback(xhr.responseText);
+ }
+ };
+ xhr.send(null);
+ };
+ }else{
+ require.fetchText = function (url, callback) {
+ callback(readFile(url));
+ };
+ }
+ }
+
+
+ require.plugin({
+ prefix: "text",
+
+ /**
+ * This callback is prefix-specific, only gets called for this prefix
+ */
+ require: function (name, deps, callback, context) {
+ //No-op, require never gets these text items, they are always
+ //a dependency, see load for the action.
+ },
+
+ /**
+ * Called when a new context is defined. Use this to store
+ * context-specific info on it.
+ */
+ newContext: function (context) {
+ require.mixin(context, {
+ text: {},
+ textWaiting: []
+ });
+ },
+
+ /**
+ * Called when a dependency needs to be loaded.
+ */
+ load: function (name, contextName) {
+ //Name has format: some.module!filext!strip!text
+ //The strip and text parts are optional.
+ //if strip is present, then that means only get the string contents
+ //inside a body tag in an HTML string. For XML/SVG content it means
+ //removing the <?xml ...?> declarations so the content can be inserted
+ //into the current doc without problems.
+ //If text is present, it is the actual text of the file.
+ var strip = false, text = null, key, url, index = name.indexOf("."),
+ modName = name.substring(0, index), fullKey,
+ ext = name.substring(index + 1, name.length),
+ context = require.s.contexts[contextName],
+ tWaitAry = context.textWaiting;
+
+ index = ext.indexOf("!");
+ if (index !== -1) {
+ //Pull off the strip arg.
+ strip = ext.substring(index + 1, ext.length);
+ ext = ext.substring(0, index);
+ index = strip.indexOf("!");
+ if (index !== -1 && strip.substring(0, index) === "strip") {
+ //Pull off the text.
+ text = strip.substring(index + 1, strip.length);
+ strip = "strip";
+ } else if (strip !== "strip") {
+ //strip is actually the inlined text.
+ text = strip;
+ strip = null;
+ }
+ }
+ key = modName + "!" + ext;
+ fullKey = strip ? key + "!" + strip : key;
+
+ //Store off text if it is available for the given key and be done.
+ if (text !== null && !context.text[key]) {
+ context.defined[name] = context.text[key] = text;
+ return;
+ }
+
+ //If text is not available, load it.
+ if (!context.text[key] && !context.textWaiting[key] && !context.textWaiting[fullKey]) {
+ //Keep track that the fullKey needs to be resolved, during the
+ //orderDeps stage.
+ if (!tWaitAry[fullKey]) {
+ tWaitAry[fullKey] = tWaitAry[(tWaitAry.push({
+ name: name,
+ key: key,
+ fullKey: fullKey,
+ strip: !!strip
+ }) - 1)];
+ }
+
+ //Load the text.
+ url = require.nameToUrl(modName, "." + ext, contextName);
+ context.loaded[name] = false;
+ require.fetchText(url, function (text) {
+ context.text[key] = text;
+ context.loaded[name] = true;
+ require.checkLoaded(contextName);
+ });
+ }
+ },
+
+ /**
+ * Called when the dependencies of a module are checked.
+ */
+ checkDeps: function (name, deps, context) {
+ //No-op, checkDeps never gets these text items, they are always
+ //a dependency, see load for the action.
+ },
+
+ /**
+ * Called to determine if a module is waiting to load.
+ */
+ isWaiting: function (context) {
+ return !!context.textWaiting.length;
+ },
+
+ /**
+ * Called when all modules have been loaded.
+ */
+ orderDeps: function (context) {
+ //Clear up state since further processing could
+ //add more things to fetch.
+ var i, dep, text, tWaitAry = context.textWaiting;
+ context.textWaiting = [];
+ for (i = 0; (dep = tWaitAry[i]); i++) {
+ text = context.text[dep.key];
+ context.defined[dep.name] = dep.strip ? require.textStrip(text) : text;
+ }
+ }
+ });
+}());
Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/lib/js/requirejs/require/text.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js?rev=987173&r1=987172&r2=987173&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/SCXMLCompiler.js Thu Aug 19 14:48:56 2010
@@ -40,9 +40,7 @@ require.def("src/javascript/scxml/cgf/SC
supported options:
backend {switch | table | state}
ie
- noForEach
noIndexOf
- noMap
beautify
log
verbose
@@ -54,15 +52,7 @@ require.def("src/javascript/scxml/cgf/SC
options.noIndexOf = true;
}
- var backendModuleToImport =
- ({
- state:"src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator",
- table:"src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator",
- "switch":"src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator"
- })[options.backend];
-
- require([backendModuleToImport],function(backend){
-
+ function onModuleLoad(backend){
var toReturn = options.inFiles.map(function(xmlFile){
var ir = transform(xmlFile,backend.transformations,null,"xml",options.debug);
@@ -77,9 +67,24 @@ require.def("src/javascript/scxml/cgf/SC
});
callback(toReturn);
- });
+ }
- };
+ //this slightly clunky construction is used to accomodate RequireJS's builder
+ if(options.backend==="state"){
+ require(["src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator"],function(backend){
+ onModuleLoad(backend);
+ });
+ }else if(options.backend==="table"){
+ require(["src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator"],function(backend){
+ onModuleLoad(backend);
+ });
+ }else if(options.backend==="switch"){
+ require(["src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator"],function(backend){
+ onModuleLoad(backend);
+ });
+ }
+
+ }
return {
compile : compile
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js?rev=987173&r1=987172&r2=987173&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator.js Thu Aug 19 14:48:56 2010
@@ -4,15 +4,15 @@ require.def(
[
"src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator",
- "xml!src/xslt/ir-compiler/flattenTransitions.xsl",
- "xml!src/xslt/ir-compiler/appendTransitionInformation.xsl",
- "xml!src/xslt/ir-compiler/nameTransitions.xsl",
- "xml!src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl",
- "xml!src/xslt/ir-compiler/enumerateEvents.xsl",
- "xml!src/xslt/ir-compiler/addEventRegularExpressions.xsl",
- "xml!src/xslt/ir-compiler/expandStarEvent.xsl",
- "xml!src/xslt/ir-compiler/numberStatesAndTransitions.xsl",
- "xml!src/xslt/layout/addTransitionTargetIds.xsl" ],
+ "text!src/xslt/ir-compiler/flattenTransitions.xsl",
+ "text!src/xslt/ir-compiler/appendTransitionInformation.xsl",
+ "text!src/xslt/ir-compiler/nameTransitions.xsl",
+ "text!src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl",
+ "text!src/xslt/ir-compiler/enumerateEvents.xsl",
+ "text!src/xslt/ir-compiler/addEventRegularExpressions.xsl",
+ "text!src/xslt/ir-compiler/expandStarEvent.xsl",
+ "text!src/xslt/ir-compiler/numberStatesAndTransitions.xsl",
+ "text!src/xslt/layout/addTransitionTargetIds.xsl" ],
function(
AbstractStatechartGenerator,
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js?rev=987173&r1=987172&r2=987173&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator.js Thu Aug 19 14:48:56 2010
@@ -3,15 +3,15 @@ require.def(
"src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator",
[
- "xml!src/xslt/ir-compiler/normalizeInitialStates.xsl",
- "xml!src/xslt/ir-compiler/generateUniqueStateIds.xsl",
- "xml!src/xslt/ir-compiler/generateUniqueInitialStateIds.xsl",
- "xml!src/xslt/ir-compiler/splitTransitionTargets.xsl",
- "xml!src/xslt/ir-compiler/changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl",
- "xml!src/xslt/ir-compiler/computeLCA.xsl",
- "xml!src/xslt/ir-compiler/transformIf.xsl",
- "xml!src/xslt/ir-compiler/appendStateInformation.xsl",
- "xml!src/xslt/ir-compiler/appendBasicStateInformation.xsl" ],
+ "text!src/xslt/ir-compiler/normalizeInitialStates.xsl",
+ "text!src/xslt/ir-compiler/generateUniqueStateIds.xsl",
+ "text!src/xslt/ir-compiler/generateUniqueInitialStateIds.xsl",
+ "text!src/xslt/ir-compiler/splitTransitionTargets.xsl",
+ "text!src/xslt/ir-compiler/changeTransitionsPointingToCompoundStatesToPointToInitialStates.xsl",
+ "text!src/xslt/ir-compiler/computeLCA.xsl",
+ "text!src/xslt/ir-compiler/transformIf.xsl",
+ "text!src/xslt/ir-compiler/appendStateInformation.xsl",
+ "text!src/xslt/ir-compiler/appendBasicStateInformation.xsl" ],
function(
normalizeInitialStates,
generateUniqueStateIds,
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js?rev=987173&r1=987172&r2=987173&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StatePatternStatechartGenerator.js Thu Aug 19 14:48:56 2010
@@ -4,13 +4,13 @@ require.def(
[
"src/javascript/scxml/cgf/backends/js/AbstractStatechartGenerator",
- "xml!src/xslt/ir-compiler/appendTransitionInformation.xsl",
- "xml!src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl",
- "xml!src/xslt/ir-compiler/enumerateEvents.xsl",
- "xml!src/xslt/ir-compiler/addEventRegularExpressions.xsl",
- "xml!src/xslt/ir-compiler/expandStarEvent.xsl",
- "xml!src/xslt/layout/addTransitionTargetIds.xsl",
- "xml!build/StatePatternStatechartGenerator_combined.xsl" //preprocessed stylesheet
+ "text!src/xslt/ir-compiler/appendTransitionInformation.xsl",
+ "text!src/xslt/ir-compiler/copyEnumeratedEventTransitions.xsl",
+ "text!src/xslt/ir-compiler/enumerateEvents.xsl",
+ "text!src/xslt/ir-compiler/addEventRegularExpressions.xsl",
+ "text!src/xslt/ir-compiler/expandStarEvent.xsl",
+ "text!src/xslt/layout/addTransitionTargetIds.xsl",
+ "text!build/StatePatternStatechartGenerator_combined.xsl" //preprocessed stylesheet
],
function(
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js?rev=987173&r1=987172&r2=987173&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator.js Thu Aug 19 14:48:56 2010
@@ -3,7 +3,7 @@ require.def(
"src/javascript/scxml/cgf/backends/js/StateTableStatechartGenerator",
[ "src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator",
- "xml!build/StateTableStatechartGenerator_combined.xsl" //preprocessed stylesheet
+ "text!build/StateTableStatechartGenerator_combined.xsl" //preprocessed stylesheet
],
function(AbstractEnumeratedStatechartGenerator,StateTableStatechartGenerator){
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js?rev=987173&r1=987172&r2=987173&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator.js Thu Aug 19 14:48:56 2010
@@ -3,7 +3,7 @@ require.def(
"src/javascript/scxml/cgf/backends/js/SwitchyardStatechartGenerator",
[ "src/javascript/scxml/cgf/backends/js/AbstractEnumeratedStatechartGenerator",
- "xml!build/SwitchyardStatechartGenerator_combined.xsl" //preprocessed stylesheet
+ "text!build/SwitchyardStatechartGenerator_combined.xsl" //preprocessed stylesheet
],
function(AbstractEnumeratedStatechartGenerator,SwitchyardStatechartGenerator){
Added: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/build/rhino.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/build/rhino.js?rev=987173&view=auto
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/build/rhino.js (added)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/build/rhino.js Thu Aug 19 14:48:56 2010
@@ -0,0 +1,15 @@
+/**
+This is a simple script, not a proper js module, which is used to bootstrap the build process for the RequireJS
+build system.
+It's different from runner.js in that the path to the main module is hardcoded, which is needed for RequireJS
+*/
+
+
+(function(args){
+ require(
+ ["src/javascript/scxml/cgf/main"],
+ function(main){
+ main(args);
+ }
+ );
+})(Array.prototype.slice.call(arguments));
Propchange: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/build/rhino.js
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/browser.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/browser.js?rev=987173&r1=987172&r2=987173&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/browser.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/browser.js Thu Aug 19 14:48:56 2010
@@ -1,13 +1,19 @@
require.def("src/javascript/scxml/cgf/util/xsl/browser",
-function(){
+["src/javascript/scxml/cgf/util/xml/browser"],
+function(xml){
return function(sourceDocument,transformList,params,output,debug){
- transformList = transformList && !transformList.length ?
+
+
+ transformList = Object.prototype.toString.call(transformList) !== "[object Array]" ?
[transformList] :
transformList;
+ sourceDocument = typeof sourceDocument == "string" ? xml.parseFromString(sourceDocument) : sourceDocument;
+ transformList = transformList.map(function(t){return typeof t == "string" ? xml.parseFromString(t) : t});
+
function getProcessorFromStylesheetDocument(d){
var processor = new XSLTProcessor();
processor.importStylesheet(d);
@@ -61,10 +67,10 @@ function(){
var toReturn;
switch(output){
case "text":
- toReturn = getResultTextFromDoc(docToTransform);;
+ toReturn = getResultTextFromDoc(docToTransform);
break;
case "xml":
- toReturn = docToTransform;
+ toReturn = docToTransform;
break;
}
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/ie.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/ie.js?rev=987173&r1=987172&r2=987173&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/ie.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/ie.js Thu Aug 19 14:48:56 2010
@@ -5,10 +5,20 @@ function(xmlUtil){
return function(sourceDocument,transformList,params,output){
- transformList = transformList && !transformList.length ?
+
+ transformList = Object.prototype.toString.call(transformList) !== "[object Array]" ?
[transformList] :
transformList;
+ //we want a document instead of a string here
+ sourceDocument = typeof sourceDocument === "string" ? xmlUtil.parseFromString(sourceDocument) : sourceDocument;
+
+ //we want strings instead of documents here
+ var tmpList = new Array(transformList.length);
+ for(var i=0, l=transformList.length; i<l; i++){
+ tmpList[i] = typeof transformList[i] === "string" ? transformList[i] : transformList[i].xml;
+ }
+ transformList = tmpList;
//prepare processors
//FIXME: this works in IE on WinXP 3, but due to all of the ActiveX code here, i'm not sure how portable, reliable, or performant it is
@@ -19,7 +29,7 @@ function(xmlUtil){
var xsldoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.3.0");
var xslt = new ActiveXObject("Msxml2.XSLTemplate.3.0");
xsldoc.async=false;
- xsldoc.loadXML(transformList[i].xml);
+ xsldoc.loadXML(transformList[i]);
xslt.stylesheet = xsldoc;
var xslproc = xslt.createProcessor();
@@ -55,10 +65,10 @@ function(xmlUtil){
switch(output){
case "text":
toReturn = txt;
- break;
+ break;
case "xml":
toReturn = xmlUtil.parseFromString(txt);
- break;
+ break;
}
return toReturn; //string or node
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/rhino.js
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/rhino.js?rev=987173&r1=987172&r2=987173&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/rhino.js (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/javascript/scxml/cgf/util/xsl/rhino.js Thu Aug 19 14:48:56 2010
@@ -27,8 +27,7 @@ function(xmlUtil){
}
return function(sourceDocument,transformList,params,output){
- transformList = transformList
- && !(transformList instanceof Array) ?
+ transformList = Object.prototype.toString.call(transformList) !== "[object Array]" ?
[transformList] :
transformList;
@@ -41,21 +40,38 @@ function(xmlUtil){
});
var baos = new ByteArrayOutputStream();
- var streamResult = new StreamResult(baos);
+ var result = output == "xml" ? new DOMResult() : new StreamResult(baos);
- transformHandlers[transformHandlers.length-1].setResult(streamResult);
+ transformHandlers[transformHandlers.length-1].setResult(result);
var transformer = tFactory.newTransformer();
- for(paramName in params){
- transformer.setParameter(paramName,params[paramName]);
- }
+ //set params
+
+ transformHandlers.map(function(th){return th.getTransformer()}).forEach(function(t){
+ for(paramName in params){
+ var paramValue = params[paramName];
+ if(typeof paramValue !== "object"){
+ t.setParameter(paramName,params[paramName]);
+ }
+ }
+ });
transformer.transform(getSource(sourceDocument), new SAXResult(transformHandlers[0]));
- toReturn = String(new java.lang.String(baos.toByteArray()));
+
+ var toReturn;
+ switch(output){
+ case "xml":
+ toReturn = result.getNode();
+ break;
+
+ case "text":
+ toReturn = String(new java.lang.String(baos.toByteArray()));
+ break;
+ }
- return toReturn; //string
+ return toReturn; //node or string
}
})()
});
Modified: commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl
URL: http://svn.apache.org/viewvc/commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl?rev=987173&r1=987172&r2=987173&view=diff
==============================================================================
--- commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl (original)
+++ commons/sandbox/gsoc/2010/scxml-js/trunk/src/xslt/backends/js/AbstractStatechartGenerator.xsl Thu Aug 19 14:48:56 2010
@@ -728,7 +728,7 @@
this.getCurrentConfiguration = function(){
//slice it to return a copy of the configuration rather than the conf itself
//this saves us all kinds of confusion involving references and stuff
- //<!-- TODO: refactor this name to be genCurrentConfigurationStatement -->
+ //TODO: refactor this name to be genCurrentConfigurationStatement
<value-of select="$currentConfigurationExpression"/>
return currentConfigurationExpression;
}