Mercurial Hosting > luan
comparison core/src/luan/modules/IoLuan.java @ 411:23b99a5039b5
remove Luan.newTable()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 29 Apr 2015 16:05:02 -0600 |
parents | cd2924a1052c |
children | b31d614343e8 |
comparison
equal
deleted
inserted
replaced
410:0d6098a29b3e | 411:23b99a5039b5 |
---|---|
83 }; | 83 }; |
84 return writer(luanWriter); | 84 return writer(luanWriter); |
85 } | 85 } |
86 | 86 |
87 private static LuanTable writer(LuanWriter luanWriter) { | 87 private static LuanTable writer(LuanWriter luanWriter) { |
88 LuanTable writer = Luan.newTable(); | 88 LuanTable writer = new LuanTable(); |
89 try { | 89 try { |
90 writer.put( "write", new LuanJavaFunction( | 90 writer.put( "write", new LuanJavaFunction( |
91 LuanWriter.class.getMethod( "write", LuanState.class, new Object[0].getClass() ), luanWriter | 91 LuanWriter.class.getMethod( "write", LuanState.class, new Object[0].getClass() ), luanWriter |
92 ) ); | 92 ) ); |
93 writer.put( "close", new LuanJavaFunction( | 93 writer.put( "close", new LuanJavaFunction( |
99 return writer; | 99 return writer; |
100 } | 100 } |
101 | 101 |
102 | 102 |
103 public static LuanTable binaryWriter(final OutputStream out) { | 103 public static LuanTable binaryWriter(final OutputStream out) { |
104 LuanTable writer = Luan.newTable(); | 104 LuanTable writer = new LuanTable(); |
105 try { | 105 try { |
106 writer.put( "write", new LuanJavaFunction( | 106 writer.put( "write", new LuanJavaFunction( |
107 OutputStream.class.getMethod( "write", new byte[0].getClass() ), out | 107 OutputStream.class.getMethod( "write", new byte[0].getClass() ), out |
108 ) ); | 108 ) ); |
109 writer.put( "close", new LuanJavaFunction( | 109 writer.put( "close", new LuanJavaFunction( |
201 return false; | 201 return false; |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 public LuanTable table() { | 205 public LuanTable table() { |
206 LuanTable tbl = Luan.newTable(); | 206 LuanTable tbl = new LuanTable(); |
207 try { | 207 try { |
208 tbl.put( "to_string", new LuanJavaFunction( | 208 tbl.put( "to_string", new LuanJavaFunction( |
209 LuanIn.class.getMethod( "to_string" ), this | 209 LuanIn.class.getMethod( "to_string" ), this |
210 ) ); | 210 ) ); |
211 tbl.put( "read_text", new LuanJavaFunction( | 211 tbl.put( "read_text", new LuanJavaFunction( |
391 | 391 |
392 public LuanTable children(LuanState luan) throws LuanException { | 392 public LuanTable children(LuanState luan) throws LuanException { |
393 File[] files = file.listFiles(); | 393 File[] files = file.listFiles(); |
394 if( files==null ) | 394 if( files==null ) |
395 return null; | 395 return null; |
396 LuanTable list = Luan.newTable(); | 396 LuanTable list = new LuanTable(); |
397 for( File f : files ) { | 397 for( File f : files ) { |
398 list.add(new LuanFile(luan,f).table()); | 398 list.add(new LuanFile(luan,f).table()); |
399 } | 399 } |
400 return list; | 400 return list; |
401 } | 401 } |
526 LuanTable io = (LuanTable)PackageLuan.loaded(luan).get("luan:Io"); | 526 LuanTable io = (LuanTable)PackageLuan.loaded(luan).get("luan:Io"); |
527 return (LuanTable)io.get("stdin"); | 527 return (LuanTable)io.get("stdin"); |
528 } | 528 } |
529 | 529 |
530 public static LuanTable newSchemes() { | 530 public static LuanTable newSchemes() { |
531 LuanTable schemes = Luan.newTable(); | 531 LuanTable schemes = new LuanTable(); |
532 try { | 532 try { |
533 add( schemes, "string", LuanState.class, String.class ); | 533 add( schemes, "string", LuanState.class, String.class ); |
534 add( schemes, "file", LuanState.class, String.class ); | 534 add( schemes, "file", LuanState.class, String.class ); |
535 add( schemes, "classpath", LuanState.class, String.class ); | 535 add( schemes, "classpath", LuanState.class, String.class ); |
536 add( schemes, "socket", LuanState.class, String.class ); | 536 add( schemes, "socket", LuanState.class, String.class ); |