NAME ^

src/pmc/parrotio.pmc - Parrot IO

DESCRIPTION ^

These are the vtable functions for Parrot IO.

Methods ^

METHOD INTVAL say(STRING *s)

Print the string with newline appended to SELF or to stdout if used as class method

METHOD PMC *open(STRING *file, STRING *mode, STRING *layer)

Open the file with the given mode and use the IO given layer.

METHOD INTVAL set_readline_interactive(INTVAL)

Set readline interactive mode to the given valie, if PARROT_HAS_READLINE is defined, i.e. if the readline library is available. Returns:

  -1 ... readline isn't configured
  -2 ... file not open/not input or not a tty, if turning on interactive
  0 / 1  old interactive setting
METHOD STRING *readline(STRING *prompt)

Read a line from the given PIO. If readline is interactive and a prompt is not-empty, it will be displayed. The interactive feature is not available with the readline opcode (which will be removed anyway). In interactive mode non-empty lines are added to the readline history.

Returns the line without the newline or:

  NULL  ... end of input (e.g. after ^D or end of file)
SYNOPSIS

      pio = getstdin
      $I0 = pio.'set_readline_interactive'(1)
      if $I0 >= 0 goto loop
      printerr "set_readline_interactive failed: "
      ...
  loop:
      s = pio.'readline'('hello polly> ')
      if null s goto ex
      ..
      goto loop
  ex:
void class_init()

Class initialization.

METHOD INTVAL eof()

Return 0/1 according to eof state of the object.

METHOD void flush()

Flush pending writes.

METHOD INTVAL setbuf(INTVAL)

XXX TBD

METHOD INTVAL setlinebuf()

XXX TBD

void init()

Initializes the IO PMC.

void destroy()

Destroys the IO PMC, flushing and closing as necessary.

PMC *clone()

Clones the IO PMC.

For now both PMCs refer to the same ParrotIO object. If we have different IO layers, we might copy data and struct_val.

INTVAL get_bool()

Returns whether at EOF or not.

STRING *get_string_keyed_int(INTVAL n)

Return the name of the nth layer. n >= 0 returns layer names up from the bottom. If n is negative returns layer names from top down. For non-existing layers an empty string is returned.

void push_string (STRING *value)

Push the layer name value onto the PIO's layer stack.

STRING *pop_string ()

Pop a layer off the PIO's layer stack. Returns the layer name.

HISTORY ^

Initial version by leo 2003/06/23.


parrot