summaryrefslogtreecommitdiff
path: root/rts/js/goog.js
diff options
context:
space:
mode:
Diffstat (limited to 'rts/js/goog.js')
-rw-r--r--rts/js/goog.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/rts/js/goog.js b/rts/js/goog.js
new file mode 100644
index 0000000000..09389149c5
--- /dev/null
+++ b/rts/js/goog.js
@@ -0,0 +1,55 @@
+/*
+ set up the google closure library. this is a rather hacky setup
+ to make it work with our shims without requiring compilation
+ or pulling in the google closure library module loader
+ */
+var goog = {};
+goog.global = h$getGlobal(this);
+goog.provide = function() { };
+goog.require = function() { };
+goog.isDef = function(val) { return val !== undefined; };
+goog.inherits = function(childCtor, parentCtor) {
+ /** @constructor */
+ function tempCtor() {};
+ tempCtor.prototype = parentCtor.prototype;
+ childCtor.superClass_ = parentCtor.prototype;
+ childCtor.prototype = new tempCtor();
+ /** @override */
+ childCtor.prototype.constructor = childCtor;
+
+ /**
+ * Calls superclass constructor/method.
+ *
+ * This function is only available if you use goog.inherits to
+ * express inheritance relationships between classes.
+ *
+ * NOTE: This is a replacement for goog.base and for superClass_
+ * property defined in childCtor.
+ *
+ * @param {!Object} me Should always be "this".
+ * @param {string} methodName The method name to call. Calling
+ * superclass constructor can be done with the special string
+ * 'constructor'.
+ * @param {...*} var_args The arguments to pass to superclass
+ * method/constructor.
+ * @return {*} The return value of the superclass method/constructor.
+ */
+ childCtor.base = function(me, methodName, var_args) {
+ // Copying using loop to avoid deop due to passing arguments object to
+ // function. This is faster in many JS engines as of late 2014.
+ var args = new Array(arguments.length - 2);
+ for (var i = 2; i < arguments.length; i++) {
+ args[i - 2] = arguments[i];
+ }
+ return parentCtor.prototype[methodName].apply(me, args);
+ };
+};
+
+goog.isString = function(v) {
+ return typeof v === 'string';
+}
+
+goog.math = {};
+goog.crypt = {};
+
+