Created
December 14, 2014 11:12
-
-
Save mumez/59a3da9e4cc31a1165d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SystemOrganization addCategory: #AdvMessageInterceptor! | |
ProtoObject subclass: #AdvMessageInterceptor | |
instanceVariableNames: 'originalObject' | |
classVariableNames: '' | |
poolDictionaries: '' | |
category: 'AdvMessageInterceptor'! | |
!AdvMessageInterceptor class methodsFor: 'instance creation' stamp: 'mu 12/13/2014 21:20'! | |
on: anOriginalObject | |
^self new xxxOriginalObject: anOriginalObject! ! | |
!AdvMessageInterceptor methodsFor: 'system primitives' stamp: 'mu 12/13/2014 21:20'! | |
becomeForward: otherObject | |
"Primitive. All variables in the entire system that used to point | |
to the receiver now point to the argument. | |
Fails if either argument is a SmallInteger." | |
(Array with: self) | |
elementsForwardIdentityTo: | |
(Array with: otherObject)! ! | |
!AdvMessageInterceptor methodsFor: 'system primitives' stamp: 'mu 12/13/2014 21:20'! | |
doesNotUnderstand: aMessage | |
aMessage transcriptOn: originalObject. | |
^aMessage sendTo: originalObject! ! | |
!AdvMessageInterceptor methodsFor: 'actions' stamp: 'mu 12/13/2014 21:20'! | |
intercepted | |
^self! ! | |
!AdvMessageInterceptor methodsFor: 'actions' stamp: 'mu 12/13/2014 21:20'! | |
quitIntercepting | |
self becomeForward: originalObject! ! | |
!AdvMessageInterceptor methodsFor: 'accessing' stamp: 'mu 12/13/2014 21:20'! | |
xxxOriginalObject: anObject | |
originalObject := anObject! ! | |
!Message methodsFor: '*AdvMessageInterceptor-logging' stamp: 'mu 12/13/2014 23:20'! | |
transcriptOn: receiver | |
Transcript cr; | |
show: ('a {1}({2}) >> {3}' format: {receiver class name. receiver identityHash. self selector})! ! | |
!Object methodsFor: '*AdvMessageInterceptor-actions' stamp: 'mu 12/13/2014 23:32'! | |
intercepted | |
^AdMessageInterceptor on: self | |
! ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"Developing interceptor in Smalltalk"
http://qiita.com/mumez/items/72272fac093a2aaabbee