glib: Support inline boxed cstruct slots
authorDmitry Kalyanov <Kalyanov.Dmitry@gmail.com>
Thu, 6 Aug 2009 07:33:11 +0000 (11:33 +0400)
committerDmitry Kalyanov <Kalyanov.Dmitry@gmail.com>
Thu, 6 Aug 2009 07:33:11 +0000 (11:33 +0400)
glib/gobject.boxed.lisp

index 301e175..8c93a35 100644 (file)
   name
   type
   count
-  initform)
+  initform
+  inline-p)
+
+(defstruct (cstruct-inline-slot-description (:include cstruct-slot-description))
+  boxed-type-name)
 
 (defmethod make-load-form ((object cstruct-slot-description) &optional environment)
   (make-load-form-saving-slots object :environment environment))
 
+(defmethod make-load-form ((object cstruct-inline-slot-description) &optional environment)
+  (make-load-form-saving-slots object :environment environment))
+
 (defstruct cstruct-description
   name
   slots)
   (make-load-form-saving-slots object :environment environment))
 
 (defun parse-cstruct-slot (slot)
-  (destructuring-bind (name type &key count initform) slot
-    (make-cstruct-slot-description :name name :type type :count count :initform initform)))
+  (destructuring-bind (name type &key count initform inline) slot
+    (if inline
+        (make-cstruct-inline-slot-description :name name :type (generated-cunion-name type)
+                                       :count count :initform initform :inline-p inline
+                                       :boxed-type-name type)
+        (make-cstruct-inline-slot-description :name name :type type
+                                              :count count :initform initform :inline-p inline))))
 
 (defun parse-cstruct-definition (name slots)
   (make-cstruct-description :name name
                  (for i from 0 below (cstruct-slot-description-count slot))
                  (setf (mem-aref ptr (cstruct-slot-description-type slot) i)
                        (aref array i))))
+          ((cstruct-slot-description-inline-p slot)
+           (let ((info (get-g-boxed-foreign-info (cstruct-inline-slot-description-boxed-type-name slot))))
+             (copy-slots-to-native (slot-value proxy slot-name)
+                                   (foreign-slot-pointer native cstruct-type slot-name)
+                                   (g-boxed-cstruct-wrapper-info-cstruct-description info))))
           (t
            (setf (foreign-slot-value native cstruct-type slot-name)
                  (slot-value proxy slot-name))))))
                  (for i from 0 below (cstruct-slot-description-count slot))
                  (setf (aref array i)
                        (mem-aref ptr (cstruct-slot-description-type slot) i))))
+          ((cstruct-slot-description-inline-p slot)
+           (let ((info (get-g-boxed-foreign-info (cstruct-inline-slot-description-boxed-type-name slot))))
+             (copy-slots-to-proxy (slot-value proxy slot-name)
+                                  (foreign-slot-pointer native cstruct-type slot-name)
+                                  (g-boxed-cstruct-wrapper-info-cstruct-description info))))
           (t (setf (slot-value proxy slot-name)
                    (foreign-slot-value native cstruct-type slot-name))))))