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

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

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

RubyClass.setClassIndex介绍

暂无

代码示例

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

/**
 * Will create the Ruby class Object in the runtime
 * specified. This method needs to take the actual class as an
 * argument because of the Object class' central part in runtime
 * initialization.
 */
public static RubyClass createObjectClass(Ruby runtime, RubyClass objectClass) {
  objectClass.setClassIndex(ClassIndex.OBJECT);
  objectClass.setReifiedClass(RubyObject.class);
  return objectClass;
}

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

public static RubyClass createModuleClass(Ruby runtime, RubyClass moduleClass) {
  moduleClass.setClassIndex(ClassIndex.MODULE);
  moduleClass.setReifiedClass(RubyModule.class);
  moduleClass.kindOf = new RubyModule.JavaClassKindOf(RubyModule.class);
  moduleClass.defineAnnotatedMethods(RubyModule.class);
  moduleClass.defineAnnotatedMethods(ModuleKernelMethods.class);
  return moduleClass;
}

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

/**
 * Will create the Ruby class Object in the runtime
 * specified. This method needs to take the actual class as an
 * argument because of the Object class' central part in runtime
 * initialization.
 */
public static RubyClass createBasicObjectClass(Ruby runtime, RubyClass objectClass) {
  objectClass.setClassIndex(ClassIndex.OBJECT);
  objectClass.defineAnnotatedMethods(RubyBasicObject.class);
  recacheBuiltinMethods(runtime);
  return objectClass;
}

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

public static RubyClass createModuleClass(Ruby runtime, RubyClass moduleClass) {
  moduleClass.setClassIndex(ClassIndex.MODULE);
  moduleClass.setReifiedClass(RubyModule.class);
  moduleClass.kindOf = new RubyModule.JavaClassKindOf(RubyModule.class);
  moduleClass.defineAnnotatedMethods(RubyModule.class);
  moduleClass.defineAnnotatedMethods(ModuleKernelMethods.class);
  return moduleClass;
}

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

/**
 * Will create the Ruby class Object in the runtime
 * specified. This method needs to take the actual class as an
 * argument because of the Object class' central part in runtime
 * initialization.
 */
public static RubyClass createBasicObjectClass(Ruby runtime, RubyClass objectClass) {
  objectClass.setClassIndex(ClassIndex.OBJECT);
  objectClass.defineAnnotatedMethods(RubyBasicObject.class);
  recacheBuiltinMethods(runtime);
  return objectClass;
}

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

/**
 * Will create the Ruby class Object in the runtime
 * specified. This method needs to take the actual class as an
 * argument because of the Object class' central part in runtime
 * initialization.
 */
public static RubyClass createObjectClass(Ruby runtime, RubyClass objectClass) {
  objectClass.setClassIndex(ClassIndex.OBJECT);
  objectClass.setReifiedClass(RubyObject.class);
  return objectClass;
}

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

/** Create the RubyMethod class and add it to the Ruby runtime.
 * 
 */
