diff options
author | dnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-09-15 18:52:06 +0000 |
---|---|---|
committer | dnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-09-15 18:52:06 +0000 |
commit | 170d8720517159094f96828592595cc5d3d6dd6f (patch) | |
tree | 625190ec90943d9c529029cbe701637069bed251 /libobjc | |
parent | 43a44ae12cbf3771ac8c8bbd41baaf222c07be79 (diff) |
Mainline merge as of 2002-09-15.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/tree-ssa-20020619-branch@57168 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libobjc')
-rw-r--r-- | libobjc/ChangeLog | 12 | ||||
-rw-r--r-- | libobjc/nil_method.c | 21 | ||||
-rw-r--r-- | libobjc/objc/objc.h | 9 | ||||
-rw-r--r-- | libobjc/sendmsg.c | 6 |
4 files changed, 43 insertions, 5 deletions
diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index db5a9386dfe..cd72694f810 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,3 +1,15 @@ +Thu Sep 12 12:44:37 2002 Nicola Pero <n.pero@mi.flashnet.it> + + * sendmsg.c (nil_method): Declare not to take a variable number of + args. + (objc_msg_lookup): Cast nil_method to IMP before returning it. + (objc_msg_lookup_super): The same. + +2002-09-10 Jan Hubicka <jh@suse.cz> + + * nil_method.c (nil_method): No longer defined with variable + arguments. + 2002-07-02 Rodney Brown <rbrown64@csc.com.au> * objc/encoding.h: Fix formatting. diff --git a/libobjc/nil_method.c b/libobjc/nil_method.c index 800b0e3bf53..5e37c4d5dfb 100644 --- a/libobjc/nil_method.c +++ b/libobjc/nil_method.c @@ -29,8 +29,27 @@ Boston, MA 02111-1307, USA. */ #include "runtime.h" +/* When the receiver of a method invocation is nil, the runtime + returns nil_method() as the method implementation. This function + will be casted to whatever function was supposed to be executed to + execute that method (that function will take an id, followed by a + SEL, followed by who knows what arguments, depends on the method), + and executed. + + For this reason, nil_method() should be a function which can be + called in place of any function taking an 'id' argument followed by + a 'SEL' argument, followed by zero, or one, or any number of + arguments (both a fixed number, or a variable number !). + + There is no "proper" implementation of such a nil_method function + in C, however in all existing implementations it does not matter + when extra arguments are present, so we can simply create a function + taking a receiver and a selector, and all other arguments will be + ignored. :-) +*/ + id -nil_method (id receiver, SEL op __attribute__ ((__unused__)), ...) +nil_method (id receiver, SEL op __attribute__ ((__unused__))) { return receiver; } diff --git a/libobjc/objc/objc.h b/libobjc/objc/objc.h index 79b2519e576..699542c493b 100644 --- a/libobjc/objc/objc.h +++ b/libobjc/objc/objc.h @@ -73,7 +73,14 @@ typedef struct objc_object { /* ** Definition of method type. When retrieving the implementation of a -** method, this is type of the pointer returned +** method, this is type of the pointer returned. The idea of the +** definition of IMP is to represent a 'pointer to a general function +** taking an id, a SEL, followed by other unspecified arguments'. You +** must always cast an IMP to a pointer to a function taking the +** appropriate, specific types for that function, before calling it - +** to make sure the appropriate arguments are passed to it. The code +** generated by the compiler to perform method calls automatically +** does this cast inside method calls. */ typedef id (*IMP)(id, SEL, ...); diff --git a/libobjc/sendmsg.c b/libobjc/sendmsg.c index 06fc9ba193e..6ef711b50d3 100644 --- a/libobjc/sendmsg.c +++ b/libobjc/sendmsg.c @@ -76,7 +76,7 @@ static id __objc_block_forward (id, SEL, ...); static Method_t search_for_method_in_hierarchy (Class class, SEL sel); Method_t search_for_method_in_list (MethodList_t list, SEL op); -id nil_method (id, SEL, ...); +id nil_method (id, SEL); /* Given a selector, return the proper forwarding implementation. */ __inline__ @@ -197,7 +197,7 @@ objc_msg_lookup (id receiver, SEL op) return result; } else - return nil_method; + return (IMP)nil_method; } IMP @@ -206,7 +206,7 @@ objc_msg_lookup_super (Super_t super, SEL sel) if (super->self) return get_imp (super->class, sel); else - return nil_method; + return (IMP)nil_method; } int method_get_sizeof_arguments (Method *); |