org.jruby.RubyModule.searchMethod()方法的使用及代码示例

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

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

RubyModule.searchMethod介绍

[英]Search through this module and supermodules for method definitions. Cache superclass definitions in this class.
[中]在本模块和超级模块中搜索方法定义。缓存此类中的超类定义。

代码示例

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

ArrayNewMethod(RubyModule implClass, Visibility visibility) {
  this(implClass, visibility, implClass.searchMethod("new"));
}

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

/**
 * Cache built-in versions of several core methods, to improve performance by using identity comparison (==) rather
 * than going ahead with dynamic dispatch.
 *
 * @param runtime
 */
static void recacheBuiltinMethods(Ruby runtime) {
  RubyModule module = runtime.getKernel();
  runtime.setRespondToMethod(module.searchMethod("respond_to?"));
  runtime.setRespondToMissingMethod(module.searchMethod("respond_to_missing?"));
}

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

/**
 * Cache built-in versions of several core methods, to improve performance by using identity comparison (==) rather
 * than going ahead with dynamic dispatch.
 *
 * @param runtime
 */
static void recacheBuiltinMethods(Ruby runtime) {
  RubyModule module = runtime.getKernel();
  runtime.setRespondToMethod(module.searchMethod("respond_to?"));
  runtime.setRespondToMissingMethod(module.searchMethod("respond_to_missing?"));
}

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

protected IRubyObject super_method(ThreadContext context, IRubyObject receiver, RubyModule superClass) {
  if (superClass == null) return context.nil;
  DynamicMethod newMethod = superClass.searchMethod(methodName);
  if (newMethod == UndefinedMethod.INSTANCE) return context.nil;
  if (receiver == null) {
    return RubyUnboundMethod.newUnboundMethod(superClass, methodName, superClass, originName, newMethod);
  } else {
    return RubyMethod.newMethod(superClass, methodName, superClass, originName, newMethod, receiver);
  }
}

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

/**
 * MRI: rb_method_boundp
 *
 */
public boolean isMethodBound(String name, boolean checkVisibility) {
  DynamicMethod method = searchMethod(name);
  return !method.isUndefined() && !(checkVisibility && method.getVisibility() == PRIVATE);
}

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

protected IRubyObject super_method(ThreadContext context, IRubyObject receiver, RubyModule superClass) {
  if (superClass == null) return context.nil;
  DynamicMethod newMethod = superClass.searchMethod(methodName);
  if (newMethod == UndefinedMethod.INSTANCE) return context.nil;
  if (receiver == null) {
    return RubyUnboundMethod.newUnboundMethod(superClass, methodName, superClass, originName, newMethod);
  } else {
    return RubyMethod.newMethod(superClass, methodName, superClass, originName, newMethod, receiver);
  }
}

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

static void recacheBuiltinMethods(Ruby runtime) {
  RubyModule objectClass = runtime.getBasicObject();
  if (runtime.is1_9()) { // method_missing is in Kernel in 1.9
    runtime.setDefaultMethodMissing(objectClass.searchMethod("method_missing"));
  }
}

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

static void recacheBuiltinMethods(Ruby runtime) {
  RubyModule objectClass = runtime.getBasicObject();
  // Since method_missing is marked module we actually define two builtin versions
  runtime.setDefaultMethodMissing(objectClass.searchMethod("method_missing"),
      objectClass.getMetaClass().searchMethod("method_missing"));
}

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

static void recacheBuiltinMethods(Ruby runtime) {
  RubyModule objectClass = runtime.getBasicObject();
  // Since method_missing is marked module we actually define two builtin versions
  runtime.setDefaultMethodMissing(objectClass.searchMethod("method_missing"),
      objectClass.getMetaClass().searchMethod("method_missing"));
}

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

@JRubyMethod(name = "public_method_defined?", required = 1)
public IRubyObject public_method_defined(ThreadContext context, IRubyObject symbol) {
  DynamicMethod method = searchMethod(symbol.asJavaString());
  return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PUBLIC);
}

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

@JRubyMethod(name = "private_method_defined?", required = 1)
public IRubyObject private_method_defined(ThreadContext context, IRubyObject symbol) {
  DynamicMethod method = searchMethod(symbol.asJavaString());
  return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PRIVATE);
}

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

@JRubyMethod(name = "protected_method_defined?", required = 1)
public IRubyObject protected_method_defined(ThreadContext context, IRubyObject symbol) {
  DynamicMethod method = searchMethod(symbol.asJavaString());
  return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PROTECTED);
}

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

@JRubyMethod(name = "protected_method_defined?", required = 1)
public IRubyObject protected_method_defined(ThreadContext context, IRubyObject symbol) {
  DynamicMethod method = searchMethod(TypeConverter.checkID(symbol).idString());
  return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PROTECTED);
}

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

@JRubyMethod(name = "public_method_defined?", required = 1)
public IRubyObject public_method_defined(ThreadContext context, IRubyObject symbol) {
  DynamicMethod method = searchMethod(TypeConverter.checkID(symbol).idString());
  return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PUBLIC);
}

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

@JRubyMethod(name = "public_method_defined?", required = 1)
public IRubyObject public_method_defined(ThreadContext context, IRubyObject symbol) {
  DynamicMethod method = searchMethod(TypeConverter.checkID(symbol).idString());
  return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PUBLIC);
}

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

@JRubyMethod(name = "private_method_defined?", required = 1)
public IRubyObject private_method_defined(ThreadContext context, IRubyObject symbol) {
  DynamicMethod method = searchMethod(TypeConverter.checkID(symbol).idString());
  return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PRIVATE);
}

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

@JRubyMethod(name = "protected_method_defined?", required = 1)
public IRubyObject protected_method_defined(ThreadContext context, IRubyObject symbol) {
  DynamicMethod method = searchMethod(TypeConverter.checkID(symbol).idString());
  return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PROTECTED);
}

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

@JRubyMethod(name = "private_method_defined?", required = 1)
public IRubyObject private_method_defined(ThreadContext context, IRubyObject symbol) {
  DynamicMethod method = searchMethod(TypeConverter.checkID(symbol).idString());
  return context.runtime.newBoolean(!method.isUndefined() && method.getVisibility() == PRIVATE);
}

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

private DynamicMethod deepMethodSearch(String id, Ruby runtime) {
  DynamicMethod method = searchMethod(id);
  if (method.isUndefined() && isModule()) method = runtime.getObject().searchMethod(id);
  if (method.isUndefined()) {
    RubySymbol name = runtime.newSymbol(id);
    throw runtime.newNameError(undefinedMethodMessage(runtime, name, rubyName(), isModule()), id);
  }
  return method;
}

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

private DynamicMethod deepMethodSearch(String id, Ruby runtime) {
  DynamicMethod method = searchMethod(id);
  if (method.isUndefined() && isModule()) method = runtime.getObject().searchMethod(id);
  if (method.isUndefined()) {
    RubySymbol name = runtime.newSymbol(id);
    throw runtime.newNameError(undefinedMethodMessage(runtime, name, rubyName(), isModule()), id);
  }
  return method;
}

相关文章

微信公众号

最新文章

更多

RubyModule类方法