diff options
Diffstat (limited to 'Objective-C')
-rw-r--r-- | Objective-C/libobjcl.h | 4 | ||||
-rw-r--r-- | Objective-C/libobjcl.m | 14 |
2 files changed, 11 insertions, 7 deletions
diff --git a/Objective-C/libobjcl.h b/Objective-C/libobjcl.h index 4b26fae..758c831 100644 --- a/Objective-C/libobjcl.h +++ b/Objective-C/libobjcl.h @@ -139,8 +139,8 @@ objcl_alignof_type (const char *typespec); void objcl_set_slot_value (id obj, const char *ivar_name, void *value); -void * -objcl_slot_value (id obj, const char *ivar_name); +void +objcl_get_slot_value (id obj, const char *ivar_name, void *value_out); /* The following function returns a freshly consed array that the caller must deallocate. */ diff --git a/Objective-C/libobjcl.m b/Objective-C/libobjcl.m index cd35b86..d02e58b 100644 --- a/Objective-C/libobjcl.m +++ b/Objective-C/libobjcl.m @@ -487,15 +487,19 @@ objcl_set_slot_value (id obj, const char *ivar_name, void *value) } -void * -objcl_slot_value (id obj, const char *ivar_name) +void +objcl_get_slot_value (id obj, const char *ivar_name, void *value_out) { - void *value; /* Caching Ivars may be useful here. Using those instead of strings is claimed to be faster. */ + /* For the GNU runtime, this function is defined in objc-runtime-gnu.m. */ - object_getInstanceVariable (obj, ivar_name, &value); - return value; + + /* NOTE: Contrary to what the official Objective-C runtime docs claim, + value_out is actually a (void *) rather than a (void **). + Likewise, the result that is copied to value_out is the slot value + itself, not a pointer to it. */ + object_getInstanceVariable (obj, ivar_name, value_out); } |