Add translate-to-foreign and free-translated-object methods to gobject:fixed-array...
authorDmitry Kalyanov <Kalyanov.Dmitry@gmail.com>
Sun, 29 Aug 2010 14:01:45 +0000 (18:01 +0400)
committerDmitry Kalyanov <Kalyanov.Dmitry@gmail.com>
Sun, 29 Aug 2010 14:01:45 +0000 (18:01 +0400)
gdk/gdk.objects.lisp

index 79ebcb7..3c540be 100644 (file)
          do (setf (aref result i) (mem-aref ptr el-type i)))
       result)))
 
+(defmethod translate-to-foreign (value (type fixed-array))
+  (if (null value)
+      (null-pointer)
+      (foreign-alloc (fixed-array-element-type type) :count (length value) :initial-contents value)))
+
+(defmethod free-translated-object (value (type fixed-array) param)
+  (declare (ignore param))
+  (unless (null-pointer-p value)
+    (foreign-free value)))
+
 (define-g-boxed-cstruct rectangle "GdkRectangle"
   (x :int :initform 0)
   (y :int :initform 0)