runtime/module.js in opal-0.3.6 vs runtime/module.js in opal-0.3.9

- old
+ new

@@ -1,52 +1,52 @@ /** Define a top level module with the given id */ -function define_module(id) { - return define_module_under(cObject, id); +function rb_define_module(id) { + return rb_define_module_under(rb_cObject, id); }; -function define_module_under(base, id) { +function rb_define_module_under(base, id) { var module; - if (const_defined(base, id)) { - module = const_get(base, id); - if (module.$flags & T_MODULE) { + if (rb_const_defined(base, id)) { + module = rb_const_get(base, id); + if (module.$f & T_MODULE) { return module; } - throw new Error(id + " is not a module."); + rb_raise(rb_eException, id + " is not a module"); } - module = define_module_id(id); + module = rb_define_module_id(id); - if (base == cObject) { - name_class(module, id); + if (base == rb_cObject) { + rb_name_class(module, id); } else { - name_class(module, base.__classid__ + '::' + id); + rb_name_class(module, base.__classid__ + '::' + id); } - const_set(base, id, module); + rb_const_set(base, id, module); module.$parent = base; return module; }; -function define_module_id(id) { - var module = class_create(cModule); - make_metaclass(module, cModule); +function rb_define_module_id(id) { + var module = rb_class_create(rb_cModule); + rb_make_metaclass(module, rb_cModule); - module.$flags = T_MODULE; + module.$f = T_MODULE; module.$included_in = []; return module; }; -function mod_create() { - return class_boot(cModule); +function rb_mod_create() { + return rb_class_boot(rb_cModule); }; -function include_module(klass, module) { +function rb_include_module(klass, module) { if (!klass.$included_modules) { klass.$included_modules = []; } @@ -59,28 +59,25 @@ module.$included_in = []; } module.$included_in.push(klass); - for (var method in module.$method_table) { - if (module.$method_table.hasOwnProperty(method)) { - define_raw_method(klass, method, - module.$m_tbl[method], - module.$m_tbl['$' + method]); + for (var method in module.$m) { + if (hasOwnProperty.call(module.$m, method)) { + rb_define_raw_method(klass, method, + module.$a.prototype[method]); } } - for (var constant in module.$c) { - if (module.$c.hasOwnProperty(constant)) { - const_set(klass, constant, module.$c[constant]); - } - } + // for (var constant in module.$c) { + // if (hasOwnProperty.call(module.$c, constant)) { + // const_set(klass, constant, module.$c[constant]); + // } + // } }; -Rt.include_module = include_module; - -function extend_module(klass, module) { +function rb_extend_module(klass, module) { if (!klass.$extended_modules) { klass.$extended_modules = []; } if (klass.$extended_modules.indexOf(module) != -1) { @@ -92,18 +89,15 @@ module.$extended_in = []; } module.$extended_in.push(klass); - var meta = klass.$klass; + var meta = klass.$k; - for (var method in module.$method_table) { - if (module.$method_table.hasOwnProperty(method)) { - define_raw_method(meta, method, - module.$m_tbl[method], - module.$m_tbl['$' + method]); + for (var method in module.o$m) { + if (hasOwnProperty.call(module.o$m, method)) { + rb_define_raw_method(meta, method, + module.o$a.prototype[method]); } } }; - -Rt.extend_module = extend_module;