本文整理了Java中org.jruby.RubyModule.defineOrGetModuleUnder
方法的一些代码示例,展示了RubyModule.defineOrGetModuleUnder
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyModule.defineOrGetModuleUnder
方法的具体详情如下:
包路径:org.jruby.RubyModule
类名称:RubyModule
方法名:defineOrGetModuleUnder
[英]this method should be used only by interpreter or compiler
[中]此方法只能由解释器或编译器使用
代码示例来源:origin: asciidoctor/asciidoctorj
/**
* Returns the Ruby module Asciidoc::Extensions.
* @param rubyRuntime
* @return The Ruby object for the module Asciidoc::Extensions.
*/
private static RubyModule getExtensionsModule(Ruby rubyRuntime) {
RubyModule asciidoctorModule = rubyRuntime.getModule("Asciidoctor");
return asciidoctorModule.defineOrGetModuleUnder("Extensions");
}
代码示例来源:origin: asciidoctor/asciidoctorj
private RubyModule getExtensionsModule() {
return getAsciidoctorModule()
.defineOrGetModuleUnder("Extensions");
}
代码示例来源:origin: org.asciidoctor/asciidoctorj
/**
* Returns the Ruby module Asciidoc::Extensions.
* @param rubyRuntime
* @return The Ruby object for the module Asciidoc::Extensions.
*/
private static RubyModule getExtensionsModule(Ruby rubyRuntime) {
RubyModule asciidoctorModule = rubyRuntime.getModule("Asciidoctor");
return asciidoctorModule.defineOrGetModuleUnder("Extensions");
}
代码示例来源:origin: org.asciidoctor/asciidoctorj
private RubyModule getExtensionsModule() {
return getAsciidoctorModule()
.defineOrGetModuleUnder("Extensions");
}
代码示例来源:origin: asciidoctor/asciidoctorj
private RubyClass getConverterFactory() {
return rubyRuntime.getModule("Asciidoctor")
.defineOrGetModuleUnder("Converter")
.getClass("Factory");
}
代码示例来源:origin: org.asciidoctor/asciidoctorj
private RubyClass getConverterFactory() {
return rubyRuntime.getModule("Asciidoctor")
.defineOrGetModuleUnder("Converter")
.getClass("Factory");
}
代码示例来源:origin: asciidoctor/asciidoctorj
private static void includeModule(RubyClass clazz, String moduleName, String... moduleNames) {
RubyModule module = clazz.getRuntime().getModule(moduleName);
if (moduleNames != null && moduleNames.length > 0) {
for (String submoduleName: moduleNames) {
module = module.defineOrGetModuleUnder(submoduleName);
}
}
clazz.includeModule(module);
}
代码示例来源:origin: org.asciidoctor/asciidoctorj
private static void includeModule(RubyClass clazz, String moduleName, String... moduleNames) {
RubyModule module = clazz.getRuntime().getModule(moduleName);
if (moduleNames != null && moduleNames.length > 0) {
for (String submoduleName: moduleNames) {
module = module.defineOrGetModuleUnder(submoduleName);
}
}
clazz.includeModule(module);
}
代码示例来源:origin: org.jruby/jruby-complete
private static RubyModule newRubyModuleFromIR(ThreadContext context, IRScope irModule, Object rubyContainer) {
if (!(rubyContainer instanceof RubyModule)) {
throw context.runtime.newTypeError("no outer class/module");
}
RubyModule newRubyModule = ((RubyModule) rubyContainer).defineOrGetModuleUnder(irModule.getId());
irModule.getStaticScope().setModule(newRubyModule);
return newRubyModule;
}
代码示例来源:origin: org.jruby/jruby-core
private static RubyModule newRubyModuleFromIR(ThreadContext context, IRScope irModule, Object rubyContainer) {
if (!(rubyContainer instanceof RubyModule)) {
throw context.runtime.newTypeError("no outer class/module");
}
RubyModule newRubyModule = ((RubyModule) rubyContainer).defineOrGetModuleUnder(irModule.getId());
irModule.getStaticScope().setModule(newRubyModule);
return newRubyModule;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@Override
public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
RubyModule enclosingModule = cpath.getEnclosingModule(runtime, context, self, aBlock);
if (enclosingModule == null) throw runtime.newTypeError("no outer class/module");
String name = cpath.getName();
RubyModule module = enclosingModule.defineOrGetModuleUnder(name);
scope.setModule(module);
return ASTInterpreter.evalClassDefinitionBody(runtime, context, scope, bodyNode, module, self, aBlock);
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@Override
public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
RubyModule enclosingModule = cpath.getEnclosingModule(runtime, context, self, aBlock);
if (enclosingModule == null) throw runtime.newTypeError("no outer class/module");
String name = cpath.getName();
RubyModule module = enclosingModule.defineOrGetModuleUnder(name);
scope.setModule(module);
return ASTInterpreter.evalClassDefinitionBody(runtime, context, scope, bodyNode, module, self, aBlock);
}
}
代码示例来源:origin: asciidoctor/asciidoctorj
public static void install(final Ruby runtime, final LogHandler logHandler) {
final RubyModule asciidoctorModule = runtime.getModule("Asciidoctor");
final RubyModule loggerManager = asciidoctorModule.defineOrGetModuleUnder("LoggerManager");
final RubyClass loggerBaseClass = asciidoctorModule.getClass("Logger");
final RubyClass loggerClass = asciidoctorModule
.defineOrGetModuleUnder("LoggerManager")
.defineClassUnder("JavaLogger", loggerBaseClass, new ObjectAllocator() {
@Override
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
return new JavaLogger(runtime, klazz, logHandler);
}
});
loggerClass.defineAnnotatedMethods(JavaLogger.class);
final IRubyObject logger = loggerClass.allocate();
logger.callMethod(runtime.getCurrentContext(), "initialize", runtime.getNil());
loggerManager.callMethod("logger=", logger);
}
代码示例来源:origin: org.asciidoctor/asciidoctorj
public static void install(final Ruby runtime, final LogHandler logHandler) {
final RubyModule asciidoctorModule = runtime.getModule("Asciidoctor");
final RubyModule loggerManager = asciidoctorModule.defineOrGetModuleUnder("LoggerManager");
final RubyClass loggerBaseClass = asciidoctorModule.getClass("Logger");
final RubyClass loggerClass = asciidoctorModule
.defineOrGetModuleUnder("LoggerManager")
.defineClassUnder("JavaLogger", loggerBaseClass, new ObjectAllocator() {
@Override
public IRubyObject allocate(Ruby runtime, RubyClass klazz) {
return new JavaLogger(runtime, klazz, logHandler);
}
});
loggerClass.defineAnnotatedMethods(JavaLogger.class);
final IRubyObject logger = loggerClass.allocate();
logger.callMethod(runtime.getCurrentContext(), "initialize", runtime.getNil());
loggerManager.callMethod("logger=", logger);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@Override
public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) {
Object rubyContainer = container.retrieve(context, self, currDynScope, temp);
if (!(rubyContainer instanceof RubyModule)) {
throw context.runtime.newTypeError("no outer class/module");
}
RubyModule newRubyModule = ((RubyModule) rubyContainer).defineOrGetModuleUnder(newIRModuleBody.getName());
newIRModuleBody.getStaticScope().setModule(newRubyModule);
return new InterpretedIRMethod(newIRModuleBody, Visibility.PUBLIC, newRubyModule);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@Override
public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block block) {
Object rubyContainer = container.retrieve(context, self, currDynScope, temp);
if (!(rubyContainer instanceof RubyModule)) {
throw context.runtime.newTypeError("no outer class/module");
}
RubyModule newRubyModule = ((RubyModule) rubyContainer).defineOrGetModuleUnder(newIRModuleBody.getName());
newIRModuleBody.getStaticScope().setModule(newRubyModule);
return new InterpretedIRMethod(newIRModuleBody, Visibility.PUBLIC, newRubyModule);
}
内容来源于网络,如有侵权,请联系作者删除!