1 ! Copyright (C) 2009 Anton Gorenko.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien alien.c-types assocs
4 combinators.short-circuit gobject-introspection.common
5 gobject-introspection.repository kernel namespaces
7 IN: gobject-introspection.types
9 TUPLE: gwrapper { underlying alien } ;
10 TUPLE: grecord < gwrapper ;
11 TUPLE: gobject < gwrapper ;
14 void* bool int uint char uchar short ushort long ulong
15 longlong ulonglong float double ;
17 CONSTANT: simple-types H{
19 void* *void* >void*-array <direct-void*-array>
22 bool *bool >bool-array <direct-bool-array>
25 int *int >int-array <direct-int-array>
28 uint *uint >uint-array <direct-uint-array>
31 char *char >char-array <direct-char-array>
34 uchar *uchar >uchar-array <direct-uchar-array>
37 short *short >short-array <direct-short-array>
40 ushort *ushort >ushort-array <direct-ushort-array>
43 int *int >int-array <direct-int-array>
46 uint *uint >uint-array <direct-uint-array>
50 >longlong-array <direct-longlong-array>
54 >ulonglong-array <direct-ulonglong-array>
57 long *long >long-array <direct-long-array>
60 ulong *ulong >ulong-array <direct-ulong-array>
63 float *float >float-array <direct-float-array>
66 double *double >double-array <direct-double-array>
69 ulong *ulong >ulong-array <direct-ulong-array>
72 long *long >long-array <direct-long-array>
75 long *long >long-array <direct-long-array>
78 ulong *ulong >ulong-array <direct-ulong-array>
82 TUPLE: type-info c-type-word type-word ;
84 TUPLE: enum-info < type-info ;
86 TUPLE: bitfield-info < type-info ;
88 TUPLE: record-info < type-info ;
90 TUPLE: union-info < type-info ;
92 TUPLE: callback-info < type-info ;
94 TUPLE: class-info < type-info ;
96 TUPLE: interface-info < type-info ;
98 : aliased-type ( alias -- type )
99 aliases get ?at [ aliased-type ] when ;
101 : get-type-info ( type -- info )
102 aliased-type type-infos get at ;
104 PREDICATE: none-type < type
105 [ namespace>> not ] [ name>> "none" = ] bi and ;
107 PREDICATE: simple-type < type
109 [ namespace>> not ] [ name>> simple-types key? ] bi and ;
111 PREDICATE: utf8-type < type
113 [ namespace>> not ] [ name>> "utf8" = ] bi and ;
115 PREDICATE: any-type < type
117 [ namespace>> not ] [ name>> "any" = ] bi and ;
119 PREDICATE: enum-type < type get-type-info enum-info? ;
121 PREDICATE: bitfield-type < type get-type-info bitfield-info? ;
123 PREDICATE: record-type < type get-type-info record-info? ;
125 PREDICATE: union-type < type get-type-info union-info? ;
127 PREDICATE: callback-type < type get-type-info callback-info? ;
129 PREDICATE: class-type < type get-type-info class-info? ;
131 PREDICATE: interface-type < type get-type-info interface-info? ;
133 : absolute-type ( type -- type' )
135 [ namespace>> ] [ simple-type? ]
136 [ utf8-type? ] [ none-type? ]
137 } 1|| [ current-lib get-global >>namespace ] unless ;