/** hash_le_i * */ private boolean hash_le(RubyHash other) { return other.directEntrySet().containsAll(directEntrySet()); }
/** hash_le_i * */ private boolean hash_le(RubyHash other) { return other.directEntrySet().containsAll(directEntrySet()); }
@SuppressWarnings("unchecked") public String[] getEnv() { RubyHash hash = (RubyHash) runtime.getObject().getConstant("ENV"); String[] env = new String[hash.size()]; if (env.length == 0) return env; StringBuilder str = new StringBuilder(); int i=0; for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) { Map.Entry<Object, Object> entry = iter.next(); str.setLength(0); str.append(entry.getKey()).append('=').append(entry.getValue()); env[i] = str.toString(); } return env; }
@SuppressWarnings("unchecked") public String[] getEnv() { RubyHash hash = (RubyHash) runtime.getObject().getConstant("ENV"); String[] env = new String[hash.size()]; if (env.length == 0) return env; StringBuilder str = new StringBuilder(); int i=0; for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) { Map.Entry<Object, Object> entry = iter.next(); str.setLength(0); str.append(entry.getKey()).append('=').append(entry.getValue()); env[i] = str.toString(); } return env; }
@SuppressWarnings("unchecked") public String[] getEnv() { RubyHash hash = (RubyHash) runtime.getObject().getConstant("ENV"); int i=0; String[] env = new String[hash.size()]; for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) { Map.Entry<Object, Object> entry = iter.next(); env[i] = entry.getKey().toString() + "=" + entry.getValue().toString(); } return env; }
@SuppressWarnings("unchecked") public String[] getEnv() { RubyHash hash = (RubyHash) runtime.getObject().getConstant("ENV"); int i=0; String[] env = new String[hash.size()]; for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) { Map.Entry<Object, Object> entry = iter.next(); env[i] = entry.getKey().toString() + "=" + entry.getValue().toString(); } return env; }
private static void buildEnvp(Ruby runtime, ExecArg eargp, IRubyObject envtbl) { String[] envp_str; List<String> envp_buf; envp_buf = new ArrayList(); for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)((RubyHash)envtbl).directEntrySet()) { IRubyObject key = entry.getKey(); IRubyObject val = entry.getValue(); envp_buf.add(StringSupport.checkEmbeddedNulls(runtime, key).toString() + "=" + StringSupport.checkEmbeddedNulls(runtime, val)); } envp_str = new String[envp_buf.size()]; envp_buf.toArray(envp_str); eargp.envp_str = envp_str; eargp.envp_buf = envp_buf; }
private static void buildEnvp(Ruby runtime, ExecArg eargp, IRubyObject envtbl) { String[] envp_str; List<String> envp_buf; envp_buf = new ArrayList(); for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)((RubyHash)envtbl).directEntrySet()) { IRubyObject key = entry.getKey(); IRubyObject val = entry.getValue(); envp_buf.add(StringSupport.checkEmbeddedNulls(runtime, key).toString() + "=" + StringSupport.checkEmbeddedNulls(runtime, val)); } envp_str = new String[envp_buf.size()]; envp_buf.toArray(envp_str); eargp.envp_str = envp_str; eargp.envp_buf = envp_buf; }
private void setupStructValuesFromHash(ThreadContext context, RubyHash kwArgs) { RubyArray __members__ = __member__(); Set<Map.Entry<IRubyObject, IRubyObject>> entries = kwArgs.directEntrySet(); entries.stream().forEach( entry -> { IRubyObject key = entry.getKey(); if (!(key instanceof RubySymbol)) key = context.runtime.newSymbol(key.convertToString().getByteList()); IRubyObject index = __members__.index(context, key); if (index.isNil()) throw context.runtime.newArgumentError("unknown keywords: " + key); values[index.convertToInteger().getIntValue()] = entry.getValue(); }); }
private void setupStructValuesFromHash(ThreadContext context, RubyHash kwArgs) { RubyArray __members__ = __member__(); Set<Map.Entry<IRubyObject, IRubyObject>> entries = kwArgs.directEntrySet(); entries.stream().forEach( entry -> { IRubyObject key = entry.getKey(); if (!(key instanceof RubySymbol)) key = context.runtime.newSymbol(key.convertToString().getByteList()); IRubyObject index = __members__.index(context, key); if (index.isNil()) throw context.runtime.newArgumentError("unknown keywords: " + key); values[index.convertToInteger().getIntValue()] = entry.getValue(); }); }
for (Map.Entry entry : (Set<Map.Entry<Object, Object>>)methodNames.directEntrySet()) { String name = entry.getValue().toString(); if (methods.containsKey(entry.getValue().toString())) {
for (Map.Entry entry : (Set<Map.Entry<Object, Object>>)methodNames.directEntrySet()) { String name = entry.getValue().toString(); if (methods.containsKey(entry.getValue().toString())) {
for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)methodNames.directEntrySet()) { String name = entry.getValue().toString(); if (methods.containsKey(entry.getValue().toString())) {
@JRubyMethod(module = true) public static IRubyObject select(ThreadContext context, IRubyObject self, IRubyObject hash) { Ruby runtime = context.runtime; RubyHash cases = hash.convertToHash(); Set<RubyHash.RubyHashEntry> entries = (Set<RubyHash.RubyHashEntry>)cases.directEntrySet(); Object[] entryArray = entries.toArray(); OUTER: while (true) { for (Object _entry : entryArray) { RubyHash.RubyHashEntry entry = (RubyHash.RubyHashEntry)_entry; IRubyObject _channel = (IRubyObject)entry.getKey(); if (!(_channel instanceof JoChannel)) throw runtime.newTypeError(_channel, runtime.getClassFromPath("Jo::Channel")); IRubyObject _proc = (IRubyObject)entry.getValue(); IRubyObject value; if ((value = ((JoChannel)_channel).queue.poll()) != null) { _proc.callMethod(context, "call", value); break OUTER; } Thread.yield(); } } return context.nil; } }
for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)methodNames.directEntrySet()) { String name = entry.getValue().toString(); if (methods.containsKey(entry.getValue().toString())) {
static IRubyObject handleOptionsCommon(ThreadContext context, Ruby runtime, ExecArg eargp, RubyHash opthash, boolean raise) { if (opthash.isEmpty()) return null; RubyHash nonopts = null; for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)opthash.directEntrySet()) { IRubyObject key = entry.getKey(); IRubyObject val = entry.getValue(); if (execargAddopt(context, runtime, eargp, key, val) != ST_CONTINUE) { if (raise) { if (key instanceof RubySymbol) { switch (key.toString()) { case "gid" : throw runtime.newNotImplementedError("popen does not support :gid option in JRuby"); case "uid" : throw runtime.newNotImplementedError("popen does not support :uid option in JRuby"); default : throw runtime.newArgumentError("wrong exec option symbol: " + key); } } else { throw runtime.newArgumentError("wrong exec option: " + key); } } if (nonopts == null) nonopts = RubyHash.newHash(runtime); nonopts.op_aset(context, key, val); } } return nonopts != null ? nonopts : context.nil; }
static IRubyObject handleOptionsCommon(ThreadContext context, Ruby runtime, ExecArg eargp, RubyHash opthash, boolean raise) { if (opthash.isEmpty()) return null; RubyHash nonopts = null; for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)opthash.directEntrySet()) { IRubyObject key = entry.getKey(); IRubyObject val = entry.getValue(); if (execargAddopt(context, runtime, eargp, key, val) != ST_CONTINUE) { if (raise) { if (key instanceof RubySymbol) { switch (key.toString()) { case "gid" : throw runtime.newNotImplementedError("popen does not support :gid option in JRuby"); case "uid" : throw runtime.newNotImplementedError("popen does not support :uid option in JRuby"); default : throw runtime.newArgumentError("wrong exec option symbol: " + key); } } else { throw runtime.newArgumentError("wrong exec option: " + key); } } if (nonopts == null) nonopts = RubyHash.newHash(runtime); nonopts.op_aset(context, key, val); } } return nonopts != null ? nonopts : context.nil; }
public static RubyArray checkExecEnv(ThreadContext context, RubyHash hash, ExecArg pathArg) { Ruby runtime = context.runtime; RubyArray env; env = runtime.newArray(); for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)hash.directEntrySet()) { IRubyObject key = entry.getKey(); IRubyObject val = entry.getValue(); String k; k = StringSupport.checkEmbeddedNulls(runtime, key).toString(); if (k.indexOf('=') != -1) throw runtime.newArgumentError("environment name contains a equal : " + k); if (!val.isNil()) val = StringSupport.checkEmbeddedNulls(runtime, val); key = key.convertToString().export(context); if (!val.isNil()) val = val.convertToString().export(context); if (key.convertToString().toString().equalsIgnoreCase("PATH")) { pathArg.path_env = val; } env.push(runtime.newArray(key, val)); } return env; }
public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext context) { RubyHash hash = (RubyHash) o; resolver.marshal(hash,writer,context); writer.addAttribute("ruby-class", hash.getType().getName()); for (Entry e : (Set<Entry>)hash.directEntrySet()) { writer.startNode("entry"); writer.startNode("key"); context.convertAnother(e.getKey()); writer.endNode(); writer.startNode("value"); context.convertAnother(e.getValue()); writer.endNode(); writer.endNode(); } }
public static RubyArray checkExecEnv(ThreadContext context, RubyHash hash, ExecArg pathArg) { Ruby runtime = context.runtime; RubyArray env; env = runtime.newArray(); for (Map.Entry<IRubyObject, IRubyObject> entry : (Set<Map.Entry<IRubyObject, IRubyObject>>)hash.directEntrySet()) { IRubyObject key = entry.getKey(); IRubyObject val = entry.getValue(); String k; k = StringSupport.checkEmbeddedNulls(runtime, key).toString(); if (k.indexOf('=') != -1) throw runtime.newArgumentError("environment name contains a equal : " + k); if (!val.isNil()) val = StringSupport.checkEmbeddedNulls(runtime, val); key = key.convertToString().export(context); if (!val.isNil()) val = val.convertToString().export(context); if (key.convertToString().toString().equalsIgnoreCase("PATH")) { pathArg.path_env = val; } env.push(runtime.newArray(key, val)); } return env; }