3 (defstruct g-class-property-definition
4 "Structure describing property of a GObject class.
6 See accessor functions:
8 @item{@fun{g-class-property-definition-name}}
9 @item{@fun{g-class-property-definition-type}}
10 @item{@fun{g-class-property-definition-readable}}
11 @item{@fun{g-class-property-definition-writable}}
12 @item{@fun{g-class-property-definition-constructor}}
13 @item{@fun{g-class-property-definition-constructor-only}}
14 @item{@fun{g-class-property-definition-owner-type}}
25 (defmethod print-object ((instance g-class-property-definition
) stream
)
28 (print-unreadable-object (instance stream
)
30 "PROPERTY ~A ~A.~A (flags:~@[~* readable~]~@[~* writable~]~@[~* constructor~]~@[~* constructor-only~])"
31 (g-class-property-definition-type instance
)
32 (g-class-property-definition-owner-type instance
)
33 (g-class-property-definition-name instance
)
34 (g-class-property-definition-readable instance
)
35 (g-class-property-definition-writable instance
)
36 (g-class-property-definition-constructor instance
)
37 (g-class-property-definition-constructor-only instance
)))))
39 (setf (documentation 'g-class-property-definition-name
'function
)
40 "Name of GObject class property. See @class{g-class-property-definition}.
43 (setf (documentation 'g-class-property-definition-type
'function
)
44 "Type of GObject class property. See @class{g-class-property-definition}.
45 @return{a GType (integer)}")
47 (setf (documentation 'g-class-property-definition-readable
'function
)
48 "Whether the GObject class property is readable. See @class{g-class-property-definition}.
51 (setf (documentation 'g-class-property-definition-writable
'function
)
52 "Whether the GObject class property is writable. See @class{g-class-property-definition}.
55 (setf (documentation 'g-class-property-definition-constructor
'function
)
56 "Whether the GObject class property can be set at object construction time. See @class{g-class-property-definition}.
59 (setf (documentation 'g-class-property-definition-constructor-only
'function
)
60 "Whether the GObject class property can only be set at object construction time. See @class{g-class-property-definition}.
63 (setf (documentation 'g-class-property-definition-owner-type
'function
)
64 "The GType on which this GObject class property was defined. See @class{g-class-property-definition}.
65 @return{a GType (integer)}")
67 (defun parse-g-param-spec (param)
68 (let ((flags (foreign-slot-value param
'g-param-spec
:flags
)))
69 (make-g-class-property-definition
70 :name
(foreign-slot-value param
'g-param-spec
:name
)
71 :type
(foreign-slot-value param
'g-param-spec
:value-type
)
72 :readable
(not (null (member :readable flags
)))
73 :writable
(not (null (member :writable flags
)))
74 :constructor
(not (null (member :construct flags
)))
75 :constructor-only
(not (null (member :construct-only flags
)))
76 :owner-type
(foreign-slot-value param
'g-param-spec
:owner-type
))))
78 (defmacro with-unwind
((var expr unwind-function
) &body body
)
80 (unwind-protect (progn ,@body
)
81 (,unwind-function
,var
))))
83 (defun class-properties (g-type)
84 "@return{list of properties of GObject class @code{g-type}. Each property is described by an object of type @class{g-class-property-definition}.}
85 @arg[g-type]{an integer or a string specifying the GType}"
86 (assert (g-type-is-a g-type
+g-type-object
+))
87 (with-unwind (g-class (g-type-class-ref g-type
) g-type-class-unref
)
88 (with-foreign-object (n-properties :uint
)
89 (with-unwind (params (g-object-class-list-properties g-class n-properties
) g-free
)
91 for i from
0 below
(mem-ref n-properties
:uint
)
92 for param
= (mem-aref params
:pointer i
)
93 collect
(parse-g-param-spec param
))))))
95 (defun class-property-info (g-type property-name
)
96 (with-unwind (g-class (g-type-class-ref g-type
) g-type-class-unref
)
97 (let* ((param-spec (g-object-class-find-property g-class property-name
)))
98 (when param-spec
(parse-g-param-spec param-spec
)))))
100 (defun interface-properties (g-type)
101 "@return{list of properties of GObject interface @code{g-type}. Each property is described by an object of type @class{g-class-property-definition}.}
102 @arg[g-type]{an integer or a string specifying the GType}"
103 (assert (g-type-is-a g-type
+g-type-interface
+))
104 (with-unwind (g-iface (g-type-default-interface-ref g-type
) g-type-default-interface-unref
)
105 (with-foreign-object (n-properties :uint
)
106 (with-unwind (params (g-object-interface-list-properties g-iface n-properties
) g-free
)
108 for i from
0 below
(mem-ref n-properties
:uint
)
109 for param
= (mem-aref params
:pointer i
)
110 collect
(parse-g-param-spec param
))))))