org.jruby.Ruby.getRespondToMethod()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.jruby.Ruby.getRespondToMethod方法的一些代码示例,展示了Ruby.getRespondToMethod的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getRespondToMethod方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getRespondToMethod

Ruby.getRespondToMethod介绍

暂无

代码示例

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@Override
protected IRubyObject cacheAndCall(IRubyObject caller, RubyClass selfType, ThreadContext context, IRubyObject self, IRubyObject arg) {
  CacheEntry entry = selfType.searchWithCache(methodName);
  DynamicMethod method = entry.method;
  if (methodMissing(method, caller)) {
    return callMethodMissing(context, self, method, arg);
  }
  // alternate logic to cache the result of respond_to if it's the standard one
  // FIXME: 1.9's respond_to_missing breaks this, so we have to bail out
  if (!context.runtime.is1_9() &&
      entry.method.equals(context.runtime.getRespondToMethod())) {
    String name = arg.asJavaString();
    RespondToTuple tuple = recacheRespondsTo(entry, name, selfType, true, context);
    respondToTuple = tuple;
    return tuple.respondsTo;
  }
  // normal logic if it's not the builtin respond_to? method
  cache = entry;
  return method.call(context, self, selfType, methodName, arg);
}

代码示例来源:origin: org.jruby/jruby-complete

