Not at all. So, I created a new issue. -Yoko
On 10/30/07, Nick Sieger <[EMAIL PROTECTED]> wrote: > Would you mind attaching this patch to a new issue at > http://jira.codehaus.org/browse/JRUBY so we don't lose it? > > Thanks, > /Nick > > On 10/29/07, Yoko Harada <[EMAIL PROTECTED]> wrote: > > Sorry, again. The attachment doesn't show up, so I put the patch in > > this message. > > > > --- src/org/jruby/javasupport/.svn/text-base/JavaEmbedUtils.java.svn-base > > 2007-10-29 > > 13:40:19.000000000 -0400 > > +++ src/org/jruby/javasupport/JavaEmbedUtils.java 2007-10-29 > > 16:11:43.000000000 -0400 > > @@ -28,10 +28,18 @@ package org.jruby.javasupport; > > * the terms of any one of the CPL, the GPL or the LGPL. > > ***** END LICENSE BLOCK *****/ > > > > +import java.io.File; > > +import java.io.FileInputStream; > > +import java.io.FileNotFoundException; > > +import java.io.IOException; > > +import java.io.InputStream; > > +import java.io.Reader; > > import java.util.List; > > > > import org.jruby.Ruby; > > +import org.jruby.ast.Node; > > import org.jruby.runtime.Block; > > +import org.jruby.runtime.DynamicScope; > > import org.jruby.runtime.ThreadContext; > > import org.jruby.runtime.builtin.IRubyObject; > > > > @@ -146,4 +154,46 @@ public class JavaEmbedUtils { > > public static IRubyObject javaToRuby(Ruby runtime, short value) { > > return javaToRuby(runtime, new Short(value)); > > } > > + > > + public static Node parse(Ruby runtime, String script) { > > + return parse(runtime, script, "<script>", > > runtime.getCurrentContext().getCurrentScope()); > > + } > > + public static Node parse(Ruby runtime, String script, String filename) > > { > > + return parse(runtime, script, filename, > > runtime.getCurrentContext().getCurrentScope()); > > + } > > + public static Node parse(Ruby runtime, String script, String > > filename, DynamicScope scope) { > > + return runtime.parseEval(script, filename, scope, 0); > > + } > > + public static Node parse(Ruby runtime, Reader reader) throws > > IOException { > > + String script = getScriptFromReader(reader); > > + return parse(runtime, script, "<script>", > > runtime.getCurrentContext().getCurrentScope()); > > + } > > + public static Node parse(Ruby runtime, Reader reader, String > > filename) throws IOException { > > + if (filename == null) return parse(runtime, reader); > > + return parse(runtime, reader, filename, > > runtime.getCurrentContext().getCurrentScope()); > > + } > > + public static Node parse(Ruby runtime, Reader reader, String > > filename, DynamicScope scope) throws IOException { > > + if (filename == null) return parse(runtime, reader); > > + InputStream iStream = getInputStreamFromFile(filename); > > + return runtime.parseFile(iStream, filename, scope); > > + } > > + > > + private static String getScriptFromReader(Reader reader) throws > > IOException { > > + StringBuffer sb = new StringBuffer(); > > + char[] cbuf; > > + while (true) { > > + cbuf = new char[256]; > > + int chars = reader.read(cbuf); > > + if (chars < 0) { > > + break; > > + } > > + sb.append(cbuf); > > + } > > + cbuf = null; > > + return new String(sb); > > + } > > + > > + private static InputStream getInputStreamFromFile(String > > filename) throws FileNotFoundException { > > + return new FileInputStream(new File(filename)); > > + } > > } > > > > > > -Yoko > > > > --------------------------------------------------------------------- > > To unsubscribe from this list please visit: > > > > http://xircles.codehaus.org/manage_email > > > > > > --------------------------------------------------------------------- > To unsubscribe from this list please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
