core/class.rb in opal-0.3.18 vs core/class.rb in opal-0.3.19
- old
+ new
@@ -1,81 +1,58 @@
class Class
def self.new(sup = Object, &block)
%x{
var klass = boot_class(sup);
- klass._name = "AnonClass";
+ klass._name = nil;
make_metaclass(klass, sup._klass);
- #{sup.inherited `klass`};
+ sup.$inherited(klass);
- if (block !== null) {
- block.call(klass, null);
+ if (block !== nil) {
+ block.call(klass);
}
return klass;
}
end
- def bridge_class(constructor)
- %x{
- var prototype = constructor.prototype,
- klass = this;
-
- klass._alloc = constructor;
- klass._proto = prototype;
-
- bridged_classes.push(klass);
-
- prototype._klass = klass;
- prototype._flags = T_OBJECT;
-
- var donator = RubyObject._proto;
- for (var method in donator) {
- if (donator.hasOwnProperty(method)) {
- if (!prototype[method]) {
- prototype[method] = donator[method];
- }
- }
- }
-
- return klass;
- }
- end
-
def allocate
`new this._alloc()`
end
def new(*args, &block)
- obj = allocate()
- obj.initialize *args, &block
- obj
+ %x{
+ var obj = this.$allocate();
+ obj._p = block;
+ obj.$initialize.apply(obj, args);
+ return obj;
+ }
end
def inherited(cls)
end
def superclass
%x{
var sup = this._super;
if (!sup) {
- if (this === RubyObject) {
- return null;
+ if (this === RubyBasicObject) {
+ return nil;
}
throw RubyRuntimeError.$new('uninitialized class');
}
- while (sup && (sup._flags & T_ICLASS)) {
+ while (sup && (sup._isIClass)) {
sup = sup._super;
}
if (!sup) {
- return null;
+ return nil;
}
return sup;
}
end
-end
+end
\ No newline at end of file