Next: , Up: GBoxed

4.12.1 define-g-boxed-cstruct

— Macro: define-g-boxed-cstruct
     (define-g-boxed-cstruct name g-type-name
       &body slot*)
     slot ::= (slot-name slot-type &key count initform inline)
A symbol naming the type being defined
A string specifying the GType name of this GBoxed. This may be nil if this type is not registered with GObject type system.
A symbol naming the slot of a structure
A foreign type of a slot
An integer. Corresponds to :count option of slot in CFFI defcstruct. If count is not NIL, then the slot is mapped to Lisp array.
A form that is the initform of Lisp structure slot
A boolean. If it is true, then the slot contains GBoxed structure whose name is slot-type.

Defines the “simple” GBoxed structure corresponding to C structure. The slot specification is analogous to CFFI defstruct slot specification with the addition of inline option. This also defines the name-cstruct CFFI structure definition with equivalent structure.

Example of usage:

     (define-g-boxed-cstruct rectangle "GdkRectangle"
       (left :int :initform 0)
       (top :int :initform 0)
       (width :int :initform 0)
       (height :int :initform 0))
     (define-g-boxed-cstruct point nil
       (x :int :initform 0)
       (y :int :initform 0))
     (define-g-boxed-cstruct vector4 nil
       (coords :double :count 4 :initform (vector 0d0 0d0 0d0 0d0)))
     (define-g-boxed-cstruct segment nil
       (a point :inline t :initform (make-point))
       (b point :inline t :initform (make-point)))