This will be the interface for doing all sorts of IO layer stuff such as
buffering, blocking, async, etc. At least until someone has a better
way to do it.
Also added record separator field to ParrotIO object and allow changing
from default \n. Needs finishing so we can support setting recsep to
NULL for slurp mode. Currently tests fail if I set to linebuf by default.
-Melvin
> Added pioctl op and PIO_pioctl API call. General purpose op for IO manipulation
> in tradition of UNIX ioctl call.
>
> This will be the interface for doing all sorts of IO layer stuff such as
> buffering, blocking, async, etc. At least until someone has a better
> way to do it.
I think it's time to start thinking about it. (And I think we need a new
name, but that's because I've always hated 'ioctl' :)
Dan
:)
I also considered iocmd, ioattr and ioset.
IPop your favorite into the suggestion box...
-Melvin
How about keyed access to the IO PMC?
set I0, P0[.CMDGETBUFSIZE]
set P0[.CMDSETBUFSIZE], I0
I like that.
Actually it could look even simpler since we have separate setkeyed
and getkeyed support:
set IO, P0[.BUFSIZE]
set P0[.BUFSIZE], 8192
-Melvin
Actually, looking at that suggests that perhaps this should be done
through the setprop/getprop interface instead, since that seems like a
closer semantic fit to what you're doing.
IMHO is the keyed access clearly denoting what's goin on. The property
stuff is AFAIK for different things. You could attach e.g. an utf8 layer
via setting a property.
Either above or via method calls:
set S0, "bufsize" # method currently "setbuf"
set P5, P0 # first param = PIO
set I5, 8192
callmeth
# P0 is the method now
or
find_method P1, "bufsize" # "setbuf"
set I5, 8192
invoke P1
s. t/pmc/io.t, t/classes/parrotio.pmc:enter_nci_method
OTOH, the property interface can have hints for creating a buffered PIO
object with a specific buffer size, e.g.
new P1, .PerlHash
new P2, .PerlInt
set P2, 8192
set P1["bufsize"], P2 # create property hash
null P3
new P0, .ParrotIO, P3, P1 # init_pmc_props
assign P0, "< the_file" # use existing handle for open TODO
# or combine above 3 lines to an extended open opcode
Properies are probably more the static side of the moon, while method
calls are dynamic.
leo