# New Ticket Created by Jürgen Bömmels # Please include the string: [perl #21520] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=21520 >
Hello, here is something that sometime needs to be done: Move the IO from mixed stdio/PIO to pure PIO. I started with this task by moving the print ops from core.ops to io.ops (because thats the place where they IMHO belong) and move from printf to PIO_printf/PIO_putps. All test pass on i386/linux except one: hacks_2.pasm: This tests an open of an filediscriptor and a print to. To get this work open has to be ported from stdio to PIO. I will look into this when this patch is in. native_pbc/*: These are not really falling, but because of the change in core.ops and io.ops the fingerprint changes and so it fails. So the pbc files need to be regenerated. What is the best way to submit the new pbc-files? bye boe -- attachment 1 ------------------------------------------------------ url: http://rt.perl.org/rt2/attach/53476/40299/9a9f68/io.diff
Index: core.ops =================================================================== RCS file: /cvs/public/parrot/core.ops,v retrieving revision 1.261 diff -u -r1.261 core.ops --- core.ops 26 Feb 2003 17:02:48 -0000 1.261 +++ core.ops 8 Mar 2003 15:49:57 -0000 @@ -235,127 +235,6 @@ ######################################## -=item B<print>(in INT) - -=item B<print>(in NUM) - -=item B<print>(in PMC) - -=item B<print>(in STR) - -Print $1 to standard output. - -=item B<print>(in INT, in INT) - -=item B<print>(in INT, in NUM) - -=item B<print>(in INT, in STR) - -=item B<print>(in INT, in PMC) - -Print $2 to the file specified by file descriptor $1; for $1 equal to -0, 1 or 2, we use stdin, stdout or stderr respectively. - -=cut - -inline op print(in INT) { - printf(INTVAL_FMT, (INTVAL)$1); - goto NEXT(); -} - -inline op print(in NUM) { - printf(FLOATVAL_FMT, $1); - goto NEXT(); -} - -op print(in STR) { - STRING *s = $1; - if (s && string_length(s)) { - fwrite(s->strstart, s->strlen, 1, stdout); - } - goto NEXT(); -} - -op print(in PMC) { - PMC *p = $1; - STRING *s = (p->vtable->get_string(interpreter, p)); - if (s) { - fwrite(s->strstart, s->strlen, 1, stdout); - } - goto NEXT(); -} - - -op print(in INT, in INT) { - FILE *file; - switch ($1) { - case 0: file = stdin; - break; - case 1: file = stdout; - break; - case 2: file = stderr; - break; - default: file = OPCODE_T2PTR(FILE *, $1); - } - fprintf(file, INTVAL_FMT, (INTVAL)$2); - goto NEXT(); -} - -op print(in INT, in NUM) { - FILE *file; - switch ($1) { - case 0: file = stdin; - break; - case 1: file = stdout; - break; - case 2: file = stderr; - break; - default: file = OPCODE_T2PTR(FILE *, $1); - } - fprintf(file, FLOATVAL_FMT, $2); - goto NEXT(); -} - -op print(in INT, in STR) { - FILE *file; - STRING *s = $2; - switch ($1) { - case 0: file = stdin; - break; - case 1: file = stdout; - break; - case 2: file = stderr; - break; - default: file = OPCODE_T2PTR(FILE *, $1); - } - if (s && string_length(s)) { - fwrite(s->strstart, s->strlen, 1, file); - } - goto NEXT(); -} - -op print(in INT, in PMC) { - FILE *file; - PMC *p = $2; - STRING *s = (p->vtable->get_string(interpreter, p)); - switch ($1) { - case 0: file = stdin; - break; - case 1: file = stdout; - break; - case 2: file = stderr; - break; - default: file = OPCODE_T2PTR(FILE *, $1); - } - if (s) { - fwrite(s->strstart, s->strlen, 1, file); - } - goto NEXT(); -} - - -######################################## - =item B<read>(out INT, in INT) Read an INTVAL from file descriptor $2 into $1. Index: io.ops =================================================================== RCS file: /cvs/public/parrot/io.ops,v retrieving revision 1.13 diff -u -r1.13 io.ops --- io.ops 2 Nov 2002 01:53:18 -0000 1.13 +++ io.ops 8 Mar 2003 15:49:58 -0000 @@ -98,6 +98,93 @@ goto NEXT(); } +######################################## + +=item B<print>(in INT) + +=item B<print>(in NUM) + +=item B<print>(in PMC) + +=item B<print>(in STR) + +Print $1 to standard output. + +=item B<print>(in INT, in INT) + +=item B<print>(in INT, in NUM) + +=item B<print>(in INT, in STR) + +=item B<print>(in INT, in PMC) + +Print $2 to the file specified by file descriptor $1; for $1 equal to +0, 1 or 2, we use stdin, stdout or stderr respectively. + +=cut + +inline op print(in INT) { + PIO_printf(interpreter, INTVAL_FMT, (INTVAL)$1); + goto NEXT(); +} + +inline op print(in NUM) { + PIO_printf(interpreter, FLOATVAL_FMT, $1); + goto NEXT(); +} + +op print(in STR) { + STRING *s = $1; + if (s && string_length(s)) { + PIO_putps(interpreter, PIO_STDOUT(interpreter), s); + } + goto NEXT(); +} + +op print(in PMC) { + PMC *p = $1; + STRING *s = (p->vtable->get_string(interpreter, p)); + if (s) { + PIO_putps(interpreter, PIO_STDOUT(interpreter), s); + } + goto NEXT(); +} + + +op print(in INT, in INT) { + ParrotIO *io = ((ParrotIOData*)interpreter->piodata)->table[$1]; + STRING *s = Parrot_sprintf_c(interpreter, INTVAL_FMT, $2); + PIO_putps(interpreter, io, s); + goto NEXT(); +} + +op print(in INT, in NUM) { + ParrotIO *io = ((ParrotIOData*)interpreter->piodata)->table[$1]; + STRING *s = Parrot_sprintf_c(interpreter, FLOATVAL_FMT, $2); + PIO_putps(interpreter, io, s); + goto NEXT(); +} + +op print(in INT, in STR) { + STRING *s = $2; + ParrotIO *io = ((ParrotIOData*)interpreter->piodata)->table[$1]; + if (s && string_length(s)) { + PIO_putps(interpreter, io, s); + } + goto NEXT(); +} + +op print(in INT, in PMC) { + PMC *p = $2; + ParrotIO *io = ((ParrotIOData*)interpreter->piodata)->table[$1]; + STRING *s = (p->vtable->get_string(interpreter, p)); + if (s) { + PIO_putps(interpreter, io, s); + } + goto NEXT(); +} + + ########################################## =item B<print>(in PMC, in STR) @@ -164,7 +251,7 @@ } op puts(in NUM) { - STRING * s = Parrot_sprintf_c(interpreter, "%Vf", $1); + STRING * s = Parrot_sprintf_c(interpreter, "%f", $1); if (string_length(s)) { PIO_write(interpreter, PIO_STDOUT(interpreter), s->strstart, string_length(s)); Index: t/op/hacks.t =================================================================== RCS file: /cvs/public/parrot/t/op/hacks.t,v retrieving revision 1.3 diff -u -r1.3 hacks.t --- t/op/hacks.t 14 Dec 2002 01:08:40 -0000 1.3 +++ t/op/hacks.t 8 Mar 2003 15:49:58 -0000 @@ -1,6 +1,7 @@ #! perl -w use Parrot::Test tests => 3; +use Test::More; # It would be very embarrassing if these didn't work... open FOO, ">temp.file"; @@ -20,6 +21,9 @@ 2 OUTPUT +SKIP: { + skip("open not already ported to PIO", 1); + open FOO, ">temp.file"; # Clobber previous contents close FOO; @@ -49,6 +53,7 @@ open FOO, ">temp.file"; # Clobber previous contents close FOO; +} output_is(<<'CODE', <<'OUTPUT', "3-arg open"); open I1, "temp.file", "w"