/** * Finds a module that is within the current module (or class). * * @param name to be found in this module (or class) * @return the module or null if no such module * @since 9.2 */ public RubyModule getModule(String name) { return (RubyModule) getConstantAt(name); }
/** * Finds a class that is within the current module (or class). * * @param name to be found in this module (or class) * @return the class or null if no such class */ public RubyClass getClass(String name) { return (RubyClass) getConstantAt(name); }
/** * Finds a class that is within the current module (or class). * * @param name to be found in this module (or class) * @return the class or null if no such class */ public RubyClass getClass(String name) { return (RubyClass) getConstantAt(name); }
/** * Finds a class that is within the current module (or class). * * @param name to be found in this module (or class) * @return the class or null if no such class */ public RubyClass getClass(String name) { IRubyObject module; if ((module = getConstantAt(name)) instanceof RubyClass) { return (RubyClass)module; } return null; }
/** * Finds a module that is within the current module (or class). * * @param name to be found in this module (or class) * @return the module or null if no such module * @since 9.2 */ public RubyModule getModule(String name) { return (RubyModule) getConstantAt(name); }
public IRubyObject getConstantAt(String name) { return getConstantAt(name, true); }
/** * Finds a class that is within the current module (or class). * * @param name to be found in this module (or class) * @return the class or null if no such class */ public RubyClass getClass(String name) { IRubyObject module; if ((module = getConstantAt(name)) instanceof RubyClass) { return (RubyClass)module; } return null; }
@Deprecated public IRubyObject fastGetConstantAt(String internedName) { return getConstantAt(internedName); }
@Deprecated public IRubyObject fastGetConstantAt(String internedName) { return getConstantAt(internedName); }
@Deprecated public IRubyObject fastGetConstantAt(String internedName) { return getConstantAt(internedName); }
private IRubyObject iterateConstantNoConstMissing(String name, RubyModule init, boolean inherit) { for (RubyModule p = init; p != null; p = p.getSuperClass()) { IRubyObject value = p.getConstantAt(name); if (value != null) return value == UNDEF ? null : value; if (!inherit) break; } return null; }
private IRubyObject iterateConstantNoConstMissing(String name, RubyModule init, boolean inherit) { for (RubyModule p = init; p != null; p = p.getSuperClass()) { IRubyObject value = p.getConstantAt(name); if (value != null) return value == UNDEF ? null : value; if (!inherit) break; } return null; }
private static RubyModule getPackageModule(final Ruby runtime, final String name) { final RubyModule javaModule = runtime.getJavaSupport().getJavaModule(); final IRubyObject packageModule = javaModule.getConstantAt(name); if ( packageModule instanceof RubyModule ) return (RubyModule) packageModule; final String packageName; if ( "Default".equals(name) ) packageName = ""; else { Matcher match = CAMEL_CASE_PACKAGE_SPLITTER.matcher(name); packageName = match.replaceAll("$1.$2").toLowerCase(); } return createPackageModule(runtime, javaModule, name, packageName); }
private static RubyModule getPackageModule(final Ruby runtime, final String name) { final RubyModule javaModule = runtime.getJavaSupport().getJavaModule(); final IRubyObject packageModule = javaModule.getConstantAt(name); if ( packageModule instanceof RubyModule ) return (RubyModule) packageModule; final String packageName; if ( "Default".equals(name) ) packageName = ""; else { Matcher match = CAMEL_CASE_PACKAGE_SPLITTER.matcher(name); packageName = match.replaceAll("$1.$2").toLowerCase(); } return createPackageModule(runtime, javaModule, name, packageName); }
void install(final RubyModule proxy) { if (proxy.getConstantAt(field.getName()) == null) { // TODO: catch exception if constant is already set by other // thread try { proxy.setConstant(field.getName(), JavaUtil.convertJavaToUsableRubyObject(proxy.getRuntime(), field.get(null))); } catch (IllegalAccessException iae) { // if we can't read it, we don't set it } } } static boolean isConstant(final Field field) {
void install(final RubyModule proxy) { if (proxy.getConstantAt(field.getName()) == null) { // TODO: catch exception if constant is already set by other // thread try { proxy.setConstant(field.getName(), JavaUtil.convertJavaToUsableRubyObject(proxy.getRuntime(), field.get(null))); } catch (IllegalAccessException iae) { // if we can't read it, we don't set it } } } static boolean isConstant(final Field field) {
void install(final RubyModule proxy) { final String name = field.getName(); if ( proxy.getConstantAt(name) == null ) { try { final Object value = field.get(null); proxy.setConstant(name, JavaUtil.convertJavaToUsableRubyObject(proxy.getRuntime(), value)); } catch (IllegalAccessException iae) { // if we can't read it, we don't set it } } }
void install(final RubyModule proxy) { final String name = field.getName(); if ( proxy.getConstantAt(name) == null ) { try { final Object value = field.get(null); proxy.setConstant(name, JavaUtil.convertJavaToUsableRubyObject(proxy.getRuntime(), value)); } catch (IllegalAccessException iae) { // if we can't read it, we don't set it } } }
protected static RubyThread startWaiterThread(final Ruby runtime, int pid, Block block) { final IRubyObject waiter = runtime.getProcess().getConstantAt("Waiter"); // Process::Waiter final RubyThread rubyThread = new RubyThread(runtime, (RubyClass) waiter); rubyThread.op_aset(runtime.newSymbol("pid"), runtime.newFixnum(pid)); rubyThread.callInit(IRubyObject.NULL_ARRAY, block); return rubyThread; }
protected static RubyThread startWaiterThread(final Ruby runtime, int pid, Block block) { final IRubyObject waiter = runtime.getProcess().getConstantAt("Waiter"); // Process::Waiter final RubyThread rubyThread = new RubyThread(runtime, (RubyClass) waiter); rubyThread.op_aset(runtime.newSymbol("pid"), runtime.newFixnum(pid)); rubyThread.callInit(IRubyObject.NULL_ARRAY, block); return rubyThread; }