本文整理了Java中org.jruby.RubyClass.getClassIndex
方法的一些代码示例,展示了RubyClass.getClassIndex
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyClass.getClassIndex
方法的具体详情如下:
包路径:org.jruby.RubyClass
类名称:RubyClass
方法名:getClassIndex
暂无
代码示例来源:origin: org.jruby/jruby-core
public IncludedModule(Ruby runtime, RubyClass superClass, RubyModule origin) {
super(runtime, superClass, false);
this.origin = origin;
this.metaClass = origin.metaClass;
if (superClass != null) {
setClassIndex(superClass.getClassIndex()); // use same ClassIndex as metaclass, since we're technically still of that type
}
}
代码示例来源:origin: org.jruby/jruby-complete
public IncludedModule(Ruby runtime, RubyClass superClass, RubyModule origin) {
super(runtime, superClass, false);
this.origin = origin;
this.metaClass = origin.metaClass;
if (superClass != null) {
setClassIndex(superClass.getClassIndex()); // use same ClassIndex as metaclass, since we're technically still of that type
}
}
代码示例来源:origin: org.jruby/jruby-core
private static DynamicMethod getMethodCached(ThreadContext context, RubyClass metaclass, int index, String name) {
if (metaclass.getClassIndex() == ClassIndex.NO_INDEX) return metaclass.searchMethod(name);
return context.runtimeCache.getMethod(context, metaclass, metaclass.getClassIndex().ordinal() * (index + 1), name);
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* rb_class_boot for meta classes ({@link #makeMetaClass(RubyClass)})
*/
MetaClass(Ruby runtime, RubyClass superClass, RubyBasicObject attached) {
super(runtime, superClass, false);
this.attached = attached;
// use same ClassIndex as metaclass, since we're technically still of that type
setClassIndex(superClass.getClassIndex());
superClass.addSubclass(this);
}
代码示例来源:origin: org.jruby/jruby-core
/**
* rb_class_boot for meta classes ({@link #makeMetaClass(RubyClass)})
*/
MetaClass(Ruby runtime, RubyClass superClass, RubyBasicObject attached) {
super(runtime, superClass, false);
this.attached = attached;
// use same ClassIndex as metaclass, since we're technically still of that type
setClassIndex(superClass.getClassIndex());
superClass.addSubclass(this);
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Overridden dup for fast-path logic.
*
* @return A new RubyArray sharing the original backing store.
*/
public IRubyObject dup() {
if (metaClass.getClassIndex() != ClassIndex.ARRAY) return super.dup();
RubyArray dup = new RubyArray(metaClass.getClassRuntime(), values, begin, realLength);
dup.isShared = isShared = true;
dup.flags |= flags & TAINTED_F; // from DUP_SETUP
return dup;
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Overridden dup for fast-path logic.
*
* @return A new RubyArray sharing the original backing store.
*/
public IRubyObject dup() {
if (metaClass.getClassIndex() != ClassIndex.ARRAY) return super.dup();
RubyArray dup = new RubyArray(metaClass.getClassRuntime(), values, begin, realLength);
dup.isShared = isShared = true;
dup.flags |= flags & TAINTED_F; // from DUP_SETUP
return dup;
}
代码示例来源:origin: org.jruby/jruby-core
public static boolean f_integer_p(ThreadContext context, RubyNumeric x) {
switch (x.getMetaClass().getClassIndex()) {
case FIXNUM:
case BIGNUM:
return true;
case FLOAT:
case RATIONAL:
case COMPLEX:
return false;
}
return sites(context).integer.call(context, x, x).isTrue();
}
代码示例来源:origin: org.jruby/jruby-complete
public static boolean f_integer_p(ThreadContext context, RubyNumeric x) {
switch (x.getMetaClass().getClassIndex()) {
case FIXNUM:
case BIGNUM:
return true;
case FLOAT:
case RATIONAL:
case COMPLEX:
return false;
}
return sites(context).integer.call(context, x, x).isTrue();
}
代码示例来源:origin: org.jruby/jruby-complete
/** flo_ge
*
*/
@JRubyMethod(name = ">=", required = 1)
public IRubyObject op_ge(ThreadContext context, IRubyObject other) {
switch (other.getMetaClass().getClassIndex()) {
case INTEGER:
case FLOAT:
double b = ((RubyNumeric) other).getDoubleValue();
return RubyBoolean.newBoolean(context.runtime, !Double.isNaN(b) && value >= b);
default:
return coerceRelOp(context, sites(context).op_ge, other);
}
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Overridden dup for fast-path logic.
*
* @return A new RubyString sharing the original backing store.
*/
@Override
public IRubyObject dup() {
RubyClass mc = metaClass.getRealClass();
if (mc.getClassIndex() != ClassIndex.STRING) return super.dup();
return strDup(mc.getClassRuntime(), mc.getRealClass());
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Overridden dup for fast-path logic.
*
* @return A new RubyString sharing the original backing store.
*/
@Override
public IRubyObject dup() {
RubyClass mc = metaClass.getRealClass();
if (mc.getClassIndex() != ClassIndex.STRING) return super.dup();
return strDup(mc.getClassRuntime(), mc.getRealClass());
}
代码示例来源:origin: org.jruby/jruby-core
@Override
public final int compareTo(IRubyObject other) {
switch (other.getMetaClass().getClassIndex()) {
case INTEGER:
case FLOAT:
return Double.compare(value, ((RubyNumeric) other).getDoubleValue());
default:
ThreadContext context = getRuntime().getCurrentContext();
return (int) coerceCmp(context, sites(context).op_cmp, other).convertToInteger().getLongValue();
}
}
代码示例来源:origin: org.jruby/jruby-complete
@Override
public final int compareTo(IRubyObject other) {
switch (other.getMetaClass().getClassIndex()) {
case INTEGER:
case FLOAT:
return Double.compare(value, ((RubyNumeric) other).getDoubleValue());
default:
ThreadContext context = getRuntime().getCurrentContext();
return (int) coerceCmp(context, sites(context).op_cmp, other).convertToInteger().getLongValue();
}
}
代码示例来源:origin: org.jruby/jruby-core
/** flo_minus
*
*/
@JRubyMethod(name = "-", required = 1)
public IRubyObject op_minus(ThreadContext context, IRubyObject other) {
switch (other.getMetaClass().getClassIndex()) {
case INTEGER:
case FLOAT:
return RubyFloat.newFloat(context.runtime, value - ((RubyNumeric) other).getDoubleValue());
default:
return coerceBin(context, sites(context).op_minus, other);
}
}
代码示例来源:origin: org.jruby/jruby-core
/** flo_mul
*
*/
@JRubyMethod(name = "*", required = 1)
public IRubyObject op_mul(ThreadContext context, IRubyObject other) {
switch (other.getMetaClass().getClassIndex()) {
case INTEGER:
case FLOAT:
return RubyFloat.newFloat(context.runtime, value * ((RubyNumeric) other).getDoubleValue());
default:
return coerceBin(context, sites(context).op_times, other);
}
}
代码示例来源:origin: org.jruby/jruby-complete
/** flo_mul
*
*/
@JRubyMethod(name = "*", required = 1)
public IRubyObject op_mul(ThreadContext context, IRubyObject other) {
switch (other.getMetaClass().getClassIndex()) {
case INTEGER:
case FLOAT:
return RubyFloat.newFloat(context.runtime, value * ((RubyNumeric) other).getDoubleValue());
default:
return coerceBin(context, sites(context).op_times, other);
}
}
代码示例来源:origin: org.jruby/jruby-complete
/** flo_plus
*
*/
@JRubyMethod(name = "+", required = 1)
@Override
public IRubyObject op_plus(ThreadContext context, IRubyObject other) {
switch (other.getMetaClass().getClassIndex()) {
case INTEGER:
case FLOAT:
return RubyFloat.newFloat(context.runtime, value + ((RubyNumeric) other).getDoubleValue());
default:
return coerceBin(context, sites(context).op_plus, other);
}
}
代码示例来源:origin: org.jruby/jruby-core
public static void checkType(ThreadContext context, IRubyObject x, final RubyModule type) {
assert x != RubyBasicObject.UNDEF;
ClassIndex xt = x.getMetaClass().getClassIndex();
// MISSING: special error for T_DATA of a certain type
if (xt != type.getClassIndex()) {
Ruby runtime = context.runtime;
throw context.runtime.newTypeError(str(runtime, "wrong argument type ", types(runtime, x.getMetaClass()), " (expected ", types(runtime, type), ")"));
}
}
代码示例来源:origin: org.jruby/jruby-complete
public static void checkType(ThreadContext context, IRubyObject x, final RubyModule type) {
assert x != RubyBasicObject.UNDEF;
ClassIndex xt = x.getMetaClass().getClassIndex();
// MISSING: special error for T_DATA of a certain type
if (xt != type.getClassIndex()) {
Ruby runtime = context.runtime;
throw context.runtime.newTypeError(str(runtime, "wrong argument type ", types(runtime, x.getMetaClass()), " (expected ", types(runtime, type), ")"));
}
}
内容来源于网络,如有侵权,请联系作者删除!