On Apr 30, 2011, at 7:56 PM, David Chisnall wrote:

> On 30 Apr 2011, at 18:52, Mathieu Suen wrote:
> 
>> 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?
> 
> Wrong way around.  Correct order is 1, 3, 2.  You should create the class, 
> set its methods and ivars, and then register it.
> 
> You can still add methods after the class is registered, but not ivars.

Ok so that is what I do:


1. objc_allocateClassPair
2. class_addIvar
3. objc_registerClassPair
4. class_addMethod
533       BOOL result = class_addMethod (cls, sel_getUid (selector), (IMP)code, 
typeStr);

(gdb) po cls
MyNSView
(gdb) p selector
$1 = 0x10020e2a0 "drawRect:"
(gdb) p cls
$2 = (Class) 0x10020de40
(gdb) p $rax
$3 = 1


5. MyView alloc init
(gdb) p (Class)[0x13132d140 class]
$4 = (Class) 0x10020de40
(gdb) po (Class)class_getSuperclass (0x10020de40)
NSView
(gdb) p (SEL)sel_getUid("drawRect:")
$5 = (SEL) 0x7fff87ec5cb0
(gdb) p (BOOL)[0x13132d140 respondsToSelector: 0x7fff87ec5cb0]
$6 = 1 '\001'


6. nsWindow setContentView: view.
7. nsWindow center.
8. nsWindow orderFront: 0.
9. nsWindow contentView.

On this stage on osx I don't get any window.

10. nsApp run.

But #drawRect: never get called. No even my trampoline method.
If anybody got an idea?


Thanks for the help


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

Mathieu


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

Répondre à