本文整理了Java中org.jruby.Ruby.defineClassUnder
方法的一些代码示例,展示了Ruby.defineClassUnder
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.defineClassUnder
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:defineClassUnder
[英]Define a new class with the given name under the given module or class namespace. Roughly equivalent to rb_define_class_under in MRI. If the name specified is already bound, its value will be returned if: * It is a class * No new superclass is being defined
[中]在给定的模块或类命名空间下定义一个具有给定名称的新类。大致相当于核磁共振成像中的rb_define_class_。如果指定的名称已绑定,则在以下情况下将返回其值:它是一个类未定义新的超类
代码示例来源:origin: org.jruby/jruby-complete
/** rb_define_class_under
* this method should be used only as an API to define/open nested classes
*/
public RubyClass defineClassUnder(String name, RubyClass superClass, ObjectAllocator allocator) {
return getRuntime().defineClassUnder(name, superClass, allocator, this);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/** rb_define_class_under
* this method should be used only as an API to define/open nested classes
*/
public RubyClass defineClassUnder(String name, RubyClass superClass, ObjectAllocator allocator) {
return getRuntime().defineClassUnder(name, superClass, allocator, this);
}
代码示例来源:origin: org.jruby/jruby-core
/** rb_define_class_under
* this method should be used only as an API to define/open nested classes
*/
public RubyClass defineClassUnder(String name, RubyClass superClass, ObjectAllocator allocator) {
return getRuntime().defineClassUnder(name, superClass, allocator, this);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static void initPsychEmitter(Ruby runtime, RubyModule psych) {
RubyClass psychHandler = runtime.defineClassUnder("Handler", runtime.getObject(), runtime.getObject().getAllocator(), psych);
RubyClass psychEmitter = runtime.defineClassUnder("Emitter", psychHandler, new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
return new PsychEmitter(runtime, klazz);
}
}, psych);
psychEmitter.defineAnnotatedMethods(PsychEmitter.class);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static void initPsychEmitter(Ruby runtime, RubyModule psych) {
RubyClass psychHandler = runtime.defineClassUnder("Handler", runtime.getObject(), runtime.getObject().getAllocator(), psych);
RubyClass psychEmitter = runtime.defineClassUnder("Emitter", psychHandler, new ObjectAllocator() {
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
return new PsychEmitter(runtime, klazz);
}
}, psych);
psychEmitter.defineAnnotatedMethods(PsychEmitter.class);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static void initPsychToRuby(Ruby runtime, RubyModule psych) {
RubyModule visitors = runtime.defineModuleUnder("Visitors", psych);
RubyClass visitor = runtime.defineClassUnder("Visitor", runtime.getObject(), runtime.getObject().getAllocator(), visitors);
RubyClass psychToRuby = runtime.defineClassUnder("ToRuby", visitor, RubyObject.OBJECT_ALLOCATOR, visitors);
psychToRuby.defineAnnotatedMethods(PsychToRuby.class);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static void initPsychToRuby(Ruby runtime, RubyModule psych) {
RubyModule visitors = runtime.defineModuleUnder("Visitors", psych);
RubyClass visitor = runtime.defineClassUnder("Visitor", runtime.getObject(), runtime.getObject().getAllocator(), visitors);
RubyClass psychToRuby = runtime.defineClassUnder("ToRuby", visitor, RubyObject.OBJECT_ALLOCATOR, visitors);
psychToRuby.defineAnnotatedMethods(PsychToRuby.class);
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyClass createFileDescriptorIOClass(Ruby runtime, RubyModule module) {
RubyClass result = runtime.defineClassUnder(CLASS_NAME, runtime.getClass("IO"),
Allocator.INSTANCE, module);
result.defineAnnotatedMethods(FileDescriptorIO.class);
result.defineAnnotatedConstants(FileDescriptorIO.class);
return result;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static RubyClass createFileDescriptorIOClass(Ruby runtime, RubyModule module) {
RubyClass result = runtime.defineClassUnder(CLASS_NAME, runtime.getClass("IO"),
Allocator.INSTANCE, module);
result.defineAnnotatedMethods(FileDescriptorIO.class);
result.defineAnnotatedConstants(FileDescriptorIO.class);
return result;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static void initPsychYamlTree(Ruby runtime, RubyModule psych) {
RubyModule visitors = (RubyModule)psych.getConstant("Visitors");
RubyClass visitor = (RubyClass)visitors.getConstant("Visitor");
RubyClass psychYamlTree = runtime.defineClassUnder("YAMLTree", visitor, RubyObject.OBJECT_ALLOCATOR, visitors);
psychYamlTree.defineAnnotatedMethods(PsychYamlTree.class);
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyClass createFileDescriptorIOClass(Ruby runtime, RubyModule module) {
RubyClass result = runtime.defineClassUnder(CLASS_NAME, runtime.getClass("IO"),
Allocator.INSTANCE, module);
result.defineAnnotatedMethods(FileDescriptorIO.class);
result.defineAnnotatedConstants(FileDescriptorIO.class);
return result;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static RubyClass createYielderClass(Ruby runtime) {
RubyClass yielderc = runtime.defineClassUnder("Yielder", runtime.getObject(), YIELDER_ALLOCATOR, runtime.getEnumerator());
runtime.setYielder(yielderc);
yielderc.index = ClassIndex.YIELDER;
yielderc.kindOf = new RubyModule.JavaClassKindOf(RubyYielder.class);
yielderc.defineAnnotatedMethods(RubyYielder.class);
return yielderc;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static RubyClass createYielderClass(Ruby runtime) {
RubyClass yielderc = runtime.defineClassUnder("Yielder", runtime.getObject(), YIELDER_ALLOCATOR, runtime.getEnumerator());
runtime.setYielder(yielderc);
yielderc.index = ClassIndex.YIELDER;
yielderc.kindOf = new RubyModule.JavaClassKindOf(RubyYielder.class);
yielderc.defineAnnotatedMethods(RubyYielder.class);
return yielderc;
}
代码示例来源: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 void createGeneratorClass(Ruby runtime) {
RubyClass genc = runtime.defineClassUnder("Generator", runtime.getObject(), new ObjectAllocator() {
@Override
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
return new RubyGenerator(runtime, klazz);
}
}, runtime.getEnumerator());
genc.includeModule(runtime.getEnumerable());
genc.defineAnnotatedMethods(RubyGenerator.class);
runtime.setGenerator(genc);
}
代码示例来源:origin: org.jruby/jruby-core
public static void createGeneratorClass(Ruby runtime) {
RubyClass genc = runtime.defineClassUnder("Generator", runtime.getObject(), new ObjectAllocator() {
@Override
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
return new RubyGenerator(runtime, klazz);
}
}, runtime.getEnumerator());
genc.includeModule(runtime.getEnumerable());
genc.defineAnnotatedMethods(RubyGenerator.class);
runtime.setGenerator(genc);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public static RubyClass createConverterClass(Ruby runtime) {
RubyClass converterc = runtime.defineClassUnder("Converter", runtime.getClass("Data"), CONVERTER_ALLOCATOR, runtime.getEncoding());
runtime.setConverter(converterc);
converterc.index = ClassIndex.CONVERTER;
converterc.setReifiedClass(RubyConverter.class);
converterc.kindOf = new RubyModule.JavaClassKindOf(RubyConverter.class);
converterc.defineAnnotatedMethods(RubyConverter.class);
converterc.defineAnnotatedConstants(RubyConverter.class);
return converterc;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public static RubyClass createConverterClass(Ruby runtime) {
RubyClass converterc = runtime.defineClassUnder("Converter", runtime.getClass("Data"), CONVERTER_ALLOCATOR, runtime.getEncoding());
runtime.setConverter(converterc);
converterc.index = ClassIndex.CONVERTER;
converterc.setReifiedClass(RubyConverter.class);
converterc.kindOf = new RubyModule.JavaClassKindOf(RubyConverter.class);
converterc.defineAnnotatedMethods(RubyConverter.class);
converterc.defineAnnotatedConstants(RubyConverter.class);
return converterc;
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyClass createConverterClass(Ruby runtime) {
RubyClass converterc = runtime.defineClassUnder("Converter", runtime.getData(), CONVERTER_ALLOCATOR, runtime.getEncoding());
runtime.setConverter(converterc);
converterc.setClassIndex(ClassIndex.CONVERTER);
converterc.setReifiedClass(RubyConverter.class);
converterc.kindOf = new RubyModule.JavaClassKindOf(RubyConverter.class);
converterc.defineAnnotatedMethods(RubyConverter.class);
converterc.defineAnnotatedConstants(RubyConverter.class);
return converterc;
}
代码示例来源:origin: org.jruby/jruby-core
public static RubyClass createConverterClass(Ruby runtime) {
RubyClass converterc = runtime.defineClassUnder("Converter", runtime.getData(), CONVERTER_ALLOCATOR, runtime.getEncoding());
runtime.setConverter(converterc);
converterc.setClassIndex(ClassIndex.CONVERTER);
converterc.setReifiedClass(RubyConverter.class);
converterc.kindOf = new RubyModule.JavaClassKindOf(RubyConverter.class);
converterc.defineAnnotatedMethods(RubyConverter.class);
converterc.defineAnnotatedConstants(RubyConverter.class);
return converterc;
}
内容来源于网络,如有侵权,请联系作者删除!