Expose struct slot type and count via FOREIGN-SLOT-TYPE and FOREIGN-SLOT-COUNT.
authorJoshua Elsasser <joshua@elsasser.org>
Sat, 15 Dec 2012 16:09:05 +0000 (08:09 -0800)
committerLuís Oliveira <loliveira@common-lisp.net>
Sun, 6 Jan 2013 20:53:17 +0000 (20:53 +0000)
This is especially useful when the type and count have been groveled.

src/package.lisp
src/types.lisp

index 5dd0ade..77fa56e 100644 (file)
    #:foreign-bitfield-value
    #:foreign-slot-pointer
    #:foreign-slot-value
+   #:foreign-slot-type
    #:foreign-slot-offset
+   #:foreign-slot-count
    #:foreign-slot-names
    #:foreign-type-alignment
    #:foreign-type-size
index 3a90050..582a94d 100644 (file)
@@ -701,10 +701,18 @@ The foreign array must be freed with foreign-array-free."
   "Return the address of SLOT-NAME in the structure at PTR."
   (foreign-struct-slot-pointer ptr (get-slot-info type slot-name)))
 
+(defun foreign-slot-type (type slot-name)
+  "Return the type of SLOT in a struct TYPE."
+  (slot-type (get-slot-info type slot-name)))
+
 (defun foreign-slot-offset (type slot-name)
   "Return the offset of SLOT in a struct TYPE."
   (slot-offset (get-slot-info type slot-name)))
 
+(defun foreign-slot-count (type slot-name)
+  "Return the number of items in SLOT in a struct TYPE."
+  (slot-count (get-slot-info type slot-name)))
+
 (defun foreign-slot-value (ptr type slot-name)
   "Return the value of SLOT-NAME in the foreign structure at PTR."
   (foreign-struct-slot-value ptr (get-slot-info type slot-name)))