I still have the same issue the drawRect: is not called.
But I suspect that I did not add correctly the method.

The step for creating the new class is:

1. objc_allocateClassPair
2. objc_registerClassPair
3. class_addMethod

I did this way because in step 1 and 2  my smalltalk class doesn't have the 
method yet.
So is that ok?

Thanks 


So in order to create a class I have use 

On Apr 29, 2011, at 7:54 PM, David Chisnall wrote:

> On 29 Apr 2011, at 18:45, Mathieu Suen wrote:
> 
>> For the forwardInvocation: I am just wondering how could I add method like 
>> drawRect:. I guess that drawRect:  is implement in the NSView class so 
>> forwardInvocation: will never be called.
> 
> Yes, sorry, I wasn't thinking.  You will need to explicitly register a 
> trampoline for each method that your subclass calls.  This will need to 
> collect the arguments from the ObjC method and then call the Smalltalk method.
> 
>> Or do you mean that each method added to MyView should be add in objective-c 
>> with the same code than forwardInvocation: I have implement up to now. 
> 
> That wasn't what I meant, but it's what I would have meant if I'd done the 
> thinking before the typing.
> 
>> Do you mean that +resolveInstanceMethod: is call each time before sending a 
>> message to an object?
> 
> No, it's only called if the runtime can't find a method corresponding to the 
> selector.  It's fine for proxies, not so fine for subclasses that need to 
> override the real methods.
> 
>>> You will also have some fun handling message sends to super from Smalltalk. 
>>>  Probably the best thing to do is support some kind of composition that 
>>> looks like subclassing from the Objective-C side, but not from the 
>>> Smalltalk side.
>> 
>> Thanks a lot
>> PS. I have seen your books on amazon there look very interesting. Which one 
>> do you recommend? 
> 
> Depends on what you're interested in.  The Xen one only if you're interested 
> in operating systems.  Cocoa Programming goes into a lot of detail about the 
> Cocoa / GNUstep APIs.  The phrasebook is a pocket reference containing things 
> I think every ObjC programmer should know.
> 
> David
> 
> --
> This email complies with ISO 3103
> _______________________________________________
> Etoile-discuss mailing list
> [email protected]
> https://mail.gna.org/listinfo/etoile-discuss


_______________________________________________
Etoile-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-discuss

Répondre à