Front page | perl.perl5.porters |
Postings from April 2000
Line disciplines
From:
simon
Date:
April 22, 2000 13:08
Subject:
Line disciplines
Message ID:
slrn8g41l0.s3t.simon@justanother.perlhacker.org
OK, I think I'm near to cracking this one, but there's one piece
missing.
Here's the basic idea:
Discipline XSUBs add entries to a global hash (possibly PL_modglobal)
with the key "disc_".whatever and a pointer to the discipline
transforming function.
open(FH,":foo",$file) and binmode(FH, ":foo") do the usual checks for
raw and crlf, then look up disc_foo in the hash. They then add the
appropriate function pointer to an appropriate array held in the
filehandle.
When anything reads or writes using the filehandle, each function
reference is called on the incoming data. It's a nice, simple and
extensible model.
The problem I'm facing is that the open() is processed and turned into
an op before the filehandle is created, obviously. So we don't have the
filehandle present when we're trying to add function pointers into the
array to the PerlIO structure. Therefore we've got to pass a message
by hanging the array onto the op somewhere. Where?
Thankfully, binmode is a lot easier because we have the filehandle
present. We could, I guess, give up on open() and just make it work
for binmode().
Ideas appreciated.