Ticket #680: setstdin.patch

File setstdin.patch, 3.7 KB (added by flh, 5 years ago)

Add a setstdin opcode + docs update

  • src/ops/ops.num

     
    12701270find_name_p_sc                 1246 
    12711271find_sub_not_null_p_s          1247 
    12721272find_sub_not_null_p_sc         1248 
     1273setstdin_p                     1249 
  • src/ops/io.ops

     
    4646 
    4747=item B<fdopen>(out PMC, in INT, in STR) 
    4848 
    49 Create ParrotIO object in $1 as a copy of file descriptor $2. 
     49Create FileHandle object in $1 as a copy of file descriptor $2. 
    5050 
    5151RT#42373: integral file descriptors might not exist outside of the UNIX 
    5252     platform.  This op needs work. 
     
    6161 
    6262=item B<getstdin>(out PMC) 
    6363 
    64 Create a new ParrotIO object for the stdin file descriptor and 
     64Create a new FileHandle object for the stdin file descriptor and 
    6565store it in $1 
    6666 
    6767=item B<getstdout>(out PMC) 
    6868 
    69 Create a new ParrotIO object for the stdout file descriptor and 
     69Create a new FileHandle object for the stdout file descriptor and 
    7070store it in $1 
    7171 
    7272=item B<getstderr>(out PMC) 
    7373 
    74 Create a new ParrotIO object for the stderr file descriptor and 
     74Create a new FileHandle object for the stderr file descriptor and 
    7575store it in $1 
    7676 
    7777=cut 
     
    9090 
    9191######################################### 
    9292 
     93=item B<setstdin>(invar PMC) 
     94 
     95Sets the standard input for a bare C<read> op to go to the supplied FileHandle 
     96PMC.  Call C<getstdin> first if you care about retaining the previous PMC. 
     97 
    9398=item B<setstdout>(invar PMC) 
    9499 
    95 Sets the standard output for a bare C<print> op to go to the supplied ParrotIO 
     100Sets the standard output for a bare C<print> op to go to the supplied FileHandle 
    96101PMC.  Call C<getstdout> first if you care about retaining the previous PMC. 
    97102 
    98103=item B<setstderr>(invar PMC) 
    99104 
    100105Sets the standard error for a bare C<printerr> op to go to the supplied 
    101 ParrotIO PMC.  Call C<getstderr> first if you care about retaining the previous 
     106FileHandle PMC.  Call C<getstderr> first if you care about retaining the 
     107previous 
    102108PMC. 
    103109 
    104110=cut 
    105111 
     112inline op setstdin(invar PMC) :base_io { 
     113        _PIO_STDIN(interp) = $1; 
     114} 
     115 
    106116inline op setstdout(invar PMC) :base_io { 
    107117        _PIO_STDOUT(interp) = $1; 
    108118} 
  • docs/book/ch10_opcode_reference.pod

     
    846846 
    847847  fdopen R<DEST>, R<INT>, R<MODE> 
    848848 
    849 Get a ParrotIO object for handle R<INT> with open mode R<MODE>. 
     849Get a FileHandle object for handle R<INT> with open mode R<MODE>. 
    850850 
    851851I<Arguments: P, I, S> 
    852852 
     
    11241124  getstdin R<DEST> 
    11251125  getstdout R<DEST> 
    11261126 
    1127 Get a ParrotIO object for the given standard handle. 
     1127Get a FileHandle object for the given standard handle. 
    11281128 
    11291129I<Arguments: P> 
    11301130 
     
    17871787  peek R<DEST> 
    17881788  peek R<DEST>, R<PIO> 
    17891789 
    1790 Read the next byte from the given ParrotIO object or from C<stdin> but 
     1790Read the next byte from the given FileHandle object or from C<stdin> but 
    17911791don't remove it. 
    17921792 
    17931793I<Arguments: SR or SR, P> 
     
    22352235 
    22362236X<setstderr opcode (PASM)> 
    22372237X<setstdout opcode (PASM)> 
     2238X<setstdin  opcode (PASM)> 
    22382239 
    22392240  setstderr R<DEST> 
    22402241  setstdout R<DEST> 
     2242  setstdin  R<DEST> 
    22412243 
    2242 Set a ParrotIO object for the given standard handle. 
     2244Set a FileHandle object for the given standard handle. 
    22432245 
    22442246I<Arguments: P> 
    22452247 
     
    27142716  tell R<DEST>, R<PIO> 
    27152717  tell R<UPPER32>, R<LOWER32>, R<PIO> 
    27162718 
    2717 Return the file position of the given ParrotIO object. 
     2719Return the file position of the given FileHandle object. 
    27182720 
    27192721I<Arguments: IR, P or IR, I, P> 
    27202722