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

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

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

RubyClass.getConstantAt介绍

暂无

代码示例

代码示例来源:origin: bazelbuild/bazel

public static void checkNameAvailability(ThreadContext context, String name) {
  if (context.runtime.getObject().getConstantAt(name) != null)
    throw context.runtime.newNameError(name + " is already defined", name);
}

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

/**
 * Retrieve the module with the given name from the Object namespace.
 * 
 * @param name The name of the module
 * @return The module or null if not found
 */
public RubyModule getModule(String name) {
  return (RubyModule) objectClass.getConstantAt(name);
}

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

/**
 * Retrieve the module with the given name from the Object namespace.
 * 
 * @param name The name of the module
 * @return The module or null if not found
 */
public RubyModule getModule(String name) {
  return (RubyModule) objectClass.getConstantAt(name);
}

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

static RubyClass getDate(final Ruby runtime) {
  return (RubyClass) runtime.getObject().getConstantAt("Date");
}

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

static RubyClass getDate(final Ruby runtime) {
  return (RubyClass) runtime.getObject().getConstantAt("Date");
}

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

static RubyClass getDateTime(final Ruby runtime) {
  return (RubyClass) runtime.getObject().getConstantAt("DateTime");
}

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

static RubyClass getDateTime(final Ruby runtime) {
  return (RubyClass) runtime.getObject().getConstantAt("DateTime");
}

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

/**
 * From Object, retrieve the named module. If it doesn't exist a
 * new module is created.
 * 
 * @param name The name of the module
 * @returns The existing or new module
 */
public RubyModule getOrCreateModule(String name) {
  IRubyObject module = objectClass.getConstantAt(name);
  if (module == null) {
    module = defineModule(name);
  } else if (!module.isModule()) {
    throw newTypeError(name + " is not a Module");
  }
  return (RubyModule) module;
}

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

/**
 * From Object, retrieve the named module. If it doesn't exist a
 * new module is created.
 * 
 * @param name The name of the module
 * @returns The existing or new module
 */
public RubyModule getOrCreateModule(String name) {
  IRubyObject module = objectClass.getConstantAt(name);
  if (module == null) {
    module = defineModule(name);
  } else if (!module.isModule()) {
    throw newTypeError(name + " is not a Module");
  }
  return (RubyModule) module;
}

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

static DivideTSortHash newInstance(final ThreadContext context) {
  final Ruby runtime = context.runtime;
  RubyClass Set = runtime.getClass("Set");
  RubyClass klass = (RubyClass) Set.getConstantAt(NAME, true);
  if (klass == null) { // initialize on-demand when Set#divide is first called
    synchronized (DivideTSortHash.class) {
      klass = (RubyClass) Set.getConstantAt(NAME, true);
      if (klass == null) {
        klass = Set.defineClassUnder(NAME, runtime.getHash(), runtime.getHash().getAllocator());
        Set.setConstantVisibility(runtime, NAME, true); // private
        klass.includeModule(getTSort(runtime));
        klass.defineAnnotatedMethods(DivideTSortHash.class);
      }
    }
  }
  return new DivideTSortHash(runtime, klass);
}

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

private RubyArray getLines(ParserConfiguration configuration, Ruby runtime, String file) {
  RubyArray list = null;
  IRubyObject scriptLines = runtime.getObject().getConstantAt("SCRIPT_LINES__");
  if (!configuration.isEvalParse() && scriptLines != null) {
    if (scriptLines instanceof RubyHash) {
      list = runtime.newArray();
      ((RubyHash) scriptLines).op_aset(runtime.getCurrentContext(), runtime.newString(file), list);
    }
  }
  return list;
}

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

/**
 * From Object, retrieve the named module. If it doesn't exist a
 * new module is created.
 *
 * @param id The name of the module
 * @returns The existing or new module
 */
