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

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

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

RubyClass.searchMethod介绍

暂无

代码示例

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

public IRubyObject finvoke(ThreadContext context, IRubyObject self, String name) {
  DynamicMethod method = searchMethod(name);
  if (shouldCallMethodMissing(method)) {
    return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, CallType.FUNCTIONAL, Block.NULL_BLOCK);
  }
  return method.call(context, self, this, name);
}

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

public IRubyObject invokeInherited(ThreadContext context, IRubyObject self, IRubyObject subclass) {
  DynamicMethod method = getMetaClass().searchMethod("inherited");
  if (method.isUndefined()) {
    return Helpers.callMethodMissing(context, self, method.getVisibility(), "inherited", CallType.FUNCTIONAL, Block.NULL_BLOCK);
  }
  return method.call(context, self, getMetaClass(), "inherited", subclass, Block.NULL_BLOCK);
}

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

private RubyBoolean checkMetaClassBoundMethod(final ThreadContext context, final String name, final boolean includePrivate) {
  // getMetaClass().isMethodBound(name, !includePrivate, true)
  DynamicMethod method = getMetaClass().searchMethod(name);
  if ( ! method.isUndefined() && ! method.isNotImplemented() ) {
    if ( ! includePrivate && method.getVisibility() == PRIVATE ) {
      return context.fals;
    }
    return context.tru;
  }
  return null;
}

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

private void putPointer(ThreadContext context, long offset, IRubyObject value) {
  DynamicMethod conversionMethod;
  
  if (value instanceof Pointer) {
    putPointer(context, offset, (Pointer) value);
  
  } else if (value.isNil()) {
    getMemoryIO().putAddress(offset, 0L);
  
  } else if (!(conversionMethod = value.getMetaClass().searchMethod("to_ptr")).isUndefined()) {
    putPointer(context, offset, conversionMethod.call(context, value, value.getMetaClass(), "to_ptr"));
  
  } else {
    throw context.runtime.newTypeError(value, context.runtime.getFFI().pointerClass);
  }
}

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

public static DynamicMethod selectMethodMissing(ThreadContext context, RubyClass selfClass, Visibility visibility, String name, CallType callType) {
  final Ruby runtime = context.runtime;
  if (name.equals("method_missing")) {
    return selectInternalMM(runtime, visibility, callType);
  }
  DynamicMethod methodMissing = selfClass.searchMethod("method_missing");
  if (methodMissing.isUndefined() || methodMissing.equals(runtime.getDefaultMethodMissing())) {
    return selectInternalMM(runtime, visibility, callType);
  }
  return new MethodMissingMethod(methodMissing, visibility, callType);
}

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

/**
 * Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
 */
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name,
             Block block) {
  DynamicMethod method = searchMethod(name);
  if (shouldCallMethodMissing(method, name, caller, callType)) {
    return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, callType, block);
  }
  return method.call(context, self, this, name, block);
}

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

public IRubyObject invokeInherited(ThreadContext context, IRubyObject self, IRubyObject subclass) {
  DynamicMethod method = getMetaClass().searchMethod("inherited");
  if (method.isUndefined()) {
    return Helpers.callMethodMissing(context, self, method.getVisibility(), "inherited", CallType.FUNCTIONAL, Block.NULL_BLOCK);
  }
  return method.call(context, self, getMetaClass(), "inherited", subclass, Block.NULL_BLOCK);
}

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

private void putPointer(ThreadContext context, long offset, IRubyObject value) {
  DynamicMethod conversionMethod;
  
  if (value instanceof Pointer) {
    putPointer(context, offset, (Pointer) value);
  
  } else if (value.isNil()) {
    getMemoryIO().putAddress(offset, 0L);
  
  } else if (!(conversionMethod = value.getMetaClass().searchMethod("to_ptr")).isUndefined()) {
    putPointer(context, offset, conversionMethod.call(context, value, value.getMetaClass(), "to_ptr"));
  
  } else {
    throw context.runtime.newTypeError(value, context.runtime.getFFI().pointerClass);
  }
}

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

private RubyBoolean checkMetaClassBoundMethod(final ThreadContext context, final String name, final boolean includePrivate) {
  // getMetaClass().isMethodBound(name, !includePrivate, true)
  DynamicMethod method = getMetaClass().searchMethod(name);
  if ( ! method.isUndefined() && ! method.isNotImplemented() ) {
    if ( ! includePrivate && method.getVisibility() == PRIVATE ) {
      return context.fals;
    }
    return context.tru;
  }
  return null;
}

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

public static DynamicMethod selectMethodMissing(ThreadContext context, IRubyObject receiver, Visibility visibility, String name, CallType callType) {
  Ruby runtime = context.runtime;
  if (name.equals("method_missing")) {
    return selectInternalMM(runtime, visibility, callType);
  }
  DynamicMethod methodMissing = receiver.getMetaClass().searchMethod("method_missing");
  if (methodMissing.isUndefined() || methodMissing.equals(runtime.getDefaultMethodMissing())) {
    return selectInternalMM(runtime, visibility, callType);
  }
  return new MethodMissingMethod(methodMissing, visibility, callType);
}

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

