Permalink
Browse files

Remove window dependency

  • Loading branch information...
1 parent 54bae4a commit 771881a3144d36eafd81d15d1b95b702b22d4125 @nikhilk committed Aug 26, 2012
Showing with 25 additions and 29 deletions.
  1. +5 −5 src/Core/CoreScript/BCL/Delegate.js
  2. +13 −17 src/Core/CoreScript/TypeSystem/Type.js
  3. +7 −7 src/Core/CoreScript/mscorlib.js
@@ -99,22 +99,22 @@ ss.Delegate.createExport = function#? DEBUG Delegate$createExport##(delegate, mu
// Generate a unique name if one is not specified
name = name || '__' + (new Date()).valueOf();
- // Exported delegates go on window (so they are callable using a simple identifier).
+ // Exported delegates go on global object (so they are callable using a simple identifier).
// Multi-use delegates are exported directly; for the rest a stub is exported, and the stub
// first deletes, and then invokes the actual delegate.
- window[name] = multiUse ? delegate : function() {
- try { delete window[name]; } catch(e) { window[name] = undefined; }
+ global[name] = multiUse ? delegate : function() {
+ try { delete global[name]; } catch(e) { global[name] = undefined; }
delegate.apply(null, arguments);
};
return name;
}
ss.Delegate.deleteExport = function#? DEBUG Delegate$deleteExport##(name) {
- delete window[name];
+ delete global[name];
}
ss.Delegate.clearExport = function#? DEBUG Delegate$clearExport##(name) {
- window[name] = ss.Delegate.empty;
+ global[name] = ss.Delegate.empty;
}
@@ -1,47 +1,43 @@
///////////////////////////////////////////////////////////////////////////////
// Type System Implementation
-window.Type = Function;
+global.Type = Function;
Type.__typeName = 'Type';
-window.__Namespace = function(name) {
+var __namespaces = {};
+var __rootNamespaces = [];
+
+function ns(name) {
this.__typeName = name;
}
-__Namespace.prototype = {
+ns.prototype = {
__namespace: true,
getName: function() {
return this.__typeName;
}
}
Type.registerNamespace = function#? DEBUG Type$registerNamespace##(name) {
- if (!window.__namespaces) {
- window.__namespaces = {};
- }
- if (!window.__rootNamespaces) {
- window.__rootNamespaces = [];
- }
-
- if (window.__namespaces[name]) {
+ if (__namespaces[name]) {
return;
}
- var ns = window;
+ var nsi = global;
var nameParts = name.split('.');
for (var i = 0; i < nameParts.length; i++) {
var part = nameParts[i];
- var nso = ns[part];
+ var nso = nsi[part];
if (!nso) {
- ns[part] = nso = new __Namespace(nameParts.slice(0, i + 1).join('.'));
+ nsi[part] = nso = new ns(nameParts.slice(0, i + 1).join('.'));
if (i == 0) {
- window.__rootNamespaces.add(nso);
+ __rootNamespaces.add(nso);
}
}
- ns = nso;
+ nsi = nso;
}
- window.__namespaces[name] = ns;
+ __namespaces[name] = nsi;
}
Type.prototype.registerClass = function#? DEBUG Type$registerClass##(name, baseType, interfaceType) {
@@ -2,27 +2,26 @@
//! More information at http://projects.nikhilk.net/ScriptSharp
//!
-(function () {
- window.ss = {
+(function(global) {
+ global.ss = {
version: '0.7.6.0',
- isUndefined: function (o) {
+ isUndefined: function(o) {
return (o === undefined);
},
- isNull: function (o) {
+ isNull: function(o) {
return (o === null);
},
- isNullOrUndefined: function (o) {
+ isNullOrUndefined: function(o) {
return (o === null) || (o === undefined);
},
- isValue: function (o) {
+ isValue: function(o) {
return (o !== null) && (o !== undefined);
}
};
-})();
#include "Extensions\Object.js"
@@ -69,3 +68,4 @@
#include "BCL\Task.js"
#include "BCL\App.js"
+})(this);

0 comments on commit 771881a

Please sign in to comment.