From f0942e1fd340475d0f8a141076ecef01552d2b2c Mon Sep 17 00:00:00 2001 From: FloofyPlasma Date: Mon, 9 Feb 2026 23:06:34 -0500 Subject: [PATCH 1/2] fix: update class_getWeakIvarLayout, class_getIvarLayout, class_setIvarLayout and class_setWeakIvarLayout to match Apple signatures --- objc/runtime.h | 8 ++++---- runtime.c | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/objc/runtime.h b/objc/runtime.h index 14cb2748..8359d318 100644 --- a/objc/runtime.h +++ b/objc/runtime.h @@ -414,7 +414,7 @@ OBJC_PUBLIC void class_setVersion(Class theClass, int version); OBJC_PUBLIC OBJC_GNUSTEP_RUNTIME_UNSUPPORTED("Weak instance variables") -const char *class_getWeakIvarLayout(Class cls); +const uint8_t *class_getWeakIvarLayout(Class cls); /** * Returns whether the class is a metaclass. This can be used in conjunction @@ -452,13 +452,13 @@ BOOL class_respondsToSelector(Class cls, SEL sel); * can be applied to other classes. */ OBJC_PUBLIC -const char *class_getIvarLayout(Class cls); +const uint8_t *class_getIvarLayout(Class cls); /** * Sets the class's instance variable layout. The layout argument must be a * value returned by class_getIvarLayout(). */ OBJC_PUBLIC -void class_setIvarLayout(Class cls, const char *layout); +void class_setIvarLayout(Class cls, const uint8_t *layout); /** * Sets the superclass of the specified class. This function is deprecated, @@ -469,7 +469,7 @@ OBJC_PUBLIC __attribute__((deprecated)) Class class_setSuperclass(Class cls, Class newSuper); OBJC_PUBLIC OBJC_GNUSTEP_RUNTIME_UNSUPPORTED("Weak instance variables") -void class_setWeakIvarLayout(Class cls, const char *layout); +void class_setWeakIvarLayout(Class cls, const uint8_t *layout); /** * Returns the name of an instance variable. diff --git a/runtime.c b/runtime.c index e6049441..61f3eb17 100644 --- a/runtime.c +++ b/runtime.c @@ -452,10 +452,10 @@ Ivar class_getInstanceVariable(Class cls, const char *name) // The format of the char* is undocumented. This function is only ever used in // conjunction with class_setIvarLayout(). -const char *class_getIvarLayout(Class cls) +const uint8_t *class_getIvarLayout(Class cls) { CHECK_ARG(cls); - return (char*)cls->ivars; + return (uint8_t*)cls->ivars; } @@ -471,7 +471,7 @@ int class_getVersion(Class theClass) return theClass->version; } -const char *class_getWeakIvarLayout(Class cls) +const uint8_t *class_getWeakIvarLayout(Class cls) { assert(0 && "Weak ivars not supported"); return NULL; @@ -499,7 +499,7 @@ IMP class_replaceMethod(Class cls, SEL name, IMP imp, const char *types) } -void class_setIvarLayout(Class cls, const char *layout) +void class_setIvarLayout(Class cls, const uint8_t *layout) { if ((Nil == cls) || (NULL == layout)) { return; } struct objc_ivar_list *list = (struct objc_ivar_list*)layout; @@ -575,7 +575,7 @@ void class_setVersion(Class theClass, int version) theClass->version = version; } -void class_setWeakIvarLayout(Class cls, const char *layout) +void class_setWeakIvarLayout(Class cls, const uint8_t *layout) { assert(0 && "Not implemented"); } From bb856b0510b1bc5054e975627b944dd08b7a9c51 Mon Sep 17 00:00:00 2001 From: FloofyPlasma Date: Mon, 9 Feb 2026 23:59:32 -0500 Subject: [PATCH 2/2] fix: update return types of objc_lookUpClass and objc_getRequiredClass to Class --- class_table.c | 4 ++-- objc/runtime.h | 4 ++-- runtime.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/class_table.c b/class_table.c index 4d5e6c47..55057edb 100644 --- a/class_table.c +++ b/class_table.c @@ -564,9 +564,9 @@ id objc_getClass(const char *name) return class; } -id objc_lookUpClass(const char *name) +Class objc_lookUpClass(const char *name) { - return (id)class_table_get_safe(name); + return class_table_get_safe(name); } diff --git a/objc/runtime.h b/objc/runtime.h index 8359d318..c9a0ba63 100644 --- a/objc/runtime.h +++ b/objc/runtime.h @@ -628,14 +628,14 @@ id objc_getMetaClass(const char *name); * that all required libraries are loaded. */ OBJC_PUBLIC -id objc_getRequiredClass(const char *name); +Class objc_getRequiredClass(const char *name); /** * Looks up the class with the specified name, but does not invoke any * external lazy loading mechanisms. */ OBJC_PUBLIC -id objc_lookUpClass(const char *name); +Class objc_lookUpClass(const char *name); /** * Returns the protocol with the specified name. diff --git a/runtime.c b/runtime.c index 61f3eb17..45b290e9 100644 --- a/runtime.c +++ b/runtime.c @@ -628,10 +628,10 @@ IMP method_setImplementation(Method method, IMP imp) return old; } -id objc_getRequiredClass(const char *name) +Class objc_getRequiredClass(const char *name) { CHECK_ARG(name); - id cls = objc_getClass(name); + Class cls = (Class)objc_getClass(name); if (nil == cls) { abort();