/** * 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"); }
private RubyModule getExtensionsModule() { return getAsciidoctorModule() .defineOrGetModuleUnder("Extensions"); }
/** * 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"); }
private RubyModule getExtensionsModule() { return getAsciidoctorModule() .defineOrGetModuleUnder("Extensions"); }
private RubyClass getConverterFactory() { return rubyRuntime.getModule("Asciidoctor") .defineOrGetModuleUnder("Converter") .getClass("Factory"); }
private RubyClass getConverterFactory() { return rubyRuntime.getModule("Asciidoctor") .defineOrGetModuleUnder("Converter") .getClass("Factory"); }
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); }
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); }
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; }
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; }
@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); } }
@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); } }
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); }
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); }
@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); }
@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); }