alternative to assert
[gtkD.git] / gtkD / src / glib / ScannerG.d
blobc756def3594701121a7862553bbb8dc0ffc76039
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = glib-Lexical-Scanner.html
26 * outPack = glib
27 * outFile = ScannerG
28 * strct = GScanner
29 * realStrct=
30 * ctorStrct=
31 * clss = ScannerG
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_scanner
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.HashTable
45 * - glib.Str
46 * structWrap:
47 * - GHashTable* -> HashTable
48 * - GScanner* -> ScannerG
49 * module aliases:
50 * local aliases:
53 module glib.ScannerG;
55 version(noAssert)
57 version(Tango)
59 import tango.io.Stdout; // use the tango loging?
63 private import gtkc.glibtypes;
65 private import gtkc.glib;
68 private import glib.HashTable;
69 private import glib.Str;
74 /**
75 * Description
76 * The GScanner and its associated functions provide a general purpose
77 * lexical scanner.
79 public class ScannerG
82 /** the main Gtk struct */
83 protected GScanner* gScanner;
86 public GScanner* getScannerGStruct()
88 return gScanner;
92 /** the main Gtk struct as a void* */
93 protected void* getStruct()
95 return cast(void*)gScanner;
98 /**
99 * Sets our main struct and passes it to the parent class
101 public this (GScanner* gScanner)
103 version(noAssert)
105 if ( gScanner is null )
107 int zero = 0;
108 version(Tango)
110 Stdout("struct gScanner is null on constructor").newline;
112 else
114 printf("struct gScanner is null on constructor");
116 zero = zero / zero;
119 else
121 assert(gScanner !is null, "struct gScanner is null on constructor");
123 this.gScanner = gScanner;
131 * Creates a new GScanner.
132 * The config_templ structure specifies the initial settings of the scanner,
133 * which are copied into the GScanner config field.
134 * If you pass NULL then the default settings are used.
135 * config_templ:
136 * the initial scanner settings.
137 * Returns:
138 * the new GScanner.
140 public static ScannerG _New(GScannerConfig* configTempl)
142 // GScanner* g_scanner_new (const GScannerConfig *config_templ);
143 return new ScannerG( g_scanner_new(configTempl) );
148 * Prepares to scan a file.
149 * scanner:
150 * a GScanner.
151 * input_fd:
152 * a file descriptor.
154 public void _InputFile(int inputFd)
156 // void g_scanner_input_file (GScanner *scanner, gint input_fd);
157 g_scanner_input_file(gScanner, inputFd);
161 * Rewinds the filedescriptor to the current buffer position and blows
162 * the file read ahead buffer. This is useful for third party uses of
163 * the scanners filedescriptor, which hooks onto the current scanning
164 * position.
165 * scanner:
166 * a GScanner.
168 public void _SyncFileOffset()
170 // void g_scanner_sync_file_offset (GScanner *scanner);
171 g_scanner_sync_file_offset(gScanner);
175 * Prepares to scan a text buffer.
176 * scanner:
177 * a GScanner.
178 * text:
179 * the text buffer to scan.
180 * text_len:
181 * the length of the text buffer.
183 public void _InputText(char[] text, uint textLen)
185 // void g_scanner_input_text (GScanner *scanner, const gchar *text, guint text_len);
186 g_scanner_input_text(gScanner, Str.toStringz(text), textLen);
190 * Gets the next token, without removing it from the input stream.
191 * The token data is placed in the
192 * next_token,
193 * next_value,
194 * next_line, and
195 * next_position fields of the GScanner structure.
196 * Note that, while the token is not removed from the input stream (i.e.
197 * the next call to g_scanner_get_next_token() will return the same token),
198 * it will not be reevaluated. This can lead to surprising results when
199 * changing scope after peeking for the next token. Getting the next token
200 * after switching the scope will return whatever was peeked before,
201 * regardless of any symbols that may have been added or removed in the
202 * new scope.
203 * scanner:
204 * a GScanner.
205 * Returns:
206 * the type of the token.
208 public GTokenType _PeekNextToken()
210 // GTokenType g_scanner_peek_next_token (GScanner *scanner);
211 return g_scanner_peek_next_token(gScanner);
215 * Gets the next token, removing it from the input stream.
216 * The token data is placed in the
217 * token,
218 * value,
219 * line, and
220 * position fields of the GScanner structure.
221 * scanner:
222 * a GScanner.
223 * Returns:
224 * the type of the token.
226 public GTokenType _GetNextToken()
228 // GTokenType g_scanner_get_next_token (GScanner *scanner);
229 return g_scanner_get_next_token(gScanner);
233 * Gets the current line in the input stream (counting from 1).
234 * scanner:
235 * a GScanner.
236 * Returns:
237 * the current line.
239 public uint _CurLine()
241 // guint g_scanner_cur_line (GScanner *scanner);
242 return g_scanner_cur_line(gScanner);
246 * Gets the current position in the current line (counting from 0).
247 * scanner:
248 * a GScanner.
249 * Returns:
250 * the current position on the line.
252 public uint _CurPosition()
254 // guint g_scanner_cur_position (GScanner *scanner);
255 return g_scanner_cur_position(gScanner);
259 * Gets the current token type.
260 * This is simply the token field in the GScanner
261 * structure.
262 * scanner:
263 * a GScanner.
264 * Returns:
265 * the current token type.
267 public GTokenType _CurToken()
269 // GTokenType g_scanner_cur_token (GScanner *scanner);
270 return g_scanner_cur_token(gScanner);
274 * Gets the current token value.
275 * This is simply the value field in the GScanner
276 * structure.
277 * scanner:
278 * a GScanner.
279 * Returns:
280 * the current token value.
282 public GTokenValue _CurValue()
284 // GTokenValue g_scanner_cur_value (GScanner *scanner);
285 return g_scanner_cur_value(gScanner);
289 * Returns TRUE if the scanner has reached the end of the file or text buffer.
290 * scanner:
291 * a GScanner.
292 * Returns:
293 * TRUE if the scanner has reached the end of the file or text buffer.
295 public int _Eof()
297 // gboolean g_scanner_eof (GScanner *scanner);
298 return g_scanner_eof(gScanner);
302 * Sets the current scope.
303 * scanner:
304 * a GScanner.
305 * scope_id:
306 * the new scope id.
307 * Returns:
308 * the old scope id.
310 public uint _SetScope(uint scopeId)
312 // guint g_scanner_set_scope (GScanner *scanner, guint scope_id);
313 return g_scanner_set_scope(gScanner, scopeId);
317 * Adds a symbol to the given scope.
318 * scanner:
319 * a GScanner.
320 * scope_id:
321 * the scope id.
322 * symbol:
323 * the symbol to add.
324 * value:
325 * the value of the symbol.
327 public void _ScopeAddSymbol(uint scopeId, char[] symbol, void* value)
329 // void g_scanner_scope_add_symbol (GScanner *scanner, guint scope_id, const gchar *symbol, gpointer value);
330 g_scanner_scope_add_symbol(gScanner, scopeId, Str.toStringz(symbol), value);
334 * Calls the given function for each of the symbol/value pairs in the
335 * given scope of the GScanner. The function is passed the symbol and
336 * value of each pair, and the given user_data parameter.
337 * scanner:
338 * a GScanner.
339 * scope_id:
340 * the scope id.
341 * func:
342 * the function to call for each symbol/value pair.
343 * user_data:
344 * user data to pass to the function.
346 public void _ScopeForeachSymbol(uint scopeId, GHFunc func, void* userData)
348 // void g_scanner_scope_foreach_symbol (GScanner *scanner, guint scope_id, GHFunc func, gpointer user_data);
349 g_scanner_scope_foreach_symbol(gScanner, scopeId, func, userData);
353 * Looks up a symbol in a scope and return its value. If the
354 * symbol is not bound in the scope, NULL is returned.
355 * scanner:
356 * a GScanner.
357 * scope_id:
358 * the scope id.
359 * symbol:
360 * the symbol to look up.
361 * Returns:
362 * the value of symbol in the given scope, or NULL
363 * if symbol is not bound in the given scope.
365 public void* _ScopeLookupSymbol(uint scopeId, char[] symbol)
367 // gpointer g_scanner_scope_lookup_symbol (GScanner *scanner, guint scope_id, const gchar *symbol);
368 return g_scanner_scope_lookup_symbol(gScanner, scopeId, Str.toStringz(symbol));
372 * Removes a symbol from a scope.
373 * scanner:
374 * a GScanner.
375 * scope_id:
376 * the scope id.
377 * symbol:
378 * the symbol to remove.
380 public void _ScopeRemoveSymbol(uint scopeId, char[] symbol)
382 // void g_scanner_scope_remove_symbol (GScanner *scanner, guint scope_id, const gchar *symbol);
383 g_scanner_scope_remove_symbol(gScanner, scopeId, Str.toStringz(symbol));
389 * Looks up a symbol in the current scope and return its value. If the
390 * symbol is not bound in the current scope, NULL is returned.
391 * scanner:
392 * a GScanner.
393 * symbol:
394 * the symbol to look up.
395 * Returns:
396 * the value of symbol in the current scope, or NULL
397 * if symbol is not bound in the current scope.
399 public void* _LookupSymbol(char[] symbol)
401 // gpointer g_scanner_lookup_symbol (GScanner *scanner, const gchar *symbol);
402 return g_scanner_lookup_symbol(gScanner, Str.toStringz(symbol));
406 * Outputs a warning message, via the GScanner message handler.
407 * scanner:
408 * a GScanner.
409 * format:
410 * the message format. See the printf()
411 * documentation.
412 * ...:
413 * the parameters to insert into the format string.
415 public void _Warn(char[] format, ... )
417 // void g_scanner_warn (GScanner *scanner, const gchar *format, ...);
418 g_scanner_warn(gScanner, Str.toStringz(format));
422 * Outputs an error message, via the GScanner message handler.
423 * scanner:
424 * a GScanner.
425 * format:
426 * the message format. See the printf()
427 * documentation.
428 * ...:
429 * the parameters to insert into the format string.
431 public void _Error(char[] format, ... )
433 // void g_scanner_error (GScanner *scanner, const gchar *format, ...);
434 g_scanner_error(gScanner, Str.toStringz(format));
438 * Outputs a message through the scanner's msg_handler, resulting from an
439 * unexpected token in the input stream.
440 * Note that you should not call g_scanner_peek_next_token() followed by
441 * g_scanner_unexp_token() without an intermediate call to
442 * g_scanner_get_next_token(), as g_scanner_unexp_token() evaluates the
443 * scanner's current token (not the peeked token) to construct part
444 * of the message.
445 * scanner:
446 * a GScanner.
447 * expected_token:
448 * the expected token.
449 * identifier_spec:
450 * a string describing how the scanner's user refers to
451 * identifiers (NULL defaults to "identifier").
452 * This is used if expected_token is G_TOKEN_IDENTIFIER
453 * or G_TOKEN_IDENTIFIER_NULL.
454 * symbol_spec:
455 * a string describing how the scanner's user refers to
456 * symbols (NULL defaults to "symbol").
457 * This is used if expected_token is G_TOKEN_SYMBOL or
458 * any token value greater than G_TOKEN_LAST.
459 * symbol_name:
460 * the name of the symbol, if the scanner's current token
461 * is a symbol.
462 * message:
463 * a message string to output at the end of the warning/error, or NULL.
464 * is_error:
465 * if TRUE it is output as an error. If FALSE it is output as a
466 * warning.
468 public void _UnexpToken(GTokenType expectedToken, char[] identifierSpec, char[] symbolSpec, char[] symbolName, char[] message, int isError)
470 // void g_scanner_unexp_token (GScanner *scanner, GTokenType expected_token, const gchar *identifier_spec, const gchar *symbol_spec, const gchar *symbol_name, const gchar *message, gint is_error);
471 g_scanner_unexp_token(gScanner, expectedToken, Str.toStringz(identifierSpec), Str.toStringz(symbolSpec), Str.toStringz(symbolName), Str.toStringz(message), isError);
476 * Frees all memory used by the GScanner.
477 * scanner:
478 * a GScanner.
480 public void _Destroy()
482 // void g_scanner_destroy (GScanner *scanner);
483 g_scanner_destroy(gScanner);