summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Lisp/class-definition.lisp7
-rw-r--r--Lisp/libobjcl.lisp13
-rw-r--r--Objective-C/libobjcl.h4
-rw-r--r--Objective-C/libobjcl.m14
4 files changed, 18 insertions, 20 deletions
diff --git a/Lisp/class-definition.lisp b/Lisp/class-definition.lisp
index 118e76a..28e97dd 100644
--- a/Lisp/class-definition.lisp
+++ b/Lisp/class-definition.lisp
@@ -149,9 +149,10 @@
(effective-slot-definition
foreign-effective-slot-definition))
(with-slots (foreign-name foreign-type) effective-slot-definition
- (cffi:convert-from-foreign
- (%objcl-slot-value (pointer-to instance) foreign-name)
- (typespec->c-type foreign-type))))
+ ;; FIXME: Do proper value conversion here (like LOW-LEVEL-INVOKE).
+ (cffi:with-foreign-object (return-value-cell (typespec->c-type foreign-type))
+ (%objcl-get-slot-value (pointer-to instance) foreign-name return-value-cell)
+ (mem-ref return-value-cell (typespec->c-type foreign-type)))))
(defmethod (setf c2mop:slot-value-using-class) (value
diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp
index da85f31..727bfc5 100644
--- a/Lisp/libobjcl.lisp
+++ b/Lisp/libobjcl.lisp
@@ -104,9 +104,10 @@
(slot-name :string)
(value :pointer)) ; void
-(defcfun ("objcl_slot_value" %objcl-slot-value) :pointer
+(defcfun ("objcl_get_slot_value" %objcl-get-slot-value) :void
(obj :pointer) ; id
- (slot-name :string))
+ (slot-name :string)
+ (value-out :pointer))
(defcfun ("objcl_class_direct_slots" %objcl-class-direct-slots) :pointer
(class :pointer) ; Class
@@ -849,14 +850,6 @@ separating parts by hyphens works nicely in all of the `:INVERT`,
;;;; (@* "Slot access")
-(defun objcl-set-slot-value (instance slot-name value)
- ;; FIXME
- (error "To be done."))
-
-(defun objcl-slot-value (instance slot-name)
- ;; FIXME
- (error "To be done."))
-
(defun objcl-slot-type (slot)
(%objcl-slot-type slot))
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);
}