lib/assets/javascripts/opal/runtime.js in opal-0.3.38 vs lib/assets/javascripts/opal/runtime.js in opal-0.3.39
- old
+ new
@@ -129,20 +129,21 @@
prototype.constructor = constructor;
prototype._isObject = true;
prototype._klass = constructor;
+ constructor._inherited = [];
constructor._included_in = [];
constructor._isClass = true;
constructor._name = id;
constructor._super = superklass;
constructor._methods = [];
constructor._smethods = [];
constructor._isObject = false;
constructor._donate = __donate;
- constructor._sdonate = __sdonate;
+ constructor._defs = __defs;
constructor['$==='] = module_eqq;
constructor.$to_s = module_to_s;
constructor.toString = module_to_s;
@@ -160,18 +161,19 @@
var prototype = constructor.prototype;
prototype._klass = constructor;
prototype.constructor = constructor;
+ constructor._inherited = [];
constructor._included_in = [];
constructor._isClass = true;
constructor._super = superklass;
constructor._methods = [];
constructor._isObject = false;
constructor._klass = Class;
constructor._donate = __donate
- constructor._sdonate = __sdonate;
+ constructor._defs = __defs;
constructor['$==='] = module_eqq;
constructor.$to_s = module_to_s;
constructor.toString = module_to_s;
@@ -183,26 +185,29 @@
for (var i = 0, length = smethods.length; i < length; i++) {
var m = smethods[i];
constructor[m] = superklass[m];
}
+ superklass._inherited.push(constructor);
+
return constructor;
};
var bridge_class = function(constructor) {
constructor.prototype._klass = constructor;
+ constructor._inherited = [];
constructor._included_in = [];
constructor._isClass = true;
constructor._super = Object;
constructor._klass = Class;
constructor._methods = [];
constructor._smethods = [];
constructor._isObject = false;
constructor._donate = function(){};
- constructor._sdonate = __sdonate;
+ constructor._defs = __defs;
constructor['$==='] = module_eqq;
constructor.$to_s = module_to_s;
constructor.toString = module_to_s;
@@ -294,12 +299,23 @@
}
}
}
- // Donator for singleton (class) methods
- function __sdonate(defined) {
- this._smethods = this._smethods.concat(defined);
+ // Define a singleton method on a class
+ function __defs(mid, body) {
+ this._smethods.push(mid);
+ this[mid] = body;
+
+ var inherited = this._inherited;
+ if (inherited.length) {
+ for (var i = 0, length = inherited.length, subclass; i < length; i++) {
+ subclass = inherited[i];
+ if (!subclass[mid]) {
+ subclass._defs(mid, body);
+ }
+ }
+ }
}
var bridged_classes = Object.$included_in = [];
BasicObject._scope = Object._scope = Opal;