|
106 | 106 |
|
107 | 107 | // Not specifying a superclass means we can assume it to be Object
|
108 | 108 | if (superklass === null) {
|
109 |
| - superklass = RubyObject; |
| 109 | + superklass = ObjectClass; |
110 | 110 | }
|
111 | 111 |
|
112 | 112 | var klass = base.$$scope[id];
|
|
120 | 120 | }
|
121 | 121 |
|
122 | 122 | // Make sure existing class has same superclass
|
123 |
| - if (superklass !== klass.$$super && superklass !== RubyObject) { |
| 123 | + if (superklass !== klass.$$super && superklass !== ObjectClass) { |
124 | 124 | throw Opal.TypeError.$new("superclass mismatch for class " + id);
|
125 | 125 | }
|
126 | 126 | }
|
|
142 | 142 | base[id] = base.$$scope[id] = klass;
|
143 | 143 |
|
144 | 144 | // Copy all parent constants to child, unless parent is Object
|
145 |
| - if (superklass !== RubyObject && superklass !== RubyBasicObject) { |
| 145 | + if (superklass !== ObjectClass && superklass !== BasicObjectClass) { |
146 | 146 | Opal.donate_constants(superklass, klass);
|
147 | 147 | }
|
148 | 148 |
|
|
213 | 213 | * ipothesis on why it's needed can be found below.
|
214 | 214 | *
|
215 | 215 | * @param superklass The superclass of the class/module object, for modules
|
216 |
| - * is `Module` (of `RubyModule` in JS context) |
| 216 | + * is `Module` (of `ModuleClass` in JS context) |
217 | 217 | *
|
218 | 218 | * @param prototype The prototype on which the class/module methods will
|
219 | 219 | * be stored.
|
|
268 | 268 | if ($hasOwn.call(base.$$scope, id)) {
|
269 | 269 | module = base.$$scope[id];
|
270 | 270 |
|
271 |
| - if (!module.$$is_mod && module !== RubyObject) { |
| 271 | + if (!module.$$is_mod && module !== ObjectClass) { |
272 | 272 | throw Opal.TypeError.$new(id + " is not a module");
|
273 | 273 | }
|
274 | 274 | }
|
|
291 | 291 | */
|
292 | 292 | function boot_module_object() {
|
293 | 293 | var mtor = function() {};
|
294 |
| - mtor.prototype = RubyModule.constructor.prototype; |
| 294 | + mtor.prototype = ModuleClass.constructor.prototype; |
295 | 295 |
|
296 | 296 | function module_constructor() {}
|
297 | 297 | module_constructor.prototype = new mtor();
|
298 | 298 |
|
299 | 299 | var module = new module_constructor();
|
300 | 300 | var module_prototype = {};
|
301 | 301 |
|
302 |
| - setup_module_object(module, module_constructor, RubyModule, module_prototype) |
| 302 | + setup_module_object(module, module_constructor, ModuleClass, module_prototype) |
303 | 303 | module.$$is_mod = true;
|
304 | 304 | module.$$dep = [];
|
305 | 305 |
|
|
338 | 338 | var method = methods[i], current;
|
339 | 339 |
|
340 | 340 |
|
341 |
| - if (prototype.hasOwnProperty(method) && !(current = prototype[method]).$$donated && !current.$$stub) { |
| 341 | + if ( prototype.hasOwnProperty(method) && |
| 342 | + !(current = prototype[method]).$$donated && !current.$$stub ) { |
342 | 343 | // if the target class already has a method of the same name defined
|
343 | 344 | // and that method was NOT donated, then it must be a method defined
|
344 | 345 | // by the class so we do not want to override it
|
|
420 | 421 | * @return [Class] returns new ruby class
|
421 | 422 | */
|
422 | 423 | function bridge_class(name, constructor) {
|
423 |
| - var klass = boot_class_object(RubyObject, constructor); |
| 424 | + var klass = boot_class_object(ObjectClass, constructor); |
424 | 425 |
|
425 | 426 | klass.$$name = name;
|
426 | 427 |
|
427 | 428 | create_scope(Opal, klass, name);
|
428 | 429 | bridged_classes.push(klass);
|
429 | 430 |
|
430 |
| - var object_methods = RubyBasicObject.$$methods.concat(RubyObject.$$methods); |
| 431 | + var object_methods = BasicObjectClass.$$methods.concat(ObjectClass.$$methods); |
431 | 432 |
|
432 | 433 | for (var i = 0, len = object_methods.length; i < len; i++) {
|
433 | 434 | var meth = object_methods[i];
|
434 |
| - constructor.prototype[meth] = RubyObject.$$proto[meth]; |
| 435 | + constructor.prototype[meth] = ObjectClass.$$proto[meth]; |
435 | 436 | }
|
436 | 437 |
|
437 | 438 | add_stubs_subscriber(constructor.prototype)
|
|
846 | 847 | else if (obj.$$is_class) {
|
847 | 848 | obj.$$proto[jsid] = body;
|
848 | 849 |
|
849 |
| - if (obj === RubyBasicObject) { |
| 850 | + if (obj === BasicObjectClass) { |
850 | 851 | define_basic_object_method(jsid, body);
|
851 | 852 | }
|
852 |
| - else if (obj === RubyObject) { |
| 853 | + else if (obj === ObjectClass) { |
853 | 854 | Opal.donate(obj, [jsid]);
|
854 | 855 | }
|
855 | 856 | }
|
|
873 | 874 | };
|
874 | 875 |
|
875 | 876 | function define_basic_object_method(jsid, body) {
|
876 |
| - RubyBasicObject.$$methods.push(jsid); |
| 877 | + BasicObjectClass.$$methods.push(jsid); |
877 | 878 | for (var i = 0, len = bridged_classes.length; i < len; i++) {
|
878 | 879 | bridged_classes[i].$$proto[jsid] = body;
|
879 | 880 | }
|
|
1020 | 1021 | // --------------
|
1021 | 1022 |
|
1022 | 1023 | // The actual class for BasicObject
|
1023 |
| - var RubyBasicObject; |
| 1024 | + var BasicObjectClass; |
1024 | 1025 |
|
1025 | 1026 | // The actual Object class
|
1026 |
| - var RubyObject; |
| 1027 | + var ObjectClass; |
1027 | 1028 |
|
1028 | 1029 | // The actual Module class
|
1029 |
| - var RubyModule; |
| 1030 | + var ModuleClass; |
1030 | 1031 |
|
1031 | 1032 | // The actual Class class
|
1032 |
| - var RubyClass; |
| 1033 | + var ClassClass; |
1033 | 1034 |
|
1034 | 1035 | // Constructor for instances of BasicObject
|
1035 | 1036 | function BasicObject(){}
|
|
1054 | 1055 | boot_class_alloc('Class', Class, Module);
|
1055 | 1056 |
|
1056 | 1057 | // Constructors for *classes* of core objects
|
1057 |
| - RubyBasicObject = boot_makemeta('BasicObject', BasicObject, Class); |
1058 |
| - RubyObject = boot_makemeta('Object', Object, RubyBasicObject.constructor); |
1059 |
| - RubyModule = boot_makemeta('Module', Module, RubyObject.constructor); |
1060 |
| - RubyClass = boot_makemeta('Class', Class, RubyModule.constructor); |
| 1058 | + BasicObjectClass = boot_makemeta('BasicObject', BasicObject, Class); |
| 1059 | + ObjectClass = boot_makemeta('Object', Object, BasicObjectClass.constructor); |
| 1060 | + ModuleClass = boot_makemeta('Module', Module, ObjectClass.constructor); |
| 1061 | + ClassClass = boot_makemeta('Class', Class, ModuleClass.constructor); |
1061 | 1062 |
|
1062 | 1063 | // Fix booted classes to use their metaclass
|
1063 |
| - RubyBasicObject.$$class = RubyClass; |
1064 |
| - RubyObject.$$class = RubyClass; |
1065 |
| - RubyModule.$$class = RubyClass; |
1066 |
| - RubyClass.$$class = RubyClass; |
| 1064 | + BasicObjectClass.$$class = ClassClass; |
| 1065 | + ObjectClass.$$class = ClassClass; |
| 1066 | + ModuleClass.$$class = ClassClass; |
| 1067 | + ClassClass.$$class = ClassClass; |
1067 | 1068 |
|
1068 | 1069 | // Fix superclasses of booted classes
|
1069 |
| - RubyBasicObject.$$super = null; |
1070 |
| - RubyObject.$$super = RubyBasicObject; |
1071 |
| - RubyModule.$$super = RubyObject; |
1072 |
| - RubyClass.$$super = RubyModule; |
| 1070 | + BasicObjectClass.$$super = null; |
| 1071 | + ObjectClass.$$super = BasicObjectClass; |
| 1072 | + ModuleClass.$$super = ObjectClass; |
| 1073 | + ClassClass.$$super = ModuleClass; |
1073 | 1074 |
|
1074 | 1075 | // Internally, Object acts like a module as it is "included" into bridged
|
1075 | 1076 | // classes. In other words, we donate methods from Object into our bridged
|
1076 | 1077 | // classes as their prototypes don't inherit from our root Object, so they
|
1077 | 1078 | // act like module includes.
|
1078 |
| - RubyObject.$$dep = bridged_classes; |
| 1079 | + ObjectClass.$$dep = bridged_classes; |
1079 | 1080 |
|
1080 |
| - Opal.base = RubyObject; |
1081 |
| - RubyBasicObject.$$scope = RubyObject.$$scope = Opal; |
1082 |
| - RubyBasicObject.$$orig_scope = RubyObject.$$orig_scope = Opal; |
1083 |
| - Opal.Kernel = RubyObject; |
| 1081 | + Opal.base = ObjectClass; |
| 1082 | + BasicObjectClass.$$scope = ObjectClass.$$scope = Opal; |
| 1083 | + BasicObjectClass.$$orig_scope = ObjectClass.$$orig_scope = Opal; |
| 1084 | + Opal.Kernel = ObjectClass; |
1084 | 1085 |
|
1085 |
| - RubyModule.$$scope = RubyObject.$$scope; |
1086 |
| - RubyModule.$$orig_scope = RubyObject.$$orig_scope; |
1087 |
| - RubyClass.$$scope = RubyObject.$$scope; |
1088 |
| - RubyClass.$$orig_scope = RubyObject.$$orig_scope; |
| 1086 | + ModuleClass.$$scope = ObjectClass.$$scope; |
| 1087 | + ModuleClass.$$orig_scope = ObjectClass.$$orig_scope; |
| 1088 | + ClassClass.$$scope = ObjectClass.$$scope; |
| 1089 | + ClassClass.$$orig_scope = ObjectClass.$$orig_scope; |
1089 | 1090 |
|
1090 |
| - RubyObject.$$proto.toString = function() { |
| 1091 | + ObjectClass.$$proto.toString = function() { |
1091 | 1092 | return this.$to_s();
|
1092 | 1093 | };
|
1093 | 1094 |
|
1094 |
| - RubyObject.$$proto.$require = Opal.require; |
| 1095 | + ObjectClass.$$proto.$require = Opal.require; |
1095 | 1096 |
|
1096 |
| - Opal.top = new RubyObject.$$alloc(); |
| 1097 | + Opal.top = new ObjectClass.$$alloc(); |
1097 | 1098 |
|
1098 |
| - Opal.klass(RubyObject, RubyObject, 'NilClass', NilClass); |
| 1099 | + Opal.klass(ObjectClass, ObjectClass, 'NilClass', NilClass); |
1099 | 1100 |
|
1100 | 1101 | var nil = Opal.nil = new NilClass();
|
1101 | 1102 | nil.call = nil.apply = function() { throw Opal.LocalJumpError.$new('no block given'); };
|
|
0 commit comments