Skip to content

Commit

Permalink
Change name of method I just introduced in previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Nov 23, 2016
1 parent d081169 commit 51e244e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Expand Up @@ -586,7 +586,7 @@ public final boolean respondsTo(String name) {
// fastest path; builtin respond_to? and respond_to_missing? so we just check isMethodBound
if ( respondTo.equals(runtime.getRespondToMethod()) &&
getMetaClass().searchMethod("respond_to_missing?").equals(runtime.getRespondToMissingMethod()) ) {
return getMetaClass().doesMethodRespondTo(name, false);
return getMetaClass().respondsToMethod(name, false);
}

final ThreadContext context = runtime.getCurrentContext();
Expand Down Expand Up @@ -2047,7 +2047,7 @@ public void checkFrozen() {
* benefit is important for this method.
*/
public final RubyBoolean respond_to_p(IRubyObject mname) {
return getRuntime().newBoolean(getMetaClass().doesMethodRespondTo(mname.asJavaString(), true));
return getRuntime().newBoolean(getMetaClass().respondsToMethod(mname.asJavaString(), true));
}

public final RubyBoolean respond_to_p19(IRubyObject mname) {
Expand All @@ -2066,7 +2066,7 @@ public final RubyBoolean respond_to_p19(IRubyObject mname, IRubyObject includePr
private RubyBoolean respond_to_p19(IRubyObject mname, final boolean includePrivate) {
final Ruby runtime = getRuntime();
final String name = mname.asJavaString();
if (getMetaClass().doesMethodRespondTo(name, !includePrivate)) return runtime.getTrue();
if (getMetaClass().respondsToMethod(name, !includePrivate)) return runtime.getTrue();
// MRI (1.9) always passes down a symbol when calling respond_to_missing?
if ( ! (mname instanceof RubySymbol) ) mname = runtime.newSymbol(name);
ThreadContext context = runtime.getCurrentContext();
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/RubyModule.java
Expand Up @@ -1822,13 +1822,13 @@ public boolean isMethodBound(String name, boolean checkVisibility) {
return !method.isUndefined() && !(checkVisibility && method.getVisibility() == PRIVATE);
}

public boolean doesMethodRespondTo(String name, boolean checkVisibility) {
return Helpers.doesMethodRespondTo(searchMethod(name), checkVisibility);
public boolean respondsToMethod(String name, boolean checkVisibility) {
return Helpers.respondsToMethod(searchMethod(name), checkVisibility);
}

@Deprecated
public boolean isMethodBound(String name, boolean checkVisibility, boolean checkRespondTo) {
return checkRespondTo ? doesMethodRespondTo(name, checkVisibility): isMethodBound(name, checkVisibility);
return checkRespondTo ? respondsToMethod(name, checkVisibility): isMethodBound(name, checkVisibility);
}

public IRubyObject newMethod(IRubyObject receiver, String methodName, boolean bound, Visibility visibility) {
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/org/jruby/javasupport/JavaPackage.java
Expand Up @@ -39,7 +39,6 @@
import org.jruby.exceptions.RaiseException;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.internal.runtime.methods.NullMethod;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
Expand Down Expand Up @@ -208,7 +207,7 @@ public IRubyObject respond_to_p(final ThreadContext context, IRubyObject name, I
private IRubyObject respond_to(final ThreadContext context, IRubyObject mname, final boolean includePrivate) {
String name = mname.asJavaString();

if (getMetaClass().doesMethodRespondTo(name, !includePrivate)) return context.runtime.getTrue();
if (getMetaClass().respondsToMethod(name, !includePrivate)) return context.runtime.getTrue();
/*
if ( ( name = BlankSlateWrapper.handlesMethod(name) ) != null ) {
RubyBoolean bound = checkMetaClassBoundMethod(context, name, includePrivate);
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/runtime/Helpers.java
Expand Up @@ -2850,7 +2850,7 @@ public static IRubyObject invoke(ThreadContext context, IRubyObject self, String
* We have respondTo logic in RubyModule and we have a special callsite for respond_to?.
* This method is just so we can share that logic.
*/
public static boolean doesMethodRespondTo(DynamicMethod method, boolean checkVisibility) {
public static boolean respondsToMethod(DynamicMethod method, boolean checkVisibility) {
if (method.isUndefined() || method.isNotImplemented()) return false;

return !(checkVisibility &&
Expand Down
@@ -1,13 +1,11 @@
package org.jruby.runtime.callsite;

import org.jruby.Ruby;
import org.jruby.RubySymbol;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.RubyClass;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.runtime.Visibility;

public class RespondToCallSite extends NormalCachingCallSite {
private volatile RespondToTuple respondToTuple = RespondToTuple.NULL_CACHE;
Expand Down Expand Up @@ -164,7 +162,7 @@ protected IRubyObject cacheAndCall(IRubyObject caller, RubyClass selfType, Threa

private static RespondToTuple recacheRespondsTo(CacheEntry respondToMethod, String newString, RubyClass klass, boolean checkVisibility, ThreadContext context) {
CacheEntry respondToLookupResult = klass.searchWithCache(newString);
boolean respondsTo = Helpers.doesMethodRespondTo(respondToLookupResult.method, checkVisibility);
boolean respondsTo = Helpers.respondsToMethod(respondToLookupResult.method, checkVisibility);

return new RespondToTuple(newString, checkVisibility, respondToMethod, respondToLookupResult, context.runtime.newBoolean(respondsTo));
}
Expand Down

0 comments on commit 51e244e

Please sign in to comment.