/**
 * Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
 */
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name,
               IRubyObject arg, Block block) {
  DynamicMethod method = searchMethod(name);
  if (shouldCallMethodMissing(method, name, caller, callType)) {
    return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, callType, arg, block);
  }
  return method.call(context, self, this, name, arg, block);
}

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

public IRubyObject invokeInherited(ThreadContext context, IRubyObject self, IRubyObject subclass) {
  DynamicMethod method = getMetaClass().searchMethod("inherited");
  if (method.isUndefined()) {
    return Helpers.callMethodMissing(context, self, method.getVisibility(), "inherited", CallType.FUNCTIONAL, Block.NULL_BLOCK);
  }
  return method.call(context, self, getMetaClass(), "inherited", subclass, Block.NULL_BLOCK);
}

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

private void putPointer(ThreadContext context, long offset, IRubyObject value) {
  DynamicMethod conversionMethod;
  
  if (value instanceof Pointer) {
    putPointer(context, offset, (Pointer) value);
  
  } else if (value.isNil()) {
    getMemoryIO().putAddress(offset, 0L);
  
  } else if (!(conversionMethod = value.getMetaClass().searchMethod("to_ptr")).isUndefined()) {
    putPointer(context, offset, conversionMethod.call(context, value, value.getMetaClass(), "to_ptr"));
  
  } else {
    throw context.runtime.newTypeError(value, context.runtime.getFFI().pointerClass);
  }
}

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

private LexerSource source(ThreadContext context, IRubyObject src, String filename, int lineno) {
  // FIXME: respond_to? returns private methods
  DynamicMethod method = src.getMetaClass().searchMethod("gets");
  
  if (method.isUndefined() || method.getVisibility() == Visibility.PRIVATE) {
    return new ByteListLexerSource(filename, lineno, src.convertToString().getByteList(), null);
  }
  return new GetsLexerSource(filename, lineno, src, null);
}

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

public static DynamicMethod selectMethodMissing(RubyClass selfClass, Visibility visibility, String name, CallType callType) {
  Ruby runtime = selfClass.getClassRuntime();
  if (name.equals("method_missing")) {
    return selectInternalMM(runtime, visibility, callType);
  }
  DynamicMethod methodMissing = selfClass.searchMethod("method_missing");
  if (methodMissing.isUndefined() || methodMissing.equals(runtime.getDefaultMethodMissing())) {
    return selectInternalMM(runtime, visibility, callType);
  }
  return new MethodMissingMethod(methodMissing, visibility, callType);
}

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

/**
 * Same behavior as finvoke, but uses the given caller object to check visibility if callType demands it.
 */
public IRubyObject invokeFrom(ThreadContext context, CallType callType, IRubyObject caller, IRubyObject self, String name,
             IRubyObject[] args) {
  assert args != null;
  DynamicMethod method = searchMethod(name);
  if (shouldCallMethodMissing(method, name, caller, callType)) {
    return Helpers.callMethodMissing(context, self, this, method.getVisibility(), name, callType, args, Block.NULL_BLOCK);
  }
  return method.call(context, self, this, name, args);
}

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

public IRubyObject invokeInherited(ThreadContext context, IRubyObject self, IRubyObject subclass) {
  DynamicMethod method = getMetaClass().searchMethod("inherited");
  if (method.isUndefined()) {
    return Helpers.callMethodMissing(context, self, method.getVisibility(), "inherited", CallType.FUNCTIONAL, Block.NULL_BLOCK);
  }
  return method.call(context, self, getMetaClass(), "inherited", subclass, Block.NULL_BLOCK);
}

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

private void putPointer(ThreadContext context, long offset, IRubyObject value) {
  DynamicMethod conversionMethod;
  
  if (value instanceof Pointer) {
    putPointer(context, offset, (Pointer) value);
  
  } else if (value.isNil()) {
    getMemoryIO().putAddress(offset, 0L);
  
  } else if (!(conversionMethod = value.getMetaClass().searchMethod("to_ptr")).isUndefined()) {
    putPointer(context, offset, conversionMethod.call(context, value, value.getMetaClass(), "to_ptr"));
  
  } else {
    throw context.runtime.newTypeError(value, context.runtime.getFFI().pointerClass);
  }
}

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

private LexerSource source(ThreadContext context, IRubyObject src, String filename, int lineno) {
  // FIXME: respond_to? returns private methods
  DynamicMethod method = src.getMetaClass().searchMethod("gets");
  
  if (method.isUndefined() || method.getVisibility() == Visibility.PRIVATE) {
    return new ByteListLexerSource(filename, lineno, src.convertToString().getByteList(), null);
  }
  return new GetsLexerSource(filename, lineno, src, null);
}

代码示例来源: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;
}

相关文章

微信公众号

最新文章

更多

RubyClass类方法