]> git.draconx.ca Git - gob-dx.git/blob - src/util.h
Replace gnulib patch with new common helper macro.
[gob-dx.git] / src / util.h
1 /* GOB C Preprocessor
2  * Copyright (C) 1999-2000 the Free Software Foundation.
3  * Copyright (C) 2000 Eazel, Inc.
4  * Copyright (C) 2022 Nick Bowler
5  *
6  * Author: George Lebl
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the  Free Software
20  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21  * USA.
22  */
23
24 #ifndef UTIL_H
25 #define UTIL_H
26
27 #include <glib.h>
28
29 struct Class;
30 struct Type;
31
32 enum {
33         GOB_WARN,
34         GOB_ERROR
35 };
36
37 /* print an error, or warning referring to 'line'
38  * (line can be 0 or negative for no line) */
39 void error_print(int type, int line, const char *error);
40 void error_printf(int type, int line, const char *error, ...) G_GNUC_PRINTF (3, 4);
41
42 /* remove the : separator from a typename */
43 char * remove_sep(const char *base);
44 /* replace the : separator from a typename with a different character*/
45 char * replace_sep(const char *base, char r);
46
47 #if !HAVE_G_STRING_APPEND_PRINTF
48 #  define g_string_append_printf g_string_sprintfa
49 #  define g_string_printf g_string_sprintf
50 #endif
51
52 char *gob_strup(char *s);
53 char *gob_strdown(char *s);
54
55 #if HAVE_G_ASCII_STRCASECMP
56 static inline int gob_strcasecmp(const char *s1, const char *s2)
57 {
58         return g_ascii_strcasecmp(s1, s2);
59 }
60 #else
61 int gob_strcasecmp(const char *s1, const char *s2);
62 #endif
63
64 char * gob_str_delete_quotes(char *str);
65
66 /*separate the namespace part and then replace rest of
67   separators with r*/
68 void separns_replace_sep(const char *base, char **ns, char **name, char r);
69
70 /* make a macro with some prefix before the name but after
71    namespace */
72 char * make_pre_macro(const char *base,const  char *pre);
73
74 /* get a name usable for a cast from a GObject (without G_TYPE_)*/
75 const char *get_cast(const char *type, gboolean simple_only);
76 struct Type *get_tree_type(const char *type, gboolean simple_only);
77 char *get_type(const struct Type *t, gboolean postfix_to_stars);
78
79 enum {
80         SPECIAL_2POINTER,
81         SPECIAL_3POINTER,
82         SPECIAL_INT_POINTER,
83         SPECIAL_LAST
84 };
85
86 /* returns TRUE if there are any special types at all */
87 gboolean setup_special_array(struct Class *c, gboolean *special_array);
88
89 char * make_me_type (const char *type, const char *alt);
90
91 #endif /* UTIL_H */