public static boolean respondsTo(IRubyObject self, String name) {
  if(getMetaClass(self).searchMethod("respond_to?").equals(getRuntime(self).getRespondToMethod())) {
    return getMetaClass(self).isMethodBound(name, false);
  } else {
    return callMethod(self, getRuntime(self).getCurrentContext(), "respond_to?", getRuntime(self).newSymbol(name)).isTrue();
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@Override
protected IRubyObject cacheAndCall(IRubyObject caller, RubyClass selfType, ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1) {
  CacheEntry entry = selfType.searchWithCache(methodName);
  DynamicMethod method = entry.method;
  if (methodMissing(method, caller)) {
    return callMethodMissing(context, self, method, arg0, arg1);
  }
  // alternate logic to cache the result of respond_to if it's the standard one
  // FIXME: 1.9's respond_to_missing breaks this, so we have to bail out
  // FIXME: 1.9's respond_to_missing breaks this, so we have to bail out
  if (!context.runtime.is1_9() &&
      entry.method.equals(context.runtime.getRespondToMethod())) {
    String name = arg0.asJavaString();
    RespondToTuple tuple = recacheRespondsTo(entry, name, selfType, !arg1.isTrue(), context);
    respondToTuple = tuple;
    return tuple.respondsTo;
  }
  // normal logic if it's not the builtin respond_to? method
  cache = entry;
  return method.call(context, self, selfType, methodName, arg0, arg1);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public static boolean respondsTo(IRubyObject self, String name) {
  if(getMetaClass(self).searchMethod("respond_to?").equals(getRuntime(self).getRespondToMethod())) {
    return getMetaClass(self).isMethodBound(name, false);
  } else {
    return callMethod(self, getRuntime(self).getCurrentContext(), "respond_to?", getRuntime(self).newSymbol(name)).isTrue();
  }
}

代码示例来源:origin: org.jruby/jruby-core

public static boolean respondsTo(IRubyObject self, String name) {
  if(getMetaClass(self).searchMethod("respond_to?").equals(getRuntime(self).getRespondToMethod())) {
    return getMetaClass(self).isMethodBound(name, false);
  } else {
    return callMethod(self, getRuntime(self).getCurrentContext(), "respond_to?", getRuntime(self).newSymbol(name)).isTrue();
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static boolean respondsTo(IRubyObject self, String name) {
  if(getMetaClass(self).searchMethod("respond_to?").equals(getRuntime(self).getRespondToMethod())) {
    return getMetaClass(self).isMethodBound(name, false);
  } else {
    return callMethod(self, getRuntime(self).getCurrentContext(), "respond_to?", getRuntime(self).newSymbol(name)).isTrue();
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@Override
protected IRubyObject cacheAndCall(IRubyObject caller, RubyClass selfType, ThreadContext context, IRubyObject self, IRubyObject arg) {
  CacheEntry entry = selfType.searchWithCache(methodName);
  DynamicMethod method = entry.method;
  if (methodMissing(method, caller)) {
    return callMethodMissing(context, self, method, arg);
  }
  // alternate logic to cache the result of respond_to if it's the standard one
  if (entry.method.equals(context.runtime.getRespondToMethod())) {
    String name = arg.asJavaString();
    RespondToTuple tuple = recacheRespondsTo(entry, name, selfType, true, context);
    // only cache if it's 1.8 OR it does respond_to? OR there's no custom respond_to_missing? logic
    if (!context.is19 ||
        tuple.respondsTo.isTrue() ||
        selfType.searchWithCache("respond_to_missing?").method == context.runtime.getRespondToMissingMethod()) {
      respondToTuple = tuple;
      return tuple.respondsTo;
    }
  }
  // normal logic if it's not the builtin respond_to? method
  cache = entry;
  return method.call(context, self, selfType, methodName, arg);
}

代码示例来源:origin: org.jruby/jruby-complete

@Override
protected IRubyObject cacheAndCall(IRubyObject caller, RubyClass selfType, ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1) {
  CacheEntry entry = selfType.searchWithCache(methodName);
  DynamicMethod method = entry.method;
  if (methodMissing(method, caller)) {
    return callMethodMissing(context, self, selfType, method, arg0, arg1);
  }
  // alternate logic to cache the result of respond_to if it's the standard one
  if (entry.method.equals(context.runtime.getRespondToMethod())) {
    String name = arg0.asJavaString();
    RespondToTuple tuple = recacheRespondsTo(entry, name, selfType, !arg1.isTrue(), context);
    // only cache if it does respond_to? OR there's no custom respond_to_missing? logic
    if (tuple.respondsTo.isTrue() ||
        selfType.searchWithCache("respond_to_missing?").method == context.runtime.getRespondToMissingMethod()) {
      respondToTuple = tuple;
      return tuple.respondsTo;
    }
  }
  // normal logic if it's not the builtin respond_to? method
  cache = entry;
  return method.call(context, self, selfType, methodName, arg0, arg1);
}

代码示例来源:origin: org.jruby/jruby-core

@Override
protected IRubyObject cacheAndCall(IRubyObject caller, RubyClass selfType, ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1) {
  CacheEntry entry = selfType.searchWithCache(methodName);
  DynamicMethod method = entry.method;
  if (methodMissing(method, caller)) {
    return callMethodMissing(context, self, selfType, method, arg0, arg1);
  }
  // alternate logic to cache the result of respond_to if it's the standard one
  if (entry.method.equals(context.runtime.getRespondToMethod())) {
    String name = arg0.asJavaString();
    RespondToTuple tuple = recacheRespondsTo(entry, name, selfType, !arg1.isTrue(), context);
    // only cache if it does respond_to? OR there's no custom respond_to_missing? logic
    if (tuple.respondsTo.isTrue() ||
        selfType.searchWithCache("respond_to_missing?").method == context.runtime.getRespondToMissingMethod()) {
      respondToTuple = tuple;
      return tuple.respondsTo;
    }
  }
  // normal logic if it's not the builtin respond_to? method
  cache = entry;
  return method.call(context, self, selfType, methodName, arg0, arg1);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@Override
protected IRubyObject cacheAndCall(IRubyObject caller, RubyClass selfType, ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1) {
  CacheEntry entry = selfType.searchWithCache(methodName);
  DynamicMethod method = entry.method;
  if (methodMissing(method, caller)) {
    return callMethodMissing(context, self, method, arg0, arg1);
  }
  // alternate logic to cache the result of respond_to if it's the standard one
  if (entry.method.equals(context.runtime.getRespondToMethod())) {
    String name = arg0.asJavaString();
    RespondToTuple tuple = recacheRespondsTo(entry, name, selfType, !arg1.isTrue(), context);
    // only cache if it's 1.8 OR it does respond_to? OR there's no custom respond_to_missing? logic
    if (!context.is19 ||
        tuple.respondsTo.isTrue() ||
        selfType.searchWithCache("respond_to_missing?").method == context.runtime.getRespondToMissingMethod()) {
      respondToTuple = tuple;
      return tuple.respondsTo;
    }
  }
  // normal logic if it's not the builtin respond_to? method
  cache = entry;
  return method.call(context, self, selfType, methodName, arg0, arg1);
}

代码示例来源:origin: org.jruby/jruby-core

if (!method.equals(runtime.getRespondToMethod()) && !method.isUndefined()) {

代码示例来源:origin: org.jruby/jruby-complete

if (!method.equals(runtime.getRespondToMethod()) && !method.isUndefined()) {

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

if (!method.equals(runtime.getRespondToMethod()) && !method.isUndefined()) {

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Does this object respond to the specified message? Uses a
 * shortcut if it can be proved that respond_to? haven't been
 * overridden.
 */
public final boolean respondsTo(String name) {
  DynamicMethod method = getMetaClass().searchMethod("respond_to?");
  if(method.equals(getRuntime().getRespondToMethod())) {
    // fastest path; builtin respond_to? which just does isMethodBound
    return getMetaClass().isMethodBound(name, false);
  } else if (!method.isUndefined()) {
    // medium path, invoke user's respond_to? if defined
    return method.call(getRuntime().getCurrentContext(), this, metaClass, "respond_to?", getRuntime().newSymbol(name)).isTrue();
  } else {
    // slowest path, full callMethod to hit method_missing if present, or produce error
    return callMethod(getRuntime().getCurrentContext(), "respond_to?", getRuntime().newSymbol(name)).isTrue();
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Does this object respond to the specified message? Uses a
 * shortcut if it can be proved that respond_to? haven't been
 * overridden.
 */
public final boolean respondsTo(String name) {
  DynamicMethod method = getMetaClass().searchMethod("respond_to?");
  if(method.equals(getRuntime().getRespondToMethod())) {
    // fastest path; builtin respond_to? which just does isMethodBound
    return getMetaClass().isMethodBound(name, false);
  } else if (!method.isUndefined()) {
    // medium path, invoke user's respond_to? if defined
    return method.call(getRuntime().getCurrentContext(), this, metaClass, "respond_to?", getRuntime().newSymbol(name)).isTrue();
  } else {
    // slowest path, full callMethod to hit method_missing if present, or produce error
    return callMethod(getRuntime().getCurrentContext(), "respond_to?", getRuntime().newSymbol(name)).isTrue();
  }
}

代码示例来源:origin: org.jruby/jruby-complete

} else {
  DynamicMethod method = searchMethod("respond_to?");
  if (!method.equals(runtime.getRespondToMethod()) && !method.isUndefined()) {

代码示例来源:origin: org.jruby/jruby-core

if ( respondTo.equals(runtime.getRespondToMethod()) &&
   getMetaClass().searchMethod("respond_to_missing?").equals(runtime.getRespondToMissingMethod()) ) {
  return getMetaClass().respondsToMethod(name, false);

代码示例来源:origin: org.jruby/jruby-complete

if ( respondTo.equals(runtime.getRespondToMethod()) &&
   getMetaClass().searchMethod("respond_to_missing?").equals(runtime.getRespondToMissingMethod()) ) {
  return getMetaClass().respondsToMethod(name, false);

代码示例来源:origin: org.jruby/jruby-complete

} else {
  DynamicMethod method = getSingletonClass().searchMethod("respond_to?");
  if (!method.equals(runtime.getRespondToMethod()) && !method.isUndefined()) {

代码示例来源:origin: org.jruby/jruby-core

} else {
  DynamicMethod method = getSingletonClass().searchMethod("respond_to?");
  if (!method.equals(runtime.getRespondToMethod()) && !method.isUndefined()) {

相关文章

Ruby类方法