public RubyModule getOrCreateModule(String id) {
  IRubyObject module = objectClass.getConstantAt(id);
  if (module == null) {
    module = defineModule(id);
  } else if (!module.isModule()) {
    throw newTypeError(str(this, ids(this, id), " is not a Module"));
  }
  return (RubyModule) module;
}

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

/**
 * From Object, retrieve the named module. If it doesn't exist a
 * new module is created.
 *
 * @param id The name of the module
 * @returns The existing or new module
 */
public RubyModule getOrCreateModule(String id) {
  IRubyObject module = objectClass.getConstantAt(id);
  if (module == null) {
    module = defineModule(id);
  } else if (!module.isModule()) {
    throw newTypeError(str(this, ids(this, id), " is not a Module"));
  }
  return (RubyModule) module;
}

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

private RubyArray getLines(ParserConfiguration configuration, Ruby runtime, String file) {
  RubyArray list = null;
  IRubyObject scriptLines = runtime.getObject().getConstantAt("SCRIPT_LINES__");
  if (!configuration.isEvalParse() && scriptLines != null) {
    if (scriptLines instanceof RubyHash) {
      list = runtime.newArray();
      ((RubyHash) scriptLines).op_aset(runtime.getCurrentContext(), runtime.newString(file), list);
    }
  }
  return list;
}

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

static DivideTSortHash newInstance(final ThreadContext context) {
  final Ruby runtime = context.runtime;
  RubyClass Set = runtime.getClass("Set");
  RubyClass klass = (RubyClass) Set.getConstantAt(NAME, true);
  if (klass == null) { // initialize on-demand when Set#divide is first called
    synchronized (DivideTSortHash.class) {
      klass = (RubyClass) Set.getConstantAt(NAME, true);
      if (klass == null) {
        klass = Set.defineClassUnder(NAME, runtime.getHash(), runtime.getHash().getAllocator());
        Set.setConstantVisibility(runtime, NAME, true); // private
        klass.includeModule(getTSort(runtime));
        klass.defineAnnotatedMethods(DivideTSortHash.class);
      }
    }
  }
  return new DivideTSortHash(runtime, klass);
}

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

private RubyArray getLines(ParserConfiguration configuration, Ruby runtime, String file) {
    RubyArray list = null;
    IRubyObject scriptLines = runtime.getObject().getConstantAt("SCRIPT_LINES__");
    if (!configuration.isEvalParse() && scriptLines != null) {
      if (scriptLines instanceof RubyHash) {
        RubyString filename = runtime.newString(file);
        ThreadContext context = runtime.getCurrentContext();
        IRubyObject object = ((RubyHash) scriptLines).op_aref(context, filename);
        list = (RubyArray) (object instanceof RubyArray ? object : runtime.newArray());
        ((RubyHash) scriptLines).op_aset(context, filename, list);
      }
    }
    return list;
  }
}

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

private RubyArray getLines(ParserConfiguration configuration, Ruby runtime, String file) {
    RubyArray list = null;
    IRubyObject scriptLines = runtime.getObject().getConstantAt("SCRIPT_LINES__");
    if (!configuration.isEvalParse() && scriptLines != null) {
      if (scriptLines instanceof RubyHash) {
        RubyString filename = runtime.newString(file);
        ThreadContext context = runtime.getCurrentContext();
        IRubyObject object = ((RubyHash) scriptLines).op_aref(context, filename);
        list = (RubyArray) (object instanceof RubyArray ? object : runtime.newArray());
        ((RubyHash) scriptLines).op_aset(context, filename, list);
      }
    }
    return list;
  }
}

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

IRubyObject type = superClass.getConstantAt(name);
if (type != null) {
  ThreadContext context = runtime.getCurrentContext();

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

IRubyObject type = superClass.getConstantAt(name);
if (type != null) {
  ThreadContext context = runtime.getCurrentContext();

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

IRubyObject type = superClass.getConstantAt(name);
if (type != null) {
  ThreadContext context = runtime.getCurrentContext();

相关文章

微信公众号

最新文章

更多

RubyClass类方法