org.jruby.RubyClass.isMethodBound()方法的使用及代码示例

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

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

RubyClass.isMethodBound介绍

暂无

代码示例

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

private static boolean bindJavaPackageOrClassMethod(final RubyModule parentPackage,
  final String name, final RubyModule packageOrClass) {
  if ( parentPackage.getMetaClass().isMethodBound(name, false) ) {
    return false;
  }
  final RubyClass singleton = parentPackage.getSingletonClass();
  singleton.addMethod(name.intern(), new JavaAccessor(singleton, packageOrClass, parentPackage, name));
  return true;
}

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

@Override
  public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
    return self.getMetaClass().isMethodBound(getName(), false) ? runtime.getDefinedMessage(DefinedMessage.METHOD) : null;
  }
}

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

@Override
  public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
    return self.getMetaClass().isMethodBound(getName(), false) ? runtime.getDefinedMessage(DefinedMessage.METHOD) : null;
  }
}

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

@Deprecated // NOTE: does not match Ruby 2.x rules (does method bound check only)
public final RubyBoolean respond_to_p(IRubyObject mname, IRubyObject includePrivate) {
  String name = mname.asJavaString();
  return getRuntime().newBoolean(getMetaClass().isMethodBound(name, !includePrivate.isTrue()));
}

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

@Deprecated // NOTE: does not match Ruby 2.x rules (does method bound check only)
public final RubyBoolean respond_to_p(IRubyObject mname, IRubyObject includePrivate) {
  String name = mname.asJavaString();
  return getRuntime().newBoolean(getMetaClass().isMethodBound(name, !includePrivate.isTrue()));
}

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

@JIT
public static IRubyObject isDefinedSuper(ThreadContext context, IRubyObject receiver, String frameName, RubyModule frameClass, IRubyObject definedMessage) {
  boolean defined = frameName != null && frameClass != null &&
      Helpers.findImplementerIfNecessary(receiver.getMetaClass(), frameClass).getSuperClass().isMethodBound(frameName, false);
  return defined ? definedMessage : context.nil;
}

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

@JIT @Interp
public static IRubyObject getDefinedConstantOrBoundMethod(IRubyObject left, String name, IRubyObject definedConstantMessage, IRubyObject definedMethodMessage) {
  if (isModuleAndHasConstant(left, name)) return definedConstantMessage;
  if (left.getMetaClass().isMethodBound(name, true)) return definedMethodMessage;
  return null;
}

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

@JIT @Interp
public static IRubyObject getDefinedConstantOrBoundMethod(IRubyObject left, String name, IRubyObject definedConstantMessage, IRubyObject definedMethodMessage) {
  if (isModuleAndHasConstant(left, name)) return definedConstantMessage;
  if (left.getMetaClass().isMethodBound(name, true)) return definedMethodMessage;
  return null;
}

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

@Override
public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) {
  IRubyObject receiver = (IRubyObject) getObject().retrieve(context, self, currDynScope, temp);
  return context.runtime.newBoolean(receiver.getMetaClass().isMethodBound(getName().string, false));
}

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

public static RubyString getDefinedConstantOrBoundMethod(IRubyObject left, String name) {
  if (isModuleAndHasConstant(left, name)) return left.getRuntime().getDefinedMessage(DefinedMessage.CONSTANT);
  if (left.getMetaClass().isMethodBound(name, true)) left.getRuntime().getDefinedMessage(DefinedMessage.METHOD);
  return null;
}

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

@Override
  public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
    String name = context.getFrameName();
    RubyModule klazz = context.getFrameKlazz();

    if (name != null &&
        klazz != null &&
        Helpers.findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass().isMethodBound(name, false)) {
      return runtime.getDefinedMessage(DefinedMessage.SUPER);
    }

    return null;
  }
}

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

@Override
  public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
    String name = context.getFrameName();
    RubyModule klazz = context.getFrameKlazz();

    if (name != null &&
        klazz != null &&
        Helpers.findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass().isMethodBound(name, false)) {
      return runtime.getDefinedMessage(DefinedMessage.SUPER);
    }

    return null;
  }
}

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

public static RubyString getDefinedConstantOrBoundMethod(IRubyObject left, String name) {
  if (isModuleAndHasConstant(left, name)) return left.getRuntime().getDefinedMessage(DefinedMessage.CONSTANT);
  if (left.getMetaClass().isMethodBound(name, true)) left.getRuntime().getDefinedMessage(DefinedMessage.METHOD);
  return null;
}

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

@Override
  public RubyString definition(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
    String name = context.getFrameName();
    RubyModule klazz = context.getFrameKlazz();

    if (name != null &&
        klazz != null &&
        Helpers.findImplementerIfNecessary(self.getMetaClass(), klazz).getSuperClass().isMethodBound(name, false)) {
      return ASTInterpreter.getArgumentDefinition(runtime, context, argsNode, runtime.getDefinedMessage(DefinedMessage.SUPER), self, aBlock);
    }
      
    return null;
  }
}

代码示例来源: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: 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: com.ning.billing/killbill-osgi-bundles-jruby

public IRubyObject respond_to_p19(IRubyObject mname, IRubyObject includePrivate) {
  String name = mname.asJavaString();
  IRubyObject respond = getRuntime().newBoolean(getMetaClass().isMethodBound(name, !includePrivate.isTrue()));
  if (!respond.isTrue()) {
    respond = Helpers.invoke(getRuntime().getCurrentContext(), this, "respond_to_missing?", mname, includePrivate);
    respond = getRuntime().newBoolean(respond.isTrue());
  }
  return respond;
}

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

public IRubyObject respond_to_p19(IRubyObject mname, IRubyObject includePrivate) {
  String name = mname.asJavaString();
  IRubyObject respond = getRuntime().newBoolean(getMetaClass().isMethodBound(name, !includePrivate.isTrue()));
  if (!respond.isTrue()) {
    respond = Helpers.invoke(getRuntime().getCurrentContext(), this, "respond_to_missing?", mname, includePrivate);
    respond = getRuntime().newBoolean(respond.isTrue());
  }
  return respond;
}

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

public IRubyObject respond_to_p19(IRubyObject mname) {
  String name = mname.asJavaString();
  IRubyObject respond = getRuntime().newBoolean(getMetaClass().isMethodBound(name, true, true));
  if (!respond.isTrue()) {
    respond = Helpers.invoke(getRuntime().getCurrentContext(), this, "respond_to_missing?", mname, getRuntime().getFalse());
    respond = getRuntime().newBoolean(respond.isTrue());
  }
  return respond;
}

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

public IRubyObject respond_to_p19(IRubyObject mname) {
  String name = mname.asJavaString();
  IRubyObject respond = getRuntime().newBoolean(getMetaClass().isMethodBound(name, true, true));
  if (!respond.isTrue()) {
    respond = Helpers.invoke(getRuntime().getCurrentContext(), this, "respond_to_missing?", mname, getRuntime().getFalse());
    respond = getRuntime().newBoolean(respond.isTrue());
  }
  return respond;
}

相关文章

微信公众号

最新文章

更多

RubyClass类方法