Skip to content

Commit

Permalink
Showing 8 changed files with 64 additions and 47 deletions.
2 changes: 1 addition & 1 deletion opal/corelib/class.rb
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
class Class
def self.new(sup = Object, &block)
%x{
if (!sup.$$is_class || sup.$$is_module) {
if (!sup.$$is_class) {
#{raise TypeError, "superclass must be a Class"};
}
1 change: 0 additions & 1 deletion opal/corelib/enumerable.rb
Original file line number Diff line number Diff line change
@@ -681,7 +681,6 @@ def lazy
def enumerator_size
respond_to?(:size) ? size : nil
end
private :enumerator_size

alias map collect

5 changes: 0 additions & 5 deletions opal/corelib/kernel.rb
Original file line number Diff line number Diff line change
@@ -944,11 +944,6 @@ def printf(*args)
nil
end

def private_methods(*)
[]
end
alias private_instance_methods private_methods

def proc(&block)
unless block
raise ArgumentError, "tried to create Proc object without a block"
32 changes: 0 additions & 32 deletions opal/corelib/module.rb
Original file line number Diff line number Diff line change
@@ -513,38 +513,6 @@ def name
}
end

def public(*methods)
%x{
if (methods.length === 0) {
self.$$module_function = false;
}
return nil;
}
end

alias private public
alias protected public
alias nesting public

def private_class_method(name)
`self['$' + name] || nil`
end
alias public_class_method private_class_method

def private_method_defined?(obj)
false
end

def private_constant(*)
end

alias protected_method_defined? private_method_defined?

alias public_instance_methods instance_methods

alias public_method_defined? method_defined?

def remove_class_variable(*)
end

1 change: 0 additions & 1 deletion opal/corelib/rational.rb
Original file line number Diff line number Diff line change
@@ -340,7 +340,6 @@ def truncate(precision = 0)
end
end

private
def with_precision(method, precision)
raise TypeError, "not an Integer" unless Integer === precision

24 changes: 18 additions & 6 deletions opal/corelib/runtime.js
Original file line number Diff line number Diff line change
@@ -377,7 +377,7 @@
return object.$$meta;
}

if (object.$$is_class) {
if (object.$$is_class || object.$$is_module) {
return build_class_singleton_class(object);
}

@@ -884,20 +884,32 @@

// Arity count error dispatcher
Opal.ac = function(actual, expected, object, meth) {
var inspect = (object.$$is_class ? object.$$name + '.' : object.$$class.$$name + '#') + meth;
var msg = '[' + inspect + '] wrong number of arguments(' + actual + ' for ' + expected + ')';
throw Opal.ArgumentError.$new(msg);
var inspect = '';
if (object.$$is_class || object.$$is_module) {
inspect += object.$$name + '.';
}
else {
inspect += object.$$class.$$name + '#';
}
inspect += meth;

throw Opal.ArgumentError.$new('[' + inspect + '] wrong number of arguments(' + actual + ' for ' + expected + ')');
};

// Super dispatcher
Opal.find_super_dispatcher = function(obj, jsid, current_func, iter, defs) {
var dispatcher;

if (defs) {
dispatcher = obj.$$is_class ? defs.$$super : obj.$$class.$$proto;
if (obj.$$is_class || obj.$$is_module) {
dispatcher = defs.$$super;
}
else {
dispatcher = obj.$$class.$$proto;
}
}
else {
if (obj.$$is_class) {
if (obj.$$is_class || obj.$$is_module) {
dispatcher = obj.$$super;
}
else {
1 change: 0 additions & 1 deletion opal/corelib/time.rb
Original file line number Diff line number Diff line change
@@ -710,7 +710,6 @@ def year
`self.is_utc ? self.getUTCFullYear() : self.getFullYear()`
end

private :cweek_cyear
def cweek_cyear
jan01 = Time.new(self.year, 1, 1)
jan01_wday = jan01.wday
45 changes: 45 additions & 0 deletions opal/corelib/unsupported.rb
Original file line number Diff line number Diff line change
@@ -162,3 +162,48 @@ def restore(*)
raise NotImplementedError, `ERROR`
end
end

class Module
def public(*methods)
%x{
if (methods.length === 0) {
self.$$module_function = false;
}
return nil;
}
end

alias private public

alias protected public

alias nesting public

def private_class_method(name)
`self['$' + name] || nil`
end

alias public_class_method private_class_method

def private_method_defined?(obj)
false
end

def private_constant(*)
end

alias protected_method_defined? private_method_defined?

alias public_instance_methods instance_methods

alias public_method_defined? method_defined?
end

module Kernel
def private_methods(*)
[]
end

alias private_instance_methods private_methods
end

0 comments on commit dd81fb4

Please sign in to comment.