Skip to content

Commit

Permalink
Re-refactor fixes for mocha and MRI suite back into place.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Apr 15, 2015
1 parent 3063622 commit d9ccc13
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
17 changes: 6 additions & 11 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -2309,11 +2309,11 @@ public IRubyObject methods(ThreadContext context, IRubyObject[] args, boolean us
* in the receiver will be listed.
*/
public IRubyObject public_methods(ThreadContext context, IRubyObject[] args) {
return getMetaClass().public_instance_methods(trueIfNoArgument(context, args));
return getMetaClass().instanceMethods(args, PUBLIC, true, false);
}

public IRubyObject public_methods19(ThreadContext context, IRubyObject[] args) {
return getMetaClass().public_instance_methods19(trueIfNoArgument(context, args));
return getMetaClass().instanceMethods(args, PUBLIC, true, false);
}

/** rb_obj_protected_methods
Expand All @@ -2329,11 +2329,11 @@ public IRubyObject public_methods19(ThreadContext context, IRubyObject[] args) {
* {@link RubyModule#protected_instance_methods} method.
*/
public IRubyObject protected_methods(ThreadContext context, IRubyObject[] args) {
return getMetaClass().protected_instance_methods(trueIfNoArgument(context, args));
return getMetaClass().instanceMethods(args, PROTECTED, true, false);
}

public IRubyObject protected_methods19(ThreadContext context, IRubyObject[] args) {
return getMetaClass().protected_instance_methods19(trueIfNoArgument(context, args));
return getMetaClass().instanceMethods(args, PROTECTED, true, false);
}

/** rb_obj_private_methods
Expand All @@ -2349,16 +2349,11 @@ public IRubyObject protected_methods19(ThreadContext context, IRubyObject[] args
* {@link RubyModule#private_instance_methods} method.
*/
public IRubyObject private_methods(ThreadContext context, IRubyObject[] args) {
return getMetaClass().private_instance_methods(trueIfNoArgument(context, args));
return getMetaClass().instanceMethods(args, PRIVATE, true, false);
}

public IRubyObject private_methods19(ThreadContext context, IRubyObject[] args) {
return getMetaClass().private_instance_methods19(trueIfNoArgument(context, args));
}

// FIXME: If true array is common enough we should pre-allocate and stick somewhere
private IRubyObject[] trueIfNoArgument(ThreadContext context, IRubyObject[] args) {
return args.length == 0 ? new IRubyObject[] { context.runtime.getTrue() } : args;
return getMetaClass().instanceMethods(args, PRIVATE, true, false);
}

/** rb_obj_singleton_methods
Expand Down
21 changes: 13 additions & 8 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -2240,12 +2240,17 @@ public IRubyObject attr_accessor(ThreadContext context, IRubyObject[] args) {
* @param not if true only find methods not matching supplied visibility
* @return a RubyArray of instance method names
*/
private RubyArray instance_methods(IRubyObject[] args, final Visibility visibility, boolean not) {
private RubyArray instance_methods(IRubyObject[] args, Visibility visibility, boolean not) {
boolean includeSuper = args.length > 0 ? args[0].isTrue() : true;
return instanceMethods(visibility, includeSuper, false, not);
return instanceMethods(visibility, includeSuper, true, not);
}

public RubyArray instanceMethods(final Visibility visibility, boolean includeSuper, boolean obj, boolean not) {
public RubyArray instanceMethods(IRubyObject[] args, Visibility visibility, boolean obj, boolean not) {
boolean includeSuper = args.length > 0 ? args[0].isTrue() : true;
return instanceMethods(visibility, includeSuper, obj, not);
}

public RubyArray instanceMethods(Visibility visibility, boolean includeSuper, boolean obj, boolean not) {
Ruby runtime = getRuntime();
RubyArray ary = runtime.newArray();
Set<String> seen = new HashSet<String>();
Expand All @@ -2255,7 +2260,7 @@ public RubyArray instanceMethods(final Visibility visibility, boolean includeSup
return ary;
}

public void populateInstanceMethodNames(Set<String> seen, RubyArray ary, final Visibility visibility, boolean obj, boolean not, boolean recur) {
public void populateInstanceMethodNames(Set<String> seen, RubyArray ary, Visibility visibility, boolean obj, boolean not, boolean recur) {
Ruby runtime = getRuntime();
RubyModule mod = this;
boolean prepended = false;
Expand Down Expand Up @@ -2295,7 +2300,7 @@ public RubyArray instance_methods(IRubyObject[] args) {

@JRubyMethod(name = "instance_methods", optional = 1)
public RubyArray instance_methods19(IRubyObject[] args) {
return instance_methods(args, PRIVATE, true);
return instanceMethods(args, PRIVATE, false, true);
}

public RubyArray public_instance_methods(IRubyObject[] args) {
Expand All @@ -2304,7 +2309,7 @@ public RubyArray public_instance_methods(IRubyObject[] args) {

@JRubyMethod(name = "public_instance_methods", optional = 1)
public RubyArray public_instance_methods19(IRubyObject[] args) {
return instance_methods(args, PUBLIC, false);
return instanceMethods(args, PUBLIC, false, false);
}

@JRubyMethod(name = "instance_method", required = 1)
Expand All @@ -2326,7 +2331,7 @@ public RubyArray protected_instance_methods(IRubyObject[] args) {

@JRubyMethod(name = "protected_instance_methods", optional = 1)
public RubyArray protected_instance_methods19(IRubyObject[] args) {
return instance_methods(args, PROTECTED, false);
return instanceMethods(args, PROTECTED, false, false);
}

/** rb_class_private_instance_methods
Expand All @@ -2338,7 +2343,7 @@ public RubyArray private_instance_methods(IRubyObject[] args) {

@JRubyMethod(name = "private_instance_methods", optional = 1)
public RubyArray private_instance_methods19(IRubyObject[] args) {
return instance_methods(args, PRIVATE, false);
return instanceMethods(args, PRIVATE, false, false);
}

/** rb_mod_prepend_features
Expand Down

0 comments on commit d9ccc13

Please sign in to comment.