ipbitch!
Eddie Kohler
eddietwo at cag.lcs.mit.edu
Sun Mar 28 15:53:32 EST 1999
The language is ready. It even has nice error messages because I like
wasting my time. I've checked in everything including a simple (broken)
`sample.ipb' file so you can see error messages. To run a driver from the
language, make a file `xxx.ipb' and run:
% make ed && ./ed xxx.ipb
HOW TO WRITE A LANGUAGE-READY FACTION:
1. Have a nullary constructor (no arguments).
2. Constructors shouldn't do anything except set data members. Instead...
3. Put all initialization processing in the
`int initialize(ErrorHandler *)'
method. This method should return 0 on success, -1 on failure. Please
don't call `exit()'; just return -1, and leave it to the Router object
to propagate the failure. See LiveReader and LiveWriter for examples.
4. Call methods on the `ErrorHandler *' object if there is an error. Do not
call fprintf. Again, see LiveReader and LiveWriter for examples.
5. Write a
`FACTION_SUBTYPE * clone() const'
method which returns a copy of the current faction. Please try to copy
any configuration info into the clone. In other words, I want these two
sequences of operations to have equivalent results:
ComplexFaction *f1 = new ComplexFaction;
f1->configure("blah blah blah");
ComplexFaction *f2 = f1->clone();
-and-
ComplexFaction *f1 = new ComplexFaction;
f1->configure("blah blah blah");
ComplexFaction *f2 = new ComplexFaction;
f2->configure("blah blah blah");
6. THE HARD PART: Write a
`int configure(const String &, ErrorHandler *)'
method which configures your faction dynamically from a string. I have
added this method to a couple of the existing factions (Strip,
TimedSource, TimedSink, LiveReader, LiveWriter). The problem of course
is parsing the string. The functions in `confparse.hh' may be helpful.
I will add more functions there as it becomes clear what we need.
HOW FACTIONS ARE CREATED
1. Find `ftype', which is a representative of the faction type (so a Strip,
say)
2. Set `f = ftype->clone()'. `f' is the actual faction object
3. Call `f->configure(configuration_string, error_handler)'
4. Analyze personalities (check push & pull)
5. Call `f->assign_personality(personality)' if `f' was agnostic
6. Check that the inputs & outputs are all valid.
This includes creating any inputs & outputs actually used by
factions with unlimited inputs & outputs.
7. Call `f->initialize(error_handler)'
8. All done!
love,
ed
More information about the click
mailing list