Movatterモバイル変換


[0]ホーム

URL:


Previous:, Up:GNU Objective-C Features   [Contents][Index]


9.10 Messaging with the GNU Objective-C Runtime

This section is specific for the GNU Objective-C runtime. If you areusing a different runtime, you can skip it.

The implementation of messaging in the GNU Objective-C runtime isdesigned to be portable, and so is based on standard C.

Sending a message in the GNU Objective-C runtime is composed of twoseparate steps. First, there is a call to the lookup function,objc_msg_lookup () (or, in the case of messages to super,objc_msg_lookup_super ()). This runtime function takes asargument the receiver and the selector of the method to be called; itreturns theIMP, that is a pointer to the function implementingthe method. The second step of method invocation consists of castingthis pointer function to the appropriate function pointer type, andcalling the function pointed to it with the right arguments.

For example, when the compiler encounters a method invocation such as[object init], it compiles it into a call toobjc_msg_lookup (object, @selector(init)) followed by a castof the returned value to the appropriate function pointer type, andthen it calls it.


[8]ページ先頭

©2009-2026 Movatter.jp