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

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

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

RubyModule.getConstantAt介绍

[英]This version searches superclasses if we're starting with Object. This corresponds to logic in rb_const_defined_0 that recurses for Object only.
[中]如果我们从Object开始,这个版本会搜索超类。这对应于rb_const_defined_0中仅针对对象递归的逻辑。

代码示例

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

/**
 * Finds a module that is within the current module (or class).
 *
 * @param name to be found in this module (or class)
 * @return the module or null if no such module
 * @since 9.2
 */
public RubyModule getModule(String name) {
  return (RubyModule) getConstantAt(name);
}

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

/**
 * Finds a class that is within the current module (or class).
 *
 * @param name to be found in this module (or class)
 * @return the class or null if no such class
 */
public RubyClass getClass(String name) {
  return (RubyClass) getConstantAt(name);
}

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

/**
 * Finds a class that is within the current module (or class).
 *
 * @param name to be found in this module (or class)
 * @return the class or null if no such class
 */
public RubyClass getClass(String name) {
  return (RubyClass) getConstantAt(name);
}

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

/**
 * Finds a class that is within the current module (or class).
 * 
 * @param name to be found in this module (or class)
 * @return the class or null if no such class
 */
public RubyClass getClass(String name) {
  IRubyObject module;
  if ((module = getConstantAt(name)) instanceof RubyClass) {
    return (RubyClass)module;
  }
  return null;
}

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

/**
 * Finds a module that is within the current module (or class).
 *
 * @param name to be found in this module (or class)
 * @return the module or null if no such module
 * @since 9.2
 */
public RubyModule getModule(String name) {
  return (RubyModule) getConstantAt(name);
}

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

public IRubyObject getConstantAt(String name) {
  return getConstantAt(name, true);
}

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

/**
 * Finds a class that is within the current module (or class).
 * 
 * @param name to be found in this module (or class)
 * @return the class or null if no such class
 */
public RubyClass getClass(String name) {
  IRubyObject module;
  if ((module = getConstantAt(name)) instanceof RubyClass) {
    return (RubyClass)module;
  }
  return null;
}

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

@Deprecated
public IRubyObject fastGetConstantAt(String internedName) {
  return getConstantAt(internedName);
}

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

@Deprecated
public IRubyObject fastGetConstantAt(String internedName) {
  return getConstantAt(internedName);
}

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

@Deprecated
public IRubyObject fastGetConstantAt(String internedName) {
  return getConstantAt(internedName);
}

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

private IRubyObject iterateConstantNoConstMissing(String name, RubyModule init, boolean inherit) {
  for (RubyModule p = init; p != null; p = p.getSuperClass()) {
    IRubyObject value = p.getConstantAt(name);
    if (value != null) return value == UNDEF ? null : value;
    if (!inherit) break;
  }
  return null;
}

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

private IRubyObject iterateConstantNoConstMissing(String name, RubyModule init, boolean inherit) {
  for (RubyModule p = init; p != null; p = p.getSuperClass()) {
    IRubyObject value = p.getConstantAt(name);
    if (value != null) return value == UNDEF ? null : value;
    if (!inherit) break;
  }
  return null;
}

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

private static RubyModule getPackageModule(final Ruby runtime, final String name) {
  final RubyModule javaModule = runtime.getJavaSupport().getJavaModule();
  final IRubyObject packageModule = javaModule.getConstantAt(name);
  if ( packageModule instanceof RubyModule ) return (RubyModule) packageModule;
  final String packageName;
  if ( "Default".equals(name) ) packageName = "";
  else {
    Matcher match = CAMEL_CASE_PACKAGE_SPLITTER.matcher(name);
    packageName = match.replaceAll("$1.$2").toLowerCase();
  }
  return createPackageModule(runtime, javaModule, name, packageName);
}

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

private static RubyModule getPackageModule(final Ruby runtime, final String name) {
  final RubyModule javaModule = runtime.getJavaSupport().getJavaModule();
  final IRubyObject packageModule = javaModule.getConstantAt(name);
  if ( packageModule instanceof RubyModule ) return (RubyModule) packageModule;
  final String packageName;
  if ( "Default".equals(name) ) packageName = "";
  else {
    Matcher match = CAMEL_CASE_PACKAGE_SPLITTER.matcher(name);
    packageName = match.replaceAll("$1.$2").toLowerCase();
  }
  return createPackageModule(runtime, javaModule, name, packageName);
}

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

void install(final RubyModule proxy) {
  if (proxy.getConstantAt(field.getName()) == null) {
    // TODO: catch exception if constant is already set by other
    // thread
    try {
      proxy.setConstant(field.getName(), JavaUtil.convertJavaToUsableRubyObject(proxy.getRuntime(), field.get(null)));
    } catch (IllegalAccessException iae) {
      // if we can't read it, we don't set it
    }
  }
}
static boolean isConstant(final Field field) {

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

void install(final RubyModule proxy) {
  if (proxy.getConstantAt(field.getName()) == null) {
    // TODO: catch exception if constant is already set by other
    // thread
    try {
      proxy.setConstant(field.getName(), JavaUtil.convertJavaToUsableRubyObject(proxy.getRuntime(), field.get(null)));
    } catch (IllegalAccessException iae) {
      // if we can't read it, we don't set it
    }
  }
}
static boolean isConstant(final Field field) {

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

void install(final RubyModule proxy) {
  final String name = field.getName();
  if ( proxy.getConstantAt(name) == null ) {
    try {
      final Object value = field.get(null);
      proxy.setConstant(name, JavaUtil.convertJavaToUsableRubyObject(proxy.getRuntime(), value));
    }
    catch (IllegalAccessException iae) {
      // if we can't read it, we don't set it
    }
  }
}

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

void install(final RubyModule proxy) {
  final String name = field.getName();
  if ( proxy.getConstantAt(name) == null ) {
    try {
      final Object value = field.get(null);
      proxy.setConstant(name, JavaUtil.convertJavaToUsableRubyObject(proxy.getRuntime(), value));
    }
    catch (IllegalAccessException iae) {
      // if we can't read it, we don't set it
    }
  }
}

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

protected static RubyThread startWaiterThread(final Ruby runtime, int pid, Block block) {
  final IRubyObject waiter = runtime.getProcess().getConstantAt("Waiter"); // Process::Waiter
  final RubyThread rubyThread = new RubyThread(runtime, (RubyClass) waiter);
  rubyThread.op_aset(runtime.newSymbol("pid"), runtime.newFixnum(pid));
  rubyThread.callInit(IRubyObject.NULL_ARRAY, block);
  return rubyThread;
}

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

protected static RubyThread startWaiterThread(final Ruby runtime, int pid, Block block) {
  final IRubyObject waiter = runtime.getProcess().getConstantAt("Waiter"); // Process::Waiter
  final RubyThread rubyThread = new RubyThread(runtime, (RubyClass) waiter);
  rubyThread.op_aset(runtime.newSymbol("pid"), runtime.newFixnum(pid));
  rubyThread.callInit(IRubyObject.NULL_ARRAY, block);
  return rubyThread;
}

相关文章

微信公众号

最新文章

更多

RubyModule类方法