Author: mhermanto
Date: Wed Feb 23 01:18:06 2011
New Revision: 1073572
URL: http://svn.apache.org/viewvc?rev=1073572&view=rev
Log:
Preparation to enable property renaming and strict symbol checking for JS
runtime.
http://codereview.appspot.com/4171051.
Modified:
shindig/trunk/features/src/main/javascript/features/core.config.base/config.js
shindig/trunk/features/src/main/javascript/features/core.json/json-flatten.js
shindig/trunk/features/src/main/javascript/features/core.json/json-jsimpl.js
shindig/trunk/features/src/main/javascript/features/core.json/json-native.js
shindig/trunk/features/src/main/javascript/features/core.log/log.js
shindig/trunk/features/src/main/javascript/features/core.util.urlparams/urlparams.js
shindig/trunk/features/src/main/javascript/features/core.util/util.js
shindig/trunk/features/src/main/javascript/features/rpc/ifpc.transport.js
shindig/trunk/features/src/main/javascript/features/rpc/rmr.transport.js
shindig/trunk/features/src/main/javascript/features/rpc/rpc.js
shindig/trunk/features/src/main/javascript/features/rpc/wpm.transport.js
shindig/trunk/features/src/main/javascript/features/shindig.random/random.js
shindig/trunk/features/src/main/javascript/features/shindig.random/sha1.js
Modified:
shindig/trunk/features/src/main/javascript/features/core.config.base/config.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.config.base/config.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
---
shindig/trunk/features/src/main/javascript/features/core.config.base/config.js
(original)
+++
shindig/trunk/features/src/main/javascript/features/core.config.base/config.js
Wed Feb 23 01:18:06 2011
@@ -176,7 +176,7 @@ gadgets.config = function() {
* @name register
* @function
*/
- 'register': function(component, opt_validators, opt_callback) {
+ register: function(component, opt_validators, opt_callback) {
var registered = components[component];
if (!registered) {
registered = [];
@@ -200,7 +200,7 @@ gadgets.config = function() {
* @name get
* @function
*/
- 'get': function(opt_component) {
+ get: function(opt_component) {
if (opt_component) {
return configuration[opt_component] || {};
}
@@ -217,7 +217,7 @@ gadgets.config = function() {
* @name init
* @function
*/
- 'init': function(config, opt_noValidation) {
+ init: function(config, opt_noValidation) {
___jsl = window["___jsl"] || {};
if (configuration) {
// init(...) has already been called. Merge rather than override
config.
@@ -261,7 +261,7 @@ gadgets.config = function() {
* @param updateConfig {Object} Config object, with keys for features.
* @param opt_replace {Boolean} true to replace all configuration.
*/
- 'update': function(updateConfig, opt_replace) {
+ update: function(updateConfig, opt_replace) {
configuration = opt_replace ? {} : configuration || {};
foldConfig(configuration, updateConfig);
}
Modified:
shindig/trunk/features/src/main/javascript/features/core.json/json-flatten.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.json/json-flatten.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
---
shindig/trunk/features/src/main/javascript/features/core.json/json-flatten.js
(original)
+++
shindig/trunk/features/src/main/javascript/features/core.json/json-flatten.js
Wed Feb 23 01:18:06 2011
@@ -24,7 +24,7 @@
* @param {Object} obj
* @return {Object} object with only string values.
*/
-gadgets['json'].flatten = function(obj) {
+gadgets.json.flatten = function(obj) {
var flat = {};
if (obj === null || obj === undefined) return flat;
Modified:
shindig/trunk/features/src/main/javascript/features/core.json/json-jsimpl.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.json/json-jsimpl.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
---
shindig/trunk/features/src/main/javascript/features/core.json/json-jsimpl.js
(original)
+++
shindig/trunk/features/src/main/javascript/features/core.json/json-jsimpl.js
Wed Feb 23 01:18:06 2011
@@ -44,7 +44,7 @@ if (!(window.JSON && window.JSON.parse &
* Port of the public domain JSON library by Douglas Crockford.
* See: http://www.json.org/json2.js
*/
- gadgets['json'] = function() {
+ gadgets.json = function() {
/**
* Formats integers to 2 digits.
@@ -153,8 +153,8 @@ if (!(window.JSON && window.JSON.parse &
}
return {
- 'stringify': stringify,
- 'parse': function(text) {
+ stringify: stringify,
+ parse: function(text) {
// Parsing happens in three stages. In the first stage, we run the
text against
// regular expressions that look for non-JSON patterns. We are
especially
// concerned with '()' and 'new' because they can cause invocation,
and '='
Modified:
shindig/trunk/features/src/main/javascript/features/core.json/json-native.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.json/json-native.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
---
shindig/trunk/features/src/main/javascript/features/core.json/json-native.js
(original)
+++
shindig/trunk/features/src/main/javascript/features/core.json/json-native.js
Wed Feb 23 01:18:06 2011
@@ -41,11 +41,11 @@ if (window.JSON && window.JSON.parse &&
// HTML5 implementation, or already defined.
// Not a direct alias as the opensocial specification disagrees with the
HTML5 JSON spec.
// JSON says to throw on parse errors and to support filtering functions. OS
does not.
- gadgets['json'] = (function() {
+ gadgets.json = (function() {
var endsWith___ = /___$/;
return {
/* documented below */
- 'parse': function(str) {
+ parse: function(str) {
try {
return window.JSON.parse(str);
} catch (e) {
@@ -53,7 +53,7 @@ if (window.JSON && window.JSON.parse &&
}
},
/* documented below */
- 'stringify': function(obj) {
+ stringify: function(obj) {
try {
return window.JSON.stringify(obj, function(k,v) {
return !endsWith___.test(k) ? v : null;
Modified: shindig/trunk/features/src/main/javascript/features/core.log/log.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.log/log.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.log/log.js
(original)
+++ shindig/trunk/features/src/main/javascript/features/core.log/log.js Wed Feb
23 01:18:06 2011
@@ -36,7 +36,7 @@
* @name gadgets.log
*/
-gadgets['log'] = (function() {
+gadgets.log = (function() {
/** @const */
var info_ = 1;
/** @const */
@@ -82,7 +82,7 @@ gadgets['log'] = (function() {
* @member gadgets.log
* @name setLogLevel
*/
- gadgets['setLogLevel'] = function(logLevel) {
+ gadgets.setLogLevel = function(logLevel) {
logLevelThreshold_ = logLevel;
};
Modified:
shindig/trunk/features/src/main/javascript/features/core.util.urlparams/urlparams.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.urlparams/urlparams.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
---
shindig/trunk/features/src/main/javascript/features/core.util.urlparams/urlparams.js
(original)
+++
shindig/trunk/features/src/main/javascript/features/core.util.urlparams/urlparams.js
Wed Feb 23 01:18:06 2011
@@ -27,7 +27,7 @@
* @name gadgets.util
*/
-gadgets['util'] = function() {
+gadgets.util = function() {
var parameters = null;
/**
Modified: shindig/trunk/features/src/main/javascript/features/core.util/util.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util/util.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util/util.js
(original)
+++ shindig/trunk/features/src/main/javascript/features/core.util/util.js Wed
Feb 23 01:18:06 2011
@@ -29,7 +29,7 @@ var __getUrlParameters = gadgets.util.ge
* @class Provides general-purpose utility functions.
* @name gadgets.util
*/
-gadgets['util'] = function() {
+gadgets.util = function() {
var features = {};
var services = {};
var onLoadHandlers = [];
@@ -97,7 +97,7 @@ gadgets['util'] = function() {
* @member gadgets.util
* @private Implementation detail.
*/
- 'getUrlParameters' : __getUrlParameters,
+ getUrlParameters : __getUrlParameters,
/**
* Creates a closure that is suitable for passing as a callback.
@@ -115,7 +115,7 @@ gadgets['util'] = function() {
* @member gadgets.util
* @private Implementation detail.
*/
- 'makeClosure' : function(scope, callback, var_args) {
+ makeClosure : function(scope, callback, var_args) {
// arguments isn't a real array, so we copy it into one.
var baseArgs = [];
for (var i = 2, j = arguments.length; i < j; ++i) {
@@ -140,7 +140,7 @@ gadgets['util'] = function() {
*
* @private Implementation detail.
*/
- 'makeEnum' : function(values) {
+ makeEnum : function(values) {
var i, v, obj = {};
for (i = 0; (v = values[i]); ++i) {
obj[v] = v;
@@ -156,7 +156,7 @@ gadgets['util'] = function() {
*
* @member gadgets.util
*/
- 'getFeatureParameters' : function(feature) {
+ getFeatureParameters : function(feature) {
return typeof features[feature] === 'undefined' ? null :
features[feature];
},
@@ -168,7 +168,7 @@ gadgets['util'] = function() {
*
* @member gadgets.util
*/
- 'hasFeature' : function(feature) {
+ hasFeature : function(feature) {
return typeof features[feature] !== 'undefined';
},
@@ -180,7 +180,7 @@ gadgets['util'] = function() {
*
* @member gadgets.util
*/
- 'getServices' : function() {
+ getServices : function() {
return services;
},
@@ -190,7 +190,7 @@ gadgets['util'] = function() {
*
* @member gadgets.util
*/
- 'registerOnLoadHandler' : function(callback) {
+ registerOnLoadHandler : function(callback) {
onLoadHandlers.push(callback);
},
@@ -198,7 +198,7 @@ gadgets['util'] = function() {
* Runs all functions registered via registerOnLoadHandler.
* @private Only to be used by the container, not gadgets.
*/
- 'runOnLoadHandlers' : function() {
+ runOnLoadHandlers : function() {
for (var i = 0, j = onLoadHandlers.length; i < j; ++i) {
onLoadHandlers[i]();
}
@@ -220,7 +220,7 @@ gadgets['util'] = function() {
* @return {Object} The escaped object.
* @private Only to be used by the container, not gadgets.
*/
- 'escape' : function(input, opt_escapeObjects) {
+ escape : function(input, opt_escapeObjects) {
if (!input) {
return input;
} else if (typeof input === 'string') {
@@ -253,7 +253,7 @@ gadgets['util'] = function() {
* @param {string} str The string to escape.
* @return {string} The escaped string.
*/
- 'escapeString' : function(str) {
+ escapeString : function(str) {
if (!str) return str;
var out = [], ch, shouldEscape;
for (var i = 0, j = str.length; i < j; ++i) {
@@ -275,7 +275,7 @@ gadgets['util'] = function() {
* @param {string} str The string to unescape.
* @return {string}
*/
- 'unescapeString' : function(str) {
+ unescapeString : function(str) {
if (!str) return str;
return str.replace(/&#([0-9]+);/g, unescapeEntity);
},
@@ -289,7 +289,7 @@ gadgets['util'] = function() {
* @param {function()} callback Invoked when specified event occurs.
* @param {boolean} useCapture If true, initiates capture.
*/
- 'attachBrowserEvent': function(elem, eventName, callback, useCapture) {
+ attachBrowserEvent : function(elem, eventName, callback, useCapture) {
if (typeof elem.addEventListener != 'undefined') {
elem.addEventListener(eventName, callback, useCapture);
} else if (typeof elem.attachEvent != 'undefined') {
@@ -308,7 +308,7 @@ gadgets['util'] = function() {
* @param {boolean} useCapture Specifies whether listener being removed
was added with
* capture enabled.
*/
- 'removeBrowserEvent': function(elem, eventName, callback, useCapture) {
+ removeBrowserEvent : function(elem, eventName, callback, useCapture) {
if (elem.removeEventListener) {
elem.removeEventListener(eventName, callback, useCapture);
} else if (elem.detachEvent) {
Modified:
shindig/trunk/features/src/main/javascript/features/rpc/ifpc.transport.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/rpc/ifpc.transport.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/rpc/ifpc.transport.js
(original)
+++ shindig/trunk/features/src/main/javascript/features/rpc/ifpc.transport.js
Wed Feb 23 01:18:06 2011
@@ -138,9 +138,9 @@ if (!gadgets.rpctx.ifpc) { // make lib
if (rpc.l) {
// Use legacy protocol.
// Format: #iframe_id&callId&num_packets&packet_num&block_of_data
- var callArgs = rpc.a;
+ var callArgs = rpc['a'];
src = [relay, '#', encodeLegacyData([from, callId, 1, 0,
- encodeLegacyData([from, rpc.s, '', '', from].concat(
+ encodeLegacyData([from, rpc['s'], '', '', from].concat(
callArgs))])].join('');
} else {
// Format: #targetId & sourceId@callId & packetNum & packetId &
packetData
Modified:
shindig/trunk/features/src/main/javascript/features/rpc/rmr.transport.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/rpc/rmr.transport.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/rpc/rmr.transport.js
(original)
+++ shindig/trunk/features/src/main/javascript/features/rpc/rmr.transport.js
Wed Feb 23 01:18:06 2011
@@ -342,7 +342,7 @@ if (!gadgets.rpctx.rmr) { // make lib r
// If we receive an ACK message, then mark the current
// handler as no longer waiting and send out the next
// queued message.
- if (rpc.s === gadgets.rpc.ACK) {
+ if (rpc['s'] === gadgets.rpc.ACK) {
// ACK received - whether this came from a handshake or
// an active call, in either case it indicates readiness to
// send messages to the from frame.
@@ -508,7 +508,7 @@ if (!gadgets.rpctx.rmr) { // make lib r
},
call: function(targetId, from, rpc) {
- return callRmr(targetId, rpc.s, from, rpc);
+ return callRmr(targetId, rpc['s'], from, rpc);
}
};
}();
Modified: shindig/trunk/features/src/main/javascript/features/rpc/rpc.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/rpc/rpc.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/rpc/rpc.js (original)
+++ shindig/trunk/features/src/main/javascript/features/rpc/rpc.js Wed Feb 23
01:18:06 2011
@@ -125,7 +125,8 @@ if (!gadgets.rpc) { // make lib resilien
// Fallback transport is simply a dummy impl that emits no errors
// and logs info on calls it receives, to avoid undesired side-effects
// from falling back to IFPC or some other transport.
- var clog = window['console'] && console.log ? console.log : function(){};
+ var console = window['console'];
+ var clog = console && console.log ? console.log : function(){};
var fallbackTransport = (function() {
function logFn(name) {
return function() {
@@ -133,12 +134,12 @@ if (!gadgets.rpc) { // make lib resilien
};
}
return {
- getCode: function() { return 'noop'; },
+ 'getCode': function() { return 'noop'; },
// Not really, but prevents transport assignment to IFPC.
- isParentVerifiable: function() { return true; },
- init: logFn('init'),
- setup: logFn('setup'),
- call: logFn('call')
+ 'isParentVerifiable': function() { return true; },
+ 'init': logFn('init'),
+ 'setup': logFn('setup'),
+ 'call': logFn('call')
};
})();
@@ -192,8 +193,8 @@ if (!gadgets.rpc) { // make lib resilien
for (var i = 0; i < earlyQueue.length; ++i) {
var rpc = earlyQueue[i];
// There was no auth/rpc token set before, so set it now.
- rpc.t = getAuthToken(receiverId);
- tx.call(receiverId, rpc.f, rpc);
+ rpc['t'] = getAuthToken(receiverId);
+ tx.call(receiverId, rpc['f'], rpc);
}
// Clear the queue so it won't be sent again.
@@ -253,22 +254,22 @@ if (!gadgets.rpc) { // make lib resilien
// a: The arguments for this RPC call.
// t: The authentication token.
//
- if (rpc && typeof rpc.s === 'string' && typeof rpc.f === 'string' &&
- rpc.a instanceof Array) {
+ if (rpc && typeof rpc['s'] === 'string' && typeof rpc['f'] === 'string'
&&
+ rpc['a'] instanceof Array) {
// Validate auth token.
- if (authToken[rpc.f]) {
+ if (authToken[rpc['f']]) {
// We don't do type coercion here because all entries in the
authToken
// object are strings, as are all url params. See setupReceiver(...).
- if (authToken[rpc.f] !== rpc.t) {
- gadgets.error('Invalid auth token. ' + authToken[rpc.f] + ' vs ' +
rpc.t);
- securityCallback(rpc.f, FORGED_MSG);
+ if (authToken[rpc['f']] !== rpc['t']) {
+ gadgets.error('Invalid auth token. ' + authToken[rpc['f']] + ' vs
' + rpc['t']);
+ securityCallback(rpc['f'], FORGED_MSG);
}
}
- if (rpc.s === ACK) {
+ if (rpc['s'] === ACK) {
// Acknowledgement API, used to indicate a receiver is ready.
- window.setTimeout(function() { transportReady(rpc.f, true); }, 0);
+ window.setTimeout(function() { transportReady(rpc['f'], true); }, 0);
return;
}
@@ -289,21 +290,21 @@ if (!gadgets.rpc) { // make lib resilien
// me.callback(param);
// }, 1000);
// }
- if (rpc.c) {
+ if (rpc['c']) {
rpc['callback'] = function(result) {
- gadgets.rpc.call(rpc.f, CALLBACK_NAME, null, rpc.c, result);
+ gadgets.rpc.call(rpc['f'], CALLBACK_NAME, null, rpc['c'], result);
};
}
// Call the requested RPC service.
- var result = (services[rpc.s] ||
- services[DEFAULT_NAME]).apply(rpc, rpc.a);
+ var result = (services[rpc['s']] ||
+ services[DEFAULT_NAME]).apply(rpc, rpc['a']);
// If the rpc request handler returns a value, immediately pass it back
// to the callback. Otherwise, do nothing, assuming that the rpc
handler
// will make an asynchronous call later.
- if (rpc.c && typeof result !== 'undefined') {
- gadgets.rpc.call(rpc.f, CALLBACK_NAME, null, rpc.c, result);
+ if (rpc['c'] && typeof result !== 'undefined') {
+ gadgets.rpc.call(rpc['f'], CALLBACK_NAME, null, rpc['c'], result);
}
}
}
@@ -816,7 +817,7 @@ if (!gadgets.rpc) { // make lib resilien
from = rpcId;
} else if (targetId.charAt(0) == '/') {
// sending to sibling
- from = makeSiblingId(rpcId, gadgets.rpc.getOrigin(location.href));
+ from = makeSiblingId(rpcId,
gadgets.rpc.getOrigin(window.location.href));
}
++callId;
@@ -825,12 +826,12 @@ if (!gadgets.rpc) { // make lib resilien
}
var rpc = {
- s: serviceName,
- f: from,
- c: callback ? callId : 0,
- a: Array.prototype.slice.call(arguments, 3),
- t: authToken[targetId],
- l: useLegacyProtocol[targetId]
+ 's': serviceName,
+ 'f': from,
+ 'c': callback ? callId : 0,
+ 'a': Array.prototype.slice.call(arguments, 3),
+ 't': authToken[targetId],
+ 'l': useLegacyProtocol[targetId]
};
if (targetId !== '..' &&
@@ -931,7 +932,7 @@ if (!gadgets.rpc) { // make lib resilien
*/
receiveSameDomain: function(rpc) {
// Pass through to local process method but converting to a local Array
- rpc.a = Array.prototype.slice.call(rpc.a);
+ rpc['a'] = Array.prototype.slice.call(rpc['a']);
window.setTimeout(function() { process(rpc); }, 0);
},
Modified:
shindig/trunk/features/src/main/javascript/features/rpc/wpm.transport.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/rpc/wpm.transport.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/rpc/wpm.transport.js
(original)
+++ shindig/trunk/features/src/main/javascript/features/rpc/wpm.transport.js
Wed Feb 23 01:18:06 2011
@@ -102,12 +102,12 @@ if (!gadgets.rpctx.wpm) { // make lib r
function onmessage(packet) {
var rpc = gadgets.json.parse(packet.data);
if (isForceSecure) {
- if (!rpc || !rpc.f) {
+ if (!rpc || !rpc['f']) {
return;
}
// for security, check origin against expected value
- var origRelay = gadgets.rpc.getRelayUrl(rpc.f) ||
+ var origRelay = gadgets.rpc.getRelayUrl(rpc['f']) ||
gadgets.util.getUrlParameters()['parent'];
var origin = gadgets.rpc.getOrigin(origRelay);
if (!pmEventDomain ? packet.origin !== origin :
Modified:
shindig/trunk/features/src/main/javascript/features/shindig.random/random.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/shindig.random/random.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
---
shindig/trunk/features/src/main/javascript/features/shindig.random/random.js
(original)
+++
shindig/trunk/features/src/main/javascript/features/shindig.random/random.js
Wed Feb 23 01:18:06 2011
@@ -50,7 +50,7 @@ shindig.random = (function() {
window.onmousemove = function(e) {
if (window.event) {
- e = event;
+ e = window.event;
}
var ac = (e.screenX + e.clientX) << 16;
Modified:
shindig/trunk/features/src/main/javascript/features/shindig.random/sha1.js
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/shindig.random/sha1.js?rev=1073572&r1=1073571&r2=1073572&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/shindig.random/sha1.js
(original)
+++ shindig/trunk/features/src/main/javascript/features/shindig.random/sha1.js
Wed Feb 23 01:18:06 2011
@@ -67,6 +67,18 @@ shindig.sha1 = (function() {
* @private
*/
var pad_ = [];
+
+ /**
+ * @type {number}
+ * @private
+ */
+ var inbuf_;
+
+ /**
+ * @type {number}
+ * @private
+ */
+ var total_;
pad_[0] = 128;
for (var i = 1; i < 64; ++i) {