You'd need to be very careful... and probably need to redefine instVarAt:put: in the object that handles the command/undo to do the normal thing (to avoid recursion).
Of course, assignments to ivars in methods won't actually call instVarAt:put: (done in the bytecode I believe).
Can you explain the general functionality you are hoping to obtain?
Gary.
-----Original Message----- From: squeak-dev-bounces@lists.squeakfoundation.org [mailto:squeak-dev-bounces@lists.squeakfoundation.org]On Behalf Of itsme213 Sent: 30 April 2008 3:22 PM To: squeak-dev@lists.squeakfoundation.org Subject: [squeak-dev] Re: Undoable environment ?
"Gary Chambers" gazzaguru2@btinternet.com wrote in message
A>>setFoo: aFoo Undoable newOn: [ foo := aFoo ]
Have a look at the Command and CommandHistory clasees. Worked
well for our
Report Builder...
I am hoping to find a way for Undoable to dynamically extend a few primitives (e.g. assiging to an instVar or indexedVar, probably adding or removing indexedVars, others??).
========== e.g. currently:
Object>> instVarAt: anInteger put: anObject <primitive: 74> ^self basicAt: anInteger - self class instSize put: anObject
========== Dynamically change to:
Object>> instVarAt: anInteger put: anObject self recordIVarChange: anInteger oldVal: self instVarAt: anInteger. self primInstVarAt: anInteger put: anObject
Object>> primInstVarAt: anInteger put: anObject <primitive: 74> ^self basicAt: anInteger - self class instSize put: anObject
=========== Then #recordIVarChange can put undoable/redoable records on the stack.
Does this sound feasible? Scary to dynamically re-define primitive methods, don't know where to start :-(
Sophie