14fee23f9Smrg /* GNU Objective C Runtime nil receiver function
2*b1e83836Smrg Copyright (C) 1993-2022 Free Software Foundation, Inc.
34fee23f9Smrg Contributed by Kresten Krab Thorup
44fee23f9Smrg
54fee23f9Smrg This file is part of GCC.
64fee23f9Smrg
74fee23f9Smrg GCC is free software; you can redistribute it and/or modify it under the
84fee23f9Smrg terms of the GNU General Public License as published by the Free Software
94fee23f9Smrg Foundation; either version 3, or (at your option) any later version.
104fee23f9Smrg
114fee23f9Smrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
124fee23f9Smrg WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
134fee23f9Smrg FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
144fee23f9Smrg details.
154fee23f9Smrg
164fee23f9Smrg Under Section 7 of GPL version 3, you are granted additional
174fee23f9Smrg permissions described in the GCC Runtime Library Exception, version
184fee23f9Smrg 3.1, as published by the Free Software Foundation.
194fee23f9Smrg
204fee23f9Smrg You should have received a copy of the GNU General Public License and
214fee23f9Smrg a copy of the GCC Runtime Library Exception along with this program;
224fee23f9Smrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
234fee23f9Smrg <http://www.gnu.org/licenses/>. */
244fee23f9Smrg
254fee23f9Smrg
264fee23f9Smrg /* This is the nil method, the function that is called when the receiver
274fee23f9Smrg of a method is nil */
284fee23f9Smrg
2948fb7bfaSmrg #include "objc-private/common.h"
3048fb7bfaSmrg #include "objc/objc.h"
314fee23f9Smrg
324fee23f9Smrg /* When the receiver of a method invocation is nil, the runtime
334fee23f9Smrg returns nil_method() as the method implementation. This function
344fee23f9Smrg will be casted to whatever function was supposed to be executed to
354fee23f9Smrg execute that method (that function will take an id, followed by a
364fee23f9Smrg SEL, followed by who knows what arguments, depends on the method),
374fee23f9Smrg and executed.
384fee23f9Smrg
394fee23f9Smrg For this reason, nil_method() should be a function which can be
404fee23f9Smrg called in place of any function taking an 'id' argument followed by
414fee23f9Smrg a 'SEL' argument, followed by zero, or one, or any number of
424fee23f9Smrg arguments (both a fixed number, or a variable number !).
434fee23f9Smrg
444fee23f9Smrg There is no "proper" implementation of such a nil_method function
454fee23f9Smrg in C, however in all existing implementations it does not matter
464fee23f9Smrg when extra arguments are present, so we can simply create a function
474fee23f9Smrg taking a receiver and a selector, and all other arguments will be
484fee23f9Smrg ignored. :-)
494fee23f9Smrg */
504fee23f9Smrg
514fee23f9Smrg id
nil_method(id receiver,SEL op)524fee23f9Smrg nil_method (id receiver, SEL op __attribute__ ((__unused__)))
534fee23f9Smrg {
544fee23f9Smrg return receiver;
554fee23f9Smrg }
56