private static IRubyObject getInternalVariable(RubyClass type, String internedName) { RubyClass structClass = type.getRuntime().getStructClass(); IRubyObject variable; while (type != null && type != structClass) { if ((variable = (IRubyObject)type.getInternalVariable(internedName)) != null) { return variable; } type = type.getSuperClass(); } return type.getRuntime().getNil(); }
private static IRubyObject getInternalVariable(RubyClass type, String internedName) { RubyClass structClass = type.getRuntime().getStructClass(); IRubyObject variable; while (type != null && type != structClass) { if ((variable = (IRubyObject)type.getInternalVariable(internedName)) != null) { return variable; } type = type.getSuperClass(); } return type.getRuntime().getNil(); }
private static IRubyObject getInternalVariable(RubyClass type, String internedName) { RubyClass structClass = type.getRuntime().getStructClass(); IRubyObject variable; while (type != null && type != structClass) { if ((variable = (IRubyObject)type.getInternalVariable(internedName)) != null) { return variable; } type = type.getSuperClass(); } return type.getRuntime().getNil(); }
public static RubyClass defineProcessorClass(Ruby rubyRuntime, String baseClassName, ObjectAllocator objectAllocator) { RubyClass baseClass = getExtensionBaseClass(rubyRuntime, baseClassName); final String rubyClassName = "JavaExtensionProxy_" + extensionCounter.getAndIncrement(); return getExtensionsModule(baseClass.getRuntime()).defineClassUnder(rubyClassName, baseClass, objectAllocator); }
public static RubyClass defineProcessorClass(Ruby rubyRuntime, String baseClassName, JRubyAsciidoctorObjectAllocator objectAllocator) { RubyClass baseClass = getExtensionBaseClass(rubyRuntime, baseClassName); final String rubyClassName = "JavaExtensionProxy_" + extensionCounter.getAndIncrement(); return getExtensionsModule(baseClass.getRuntime()).defineClassUnder(rubyClassName, baseClass, objectAllocator); }
private static void handleContentModelAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(ContentModel.class)) { ContentModel contentModel = processor.getAnnotation(ContentModel.class); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("content_model"), rubyRuntime.newSymbol(contentModel.value().substring(1)) }); } }
private static void handleContentModelAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(ContentModel.class)) { ContentModel contentModel = processor.getAnnotation(ContentModel.class); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("content_model"), rubyRuntime.newSymbol(contentModel.value().substring(1)) }); } }
private static void handleNameAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(Name.class)) { Name name = processor.getAnnotation(Name.class); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("name"), rubyRuntime.newString(name.value()) }); } }
public void becomeSynchronized() { // make this class and all subclasses sync synchronized (getRuntime().getHierarchyLock()) { super.becomeSynchronized(); Set<RubyClass> mySubclasses = subclasses; if (mySubclasses != null) for (RubyClass subclass : mySubclasses) { subclass.becomeSynchronized(); } } }
private static void handleLocationAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(Location.class)) { Location location = processor.getAnnotation(Location.class); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("location"), rubyRuntime.newSymbol(location.value().optionValue().substring(1)) }); } }
private static void handleLocationAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(Location.class)) { Location location = processor.getAnnotation(Location.class); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("location"), rubyRuntime.newSymbol(location.value().optionValue().substring(1)) }); } }
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 handleNameAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(Name.class)) { Name name = processor.getAnnotation(Name.class); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("name"), rubyRuntime.newString(name.value()) }); } }
public void becomeSynchronized() { // make this class and all subclasses sync synchronized (getRuntime().getHierarchyLock()) { super.becomeSynchronized(); Set<RubyClass> mySubclasses = subclasses; if (mySubclasses != null) for (RubyClass subclass : mySubclasses) { subclass.becomeSynchronized(); } } }
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 handleDefaultAttributeAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(DefaultAttribute.class)) { DefaultAttribute defaultAttribute = processor.getAnnotation(DefaultAttribute.class); RubyHash defaultAttrs = RubyHash.newHash(rubyRuntime); defaultAttrs.put(defaultAttribute.key(), defaultAttribute.value()); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("default_attrs"), defaultAttrs }); } }
private static void handleDefaultAttributeAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) { Ruby rubyRuntime = rubyClass.getRuntime(); if (processor.isAnnotationPresent(DefaultAttribute.class)) { DefaultAttribute defaultAttribute = processor.getAnnotation(DefaultAttribute.class); RubyHash defaultAttrs = RubyHash.newHash(rubyRuntime); defaultAttrs.put(defaultAttribute.key(), defaultAttribute.value()); rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{ rubyRuntime.newSymbol("default_attrs"), defaultAttrs }); } }
/** rb_class_inherited (reversed semantics!) * */ public void inherit(RubyClass superClazz) { if (superClazz == null) superClazz = runtime.getObject(); if (getRuntime().getNil() != null) { superClazz.invokeInherited(runtime.getCurrentContext(), superClazz, this); } }
/** rb_class_inherited (reversed semantics!) * */ public void inherit(RubyClass superClazz) { if (superClazz == null) superClazz = runtime.getObject(); if (getRuntime().getNil() != null) { superClazz.invokeInherited(runtime.getCurrentContext(), superClazz, this); } }
/** rb_class_inherited (reversed semantics!) * */ public void inherit(RubyClass superClazz) { if (superClazz == null) superClazz = runtime.getObject(); if (getRuntime().getNil() != null) { superClazz.invokeInherited(runtime.getCurrentContext(), superClazz, this); } }