(g-boxed-foreign name &rest option*) option ::= :return
:return
g-boxed-foreign
type deals with marshaling data between Lisp code and foreign code. The marshaling follows the following principles:
The :return
option is required to be able to properly manage memory of opaque pointer wrappers and propagate changes to foreign and lisp structures.
In order to be able to correctly use g-boxed-foreign
foreign type in callbacks, you should use glib-defcallback
. This macro is a thin wrapper around cffi:defcallback
that adds proper handling of g-boxed-foreign
foreign types.
Examples of usage:
(define-vtable ("GtkTreeModel" c-gtk-tree-model) ... (tree-model-get-path-impl tree-model-get-path-cb (g-boxed-foreign tree-path :return) (tree-model g-object) (iter (g-boxed-foreign tree-iter))) (tree-model-get-value-impl tree-model-get-value-cb :void (tree-model g-object) (iter (g-boxed-foreign tree-iter)) (n :int) (value (:pointer g-value))) (tree-model-iter-next-impl tree-model-iter-next-cb :boolean (tree-model g-object) (iter (g-boxed-foreign tree-iter))) ...) (defcfun gtk-text-iter-forward-search :boolean (iter (g-boxed-foreign text-iter)) (str (:string :free-to-foreign t)) (flags text-search-flags) (match-start (g-boxed-foreign text-iter)) (match-end (g-boxed-foreign text-iter)) (limit (g-boxed-foreign text-iter)))