From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/gcc~13/dynamically-registering-methods.html | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 devdocs/gcc~13/dynamically-registering-methods.html (limited to 'devdocs/gcc~13/dynamically-registering-methods.html') diff --git a/devdocs/gcc~13/dynamically-registering-methods.html b/devdocs/gcc~13/dynamically-registering-methods.html new file mode 100644 index 00000000..573de3eb --- /dev/null +++ b/devdocs/gcc~13/dynamically-registering-methods.html @@ -0,0 +1,8 @@ +

8.10.1 Dynamically Registering Methods ΒΆ

If objc_msg_lookup() does not find a suitable method implementation, because the receiver does not implement the required method, it tries to see if the class can dynamically register the method.

To do so, the runtime checks if the class of the receiver implements the method

+ (BOOL) resolveInstanceMethod: (SEL)selector;
+

in the case of an instance method, or

+ (BOOL) resolveClassMethod: (SEL)selector;
+

in the case of a class method. If the class implements it, the runtime invokes it, passing as argument the selector of the original method, and if it returns YES, the runtime tries the lookup again, which could now succeed if a matching method was added dynamically by +resolveInstanceMethod: or +resolveClassMethod:.

This allows classes to dynamically register methods (by adding them to the class using class_addMethod) when they are first called. To do so, a class should implement +resolveInstanceMethod: (or, depending on the case, +resolveClassMethod:) and have it recognize the selectors of methods that can be registered dynamically at runtime, register them, and return YES. It should return NO for methods that it does not dynamically registered at runtime.

If +resolveInstanceMethod: (or +resolveClassMethod:) is not implemented or returns NO, the runtime then tries the forwarding hook.

Support for +resolveInstanceMethod: and resolveClassMethod: was added to the GNU Objective-C runtime in GCC version 4.6.

+

+ © Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
+ https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Dynamically-registering-methods.html +

+
-- cgit v1.2.3