Sorry guys. Forget this. I was being so stupid. It is working perfectly.<br><br>Cheers<br><br>Mariano<br><br><div class="gmail_quote">On Thu, Mar 17, 2011 at 10:16 AM, Mariano Martinez Peck <span dir="ltr"><<a href="mailto:marianopeck@gmail.com">marianopeck@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi folks. I have a problem and I am completely clueless. I did one simple modification to the method lookup: I want to check whether the class of the receiver is a proxy and if true, send an special message. So I just modify the first lines of:<br>
<br>lookupMethodInClass: class<br> | currentClass dictionary found |<br> <inline: false><br> self assert: class ~~ objectMemory nilObject.<br> currentClass := class.<br> [currentClass ~= objectMemory nilObject]<br>
whileTrue:<br> [dictionary := objectMemory fetchPointer: MethodDictionaryIndex ofObject: currentClass.<br> <br><br style="background-color:rgb(255, 255, 0)"><span style="background-color:rgb(255, 255, 0)"> " THIS IS MY CHANGE "</span><br style="background-color:rgb(255, 255, 0)">
<span style="background-color:rgb(255, 255, 0)"> (currentClass = (objectMemory splObj: ProxyClass)) ifTrue: [</span><br style="background-color:rgb(255, 255, 0)"><span style="background-color:rgb(255, 255, 0)"> self createActualMessageTo: currentClass.</span><br style="background-color:rgb(255, 255, 0)">
<span style="background-color:rgb(255, 255, 0)"> messageSelector := objectMemory splObj: SelectorHandleProxyInvocation.</span><br style="background-color:rgb(255, 255, 0)"><span style="background-color:rgb(255, 255, 0)"> self sendBreak: messageSelector + BaseHeaderSize</span><br style="background-color:rgb(255, 255, 0)">
<span style="background-color:rgb(255, 255, 0)"> point: (objectMemory lengthOf: messageSelector)</span><br style="background-color:rgb(255, 255, 0)"><span style="background-color:rgb(255, 255, 0)"> receiver: nil.</span><br style="background-color:rgb(255, 255, 0)">
<span style="background-color:rgb(255, 255, 0)"> ^self lookupMethodInClass: (self superclassOf: currentClass)</span><br style="background-color:rgb(255, 255, 0)"><span style="background-color:rgb(255, 255, 0)"> ].</span><br style="background-color:rgb(255, 255, 0)">
<span style="background-color:rgb(255, 255, 0)"> " HERE FINISH MY CHANGE "</span><br> <br> dictionary = objectMemory nilObject ifTrue:<br> ["MethodDict pointer is nil (hopefully due a swapped out stub)<br>
-- raise exception #cannotInterpret:."<br> self createActualMessageTo: class.<br> messageSelector := objectMemory splObj: SelectorCannotInterpret.<br> self sendBreak: messageSelector + BaseHeaderSize<br>
point: (objectMemory lengthOf: messageSelector)<br> receiver: nil.<br> ^self lookupMethodInClass: (self superclassOf: currentClass)].<br> found := self lookupMethodInDictionary: dictionary.<br>
found ifTrue: [^currentClass].<br> currentClass := self superclassOf: currentClass].<br><br> "Could not find #doesNotUnderstand: -- unrecoverable error."<br> messageSelector = (objectMemory splObj: SelectorDoesNotUnderstand) ifTrue:<br>
[self error: 'Recursive not understood error encountered'].<br><br> "Cound not find a normal message -- raise exception #doesNotUnderstand:"<br> self createActualMessageTo: class.<br> messageSelector := objectMemory splObj: SelectorDoesNotUnderstand.<br>
self sendBreak: messageSelector + BaseHeaderSize<br> point: (objectMemory lengthOf: messageSelector)<br> receiver: nil.<br> ^self lookupMethodInClass: class<br><br><br><br>Now, from the image side, I added ProxyClass and SelectorHandleProxyInvocation and:<br>
<br>ClassProxy>> handleProxyInvocation: aMessage<br> Transcript show: 'a message: '; aMessage selector, 'was sent'; cr. <br><br><br>If I do ClassProxy new foo. I see TWO times the message in the Transcript. I mean, handleProxyInvocation: is being invoke twice per message. <br>
<br>Thanks in advance for any help.<br><font color="#888888"><br>Mariano<br>
</font></blockquote></div><br>