Mercurial Hosting > luan
diff core/src/luan/modules/IoLuan.java @ 427:dae264ad6a7b
fix LuanTable.put() to use metatables
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 01 May 2015 19:29:07 -0600 |
parents | 23a93c118042 |
children | 3ffe8ba5b297 |
line wrap: on
line diff
--- a/core/src/luan/modules/IoLuan.java Fri May 01 18:44:20 2015 -0600 +++ b/core/src/luan/modules/IoLuan.java Fri May 01 19:29:07 2015 -0600 @@ -38,7 +38,7 @@ public final class IoLuan { private static void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { - t.put( method, new LuanJavaFunction(IoLuan.class.getMethod(method,parameterTypes),null) ); + t.rawPut( method, new LuanJavaFunction(IoLuan.class.getMethod(method,parameterTypes),null) ); } public static String read_console_line(String prompt) throws IOException { @@ -88,10 +88,10 @@ private static LuanTable writer(LuanWriter luanWriter) { LuanTable writer = new LuanTable(); try { - writer.put( "write", new LuanJavaFunction( + writer.rawPut( "write", new LuanJavaFunction( LuanWriter.class.getMethod( "write", LuanState.class, new Object[0].getClass() ), luanWriter ) ); - writer.put( "close", new LuanJavaFunction( + writer.rawPut( "close", new LuanJavaFunction( LuanWriter.class.getMethod( "close" ), luanWriter ) ); } catch(NoSuchMethodException e) { @@ -104,10 +104,10 @@ public static LuanTable binaryWriter(final OutputStream out) { LuanTable writer = new LuanTable(); try { - writer.put( "write", new LuanJavaFunction( + writer.rawPut( "write", new LuanJavaFunction( OutputStream.class.getMethod( "write", new byte[0].getClass() ), out ) ); - writer.put( "close", new LuanJavaFunction( + writer.rawPut( "close", new LuanJavaFunction( OutputStream.class.getMethod( "close" ), out ) ); } catch(NoSuchMethodException e) { @@ -206,22 +206,22 @@ public LuanTable table() { LuanTable tbl = new LuanTable(); try { - tbl.put( "to_string", new LuanJavaFunction( + tbl.rawPut( "to_string", new LuanJavaFunction( LuanIn.class.getMethod( "to_string" ), this ) ); - tbl.put( "read_text", new LuanJavaFunction( + tbl.rawPut( "read_text", new LuanJavaFunction( LuanIn.class.getMethod( "read_text" ), this ) ); - tbl.put( "read_binary", new LuanJavaFunction( + tbl.rawPut( "read_binary", new LuanJavaFunction( LuanIn.class.getMethod( "read_binary" ), this ) ); - tbl.put( "read_lines", new LuanJavaFunction( + tbl.rawPut( "read_lines", new LuanJavaFunction( LuanIn.class.getMethod( "read_lines" ), this ) ); - tbl.put( "read_blocks", new LuanJavaFunction( + tbl.rawPut( "read_blocks", new LuanJavaFunction( LuanIn.class.getMethod( "read_blocks", Integer.class ), this ) ); - tbl.put( "exists", new LuanJavaFunction( + tbl.rawPut( "exists", new LuanJavaFunction( LuanIn.class.getMethod( "exists" ), this ) ); } catch(NoSuchMethodException e) { @@ -286,13 +286,13 @@ @Override public LuanTable table() { LuanTable tbl = super.table(); try { - tbl.put( "write", new LuanJavaFunction( + tbl.rawPut( "write", new LuanJavaFunction( LuanIO.class.getMethod( "write", LuanState.class, Object.class ), this ) ); - tbl.put( "text_writer", new LuanJavaFunction( + tbl.rawPut( "text_writer", new LuanJavaFunction( LuanIO.class.getMethod( "text_writer" ), this ) ); - tbl.put( "binary_writer", new LuanJavaFunction( + tbl.rawPut( "binary_writer", new LuanJavaFunction( LuanIO.class.getMethod( "binary_writer" ), this ) ); } catch(NoSuchMethodException e) { @@ -373,7 +373,7 @@ @Override public LuanTable table() { LuanTable tbl = super.table(); try { - tbl.put( "post", new LuanJavaFunction( + tbl.rawPut( "post", new LuanJavaFunction( LuanUrl.class.getMethod( "post", String.class ), this ) ); } catch(NoSuchMethodException e) { @@ -444,40 +444,40 @@ @Override public LuanTable table() { LuanTable tbl = super.table(); try { - tbl.put( "name", new LuanJavaFunction( + tbl.rawPut( "name", new LuanJavaFunction( File.class.getMethod( "getName" ), file ) ); - tbl.put( "is_directory", new LuanJavaFunction( + tbl.rawPut( "is_directory", new LuanJavaFunction( File.class.getMethod( "isDirectory" ), file ) ); - tbl.put( "is_file", new LuanJavaFunction( + tbl.rawPut( "is_file", new LuanJavaFunction( File.class.getMethod( "isFile" ), file ) ); - tbl.put( "delete", new LuanJavaFunction( + tbl.rawPut( "delete", new LuanJavaFunction( File.class.getMethod( "delete" ), file ) ); - tbl.put( "mkdir", new LuanJavaFunction( + tbl.rawPut( "mkdir", new LuanJavaFunction( File.class.getMethod( "mkdir" ), file ) ); - tbl.put( "mkdirs", new LuanJavaFunction( + tbl.rawPut( "mkdirs", new LuanJavaFunction( File.class.getMethod( "mkdirs" ), file ) ); - tbl.put( "last_modified", new LuanJavaFunction( + tbl.rawPut( "last_modified", new LuanJavaFunction( File.class.getMethod( "lastModified" ), file ) ); - tbl.put( "child", new LuanJavaFunction( + tbl.rawPut( "child", new LuanJavaFunction( LuanFile.class.getMethod( "child", LuanState.class, String.class ), this ) ); - tbl.put( "children", new LuanJavaFunction( + tbl.rawPut( "children", new LuanJavaFunction( LuanFile.class.getMethod( "children", LuanState.class ), this ) ); - tbl.put( "parent", new LuanJavaFunction( + tbl.rawPut( "parent", new LuanJavaFunction( LuanFile.class.getMethod( "parent", LuanState.class ), this ) ); - tbl.put( "rename_to", new LuanJavaFunction( + tbl.rawPut( "rename_to", new LuanJavaFunction( LuanFile.class.getMethod( "rename_to", String.class ), this ) ); - tbl.put( "canonical", new LuanJavaFunction( + tbl.rawPut( "canonical", new LuanJavaFunction( LuanFile.class.getMethod( "canonical", LuanState.class ), this ) ); } catch(NoSuchMethodException e) { @@ -627,10 +627,10 @@ @Override public LuanTable table() { LuanTable tbl = super.table(); try { - tbl.put( "Pickle_client", new LuanJavaFunction( + tbl.rawPut( "Pickle_client", new LuanJavaFunction( LuanSocket.class.getMethod( "Pickle_client", LuanState.class ), this ) ); - tbl.put( "run_pickle_server", new LuanJavaFunction( + tbl.rawPut( "run_pickle_server", new LuanJavaFunction( LuanSocket.class.getMethod( "run_pickle_server", LuanState.class ), this ) ); } catch(NoSuchMethodException e) { @@ -685,7 +685,7 @@ } public static void setSecurity(LuanState luan,Security s) { - luan.registry().put(SECURITY_KEY,s); + luan.registry().rawPut(SECURITY_KEY,s); } private void IoLuan() {} // never