develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33712 - in trunk/languages/lua: src/lib t

From:
fperrad
Date:
December 9, 2008 07:39
Subject:
[svn:parrot] r33712 - in trunk/languages/lua: src/lib t
Message ID:
20081209153927.42890CB9AF@x12.develooper.com
Author: fperrad
Date: Tue Dec  9 07:39:24 2008
New Revision: 33712

Modified:
   trunk/languages/lua/src/lib/luafile.pir
   trunk/languages/lua/t/io.t

Log:
[Lua] io
- implement file:setvbuf, with FileHandle PMC

Modified: trunk/languages/lua/src/lib/luafile.pir
==============================================================================
--- trunk/languages/lua/src/lib/luafile.pir	(original)
+++ trunk/languages/lua/src/lib/luafile.pir	Tue Dec  9 07:39:24 2008
@@ -285,8 +285,6 @@
 For the last two cases, sizes specifies the size of the buffer, in bytes.
 The default is an appropriate size.
 
-NOT YET IMPLEMENTED.
-
 =cut
 
 .sub 'setvbuf' :method
@@ -300,15 +298,10 @@
     $S1 = lua_checkstring(1, mode)
     $I1 = lua_checkoption(1, $S1, 'no full line')
     $I2 = lua_optint(2, size, 512)     # LUAL_BUFFERSIZE
-    new mode, 'FixedIntegerArray'
-    set mode, 3
-    mode[0] = 0     # PIO_NONBUF
-    mode[1] = 2     # PIO_FULLBUF
-    mode[2] = 1     # PIO_LINEBUF
+    mode = split ' ', 'unbuffered full-buffered line-buffered'
+    $S0 = mode[$I1]
     f = getattribute self, 'data'
-    $I0 = mode[$I1]
-    # not_implemented
-    f.'buffer_type'($I0)
+    f.'buffer_type'($S0)
     if $I1 == 0 goto L1
     f.'buffer_size'($I2)
   L1:

Modified: trunk/languages/lua/t/io.t
==============================================================================
--- trunk/languages/lua/t/io.t	(original)
+++ trunk/languages/lua/t/io.t	Tue Dec  9 07:39:24 2008
@@ -363,10 +363,6 @@
 15
 OUTPUT
 
-TODO:
-{
-    local $TODO = 'buffer_type & buffer_size are not implemented';
-
 language_output_is( 'lua', << 'CODE', << 'OUTPUT', 'file:setvbuf "no"' );
 f = io.open("file.txt")
 print(f:setvbuf("no"))
@@ -390,7 +386,7 @@
 CODE
 true
 OUTPUT
-}
+
 # clean up file.txt
 unlink('../file.txt') if ( -f '../file.txt' );
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About