Skip to content

Commit d34f42f

Browse files
committedSep 18, 2014
Merge pull request #595 from opal/elia/runtime-naming
Replace Ruby- prefix with -Class suffix
2 parents 4f46884 + 7176707 commit d34f42f

File tree

1 file changed

+44
-43
lines changed

1 file changed

+44
-43
lines changed
 

‎opal/corelib/runtime.js

+44-43
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106

107107
// Not specifying a superclass means we can assume it to be Object
108108
if (superklass === null) {
109-
superklass = RubyObject;
109+
superklass = ObjectClass;
110110
}
111111

112112
var klass = base.$$scope[id];
@@ -120,7 +120,7 @@
120120
}
121121

122122
// Make sure existing class has same superclass
123-
if (superklass !== klass.$$super && superklass !== RubyObject) {
123+
if (superklass !== klass.$$super && superklass !== ObjectClass) {
124124
throw Opal.TypeError.$new("superclass mismatch for class " + id);
125125
}
126126
}
@@ -142,7 +142,7 @@
142142
base[id] = base.$$scope[id] = klass;
143143

144144
// Copy all parent constants to child, unless parent is Object
145-
if (superklass !== RubyObject && superklass !== RubyBasicObject) {
145+
if (superklass !== ObjectClass && superklass !== BasicObjectClass) {
146146
Opal.donate_constants(superklass, klass);
147147
}
148148

@@ -213,7 +213,7 @@
213213
* ipothesis on why it's needed can be found below.
214214
*
215215
* @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)
217217
*
218218
* @param prototype The prototype on which the class/module methods will
219219
* be stored.
@@ -268,7 +268,7 @@
268268
if ($hasOwn.call(base.$$scope, id)) {
269269
module = base.$$scope[id];
270270

271-
if (!module.$$is_mod && module !== RubyObject) {
271+
if (!module.$$is_mod && module !== ObjectClass) {
272272
throw Opal.TypeError.$new(id + " is not a module");
273273
}
274274
}
@@ -291,15 +291,15 @@
291291
*/
292292
function boot_module_object() {
293293
var mtor = function() {};
294-
mtor.prototype = RubyModule.constructor.prototype;
294+
mtor.prototype = ModuleClass.constructor.prototype;
295295

296296
function module_constructor() {}
297297
module_constructor.prototype = new mtor();
298298

299299
var module = new module_constructor();
300300
var module_prototype = {};
301301

302-
setup_module_object(module, module_constructor, RubyModule, module_prototype)
302+
setup_module_object(module, module_constructor, ModuleClass, module_prototype)
303303
module.$$is_mod = true;
304304
module.$$dep = [];
305305

@@ -338,7 +338,8 @@
338338
var method = methods[i], current;
339339

340340

341-
if (prototype.hasOwnProperty(method) && !(current = prototype[method]).$$donated && !current.$$stub) {
341+
if ( prototype.hasOwnProperty(method) &&
342+
!(current = prototype[method]).$$donated && !current.$$stub ) {
342343
// if the target class already has a method of the same name defined
343344
// and that method was NOT donated, then it must be a method defined
344345
// by the class so we do not want to override it
@@ -420,18 +421,18 @@
420421
* @return [Class] returns new ruby class
421422
*/
422423
function bridge_class(name, constructor) {
423-
var klass = boot_class_object(RubyObject, constructor);
424+
var klass = boot_class_object(ObjectClass, constructor);
424425

425426
klass.$$name = name;
426427

427428
create_scope(Opal, klass, name);
428429
bridged_classes.push(klass);
429430

430-
var object_methods = RubyBasicObject.$$methods.concat(RubyObject.$$methods);
431+
var object_methods = BasicObjectClass.$$methods.concat(ObjectClass.$$methods);
431432

432433
for (var i = 0, len = object_methods.length; i < len; i++) {
433434
var meth = object_methods[i];
434-
constructor.prototype[meth] = RubyObject.$$proto[meth];
435+
constructor.prototype[meth] = ObjectClass.$$proto[meth];
435436
}
436437

437438
add_stubs_subscriber(constructor.prototype)
@@ -846,10 +847,10 @@
846847
else if (obj.$$is_class) {
847848
obj.$$proto[jsid] = body;
848849

849-
if (obj === RubyBasicObject) {
850+
if (obj === BasicObjectClass) {
850851
define_basic_object_method(jsid, body);
851852
}
852-
else if (obj === RubyObject) {
853+
else if (obj === ObjectClass) {
853854
Opal.donate(obj, [jsid]);
854855
}
855856
}
@@ -873,7 +874,7 @@
873874
};
874875

875876
function define_basic_object_method(jsid, body) {
876-
RubyBasicObject.$$methods.push(jsid);
877+
BasicObjectClass.$$methods.push(jsid);
877878
for (var i = 0, len = bridged_classes.length; i < len; i++) {
878879
bridged_classes[i].$$proto[jsid] = body;
879880
}
@@ -1020,16 +1021,16 @@
10201021
// --------------
10211022

10221023
// The actual class for BasicObject
1023-
var RubyBasicObject;
1024+
var BasicObjectClass;
10241025

10251026
// The actual Object class
1026-
var RubyObject;
1027+
var ObjectClass;
10271028

10281029
// The actual Module class
1029-
var RubyModule;
1030+
var ModuleClass;
10301031

10311032
// The actual Class class
1032-
var RubyClass;
1033+
var ClassClass;
10331034

10341035
// Constructor for instances of BasicObject
10351036
function BasicObject(){}
@@ -1054,48 +1055,48 @@
10541055
boot_class_alloc('Class', Class, Module);
10551056

10561057
// 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);
10611062

10621063
// 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;
10671068

10681069
// 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;
10731074

10741075
// Internally, Object acts like a module as it is "included" into bridged
10751076
// classes. In other words, we donate methods from Object into our bridged
10761077
// classes as their prototypes don't inherit from our root Object, so they
10771078
// act like module includes.
1078-
RubyObject.$$dep = bridged_classes;
1079+
ObjectClass.$$dep = bridged_classes;
10791080

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;
10841085

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;
10891090

1090-
RubyObject.$$proto.toString = function() {
1091+
ObjectClass.$$proto.toString = function() {
10911092
return this.$to_s();
10921093
};
10931094

1094-
RubyObject.$$proto.$require = Opal.require;
1095+
ObjectClass.$$proto.$require = Opal.require;
10951096

1096-
Opal.top = new RubyObject.$$alloc();
1097+
Opal.top = new ObjectClass.$$alloc();
10971098

1098-
Opal.klass(RubyObject, RubyObject, 'NilClass', NilClass);
1099+
Opal.klass(ObjectClass, ObjectClass, 'NilClass', NilClass);
10991100

11001101
var nil = Opal.nil = new NilClass();
11011102
nil.call = nil.apply = function() { throw Opal.LocalJumpError.$new('no block given'); };

0 commit comments

Comments
 (0)
Please sign in to comment.