summaryrefslogtreecommitdiff
path: root/Lisp
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-02-03 23:21:48 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-02-03 23:21:48 +0100
commit94383388101170742989e188e020f91b81a2ddfe (patch)
tree4b2ecbbcf6cdb7172e8cbc2cb6b2f676fc23706a /Lisp
parent046f4e6ecbe2cbef2079eb8a245895ff70238e92 (diff)
Glue layer: Add slot handling functions.
darcs-hash:27035c01db5e23dc0c8c9786ded92aa6e564e6d4
Diffstat (limited to 'Lisp')
-rw-r--r--Lisp/libobjcl.lisp51
1 files changed, 51 insertions, 0 deletions
diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp
index c973828..618a8b1 100644
--- a/Lisp/libobjcl.lisp
+++ b/Lisp/libobjcl.lisp
@@ -97,6 +97,26 @@
(defcfun ("objcl_alignof_type" %objcl-alignof-type) :long
(typespec :string))
+(defcfun ("objcl_set_slot_value" %objcl-set-slot-value) :void
+ (obj :pointer) ; id
+ (slot-name :string)
+ (value :pointer)) ; void
+
+(defcfun ("objcl_slot_value" %objcl-slot-value) :pointer
+ (obj :pointer) ; id
+ (slot-name :string))
+
+(defcfun ("objcl_class_direct_slots" %objcl-class-direct-slots) :pointer
+ (class :pointer) ; Class
+ (count :pointer) ; unsigned int
+ (element-size :pointer)) ; unsigned int
+
+(defcfun ("objcl_slot_name" %objcl-slot-name) :string
+ (slot :pointer)) ; IVAR_T
+
+(defcfun ("objcl_slot_type" %objcl-slot-type) :string
+ (slot :pointer)) ; IVAR_T
+
(defcfun ("objcl_get_nil" %objcl-get-nil) :pointer)
(defcfun objcl-get-yes :long)
(defcfun objcl-get-no :long)
@@ -702,3 +722,34 @@ separating parts by hyphens works nicely in all of the `:INVERT`,
(defun objc-2.0-runtime-p ()
(not (zerop (%objcl-objc2-p))))
+
+
+;;;; (@* "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))
+
+(defun objcl-slot-name (slot)
+ (%objcl-slot-name slot))
+
+(defun objcl-class-direct-slots (class)
+ (with-foreign-objects ((count-ptr :unsigned-int)
+ (element-size-ptr :unsigned-int))
+ (let ((array-pointer (%objcl-class-direct-slots (pointer-to class)
+ count-ptr
+ element-size-ptr)))
+ (unwind-protect
+ (loop with element-size = (mem-ref element-size-ptr :unsigned-int)
+ with count = (mem-ref count-ptr :unsigned-int)
+ for i from 0 below count
+ for current-slot = array-pointer
+ then (inc-pointer current-slot element-size)
+ collecting (mem-ref current-slot :pointer))
+ (foreign-free array-pointer)))))