public static RubyClass createMethodClass(Ruby runtime) {
  // TODO: NOT_ALLOCATABLE_ALLOCATOR is probably ok here. Confirm. JRUBY-415
  RubyClass methodClass = runtime.defineClass("Method", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setMethod(methodClass);
  methodClass.setClassIndex(ClassIndex.METHOD);
  methodClass.setReifiedClass(RubyMethod.class);
  methodClass.defineAnnotatedMethods(AbstractRubyMethod.class);
  methodClass.defineAnnotatedMethods(RubyMethod.class);
  
  return methodClass;
}

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

public static RubyClass createYielderClass(Ruby runtime) {
  RubyClass yielderc = runtime.defineClassUnder("Yielder", runtime.getObject(), YIELDER_ALLOCATOR, runtime.getEnumerator());
  runtime.setYielder(yielderc);
  yielderc.setClassIndex(ClassIndex.YIELDER);
  yielderc.kindOf = new RubyModule.JavaClassKindOf(RubyYielder.class);
  yielderc.defineAnnotatedMethods(RubyYielder.class);
  return yielderc;
}

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

public static RubyClass createProcClass(Ruby runtime) {
  RubyClass procClass = runtime.defineClass("Proc", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setProc(procClass);
  procClass.setClassIndex(ClassIndex.PROC);
  procClass.setReifiedClass(RubyProc.class);
  procClass.defineAnnotatedMethods(RubyProc.class);
  return procClass;
}

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

public static RubyClass createYielderClass(Ruby runtime) {
  RubyClass yielderc = runtime.defineClassUnder("Yielder", runtime.getObject(), YIELDER_ALLOCATOR, runtime.getEnumerator());
  runtime.setYielder(yielderc);
  yielderc.setClassIndex(ClassIndex.YIELDER);
  yielderc.kindOf = new RubyModule.JavaClassKindOf(RubyYielder.class);
  yielderc.defineAnnotatedMethods(RubyYielder.class);
  return yielderc;
}

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

/** Create the RubyMethod class and add it to the Ruby runtime.
 * 
 */
public static RubyClass createMethodClass(Ruby runtime) {
  // TODO: NOT_ALLOCATABLE_ALLOCATOR is probably ok here. Confirm. JRUBY-415
  RubyClass methodClass = runtime.defineClass("Method", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setMethod(methodClass);
  methodClass.setClassIndex(ClassIndex.METHOD);
  methodClass.setReifiedClass(RubyMethod.class);
  methodClass.defineAnnotatedMethods(AbstractRubyMethod.class);
  methodClass.defineAnnotatedMethods(RubyMethod.class);
  
  return methodClass;
}

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

public static RubyClass createThreadGroupClass(Ruby runtime) {
  RubyClass threadGroupClass = runtime.defineClass("ThreadGroup", runtime.getObject(), THREADGROUP_ALLOCATOR);
  runtime.setThreadGroup(threadGroupClass);
  threadGroupClass.setClassIndex(ClassIndex.THREADGROUP);
  
  threadGroupClass.defineAnnotatedMethods(RubyThreadGroup.class);
  
  // create the default thread group
  RubyThreadGroup defaultThreadGroup = new RubyThreadGroup(runtime, threadGroupClass);
  runtime.setDefaultThreadGroup(defaultThreadGroup);
  threadGroupClass.defineConstant("Default", defaultThreadGroup);
  return threadGroupClass;
}

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

public static RubyClass createProcClass(Ruby runtime) {
  RubyClass procClass = runtime.defineClass("Proc", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setProc(procClass);
  procClass.setClassIndex(ClassIndex.PROC);
  procClass.setReifiedClass(RubyProc.class);
  procClass.defineAnnotatedMethods(RubyProc.class);
  return procClass;
}

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

public static RubyClass createThreadGroupClass(Ruby runtime) {
  RubyClass threadGroupClass = runtime.defineClass("ThreadGroup", runtime.getObject(), THREADGROUP_ALLOCATOR);
  runtime.setThreadGroup(threadGroupClass);
  threadGroupClass.setClassIndex(ClassIndex.THREADGROUP);
  
  threadGroupClass.defineAnnotatedMethods(RubyThreadGroup.class);
  
  // create the default thread group
  RubyThreadGroup defaultThreadGroup = new RubyThreadGroup(runtime, threadGroupClass);
  runtime.setDefaultThreadGroup(defaultThreadGroup);
  threadGroupClass.defineConstant("Default", defaultThreadGroup);
  return threadGroupClass;
}

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

public static RubyClass createExceptionClass(Ruby runtime) {
  RubyClass exceptionClass = runtime.defineClass("Exception", runtime.getObject(), EXCEPTION_ALLOCATOR);
  runtime.setException(exceptionClass);
  exceptionClass.setClassIndex(ClassIndex.EXCEPTION);
  exceptionClass.setReifiedClass(RubyException.class);
  exceptionClass.setMarshal(EXCEPTION_MARSHAL);
  exceptionClass.defineAnnotatedMethods(RubyException.class);
  return exceptionClass;
}

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

public static RubyClass createExceptionClass(Ruby runtime) {
  RubyClass exceptionClass = runtime.defineClass("Exception", runtime.getObject(), EXCEPTION_ALLOCATOR);
  runtime.setException(exceptionClass);
  exceptionClass.setClassIndex(ClassIndex.EXCEPTION);
  exceptionClass.setReifiedClass(RubyException.class);
  exceptionClass.setMarshal(EXCEPTION_MARSHAL);
  exceptionClass.defineAnnotatedMethods(RubyException.class);
  return exceptionClass;
}

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

public static RubyClass createTrueClass(Ruby runtime) {
  RubyClass trueClass = runtime.defineClass("TrueClass", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setTrueClass(trueClass);
  trueClass.setClassIndex(ClassIndex.TRUE);
  trueClass.setReifiedClass(RubyBoolean.class);
  
  trueClass.defineAnnotatedMethods(True.class);
  trueClass.defineAnnotatedMethods(RubyBoolean.class);
  
  trueClass.getMetaClass().undefineMethod("new");
  return trueClass;
}

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

public static RubyClass defineUnboundMethodClass(Ruby runtime) {
  RubyClass newClass = 
    runtime.defineClass("UnboundMethod", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setUnboundMethod(newClass);
  newClass.setClassIndex(ClassIndex.UNBOUNDMETHOD);
  newClass.setReifiedClass(RubyUnboundMethod.class);
  newClass.defineAnnotatedMethods(AbstractRubyMethod.class);
  newClass.defineAnnotatedMethods(RubyUnboundMethod.class);
  newClass.getSingletonClass().undefineMethod("new");
  return newClass;
}

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

public static RubyClass defineUnboundMethodClass(Ruby runtime) {
  RubyClass newClass = 
    runtime.defineClass("UnboundMethod", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setUnboundMethod(newClass);
  newClass.setClassIndex(ClassIndex.UNBOUNDMETHOD);
  newClass.setReifiedClass(RubyUnboundMethod.class);
  newClass.defineAnnotatedMethods(AbstractRubyMethod.class);
  newClass.defineAnnotatedMethods(RubyUnboundMethod.class);
  newClass.getSingletonClass().undefineMethod("new");
  return newClass;
}

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

public static RubyClass createFalseClass(Ruby runtime) {
  RubyClass falseClass = runtime.defineClass("FalseClass", runtime.getObject(), ObjectAllocator.NOT_ALLOCATABLE_ALLOCATOR);
  runtime.setFalseClass(falseClass);
  falseClass.setClassIndex(ClassIndex.FALSE);
  falseClass.setReifiedClass(RubyBoolean.class);
  
  falseClass.defineAnnotatedMethods(False.class);
  falseClass.defineAnnotatedMethods(RubyBoolean.class);
  falseClass.getMetaClass().undefineMethod("new");
  return falseClass;
}

相关文章

微信公众号

最新文章

更多

RubyClass类方法