Hi Alistair.
Do you know that you are able to count any message send? (not only external).
For this you need prevent meta recursion. Now inside message processing you do:
aMessage sendTo: anObject
which produces another intercepting message #perform:withArguments which repeats original message send.
Fortunately Ghost handles such kind of meta recursion and there is no infinite loop here: any self-sends are ignored in such cases.
If you want intercept any message try following code:
ExternalSendTrace>>send: aMessage to: anObject
announcer announce: (ExternalSendAnnouncement message: aMessage trace: self).
method := anObject class lookupSelector: aMessage selector.
^GHMetaMessages executeWith: anObject andArguments: aMessage arguments method: method��
In that case we lookup and execute method by using mirror primitive which not sends any message to object.
For example:
rect := 10@30 corner: 100@300.
trace := ExternalSendStats logStatsFor: rect.
��"a Dictionary(#area->1 #height->1 #width->1 )"