1 (in-package :gobject.ffi
)
3 (defctype g-type gsize
)
5 (define-foreign-type g-type-designator
()
6 ((mangled-p :initarg
:mangled-p
7 :reader g-type-designator-mangled-p
9 :documentation
"Whether the type designator is mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag"))
10 (:documentation
"Values of this CFFI foreign type identify the GType. GType is designated by a its name (a string) or a numeric identifier. Functions accept GType designators as a string or integer and return them as a string. Functions @fun{g-type-name} and @fun{g-type-from-name} are used to convert between name and numeric identifier.
12 Numeric identifier of GType may be different between different program runs. But string identifier of GType does not change.")
14 (:simple-parser g-type-designator
))
16 (defun unmangle-g-type (g-type)
17 (logxor g-type
(ldb (byte 1 0) g-type
)));;subtract the G_SIGNAL_TYPE_STATIC_SCOPE
19 (defmethod translate-from-foreign (value (type g-type-designator
))
20 (g-type-name (if (g-type-designator-mangled-p type
)
21 (unmangle-g-type value
)
24 (defmethod translate-to-foreign (value (type g-type-designator
))
26 (string (g-type-from-name value
))
30 (defun g-type-numeric (g-type-designator)
31 (etypecase g-type-designator
32 (string (g-type-from-name g-type-designator
))
33 (integer g-type-designator
)
36 (defun g-type-string (g-type-designator)
37 (etypecase g-type-designator
38 (string (g-type-name g-type-designator
))
39 (integer (g-type-name g-type-designator
))
42 (defcfun (g-type-name "g_type_name") :string
43 "Returns the name of a GType.@see{g-type-from-name}
47 \(g-type-from-name \"GtkLabel\")
49 \(g-type-name 7151952)
52 @arg[type]{GType designator (see @class{g-type-designator})}
54 (type g-type-designator
))
56 (defcfun (g-type-from-name "g_type_from_name") g-type
57 "Returns the numeric identifier of a GType by its name. @see{g-type-name}
61 \(g-type-from-name \"GtkLabel\")
63 \(g-type-name 7151952)
66 @arg[name]{a string - name of GType}
70 (defun g-type= (type-1 type-2
)
71 (= (g-type-numeric type-1
)
72 (g-type-numeric type-2
)))
74 (defun g-type/= (type-1 type-2
)
75 (/= (g-type-numeric type-1
)
76 (g-type-numeric type-2
)))