Hello, I'm again, trying to do some slow progress on the task of writting a cocoa application in pascal. We have objc runtime headers translated, but there are no examples explaining how to use them. In the past I posted to Apple mailling lists without sucess, so maybe someone could help me "reverse engineer" a simple example and go from there.
Attached one can find a trivial objective-c application (main.m) and
it's corresponding assembler code (main.asm).
It should be noted that any code written in objective-c should be
possible to describe in a procedural way using calls to the
objective-c runtime library.
So, here is how the app starts:
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
// Any ideas what is this? It will first call NSAutoreleasePool
alloc method and then the init method??
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
// The next 2 should be simple procedures AFAIK, no not much
problem with them.
NSApplicationLoad();
/* uses a default "OK" button and no alternate buttons */
NSRunAlertPanel(@"This is the title", @"This is the message", nil,
nil, nil);
// Call release method from object pool
[pool release];
return 0;
}
I read the corresponding assembler code, but it's *very* confusing.
The order in which CALL's are made is:
// NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
call L_objc_getClass$stub
call L_objc_msgSend$stub
call L_objc_msgSend$stub
// The 2 simple procedures afaik
call L_NSApplicationLoad$stub
call L_NSRunAlertPanel$stub
// [pool release];
call L_objc_msgSend$stub
So, getting which procedures are called where isn't that hard, but I
couldn't understand what is filled on the parameters. Any ideas?
By the way, what does the instruction "leal" do?? I don't remember
anything similar from intel intructions tables:
leal L_OBJC_SELECTOR_REFERENCES_0-"L00000000001$pb"(%ebx), %eax
thanks,
--
Felipe Monteiro de Carvalho
main.m
Description: Binary data
main.s
Description: Binary data
_______________________________________________ fpc-devel maillist - [email protected] http://lists.freepascal.org/mailman/listinfo/fpc-devel
