Skip to content
This repository has been archived by the owner on Sep 25, 2018. It is now read-only.

Commit

Permalink
Added license header to modules that did not have it. Added strict mo…
Browse files Browse the repository at this point in the history
…de to all modules. Tweaked code a bit to satisfy strict mode requirements. All tests pass for node and rhino.
  • Loading branch information
jbeard4 committed Aug 5, 2012
1 parent 2059488 commit 672e0d9
Show file tree
Hide file tree
Showing 31 changed files with 422 additions and 8 deletions.
18 changes: 18 additions & 0 deletions lib/browser/platform.js
@@ -1,3 +1,21 @@
/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

"use strict";

var util = require('../core/util/util'),
basePlatform = require('../embedded/platform');

Expand Down
18 changes: 18 additions & 0 deletions lib/browser/url.js
@@ -1,3 +1,21 @@
/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

"use strict";

//this url parsing technique is derived from http://james.padolsey.com/javascript/parsing-urls-with-the-dom/

function createAnchor(url){
Expand Down
18 changes: 18 additions & 0 deletions lib/core/constants.js
@@ -1,3 +1,21 @@
/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

"use strict";

module.exports = {
SCXML_NS : "http://www.w3.org/2005/07/scxml"
};
2 changes: 2 additions & 0 deletions lib/core/scxml/SCXML.js
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

"use strict";

var ArraySet = require('./set/ArraySet'),
stateKinds = require('./state-kinds-enum'),
setupDefaultOpts = require('./setup-default-opts'),
Expand Down
1 change: 1 addition & 0 deletions lib/core/scxml/default-transition-selector.js
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

"use strict";

module.exports = function(state,eventNames,evaluator){
return state.transitions.filter(function(t){
Expand Down
14 changes: 9 additions & 5 deletions lib/core/scxml/json2model.js
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

"use strict";

var pm = require('../../platform'),
cg = require('../util/code-gen');

Expand Down Expand Up @@ -92,6 +94,13 @@ module.exports = function(json,documentUrl){
//TODO: get google closure to compile this out as dead code in the browser build
if(require.main === module){
var fileName = process.argv[2];

//this prints out the generated code from a json file which is the output of annotate-scxml-json
var done = function(err,annotatedJsonStr){
if(err) throw err;
process.stdout.write(linkReferencesAndGenerateActionFactory(JSON.parse(annotatedJsonStr)));
};

if(fileName === "-"){
//read from stdin
var s = "";
Expand All @@ -108,9 +117,4 @@ if(require.main === module){
fs.readFile(fileName,'utf8',done);
}

//this prints out the generated code from a json file which is the output of annotate-scxml-json
function done(err,annotatedJsonStr){
if(err) throw err;
process.stdout.write(linkReferencesAndGenerateActionFactory(JSON.parse(annotatedJsonStr)));
}
}
2 changes: 2 additions & 0 deletions lib/core/scxml/model.js
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

"use strict";

var stateKinds = require('./state-kinds-enum');

var model = {
Expand Down
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

"use strict";

var eventNameReCache = {};

function eventNameToRe(name) {
Expand Down
2 changes: 2 additions & 0 deletions lib/core/scxml/set/ArraySet.js
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

"use strict";

/** @constructor */
function ArraySet(l) {
l = l || [];
Expand Down
2 changes: 2 additions & 0 deletions lib/core/scxml/setup-default-opts.js
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

"use strict";

var selector = require('./scxml-dynamic-name-match-transition-selector'),
ArraySet = require('./set/ArraySet'),
m = require('./model');
Expand Down
2 changes: 2 additions & 0 deletions lib/core/scxml/state-kinds-enum.js
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

"use strict";

module.exports = {
BASIC: 0,
COMPOSITE: 1,
Expand Down
7 changes: 4 additions & 3 deletions lib/core/util/annotate-scxml-json.js
@@ -1,4 +1,3 @@

/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Expand All @@ -20,6 +19,8 @@ This module transforms an SCXML document to a proprietary JSON-based intermediat
*/


"use strict";

var codeGen = require('./code-gen'),
dom = require('../util/dom'),
constants = require('../constants');
Expand Down Expand Up @@ -280,14 +281,14 @@ function transformStateNode(node, ancestors) {
var hasInitialAttribute = node.hasAttribute("initial");

//create a fake initial state and process him
function generateFakeInitialState(targetId) {
var generateFakeInitialState = function(targetId) {
var initial = document.createElementNS(constants.SCXML_NS,"initial");
var transition = document.createElementNS(constants.SCXML_NS,"transition");
transition.setAttribute("target",targetId);
initial.appendChild(transition);

return processInitialState(initial);
}
};

if (hasInitialAttribute) {
generateFakeInitialState(dom.getAttribute(node,"initial"));
Expand Down
18 changes: 18 additions & 0 deletions lib/core/util/code-gen.js
@@ -1,6 +1,24 @@
/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

//this model handles code generation for action code
//it should be possible to extend this to support custom actions

"use strict";

var dom = require('./dom'),
platform = require('../../platform'),
constants = require('../constants');
Expand Down
18 changes: 18 additions & 0 deletions lib/core/util/docToModel.js
@@ -1,3 +1,21 @@
/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

"use strict";

var annotator = require('./annotate-scxml-json'),
json2model = require('../scxml/json2model'),
pm = require('../../platform'),
Expand Down
18 changes: 18 additions & 0 deletions lib/core/util/dom.js
@@ -1,3 +1,21 @@
/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

"use strict";

//a small DOM helper/compatibility layer
//tested on node xmldom, rhino JDK 6 native DOM, and various browser DOMs (Firefox, Chrome, IE6+)

Expand Down
18 changes: 18 additions & 0 deletions lib/core/util/util.js
@@ -1,3 +1,21 @@
/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

"use strict";

module.exports = {
merge : function(target){
for(var i=1; i < arguments.length; i++){
Expand Down
18 changes: 18 additions & 0 deletions lib/embedded/path.js
@@ -1,3 +1,21 @@
/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

"use strict";

//these are quick-and-dirty implementations
//there may be missing edge cases
module.exports = {
Expand Down
18 changes: 18 additions & 0 deletions lib/embedded/platform.js
@@ -1,3 +1,21 @@
/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

"use strict";

//this provides an incomplete base platform implementation
//other platform implementations can optionally extend it.

Expand Down
18 changes: 18 additions & 0 deletions lib/embedded/url.js
@@ -1,3 +1,21 @@
/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

"use strict";

//this base module could be used with jsuri [http://code.google.com/p/jsuri/], a portable, pure-js URI parser implemenation
//currently, none of the "blessed" environments use it, but it could simplify things for embedding
//assume global Uri object
Expand Down
18 changes: 18 additions & 0 deletions lib/node/get.js
@@ -1,3 +1,21 @@
/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

"use strict";

/**
* This module contains some utility functions for getting stuff in node.js.
*/
Expand Down
18 changes: 18 additions & 0 deletions lib/node/node-listener-client.js
@@ -1,3 +1,21 @@
/*
Copyright 2011-2012 Jacob Beard, INFICON, and other SCION contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

"use strict";

var http = require('http');

function HTTPClientListener(options){
Expand Down

0 comments on commit 672e0d9

Please sign in to comment.