Doc for writing Pluggable Prims?

Tim Rowledge rowledge at interval.com
Tue Jul 20 17:52:25 UTC 1999


> http://minnow.cc.gatech.edu/squeak.464
>
It's an excellent start. A part that is missing from what Stephen will want to
know is the conversion needed in quite a few places; for example, you typically
want to change
	success ifTrue:[....
to
	interpreterProxy failed ifFalse:[...
which gets to look a little cumbersome after a while, but it works.

So far in my conversion pilgrimage for the midi/serial/sockets/sound etc, I
have found the following conversions:-

- success ifTrue:[ --> interpreterProxy failed ifFalse: Use interpreterProxy
success: to set the boolean.
- you can't do formatOf: and use it to check for oops/bytes etc anymore, you
use isBytes: isPointers: and so on. Quite a few methods needed changing for
this.
- lengthOf: is usurped by slotSizeOf:  which returns the number of bytes for
byte objects and the number of words otherwise (remember to check you're not
multiplying it again later!) .
- instantiating is changed to  "interpreterProxy instantiateClass:
interpreterProxy classString indexableSize: sz" from "self instantiateClass:
(self splObj: ClassString) indexableSize: sz". Note that splObj: is not used,
it's now a send to interpreterProxy of things like classString or
classByteArray instead.

pop:, push: pushInteger: stackValue: stackIntegerValue: etc are all used with
interpreterProxy. You lose stackTop.

"export: true" is needed to mark the prim for Windows (and possibly other OSs)
cCode: stays as a self message.

Although it's not hard to do the conversions, it certainly involves a bunch of
tedious editing. I think a small but useful improvement would be to add
#succeeded to InterpreterProxy - this would mean that
" success ifTrue:[..." could be converted to "interpterProxy succeeded
ifTrue:[..." leaving the logic inthe same order instead of reversing it. I
predict that this will be one of the main bugs that will surface in testing!

If people would like to add anything I've missed to this list, we should
probably add a complete description to the above swiki page sometime soon.

tim
NB we could do with a method to cleanly derive the base address from an oop,
rather than hardcoding magic numbers (i.e. 4)
 


-- 
It's here at last: We've released a 26-week project in 48 weeks.
Tim Rowledge:  rowledge at interval.com (w)  +1 (650) 842-6110 (w)
 tim at sumeru.stanford.edu (h)  <http://sumeru.stanford.edu/tim>





More information about the Squeak-dev mailing list