Auto Generation of Getters/Setters and help needed ...

Andrew P. Black apb at cse.ogi.edu
Sat Dec 25 09:59:06 UTC 1999


At 11:20 -0800 1999.12.2, Stephen Travis Pope wrote:
>There's a basic access method generator in the STP12 goodies at 
>ftp://ftp.create.ucsb.edu/pub/Squeak/goodies/STP12/STP12/System/CodeGe 
>n.st.
>
>It implements the method for the message "publish" that can be sent 
>to a class. It'd be pretty easy to add it to the class list menu in 
>the browser.

I got a bit carried away with this.  Stephen's code for creating the 
accessor methods is fine, if one wants them all.  But often one wants 
a subset.   And some of the accessors may be custom coded, in which 
case one does not want to accidentally overwrite them.

So I added a menu item to the class pane of the Browser, called 'auto 
accessors ...'.  It is adjacent to the show instance variable 
references and assignments menu items.  It brings up a little 
preferences dialog that shows which reader and writer methods already 
exist for each instance variable, and whether the code is custom or 
auto-generated.  If there is no accessor, clicking on 'false' will 
generate one.  If there is an auto-generated accessor, clicking on 
'true' will remove it.

My code is at

http://www.cse.ogi.edu/cse504/programs/AccessorCodeGen.25Dec119am.cs

It works, but there is a very obvious bug, which I'm hoping that 
someone will help me to fix.  The window that encloses the 
preferences dialog is much too big, and I don't know why, 
particularly since I stole the code from 'Preferences class' which 
does not have this problem.  I have messed with this a lot, but I 
guess that I just don't know enough about Morphic to figure it out. 
Help!  The offending code is in AccessorPreferences | openPanel .

With this bug fixed, I suggest that this code might become a part of 
the official browser.  (Except that the generation code itself is in 
class class, following STP's submission ... from the point of view of 
building a minimal image, perhaps it should be somewhere else, like 
PseudoClass.)  And perhaps the code for that deals with 
auto-generation of accessors should be moved out of 
Object|doesNotUnderstand: and Object|tryToDefineVariableAccess:

Incidentally, is there any documentation on _programming_ in Morphic 
?  I have read John Maloney's tutorials, which give a good overview. 
but I'm looking, for example, for details on the way that fullBounds 
and bounds interact ...

[ This is my first submission to the "source pool", so I would 
appreciate constructive criticism ]

	Andrew





More information about the Squeak-dev mailing list