1 /* GObject introspection: public scanner api
3 * Copyright (C) 2007 Jürg Billeter
4 * Copyright (C) 2008 Johan Dahlin
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 #ifndef __SOURCE_SCANNER_H__
24 #define __SOURCE_SCANNER_H__
31 typedef struct _GISourceScanner GISourceScanner;
32 typedef struct _GISourceSymbol GISourceSymbol;
33 typedef struct _GISourceType GISourceType;
34 typedef struct _GISourceDirective GISourceDirective;
41 CSYMBOL_TYPE_FUNCTION,
64 STORAGE_CLASS_NONE = 0,
65 STORAGE_CLASS_TYPEDEF = 1 << 1,
66 STORAGE_CLASS_EXTERN = 1 << 2,
67 STORAGE_CLASS_STATIC = 1 << 3,
68 STORAGE_CLASS_AUTO = 1 << 4,
69 STORAGE_CLASS_REGISTER = 1 << 5
70 } StorageClassSpecifier;
74 TYPE_QUALIFIER_NONE = 0,
75 TYPE_QUALIFIER_CONST = 1 << 1,
76 TYPE_QUALIFIER_RESTRICT = 1 << 2,
77 TYPE_QUALIFIER_VOLATILE = 1 << 3
83 FUNCTION_INLINE = 1 << 1
89 UNARY_POINTER_INDIRECTION,
92 UNARY_BITWISE_COMPLEMENT,
93 UNARY_LOGICAL_NEGATION
96 struct _GISourceScanner
98 char *current_filename;
102 GHashTable *directives_map;
103 GHashTable *typedef_table;
104 GHashTable *struct_or_union_or_enum_table;
107 struct _GISourceSymbol
110 GISourceSymbolType type;
113 GISourceType *base_type;
114 gboolean const_int_set;
117 GSList *directives; /* list of GISourceDirective */
122 GISourceTypeType type;
123 StorageClassSpecifier storage_class_specifier;
124 TypeQualifier type_qualifier;
125 FunctionSpecifier function_specifier;
127 GISourceType *base_type;
128 GList *child_list; /* list of GISourceSymbol */
131 struct _GISourceDirective
135 GSList *options; /* list of options (key=value) */
138 GISourceScanner * gi_source_scanner_new (void);
139 gboolean gi_source_scanner_lex_filename (GISourceScanner *igenerator,
140 const gchar *filename);
141 gboolean gi_source_scanner_parse_file (GISourceScanner *igenerator,
143 void gi_source_scanner_set_macro_scan (GISourceScanner *scanner,
144 gboolean macro_scan);
145 GSList * gi_source_scanner_get_symbols (GISourceScanner *scanner);
146 GSList * gi_source_scanner_get_directives (GISourceScanner *scanner,
148 void gi_source_scanner_free (GISourceScanner *scanner);
150 GISourceSymbol * gi_source_symbol_new (GISourceSymbolType type);
151 gboolean gi_source_symbol_get_const_boolean (GISourceSymbol *symbol);
152 GISourceSymbol * gi_source_symbol_ref (GISourceSymbol *symbol);
153 void gi_source_symbol_unref (GISourceSymbol *symbol);
155 GISourceDirective * gi_source_directive_new (const gchar *name,
158 void gi_source_directive_free (GISourceDirective *directive);
161 GISourceType * gi_source_array_new (void);
162 void gi_source_scanner_add_symbol (GISourceScanner *scanner,
163 GISourceSymbol *symbol);
164 gboolean gi_source_scanner_is_typedef (GISourceScanner *scanner,
166 void gi_source_symbol_merge_type (GISourceSymbol *symbol,
168 GISourceType * gi_source_type_new (GISourceTypeType type);
169 GISourceType * gi_source_type_copy (GISourceType *type);
170 GISourceType * gi_source_basic_type_new (const char *name);
171 GISourceType * gi_source_typedef_new (const char *name);
172 GISourceType * gi_source_struct_new (const char *name);
173 GISourceType * gi_source_union_new (const char *name);
174 GISourceType * gi_source_enum_new (const char *name);
175 GISourceType * gi_source_pointer_new (GISourceType *base_type);
176 GISourceType * gi_source_array_new (void);
177 GISourceType * gi_source_function_new (void);
181 #endif /* __SOURCE_SCANNER_H__ */