2 * Copyright (C) 1999-2000 the Free Software Foundation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
32 print_error(int is_warn, char *error,int line)
42 fprintf(stderr,"%s:%d: %s %s\n",filename,line,w,error);
44 fprintf(stderr,"%s: %s %s\n",filename,w,error);
45 if((!is_warn || exit_on_warn) && exit_on_error)
50 remove_sep(char *base)
53 char *s = g_strdup(base);
54 while((p=strchr(s,':')))
60 replace_sep(char *base, char r)
63 char *s = g_strdup(base);
64 while((p=strchr(s,':')))
74 /*separate the namespace part and then replace rest of
77 separns_replace_sep(char *base, char **ns, char **name, char r)
80 char *s = g_strdup(base);
82 if((p=strchr(s,':')) && p!=s) {
89 while((p=strchr(s,':')))
92 *name = g_strdup(s+1);
98 /* make a macro with some prefix before the name but after
101 make_pre_macro(char *base, char *pre)
106 separns_replace_sep(base,&s1,&s2,'_');
108 s = g_strconcat(s1,"_",pre,"_",s2,NULL);
110 s = g_strconcat(pre,"_",s2,NULL);
120 /* here we will find out how inconsistent gtk really is :) */
121 /* the commented out types mean that these types don't actually
122 exist. so we "emulate them" with an equivalent */
127 } our_gtk_type_table[] = {
128 { TRUE, "NONE", "void " },
129 { TRUE, "CHAR", "gchar " },
130 { TRUE, "UCHAR", "guchar " },
131 { TRUE, "BOOL", "gboolean " },
132 { TRUE, "INT", "gint " },
133 { TRUE, "UINT", "guint " },
134 { TRUE, "LONG", "glong " },
135 { TRUE, "ULONG", "gulong " },
136 { TRUE, "FLOAT", "gfloat " },
137 { TRUE, "DOUBLE", "gdouble " },
138 { TRUE, "STRING", /*"GtkString"*/"gchar *" },
139 { TRUE, "ENUM", /*"GtkEnum"*/"gint " },
140 { TRUE, "FLAGS", /*"GtkFlags"*/"guint " },
141 { TRUE, "BOXED", /*"GtkBoxed"*/"gpointer " },
142 { TRUE, "POINTER", "gpointer " },
143 { TRUE, "OBJECT", "GtkObject *" },
144 { FALSE, "SIGNAL", /*"GtkSignal"*/"___twopointertype " },
145 { FALSE, "ARGS", /*"GtkArgs"*/"___twopointertype " },
146 { FALSE, "CALLBACK", /*"GtkCallback"*/"___threepointertype " },
147 { FALSE, "C_CALLBACK", /*"GtkCCallback"*/"___twopointertype " },
148 { FALSE, "FOREIGN", /*"GtkForeign"*/"___twopointertype " },
150 { FALSE, NULL, NULL }
154 get_cast(char *type, gboolean simple_only)
157 for(i=0;our_gtk_type_table[i].gtkname;i++) {
158 if(strcmp(our_gtk_type_table[i].gtkname,type)==0) {
160 !our_gtk_type_table[i].simple)
162 return our_gtk_type_table[i].typename;