Mercurial Hosting > luan
diff src/luan/modules/IoLuan.java @ 1257:e38f5869e9df
don't reset in send_redirect and other improvements
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 20 Sep 2018 21:04:41 -0600 |
parents | ddd2ec2c0769 |
children | 9fa8b8389578 |
line wrap: on
line diff
--- a/src/luan/modules/IoLuan.java Wed Sep 19 20:15:16 2018 -0600 +++ b/src/luan/modules/IoLuan.java Thu Sep 20 21:04:41 2018 -0600 @@ -55,6 +55,7 @@ public interface LuanWriter { + public Object out(); public void write(LuanState luan,Object... args) throws LuanException, IOException; public void close() throws IOException; } @@ -62,6 +63,10 @@ private static LuanWriter luanWriter(final PrintStream out) { return new LuanWriter() { + public Object out() { + return out; + } + public void write(LuanState luan,Object... args) throws LuanException { for( Object obj : args ) { out.print( luan.toString(obj) ); @@ -81,6 +86,10 @@ private static LuanWriter luanWriter(final Writer out) { return new LuanWriter() { + public Object out() { + return out; + } + public void write(LuanState luan,Object... args) throws LuanException, IOException { for( Object obj : args ) { out.write( luan.toString(obj) ); @@ -99,6 +108,7 @@ private static LuanTable writer(LuanWriter luanWriter) { LuanTable writer = new LuanTable(); + writer.rawPut( "java", luanWriter.out() ); try { writer.rawPut( "write", new LuanJavaFunction( LuanWriter.class.getMethod( "write", LuanState.class, new Object[0].getClass() ), luanWriter @@ -115,6 +125,7 @@ public static LuanTable binaryWriter(final OutputStream out) { LuanTable writer = new LuanTable(); + writer.rawPut( "java", out ); try { writer.rawPut( "write", new LuanJavaFunction( OutputStream.class.getMethod( "write", new byte[0].getClass() ), out @@ -442,6 +453,10 @@ @Override public LuanTable text_writer() throws IOException { LuanWriter luanWriter = new LuanWriter() { private final Writer out = new StringWriter(); + + public Object out() { + return out; + } public void write(LuanState luan,Object... args) throws LuanException, IOException { for( Object obj : args ) {