(slot-value proxy slot)))))
(defmethod translate-to-foreign (proxy (type g-boxed-foreign-type))
- (let* ((info (g-boxed-foreign-info type)))
- (values (create-temporary-native info proxy) proxy)))
+ (if proxy
+ (let* ((info (g-boxed-foreign-info type)))
+ (values (create-temporary-native info proxy) proxy))
+ (null-pointer)))
(defmethod free-translated-object (native-structure (type g-boxed-foreign-type) proxy)
- (free-temporary-native (g-boxed-foreign-info type) proxy native-structure))
+ (when proxy
+ (free-temporary-native (g-boxed-foreign-info type) proxy native-structure)))
(defmethod translate-from-foreign (native-structure (type g-boxed-foreign-type))
- (let* ((info (g-boxed-foreign-info type)))
- (cond
- ((g-boxed-foreign-for-callback type)
- (create-reference-proxy info native-structure))
- ((or (g-boxed-foreign-free-to-foreign type)
- (g-boxed-foreign-free-from-foreign type))
- (error "Feature not yet handled"))
- (t (create-proxy-for-native info native-structure)))))
+ (unless (null-pointer-p native-structure)
+ (let* ((info (g-boxed-foreign-info type)))
+ (cond
+ ((g-boxed-foreign-for-callback type)
+ (create-reference-proxy info native-structure))
+ ((or (g-boxed-foreign-free-to-foreign type)
+ (g-boxed-foreign-free-from-foreign type))
+ (error "Feature not yet handled"))
+ (t (create-proxy-for-native info native-structure))))))
(defmethod cleanup-translated-object-for-callback ((type g-boxed-foreign-type) proxy native-structure)
- (free-reference-proxy (g-boxed-foreign-info type) proxy native-structure))
+ (unless (null-pointer-p native-structure)
+ (free-reference-proxy (g-boxed-foreign-info type) proxy native-structure)))
(defmethod has-callback-cleanup ((type g-boxed-foreign-type))
t)
(iter (for slot in slots)
(setf (foreign-slot-value native-ptr actual-cstruct slot)
(slot-value proxy slot)))))
-
-(define-boxed-variant-cstruct evt "evt"
- (type :int :initform 0)
- (time :uint :initform 0)
- (:variant type
- (0 evt-zero
- (x :double :initform 0.0d0)
- (y :double :initform 0.0d0))
- ((1 2 3) evt-multi
- (t2 :int :initform 0)
- (:variant t2
- (1 evt-single
- (item :uchar :initform 0))))))
-
-(defcallback test-evt (g-boxed-foreign evt)
- ((time :int) (e1 (g-boxed-foreign evt)))
- (print time)
- (print e1)
- (incf (evt-time e1) time)
- (make-evt-multi :time time :t2 123))
-
-(defun do-test-evt (e1 time)
- (let ((e2 (foreign-funcall-pointer (callback test-evt) () :int time (g-boxed-foreign evt) e1 (g-boxed-foreign evt))))
- (values e1 e2)))
--- /dev/null
+(in-package :gobject)
+
+(define-boxed-variant-cstruct evt "evt"
+ (type :int :initform 0)
+ (time :uint :initform 0)
+ (:variant type
+ (0 evt-zero
+ (x :double :initform 0.0d0)
+ (y :double :initform 0.0d0))
+ ((1 2 3) evt-multi
+ (t2 :int :initform 0)
+ (:variant t2
+ (1 evt-single
+ (item :uchar :initform 0))))))
+
+(defcallback test-evt (g-boxed-foreign evt)
+ ((time :int) (e1 (g-boxed-foreign evt)))
+ (print time)
+ (print e1)
+ (when e1
+ (incf (evt-time e1) time))
+ (make-evt-multi :time time :t2 123))
+
+(defun do-test-evt (e1 time)
+ (let ((e2 (foreign-funcall-pointer (callback test-evt) () :int time (g-boxed-foreign evt) e1 (g-boxed-foreign evt))))
+ (values e1 e2)))