2 * Copyright (C) 1999,2000 the Free Software Foundation.
3 * Copyright (C) 2000 Eazel, Inc.
4 * Copyright (C) 2001 George Lebl
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.
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.
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,
33 #include "treefuncs.h"
41 char *filename = NULL;
50 extern GList *include_files;
52 extern GHashTable *gtk_doc_hash;
55 static char *funcbase;
56 static char *pfuncbase;
57 static char *macrobase;
59 static char *pmacrois;
60 static char *macrotype;
61 static char *pmacrotype;
62 static char *typebase;
63 static char *ptypebase;
65 static int signals = 0; /* number of signals */
66 static int set_properties = 0; /* number of named (set) properties */
67 static int get_properties = 0; /* number of named (get) properties */
68 static int overrides = 0; /* number of override methods */
69 static int privates = 0; /* number of private data members */
70 static int protecteds = 0; /* number of protected methods */
71 static int unreftors = 0; /* number of variable unreffing destructors */
72 static int destructors = 0; /* number of variable non-unreffing destructors */
73 static int initializers = 0; /* number of variable initializers */
74 static gboolean overrode_get_type = FALSE; /* provided your won _get_type */
76 static gboolean made_aliases = FALSE; /* if we made any shorthand aliases
77 and need the REALLY UGLY HACK to
80 /* the special variable types we need to define */
81 static gboolean special_array[SPECIAL_LAST] = {0};
82 static gboolean any_special = FALSE;
84 static gboolean need_shutdown = FALSE;
85 static Method * shutdown_handler = NULL;
87 static gboolean need_finalize = FALSE;
88 static Method * finalize_handler = NULL;
95 gboolean no_touch_headers = FALSE;
96 gboolean for_cpp = FALSE;
97 gboolean no_gnu = FALSE;
98 gboolean exit_on_warn = FALSE;
99 gboolean exit_on_error = TRUE;
100 gboolean got_error = FALSE;
101 gint private_header = PRIVATE_HEADER_ONDEMAND;
102 gboolean no_extern_c = FALSE;
103 gboolean no_write = FALSE;
104 gboolean no_lines = FALSE;
105 gboolean no_self_alias = FALSE;
106 gboolean always_private_struct = FALSE;
108 int method_unique_id = 1;
113 filebase = replace_sep (((Class *)class)->otype, '-');
114 g_strdown (filebase);
116 funcbase = replace_sep (((Class *)class)->otype, '_');
117 g_strdown (funcbase);
119 pfuncbase = replace_sep (((Class *)class)->ptype, '_');
120 g_strdown (pfuncbase);
122 macrobase = replace_sep (((Class *)class)->otype, '_');
125 macrois = make_pre_macro (((Class *)class)->otype, "IS");
126 pmacrois = make_pre_macro (((Class *)class)->ptype, "IS");
128 macrotype = make_pre_macro (((Class *)class)->otype, "TYPE");
129 pmacrotype = make_pre_macro (((Class *)class)->ptype, "TYPE");
131 typebase = remove_sep (((Class *)class)->otype);
133 ptypebase = remove_sep (((Class *)class)->ptype);
137 get_type (const Type *t, gboolean postfix_to_stars)
144 s = remove_sep(t->name);
145 gs = g_string_new(s);
149 if (postfix_to_stars) {
151 /*XXX: this is ugly perhaps we can do this whole postfix thing
152 in a nicer way, we just count the number of '[' s and from
153 that we deduce the number of dimensions, so that we can print
155 for (p = t->postfix; p && *p; p++)
156 if(*p == '[') extra++;
158 g_string_append_c(gs, ' ');
160 if (t->pointer != NULL) {
161 g_string_append (gs, t->pointer);
162 for (i=0; i < extra; i++)
163 g_string_append_c (gs, '*');
164 g_string_append_c (gs, ' ');
168 g_string_free (gs, FALSE);
173 get_gtk_doc (const char *id)
180 val = g_hash_table_lookup(gtk_doc_hash, id);
182 return g_strdup_printf("/**\n * %s_%s:\n%s **/\n",
184 val = g_hash_table_lookup(gtk_doc_hash, id);
186 return g_strdup_printf("/**\n * %s_%s:\n%s **/\n",
192 print_type(FILE *fp, const Type *t, gboolean postfix_to_stars)
196 s = get_type(t, postfix_to_stars);
197 out_printf(fp, "%s", s);
203 print_method (FILE *fp,
204 const char *typeprefix,
205 const char *nameprefix,
206 const char *subnameprefix,
207 const char *namepostfix,
208 const char *afterargs,
211 gboolean one_arg_per_line,
212 gboolean no_funcbase,
213 gboolean kill_underscore)
218 out_printf(fp, "%s", typeprefix);
219 print_type(fp, m->mtype, TRUE);
224 out_printf(fp, "%s%s%s%s(",
225 nameprefix, subnameprefix, id, namepostfix);
227 out_printf(fp, "%s%s_%s%s%s(",
228 nameprefix, funcbase, subnameprefix, id,
232 for(li=m->args; li; li=g_list_next(li)) {
233 FuncArg *arg = li->data;
234 print_type(fp, arg->atype, FALSE);
236 out_printf(fp, "%s%s,%s", arg->name,
237 arg->atype->postfix ?
238 arg->atype->postfix : "",
239 one_arg_per_line ? "\n\t\t\t\t\t" : " ");
241 out_printf(fp, "%s%s", arg->name,
242 arg->atype->postfix ?
243 arg->atype->postfix : "");
246 out_printf(fp, ",%s...",
247 one_arg_per_line ? "\n\t\t\t\t\t" : " ");
249 out_printf(fp, "void");
251 out_printf(fp, "%s)%s", afterargs, postfix);
255 any_method_to_alias(Class *c)
259 for(li=c->nodes;li;li=g_list_next(li)) {
260 Node *node = li->data;
261 if(node->type == METHOD_NODE) {
262 Method *m = (Method *)node;
264 if(m->method == INIT_METHOD ||
265 m->method == CLASS_INIT_METHOD ||
266 m->method == OVERRIDE_METHOD)
276 /* just the vararg macros, we use the same func pointers for these as in non-gnu */
278 make_method_gnu_aliases(Class *c)
282 for(li = c->nodes; li != NULL; li = li->next) {
283 Node *node = li->data;
284 if(node->type == METHOD_NODE) {
285 Method *m = (Method *)node;
287 if(m->method == INIT_METHOD ||
288 m->method == CLASS_INIT_METHOD ||
289 m->method == OVERRIDE_METHOD)
293 out_printf(out, "#define self_%s(args...) "
294 "%s_%s(args)\n", m->id,
297 out_printf(out, "#define self_%s() "
305 make_method_nongnu_aliases(Class *c)
309 gboolean local_made_aliases = FALSE;
311 for(li=c->nodes; li; li=g_list_next(li)) {
312 Node *node = li->data;
313 if(node->type == METHOD_NODE) {
314 Method *m = (Method *)node;
316 if(m->method == INIT_METHOD ||
317 m->method == CLASS_INIT_METHOD ||
318 m->method == OVERRIDE_METHOD)
321 if( ! local_made_aliases)
322 out_printf(out, "\n/* Short form pointers */\n");
324 print_method(out, "static ", "(* const self_", "", ") ",
326 m, FALSE, TRUE, FALSE);
327 out_printf(out, " = %s_%s;\n", funcbase,
330 local_made_aliases = TRUE;
333 if(local_made_aliases) {
334 out_printf(out, "\n");
340 add_bad_hack_to_avoid_unused_warnings(Class *c)
344 /* if we haven't had any methods, just return */
349 out_printf(out, "\n\n#if (!defined __GNUC__) || (defined __GNUC__ && defined __STRICT_ANSI__)\n");
351 "/*REALLY BAD HACK\n"
352 " This is to avoid unused warnings if you don't call\n"
353 " some method. I need to find a better way to do\n"
354 " this, not needed in GCC since we use some gcc\n"
355 " extentions to make saner, faster code */\n"
357 "___%s_really_bad_hack_to_avoid_warnings(void)\n"
359 out_printf(out, "\t((void (*)(void))GET_NEW_VARG)();\n");
360 for(li=c->nodes;li;li=g_list_next(li)) {
361 Node *node = li->data;
362 if(node->type == METHOD_NODE) {
363 Method *m = (Method *)node;
365 if(m->method == INIT_METHOD ||
366 m->method == CLASS_INIT_METHOD ||
367 m->method == OVERRIDE_METHOD)
370 /* in C++ mode we don't alias new */
371 if(for_cpp && strcmp(m->id, "new")==0)
374 out_printf(out, "\t((void (*)(void))self_%s)();\n", m->id);
377 out_printf(out, "\t___%s_really_bad_hack_to_avoid_warnings();\n",
380 out_printf(out, "}\n#endif /* !__GNUC__ || (__GNUC__ && __STRICT_ANSI__) */\n\n");
382 out_printf(out, "}\n\n");
386 put_variable(Variable *v, FILE *fp)
388 out_printf(fp, "\t");
389 print_type(fp, v->vtype, FALSE);
390 out_printf(fp, "%s%s;", v->id,
392 v->vtype->postfix:"");
393 if(v->scope == PROTECTED_SCOPE)
394 out_printf(fp, " /* protected */");
395 out_printf(fp, "\n");
399 put_vs_method(const Method *m)
401 if(m->method != SIGNAL_LAST_METHOD &&
402 m->method != SIGNAL_FIRST_METHOD &&
403 m->method != VIRTUAL_METHOD)
406 /* if a signal mark it as such */
407 if(m->method != VIRTUAL_METHOD)
408 print_method(outh, "\t/*signal*/", "(* ", "", ") ", "", ";\n",
409 m, FALSE, TRUE, TRUE);
411 print_method(outh, "\t", "(* ", "", ") ", "", ";\n",
412 m, FALSE, TRUE, TRUE);
416 put_pub_method(const Method *m)
418 if(m->scope != PUBLIC_SCOPE)
421 print_method(outh, "", "\t", "", "\t", "", ";\n", m, TRUE, FALSE, TRUE);
425 put_signal_macro (const Method *m, gboolean gnu)
429 if(m->method != SIGNAL_LAST_METHOD &&
430 m->method != SIGNAL_FIRST_METHOD)
433 id = g_strdup (m->id);
437 out_printf (outh, "#define %s_SIGNAL_%s(func)\t"
438 "\"%s\",(GCallback)(func)\n",
439 macrobase, id, m->id);
441 out_printf (outh, "#define %s_SIGNAL_%s(func)\t"
442 "\"%s\",(GCallback)(({",
443 macrobase, id, m->id);
444 print_method (outh, "", "(* ___", "", ") ", ", gpointer data ",
445 " = func; ", m, FALSE, TRUE, TRUE);
446 out_printf (outh, "___%s; }))\n", m->id);
453 put_signal_macros (const Class *c, gboolean gnu)
460 for (li = c->nodes; li != NULL; li = li->next) {
461 const Node *n = li->data;
462 if (n->type == METHOD_NODE)
463 put_signal_macro ((Method *)n, gnu);
469 put_prot_method(const Method *m)
471 if(m->scope != PROTECTED_SCOPE)
475 print_method(outph, "", "\t", "", "\t", "", ";\n",
476 m, FALSE, FALSE, TRUE);
478 print_method(out, "", "\t", "", "\t", "", ";\n",
479 m, FALSE, FALSE, TRUE);
483 put_priv_method_prot(Method *m)
485 if(m->method == SIGNAL_LAST_METHOD ||
486 m->method == SIGNAL_FIRST_METHOD ||
487 m->method == VIRTUAL_METHOD) {
490 "static ", "___real_", "", " ", "", ";\n",
491 m, FALSE, FALSE, TRUE);
493 /* no else, here, it might still have a private prototype, it's not
496 if((m->method == OVERRIDE_METHOD &&
499 char *s = g_strdup_printf("___%x_", (guint)m->unique_id);
500 print_method(out, "static ", s, "", " ", "",
501 no_gnu?";\n":" G_GNUC_UNUSED;\n",
502 m, FALSE, FALSE, FALSE);
504 } else if(m->scope == PRIVATE_SCOPE ||
505 m->method == INIT_METHOD ||
506 m->method == CLASS_INIT_METHOD) {
507 print_method(out, "static ", "", "", " ", "",
508 no_gnu?";\n":" G_GNUC_UNUSED;\n",
509 m, FALSE, FALSE, TRUE);
514 make_func_arg(char *typename, int is_class, char *name)
521 tn = g_strconcat(typename, ":Class", NULL);
523 tn = g_strdup(typename);
525 type = node_new (TYPE_NODE,
529 node = node_new (FUNCARG_NODE,
530 "atype:steal", (Type *)type,
533 return g_list_prepend(NULL, node);
537 make_inits(Class *cl)
539 int got_class_init = FALSE;
540 int got_init = FALSE;
543 for(li=cl->nodes;li;li=g_list_next(li)) {
545 if(n->type == METHOD_NODE) {
546 Method *m = (Method *)n;
547 if(m->method == INIT_METHOD) {
549 error_print(GOB_ERROR, m->line_no, "init defined more then once");
551 } else if(m->method == CLASS_INIT_METHOD) {
553 error_print(GOB_ERROR, m->line_no, "class_init defined more then once");
554 got_class_init = TRUE;
558 if(!got_class_init) {
559 Type *type = (Type *)node_new (TYPE_NODE,
562 node = node_new (METHOD_NODE,
564 "method", CLASS_INIT_METHOD,
567 "args:steal", make_func_arg (cl->otype, TRUE, g_strdup("c")),
568 "unique_id", method_unique_id++,
570 cl->nodes = g_list_prepend(cl->nodes, node);
573 Type *type = (Type *)node_new (TYPE_NODE,
576 node = node_new (METHOD_NODE,
578 "method", INIT_METHOD,
581 "args:steal", make_func_arg (cl->otype, TRUE, g_strdup("o")),
582 "unique_id", method_unique_id++,
584 cl->nodes = g_list_prepend(cl->nodes, node);
589 find_shutdown(Class *cl)
593 shutdown_handler = NULL;
594 for(li=cl->nodes;li;li=g_list_next(li)) {
596 if(n->type == METHOD_NODE) {
597 Method *m = (Method *)n;
598 if(m->method == OVERRIDE_METHOD &&
599 strcmp(m->id, "shutdown")==0) {
600 if(strcmp(m->otype, "G:Object") != 0) {
601 error_print(GOB_ERROR, m->line_no,
602 "shutdown method override "
603 "of class other then "
606 if(g_list_length(m->args) != 1) {
607 error_print(GOB_ERROR, m->line_no,
608 "shutdown method override "
609 "with more then one "
612 shutdown_handler = m;
620 find_finalize(Class *cl)
624 finalize_handler = NULL;
625 for(li=cl->nodes;li;li=g_list_next(li)) {
627 if(n->type == METHOD_NODE) {
628 Method *m = (Method *)n;
629 if(m->method == OVERRIDE_METHOD &&
630 strcmp(m->id, "finalize")==0) {
631 if(strcmp(m->otype, "G:Object") != 0) {
632 error_print(GOB_ERROR, m->line_no,
633 "finalize method override "
634 "of class other then "
637 if(g_list_length(m->args) != 1) {
638 error_print(GOB_ERROR, m->line_no,
639 "finalize method override "
640 "with more then one "
643 finalize_handler = m;
651 /* hash of method -> name of signal prototype */
652 static GHashTable *marsh = NULL;
654 /* list of methods with different signal prototypes,
655 we check this list if we can use a signal prototype of a
656 previous signal method, there are only uniques here */
657 static GList *eq_signal_methods = NULL;
659 /* compare a list of strings */
661 is_list_equal(GList *a, GList *b)
663 for(;a && b; a=a->next, b=b->next) {
664 if(strcmp(a->data, b->data)!=0) {
668 /* the the lists were different length */
675 find_same_type_signal(Method *m)
678 for(li=eq_signal_methods;li;li=li->next) {
679 Method *mm = li->data;
680 if(is_list_equal(mm->gtktypes, m->gtktypes))
687 print_signal_marsal_args (Method *m)
689 if (strcmp (m->gtktypes->next->data, "NONE") != 0) {
692 for (i = 0, li = m->gtktypes->next;
694 i++, li = li->next) {
695 char *get_func = g_strdup_printf
696 ("g_value_get_%s", (char *)li->data);
697 g_strdown (get_func);
698 out_printf (out, ",\n\t\t(%s) "
699 "%s (param_values + %d)",
700 get_cast (li->data, FALSE),
705 out_printf (out, ",\n\t\tdata2);\n");
710 add_signal_prots(Method *m)
716 gboolean ret_none = FALSE;
717 gboolean arglist_none = FALSE;
720 if (m->method != SIGNAL_LAST_METHOD &&
721 m->method != SIGNAL_FIRST_METHOD)
725 marsh = g_hash_table_new(NULL, NULL);
727 g_assert (m->gtktypes->next != NULL);
729 ret_none = strcmp(m->gtktypes->data, "NONE") == 0;
730 arglist_none = strcmp(m->gtktypes->next->data, "NONE") == 0;
732 if (ret_none && arglist_none)
735 /* if we already did a signal prototype just use that */
736 mm = find_same_type_signal (m);
738 s = g_hash_table_lookup (marsh, mm);
739 g_hash_table_insert (marsh, m, s);
746 retcast = get_cast (m->gtktypes->data, FALSE);
748 s = g_strdup_printf("Sig%d", sig++);
750 g_hash_table_insert(marsh, m, s);
751 eq_signal_methods = g_list_prepend(eq_signal_methods, m);
753 /* we know that we'll know all the gtktypes (so get_cast can't fail) */
754 out_printf(out, "\ntypedef %s (*___%s) (%s *, ",
755 get_cast(m->gtktypes->data, FALSE), s, typebase);
757 if ( ! arglist_none) {
758 for (li = m->gtktypes->next; li != NULL; li = li->next)
759 out_printf (out, "%s, ", get_cast (li->data, FALSE));
761 out_printf (out, "gpointer);\n");
763 out_printf (out, "\nstatic void\n"
764 "___marshal_%s (GClosure *closure,\n"
765 "\tGValue *return_value,\n"
766 "\tguint n_param_values,\n"
767 "\tconst GValue *param_values,\n"
768 "\tgpointer invocation_hint,\n"
769 "\tgpointer marshal_data)\n"
773 out_printf (out, "\t%s v_return;\n", retcast);
775 out_printf (out, "\tregister ___%s callback;\n"
776 "\tregister GCClosure *cc = (GCClosure*) closure;\n"
777 "\tregister gpointer data1, data2;\n\n",
780 out_printf (out, "\tg_return_if_fail (n_param_values == %d);\n\n",
781 arglist_none ? 1 : g_list_length (m->gtktypes));
784 "\tif (G_CCLOSURE_SWAP_DATA (closure)) {\n"
785 "\t\tdata1 = closure->data;\n"
786 "\t\tdata2 = g_value_peek_pointer (param_values + 0);\n"
788 "\t\tdata1 = g_value_peek_pointer (param_values + 0);\n"
789 "\t\tdata2 = closure->data;\n"
792 out_printf (out, "\tcallback = (___%s) "
793 "(marshal_data != NULL ? marshal_data : cc->callback);"
797 out_printf (out, "\tcallback ((%s *)data1", typebase);
799 out_printf (out, "\tv_return = callback ((%s *)data1",
803 print_signal_marsal_args (m);
806 /* FIXME: This code is so fucking ugly it hurts */
807 gboolean take_ownership =
808 (strcmp ((char *)m->gtktypes->data, "STRING") == 0 ||
809 strcmp ((char *)m->gtktypes->data, "BOXED") == 0);
810 char *set_func = g_strdup_printf ("g_value_set_%s%s",
811 (char *)m->gtktypes->data,
813 "_take_ownership" : "");
814 g_strdown (set_func);
816 out_printf (out, "\n\t%s (return_value, v_return);\n",
821 out_printf (out, "}\n\n");
828 out_printf(out, "\n");
830 out_printf(out, "enum {\n");
831 for(li=c->nodes;li;li=g_list_next(li)) {
833 if(n->type == METHOD_NODE) {
834 Method *m = (Method *)n;
835 if(m->method == SIGNAL_LAST_METHOD ||
836 m->method == SIGNAL_FIRST_METHOD) {
837 char *s = g_strdup(m->id);
839 out_printf(out, "\t%s_SIGNAL,\n", s);
844 out_printf(out, "\tLAST_SIGNAL\n};\n\n");
846 if (set_properties > 0 ||
847 get_properties > 0) {
848 out_printf(out, "enum {\n\tPROP_0");
849 for(li=c->nodes;li;li=g_list_next(li)) {
851 if (n->type == PROPERTY_NODE) {
852 Property *p = (Property *)n;
853 char *s = g_strdup (p->name);
855 out_printf (out, ",\n\tPROP_%s", s);
857 } else if (n->type == ARGUMENT_NODE) {
858 Argument *a = (Argument *)n;
859 char *s = g_strdup(a->name);
861 out_printf(out, ",\n\tPROP_%s", s);
865 out_printf(out, "\n};\n\n");
870 "static guint object_signals[LAST_SIGNAL] = {0};\n\n");
872 out_printf(out, "/* pointer to the class of our parent */\n");
873 out_printf(out, "static %sClass *parent_class = NULL;\n\n", ptypebase);
879 /*char *chunk_size = ((Class*)class)->chunk_size;*/
883 "%s_get_type (void)\n"
885 "\tstatic GType type = 0;\n\n"
886 "\tif (type == 0) {\n"
887 "\t\tstatic const GTypeInfo info = {\n"
888 "\t\t\tsizeof (%sClass),\n"
889 "\t\t\t(GBaseInitFunc) NULL,\n"
890 "\t\t\t(GBaseFinalizeFunc) NULL,\n"
891 "\t\t\t(GClassInitFunc) %s_class_init,\n"
892 "\t\t\t(GClassFinalizeFunc) NULL,\n"
893 "\t\t\tNULL /* class_data */,\n"
894 "\t\t\tsizeof (%s),\n"
895 "\t\t\t0 /* n_preallocs */,\n"
896 "\t\t\t(GInstanceInitFunc) %s_init,\n"
898 "\t\ttype = g_type_register_static (%s, \"%s\", &info, (GTypeFlags)0);\n",
899 funcbase, typebase, funcbase, typebase, funcbase,
900 pmacrotype, typebase);
905 "\t\tgtk_type_set_chunk_alloc(type, %s);\n"
907 chunk_size, chunk_size);
917 add_bonobo_x_get_type (void)
919 /* char *chunk_size = ((Class*)class)->chunk_size; */
922 "\n#error \"BonoboX isn't ported to glib 2.0 and "
923 "gob2 doesn't support it yet\"");
927 "%s_get_type (void)\n"
929 "\tstatic GtkType type = 0;\n\n"
930 "\tif (type == 0) {\n"
931 "\t\tstatic const GtkTypeInfo info = {\n"
933 "\t\t\tsizeof (%s),\n"
934 "\t\t\tsizeof (%sClass),\n"
935 "\t\t\t(GtkClassInitFunc) %s_class_init,\n"
936 "\t\t\t(GtkObjectInitFunc) %s_init,\n"
937 "\t\t\t/* reserved_1 */ NULL,\n"
938 "\t\t\t/* reserved_2 */ NULL,\n"
939 "\t\t\t(GtkClassInitFunc) NULL\n"
941 "\t\ttype = bonobo_x_type_unique\n"
942 "\t\t\t(%s_get_type (),\n"
943 "\t\t\tPOA_%s__init, NULL,\n"
944 "\t\t\tGTK_STRUCT_OFFSET (%sClass, _epv),\n"
946 funcbase, typebase, typebase, typebase,
947 funcbase, funcbase, pfuncbase,
948 ((Class*)class)->bonobo_x_class,
953 "\t\tgtk_type_set_chunk_alloc(type, %s);\n"
955 chunk_size, chunk_size);
964 add_overrides(Class *c, const char *oname,
965 gboolean did_base_obj)
971 done = g_hash_table_new (g_str_hash, g_str_equal);
973 s = g_strdup ("GObject");
974 g_hash_table_insert (done, s, s);
976 for (li = c->nodes; li != NULL; li = li->next) {
979 Method *m = (Method *)n;
980 if(n->type != METHOD_NODE ||
981 m->method != OVERRIDE_METHOD)
984 s = remove_sep(m->otype);
986 if(g_hash_table_lookup(done, s)) {
990 g_hash_table_insert(done, s, s);
992 f = replace_sep(m->otype, '_');
995 out_printf(out, "\t%sClass *%s_class = (%sClass *)%s;\n",
1000 g_hash_table_foreach (done, (GHFunc)g_free, NULL);
1001 g_hash_table_destroy (done);
1005 make_run_signal_flags(Method *m, gboolean last)
1020 gs = g_string_new(NULL);
1023 g_string_assign(gs, "G_SIGNAL_RUN_LAST");
1025 g_string_assign(gs, "G_SIGNAL_RUN_FIRST");
1027 if(m->scope == PUBLIC_SCOPE)
1028 g_string_append(gs, " | G_SIGNAL_ACTION");
1030 for(li = m->flags; li; li = li->next) {
1031 char *flag = li->data;
1033 for(i=0;flags[i];i++) {
1034 if(strcmp(flags[i], flag)==0)
1037 /* if we haven't found it in our list */
1039 error_printf(GOB_WARN, m->line_no,
1040 "Unknown flag '%s' used, "
1041 "perhaps it was misspelled",
1044 g_string_sprintfa(gs, " | G_SIGNAL_%s", flag);
1048 char *ret = gs->str;
1049 g_string_free(gs, FALSE);
1056 add_signals(Class *c)
1060 out_printf(out, "\n");
1061 for(li=c->nodes;li;li=g_list_next(li)) {
1063 char *mar, *sig, *flags;
1064 gboolean is_none, last = FALSE;
1065 Method *m = (Method *)n;
1067 if(n->type != METHOD_NODE ||
1068 (m->method != SIGNAL_FIRST_METHOD &&
1069 m->method != SIGNAL_LAST_METHOD))
1072 if(m->method == SIGNAL_FIRST_METHOD)
1077 if(g_hash_table_lookup(marsh, m))
1078 mar = g_strconcat("___marshal_",
1079 (char *)g_hash_table_lookup(marsh, m),
1082 mar = g_strdup("g_cclosure_marshal_VOID__VOID");
1084 is_none = (strcmp(m->gtktypes->next->data, "NONE")==0);
1086 sig = g_strdup (m->id);
1088 flags = make_run_signal_flags (m, last);
1089 out_printf (out, "\tobject_signals[%s_SIGNAL] =\n"
1090 "\t\tg_signal_new (\"%s\",\n"
1091 "\t\t\tG_TYPE_FROM_CLASS (g_object_class),\n"
1092 "\t\t\t(GSignalFlags)(%s),\n"
1093 "\t\t\tG_STRUCT_OFFSET (%sClass, %s),\n"
1094 "\t\t\tNULL, NULL,\n"
1096 "\t\t\tG_TYPE_%s, %d",
1099 typebase, m->id, mar,
1100 (char *)m->gtktypes->data,
1101 is_none ? 0 : g_list_length(m->gtktypes->next));
1108 for(l = m->gtktypes->next; l != NULL; l = l->next)
1109 out_printf(out, ",\n\t\t\tG_TYPE_%s",
1113 out_printf(out, ");\n");
1115 if(strcmp(m->gtktypes->data, "NONE") != 0 ||
1119 out_printf(out, "\tif(");
1120 if(strcmp(m->gtktypes->data, "NONE") != 0) {
1121 out_printf(out, "%s sizeof(", sep);
1122 print_type(out, m->mtype, FALSE);
1123 out_printf(out, "%s",
1125 m->mtype->postfix : "");
1126 out_printf(out, ") != sizeof(%s)",
1127 get_cast(m->gtktypes->data, FALSE));
1132 for(al = m->args->next, gl = m->gtktypes->next;
1133 al != NULL && gl != NULL;
1134 al = al->next, gl = gl->next) {
1135 FuncArg *arg = al->data;
1136 char *gtkarg = gl->data;
1138 out_printf(out, "%ssizeof(", sep);
1139 print_type(out, arg->atype, FALSE);
1140 out_printf(out, "%s",
1141 arg->atype->postfix ?
1142 arg->atype->postfix : "");
1143 out_printf(out, ") != sizeof(%s)",
1144 get_cast(gtkarg, FALSE));
1148 out_printf(out, ") {\n"
1149 "\t\tg_error(\"%s line %d: Type mismatch "
1150 "of \\\"%s\\\" signal signature\");\n"
1152 filename, m->line_no, m->id);
1159 set_def_handlers(Class *c, const char *oname)
1162 gboolean set_line = FALSE;
1164 out_printf(out, "\n");
1165 for(li = c->nodes; li; li = g_list_next(li)) {
1167 Method *m = (Method *)n;
1169 if(n->type != METHOD_NODE ||
1170 (m->method != SIGNAL_FIRST_METHOD &&
1171 m->method != SIGNAL_LAST_METHOD &&
1172 m->method != VIRTUAL_METHOD &&
1173 m->method != OVERRIDE_METHOD))
1176 if(m->line_no > 0 && m->cbuf) {
1177 out_addline_infile(out, m->line_no);
1179 } else if(set_line) {
1180 out_addline_outfile(out);
1185 if (m->method == OVERRIDE_METHOD) {
1187 s = replace_sep (m->otype, '_');
1190 if (need_shutdown &&
1191 shutdown_handler != NULL &&
1192 strcmp (m->id, "shutdown") == 0)
1193 out_printf (out, "\tg_object_class->shutdown "
1194 "= ___shutdown;\n");
1195 else if (need_finalize &&
1197 strcmp(m->id, "finalize") == 0)
1199 "\tg_object_class->finalize = ___finalize;\n");
1200 else if (m->cbuf != NULL)
1202 "\t%s_class->%s = ___%x_%s_%s;\n",
1203 s, m->id, (guint)m->unique_id,
1206 out_printf(out, "\t%s_class->%s = NULL;\n",
1210 out_printf(out, "\t%s->%s = ___real_%s_%s;\n",
1214 out_printf(out, "\t%s->%s = NULL;\n",
1219 out_addline_outfile(out);
1223 make_argument (Argument *a)
1228 char *argflags[] = {
1236 flags = g_string_new ("(GParamFlags)(");
1238 if(a->get && a->set)
1239 g_string_append (flags, "G_PARAM_READABLE | G_PARAM_WRITABLE");
1241 g_string_append (flags, "G_PARAM_READABLE");
1243 g_string_append (flags, "G_PARAM_WRITABLE");
1245 g_assert(a->get || a->set);
1247 for (l = a->flags; l != NULL; l = l->next) {
1248 char *flag = l->data;
1250 if(strcmp (flag, "READABLE") == 0 ||
1251 strcmp (flag, "WRITABLE") == 0) {
1252 error_print(GOB_WARN, a->line_no,
1254 "WRITABLE argument flags are "
1255 "set automatically");
1258 for(i = 0; argflags[i]; i++) {
1259 if(strcmp(argflags[i], flag)==0)
1262 /* if we haven't found it in our list */
1263 if( ! argflags[i]) {
1264 error_printf(GOB_WARN, a->line_no,
1265 "Unknown flag '%s' used, "
1266 "perhaps it was misspelled", flag);
1268 g_string_sprintfa(flags, " | G_PARAM_%s", flag);
1271 g_string_append (flags, ")");
1273 s = g_strdup(a->name);
1275 if (!strcmp (a->gtktype, "ENUM"))
1276 out_printf(out, "\tparam_spec = g_param_spec_enum (\"%s\", NULL, NULL,\n"
1277 "\t\tG_TYPE_ENUM, 0,\n"
1279 a->name, flags->str);
1280 if (!strcmp (a->gtktype, "FLAGS"))
1281 out_printf(out, "\tparam_spec = g_param_spec_flags (\"%s\", NULL, NULL,\n"
1282 "\t\tG_TYPE_FLAGS, 0,\n"
1284 a->name, flags->str);
1285 else if (!strcmp (a->gtktype, "OBJECT"))
1286 out_printf(out, "\tparam_spec = g_param_spec_object (\"%s\", NULL, NULL,\n"
1287 "\t\tG_TYPE_OBJECT,\n"
1289 a->name, flags->str);
1290 else if (!strcmp (a->gtktype, "STRING"))
1291 out_printf(out, "\tparam_spec = g_param_spec_string (\"%s\", NULL, NULL,\n"
1294 a->name, flags->str);
1295 else if (!strcmp (a->gtktype, "INT"))
1296 out_printf(out, "\tparam_spec = g_param_spec_int (\"%s\", NULL, NULL,\n"
1297 "\t\tG_MININT, G_MAXINT,\n"
1300 a->name, flags->str);
1301 else if (!strcmp (a->gtktype, "UINT"))
1302 out_printf(out, "\tparam_spec = g_param_spec_uint (\"%s\", NULL, NULL,\n"
1303 "\t\t0, G_MAXUINT,\n"
1306 a->name, flags->str);
1307 else if (!strcmp (a->gtktype, "INT"))
1308 out_printf(out, "\tparam_spec = g_param_spec_int (\"%s\", NULL, NULL,\n"
1309 "\t\tG_MININT, G_MAXINT,\n"
1312 a->name, flags->str);
1313 else if (!strcmp (a->gtktype, "CHAR"))
1314 out_printf(out, "\tparam_spec = g_param_spec_char (\"%s\", NULL, NULL,\n"
1318 a->name, flags->str);
1319 else if (!strcmp (a->gtktype, "UCHAR"))
1320 out_printf(out, "\tparam_spec = g_param_spec_uchar (\"%s\", NULL, NULL,\n"
1324 a->name, flags->str);
1325 else if (!strcmp (a->gtktype, "BOOL") ||
1326 !strcmp (a->gtktype, "BOOLEAN"))
1327 out_printf(out, "\tparam_spec = g_param_spec_boolean (\"%s\", NULL, NULL,\n"
1330 a->name, flags->str);
1331 else if (!strcmp (a->gtktype, "LONG"))
1332 out_printf(out, "\tparam_spec = g_param_spec_long (\"%s\", NULL, NULL,\n"
1333 "\t\tG_MINLONG, G_MAXLONG,\n"
1336 a->name, flags->str);
1337 else if (!strcmp (a->gtktype, "ULONG"))
1338 out_printf(out, "\tparam_spec = g_param_spec_ulong (\"%s\", NULL, NULL,\n"
1339 "\t\t0, G_MAXULONG,\n"
1342 a->name, flags->str);
1343 else if (!strcmp (a->gtktype, "FLOAT"))
1344 out_printf(out, "\tparam_spec = g_param_spec_float (\"%s\", NULL, NULL,\n"
1345 "\t\tG_MINFLOAT, G_MAXFLOAT,\n"
1348 a->name, flags->str);
1349 else if (!strcmp (a->gtktype, "DOUBLE"))
1350 out_printf(out, "\tparam_spec = g_param_spec_double (\"%s\", NULL, NULL,\n"
1351 "\t\tG_MINDOUBLE, G_MAXDOUBLE,\n"
1354 a->name, flags->str);
1355 else if (!strcmp (a->gtktype, "POINTER"))
1356 out_printf(out, "\tparam_spec = g_param_spec_pointer (\"%s\", NULL, NULL,\n"
1358 a->name, flags->str);
1360 error_printf (GOB_ERROR, a->line_no,
1361 "%s type is not supported for arguments, try using properties",
1364 out_printf(out, "\tg_object_class_install_property (g_object_class,\n"
1365 "\t\tPROP_%s, param_spec);\n", s);
1369 g_string_free(flags, TRUE);
1372 #define value_for_print(str, alt) (str != NULL ? str : alt)
1375 make_property (Property *p)
1380 char *argflags[] = {
1388 flags = g_string_new ("(GParamFlags)(");
1390 if (p->get != NULL && p->set != NULL)
1391 g_string_append (flags, "G_PARAM_READABLE | G_PARAM_WRITABLE");
1392 else if (p->get != NULL)
1393 g_string_append (flags, "G_PARAM_READABLE");
1395 g_string_append (flags, "G_PARAM_WRITABLE");
1397 if (p->get == NULL && p->set == NULL) {
1398 error_print (GOB_ERROR, p->line_no,
1399 "Property has no getter nor setter");
1402 for (l = p->flags; l != NULL; l = l->next) {
1403 char *flag = l->data;
1405 if(strcmp (flag, "READABLE") == 0 ||
1406 strcmp (flag, "WRITABLE") == 0) {
1407 error_print(GOB_WARN, p->line_no,
1409 "WRITABLE argument flags are "
1410 "set automatically");
1413 for(i = 0; argflags[i]; i++) {
1414 if(strcmp(argflags[i], flag)==0)
1417 /* if we haven't found it in our list */
1418 if( ! argflags[i]) {
1419 error_printf(GOB_WARN, p->line_no,
1420 "Unknown flag '%s' used, "
1421 "perhaps it was misspelled", flag);
1423 g_string_sprintfa(flags, " | G_PARAM_%s", flag);
1426 g_string_append (flags, ")");
1428 if (strcmp (p->gtktype, "CHAR") == 0)
1429 out_printf (out, "\tparam_spec = g_param_spec_char\n"
1430 "\t\t(\"%s\" /* name */,\n"
1431 "\t\t %s /* nick */,\n"
1432 "\t\t %s /* blurb */,\n"
1433 "\t\t %s /* minimum */,\n"
1434 "\t\t %s /* maximum */,\n"
1435 "\t\t %s /* default_value */,\n"
1438 value_for_print (p->nick, "NULL"),
1439 value_for_print (p->blurb, "NULL"),
1440 value_for_print (p->minimum, "-128"),
1441 value_for_print (p->maximum, "127"),
1442 value_for_print (p->default_value, "0"),
1444 else if (strcmp (p->gtktype, "UCHAR") == 0)
1445 out_printf (out, "\tparam_spec = g_param_spec_uchar\n"
1446 "\t\t(\"%s\" /* name */,\n"
1447 "\t\t %s /* nick */,\n"
1448 "\t\t %s /* blurb */,\n"
1449 "\t\t %s /* minimum */,\n"
1450 "\t\t %s /* maximum */,\n"
1451 "\t\t %s /* default_value */,\n"
1454 value_for_print (p->nick, "NULL"),
1455 value_for_print (p->blurb, "NULL"),
1456 value_for_print (p->minimum, "0"),
1457 value_for_print (p->maximum, "0xFF"),
1458 value_for_print (p->default_value, "0"),
1460 else if (strcmp (p->gtktype, "BOOLEAN") == 0)
1461 out_printf (out, "\tparam_spec = g_param_spec_boolean\n"
1462 "\t\t(\"%s\" /* name */,\n"
1463 "\t\t %s /* nick */,\n"
1464 "\t\t %s /* blurb */,\n"
1465 "\t\t %s /* default_value */,\n"
1468 value_for_print (p->nick, "NULL"),
1469 value_for_print (p->blurb, "NULL"),
1470 value_for_print (p->default_value, "FALSE"),
1472 else if (strcmp (p->gtktype, "INT") == 0)
1473 out_printf (out, "\tparam_spec = g_param_spec_int\n"
1474 "\t\t(\"%s\" /* name */,\n"
1475 "\t\t %s /* nick */,\n"
1476 "\t\t %s /* blurb */,\n"
1477 "\t\t %s /* minimum */,\n"
1478 "\t\t %s /* maximum */,\n"
1479 "\t\t %s /* default_value */,\n"
1482 value_for_print (p->nick, "NULL"),
1483 value_for_print (p->blurb, "NULL"),
1484 value_for_print (p->minimum, "G_MININT"),
1485 value_for_print (p->maximum, "G_MAXINT"),
1486 value_for_print (p->default_value, "0"),
1488 else if (strcmp (p->gtktype, "UINT") == 0)
1489 out_printf (out, "\tparam_spec = g_param_spec_uint\n"
1490 "\t\t(\"%s\" /* name */,\n"
1491 "\t\t %s /* nick */,\n"
1492 "\t\t %s /* blurb */,\n"
1493 "\t\t %s /* minimum */,\n"
1494 "\t\t %s /* maximum */,\n"
1495 "\t\t %s /* default_value */,\n"
1498 value_for_print (p->nick, "NULL"),
1499 value_for_print (p->blurb, "NULL"),
1500 value_for_print (p->minimum, "0"),
1501 value_for_print (p->maximum, "G_MAXUINT"),
1502 value_for_print (p->default_value, "0"),
1504 else if (strcmp (p->gtktype, "LONG") == 0)
1505 out_printf (out, "\tparam_spec = g_param_spec_long\n"
1506 "\t\t(\"%s\" /* name */,\n"
1507 "\t\t %s /* nick */,\n"
1508 "\t\t %s /* blurb */,\n"
1509 "\t\t %s /* minimum */,\n"
1510 "\t\t %s /* maximum */,\n"
1511 "\t\t %s /* default_value */,\n"
1514 value_for_print (p->nick, "NULL"),
1515 value_for_print (p->blurb, "NULL"),
1516 value_for_print (p->minimum, "G_MINLONG"),
1517 value_for_print (p->maximum, "G_MAXLONG"),
1518 value_for_print (p->default_value, "0"),
1520 else if (strcmp (p->gtktype, "ULONG") == 0)
1521 out_printf (out, "\tparam_spec = g_param_spec_ulong\n"
1522 "\t\t(\"%s\" /* name */,\n"
1523 "\t\t %s /* nick */,\n"
1524 "\t\t %s /* blurb */,\n"
1525 "\t\t %s /* minimum */,\n"
1526 "\t\t %s /* maximum */,\n"
1527 "\t\t %s /* default_value */,\n"
1530 value_for_print (p->nick, "NULL"),
1531 value_for_print (p->blurb, "NULL"),
1532 value_for_print (p->minimum, "0"),
1533 value_for_print (p->maximum, "G_MAXULONG"),
1534 value_for_print (p->default_value, "0"),
1536 else if (strcmp (p->gtktype, "UNICHAR") == 0)
1537 out_printf (out, "\tparam_spec = g_param_spec_unichar\n"
1538 "\t\t(\"%s\" /* name */,\n"
1539 "\t\t %s /* nick */,\n"
1540 "\t\t %s /* blurb */,\n"
1541 "\t\t %s /* default_value */,\n"
1544 value_for_print (p->nick, "NULL"),
1545 value_for_print (p->blurb, "NULL"),
1546 value_for_print (p->default_value, "0"),
1548 else if (strcmp (p->gtktype, "ENUM") == 0)
1549 out_printf (out, "\tparam_spec = g_param_spec_enum\n"
1550 "\t\t(\"%s\" /* name */,\n"
1551 "\t\t %s /* nick */,\n"
1552 "\t\t %s /* blurb */,\n"
1553 "\t\t %s /* enum_type */,\n"
1554 "\t\t %s /* default_value */,\n"
1557 value_for_print (p->nick, "NULL"),
1558 value_for_print (p->blurb, "NULL"),
1559 value_for_print (p->extra_gtktype, "G_TYPE_ENUM"),
1560 value_for_print (p->default_value, "0"),
1562 else if (strcmp (p->gtktype, "FLAGS") == 0)
1563 out_printf (out, "\tparam_spec = g_param_spec_flags\n"
1564 "\t\t(\"%s\" /* name */,\n"
1565 "\t\t %s /* nick */,\n"
1566 "\t\t %s /* blurb */,\n"
1567 "\t\t %s /* flags_type */,\n"
1568 "\t\t %s /* default_value */,\n"
1571 value_for_print (p->nick, "NULL"),
1572 value_for_print (p->blurb, "NULL"),
1573 value_for_print (p->extra_gtktype, "G_TYPE_FLAGS"),
1574 value_for_print (p->default_value, "0"),
1576 else if (strcmp (p->gtktype, "FLOAT") == 0)
1577 out_printf (out, "\tparam_spec = g_param_spec_float\n"
1578 "\t\t(\"%s\" /* name */,\n"
1579 "\t\t %s /* nick */,\n"
1580 "\t\t %s /* blurb */,\n"
1581 "\t\t %s /* minimum */,\n"
1582 "\t\t %s /* maximum */,\n"
1583 "\t\t %s /* default_value */,\n"
1586 value_for_print (p->nick, "NULL"),
1587 value_for_print (p->blurb, "NULL"),
1588 value_for_print (p->minimum, "G_MINFLOAT"),
1589 value_for_print (p->maximum, "G_MAXFLOAT"),
1590 value_for_print (p->default_value, "0.0"),
1592 else if (strcmp (p->gtktype, "DOUBLE") == 0)
1593 out_printf (out, "\tparam_spec = g_param_spec_double\n"
1594 "\t\t(\"%s\" /* name */,\n"
1595 "\t\t %s /* nick */,\n"
1596 "\t\t %s /* blurb */,\n"
1597 "\t\t %s /* minimum */,\n"
1598 "\t\t %s /* maximum */,\n"
1599 "\t\t %s /* default_value */,\n"
1602 value_for_print (p->nick, "NULL"),
1603 value_for_print (p->blurb, "NULL"),
1604 value_for_print (p->minimum, "G_MINDOUBLE"),
1605 value_for_print (p->maximum, "G_MAXDOUBLE"),
1606 value_for_print (p->default_value, "0.0"),
1608 else if (strcmp (p->gtktype, "STRING") == 0)
1609 out_printf (out, "\tparam_spec = g_param_spec_string\n"
1610 "\t\t(\"%s\" /* name */,\n"
1611 "\t\t %s /* nick */,\n"
1612 "\t\t %s /* blurb */,\n"
1613 "\t\t %s /* default_value */,\n"
1616 value_for_print (p->nick, "NULL"),
1617 value_for_print (p->blurb, "NULL"),
1618 value_for_print (p->default_value, "NULL"),
1620 else if (strcmp (p->gtktype, "PARAM") == 0)
1621 out_printf (out, "\tparam_spec = g_param_spec_param\n"
1622 "\t\t(\"%s\" /* name */,\n"
1623 "\t\t %s /* nick */,\n"
1624 "\t\t %s /* blurb */,\n"
1625 "\t\t %s /* param_type */,\n"
1628 value_for_print (p->nick, "NULL"),
1629 value_for_print (p->blurb, "NULL"),
1630 value_for_print (p->extra_gtktype, "G_TYPE_PARAM"),
1632 else if (strcmp (p->gtktype, "BOXED") == 0)
1633 out_printf (out, "\tparam_spec = g_param_spec_boxed\n"
1634 "\t\t(\"%s\" /* name */,\n"
1635 "\t\t %s /* nick */,\n"
1636 "\t\t %s /* blurb */,\n"
1637 "\t\t %s /* boxed_type */,\n"
1640 value_for_print (p->nick, "NULL"),
1641 value_for_print (p->blurb, "NULL"),
1642 value_for_print (p->extra_gtktype, "G_TYPE_BOXED"),
1644 else if (strcmp (p->gtktype, "POINTER") == 0)
1645 out_printf (out, "\tparam_spec = g_param_spec_pointer\n"
1646 "\t\t(\"%s\" /* name */,\n"
1647 "\t\t %s /* nick */,\n"
1648 "\t\t %s /* blurb */,\n"
1651 value_for_print (p->nick, "NULL"),
1652 value_for_print (p->blurb, "NULL"),
1654 /* FIXME: VALUE_ARRAY */
1655 else if (strcmp (p->gtktype, "CLOSURE") == 0)
1656 out_printf (out, "\tparam_spec = g_param_spec_pointer\n"
1657 "\t\t(\"%s\" /* name */,\n"
1658 "\t\t %s /* nick */,\n"
1659 "\t\t %s /* blurb */,\n"
1662 value_for_print (p->nick, "NULL"),
1663 value_for_print (p->blurb, "NULL"),
1665 else if (strcmp (p->gtktype, "OBJECT") == 0)
1666 out_printf (out, "\tparam_spec = g_param_spec_object\n"
1667 "\t\t(\"%s\" /* name */,\n"
1668 "\t\t %s /* nick */,\n"
1669 "\t\t %s /* blurb */,\n"
1670 "\t\t %s /* object_type */,\n"
1673 value_for_print (p->nick, "NULL"),
1674 value_for_print (p->blurb, "NULL"),
1675 value_for_print (p->extra_gtktype, "G_TYPE_OBJECT"),
1678 error_printf (GOB_ERROR, p->line_no,
1679 "%s type is not supported by properties",
1682 s = g_strdup (p->name);
1684 out_printf (out, "\tg_object_class_install_property (g_object_class,\n"
1686 "\t\tparam_spec);\n", s);
1689 g_string_free (flags, TRUE);
1693 make_arguments(Class *c)
1696 out_printf (out, " {\n"
1697 "\tGParamSpec *param_spec;\n\n");
1699 for (li = c->nodes; li != NULL; li = li->next) {
1701 if (n->type == PROPERTY_NODE)
1702 make_property ((Property *)n);
1703 else if (n->type == ARGUMENT_NODE)
1704 make_argument ((Argument *)n);
1706 out_printf(out, " }\n");
1708 if (get_properties > 0)
1709 out_printf(out, "\tg_object_class->get_property = ___object_get_property;\n");
1710 if (set_properties > 0)
1711 out_printf(out, "\tg_object_class->set_property = ___object_set_property;\n");
1715 print_initializer(Method *m, Variable *v)
1719 if(v->initializer == NULL)
1722 if(v->scope == PRIVATE_SCOPE)
1723 root = g_strconcat(((FuncArg *)m->args->data)->name,
1726 root = g_strdup(((FuncArg *)m->args->data)->name);
1728 if(v->initializer_line > 0)
1729 out_addline_infile(out, v->initializer_line);
1731 out_printf(out, "\t%s->%s = %s;\n",
1732 root, v->id, v->initializer);
1734 if(v->initializer_line > 0)
1735 out_addline_outfile(out);
1741 print_destructor (Variable *v)
1745 if(v->destructor == NULL)
1748 if(v->scope == PRIVATE_SCOPE)
1749 root = "self->_priv";
1753 if(v->destructor_simple) {
1754 if(v->destructor_line > 0)
1755 out_addline_infile(out, v->destructor_line);
1757 out_printf(out, "\tif(%s->%s) { "
1758 "((*(void (*)(void *))%s)) (%s->%s); "
1759 "%s->%s = NULL; }\n",
1760 root, v->id, v->destructor, root, v->id,
1763 if(v->destructor_line > 0)
1764 out_addline_outfile(out);
1766 out_printf(out, "#define %s (%s->%s)\n", v->id, root, v->id);
1767 out_printf(out, "#define VAR %s\n", v->id);
1768 out_printf(out, "\t{\n");
1769 if(v->destructor_line > 0)
1770 out_addline_infile(out, v->destructor_line);
1772 out_printf(out, "\t%s}\n", v->destructor);
1774 if(v->destructor_line > 0)
1775 out_addline_outfile(out);
1776 out_printf(out, "\tmemset(&%s, 0, sizeof(%s));\n",
1778 out_printf(out, "#undef VAR\n");
1779 out_printf(out, "#undef %s\n", v->id);
1784 add_shutdown (Class *c)
1786 out_printf(out, "\nstatic void\n"
1787 "___shutdown (GObject *obj_self)\n"
1790 "#define __GOB_FUNCTION__ \"%s::shutdown\"\n",
1793 if (unreftors > 0) {
1794 out_printf (out, "\t%s *self = %s (obj_self);\n",
1795 typebase, macrobase);
1798 if (shutdown_handler != NULL) {
1799 /* so we get possible bad argument warning */
1800 if (shutdown_handler->line_no > 0)
1801 out_addline_infile (out, shutdown_handler->line_no);
1802 out_printf (out, "\t___%x_%s_shutdown(obj_self);\n",
1803 (guint)shutdown_handler->unique_id, funcbase);
1804 if (shutdown_handler->line_no > 0)
1805 out_addline_outfile (out);
1808 "\tif (G_OBJECT_CLASS (parent_class)->shutdown) \\\n"
1809 "\t\t(* G_OBJECT_CLASS (parent_class)->shutdown) (obj_self);\n");
1812 if (unreftors > 0) {
1814 for(li = ((Class *)class)->nodes;
1818 Variable *v = (Variable *)n;
1819 if (n->type == VARIABLE_NODE &&
1820 v->scope != CLASS_SCOPE &&
1821 v->destructor_unref)
1822 print_destructor (v);
1826 out_printf (out, "\treturn;\n");
1828 out_printf(out, "\tself = NULL;\n");
1829 out_printf(out, "}\n"
1830 "#undef __GOB_FUNCTION__\n\n");
1834 add_finalize (Class *c)
1838 "___finalize(GObject *obj_self)\n"
1841 "#define __GOB_FUNCTION__ \"%s::finalize\"\n",
1846 out_printf(out, "\t%s *self = %s (obj_self);\n",
1847 typebase, macrobase);
1850 out_printf(out, "\tgpointer priv = self->_priv;\n");
1853 if(finalize_handler) {
1854 /* so we get possible bad argument warning */
1855 if(finalize_handler->line_no > 0)
1856 out_addline_infile(out, finalize_handler->line_no);
1857 out_printf(out, "\t___%x_%s_finalize(obj_self);\n",
1858 (guint)finalize_handler->unique_id, funcbase);
1859 if(finalize_handler->line_no > 0)
1860 out_addline_outfile(out);
1863 "\tif(G_OBJECT_CLASS(parent_class)->finalize) \\\n"
1864 "\t\t(* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);\n");
1867 if (destructors > 0) {
1869 for (li = ((Class *)class)->nodes;
1873 Variable *v = (Variable *)n;
1874 if (n->type == VARIABLE_NODE &&
1875 v->scope != CLASS_SCOPE &&
1876 ! v->destructor_unref)
1877 print_destructor (v);
1882 out_printf(out, "\tg_free (priv);\n");
1884 out_printf (out, "\treturn;\n");
1885 if (destructors > 0 ||
1887 out_printf (out, "\tself = NULL;\n");
1889 out_printf(out, "}\n"
1890 "#undef __GOB_FUNCTION__\n\n");
1894 make_bonobo_x_epv (Class *c, const char *classname)
1897 gboolean added_line = FALSE;
1899 for (li = c->nodes; li != NULL; li = li->next) {
1901 Method *m = (Method *)n;
1902 if(n->type != METHOD_NODE ||
1903 m->method == OVERRIDE_METHOD)
1906 if (m->bonobo_x_func) {
1907 if(m->line_no > 0) {
1908 out_addline_infile(out, m->line_no);
1910 } else if (m->line_no == 0 &&
1912 out_addline_outfile(out);
1915 out_printf (out, "\t%s->_epv.%s = %s;\n",
1916 classname, m->id, m->id);
1920 out_addline_outfile(out);
1927 for(li=c->nodes;li;li=g_list_next(li)) {
1931 gboolean add_unused_class = FALSE;
1933 if(n->type != METHOD_NODE)
1936 if(m->method == INIT_METHOD) {
1938 out_addline_infile(out, m->line_no);
1939 print_method(out, "static ", "\n", "", " ", "", "\n",
1940 m, FALSE, FALSE, TRUE);
1942 out_addline_outfile(out);
1943 out_printf(out, "{\n"
1944 "#define __GOB_FUNCTION__ \"%s::init\"\n",
1947 out_printf(out, "\t%s->_priv = "
1948 "g_new0 (%sPrivate, 1);\n",
1949 ((FuncArg *)m->args->data)->name,
1951 } else if(always_private_struct) {
1952 out_printf(out, "\t%s->_priv = NULL;\n",
1953 ((FuncArg *)m->args->data)->name);
1955 if(initializers > 0) {
1957 for(li = ((Class *)class)->nodes;
1961 Variable *v = (Variable *)n;
1962 if(n->type != VARIABLE_NODE ||
1963 v->scope == CLASS_SCOPE)
1965 print_initializer(m, v);
1968 } else if(m->method == CLASS_INIT_METHOD) {
1969 gboolean did_base_obj = FALSE;
1972 out_addline_infile(out, m->line_no);
1973 print_method(out, "static ", "\n", "", " ", "", "\n",
1974 m, FALSE, FALSE, TRUE);
1976 out_addline_outfile(out);
1977 out_printf(out, "{\n"
1978 "#define __GOB_FUNCTION__ \"%s::class_init\"\n",
1980 if (set_properties > 0 ||
1981 get_properties > 0 ||
1988 "(GObjectClass*) %s;\n",
1989 ((FuncArg *)m->args->data)->name);
1990 add_unused_class = TRUE;
1991 did_base_obj = TRUE;
1996 ((FuncArg *)m->args->data)->name,
1999 if (initializers > 0) {
2001 for(li = ((Class *)class)->nodes;
2005 Variable *v = (Variable *)n;
2006 if(n->type == VARIABLE_NODE &&
2007 v->scope == CLASS_SCOPE)
2008 print_initializer(m, v);
2012 out_printf(out, "\n\tparent_class = ");
2014 out_printf(out, "(%sClass *)", ptypebase);
2015 out_printf(out, "g_type_class_ref (%s);\n",
2021 set_def_handlers(c, ((FuncArg *)m->args->data)->name);
2023 /* if there are no handlers for these things, we
2024 * need to set them up here */
2025 if(need_shutdown && !shutdown_handler)
2026 out_printf(out, "\tg_object_class->shutdown "
2027 "= ___shutdown;\n");
2028 if(need_finalize && !finalize_handler)
2029 out_printf(out, "\tg_object_class->finalize = "
2032 if(get_properties > 0 || set_properties > 0)
2035 if (c->bonobo_x_class != NULL) {
2036 make_bonobo_x_epv (c, ((FuncArg *)m->args->data)->name);
2042 out_printf(out, " {\n");
2043 out_addline_infile(out, m->ccode_line);
2044 out_printf(out, "%s\n", m->cbuf);
2045 out_addline_outfile(out);
2046 out_printf(out, " }\n");
2048 out_printf(out, "\treturn;\n");
2051 ((FuncArg *)m->args->data)->name);
2052 if(add_unused_class) {
2053 out_printf (out, "\tg_object_class = NULL;\n");
2055 out_printf(out, "}\n"
2056 "#undef __GOB_FUNCTION__\n");
2061 add_argument (Argument *a, gboolean is_set)
2065 char *the_type_lower;
2070 line_no = a->set_line;
2073 line_no = a->get_line;
2077 s = g_strdup(a->name);
2079 out_printf(out, "\tcase PROP_%s:\n\t{", s);
2081 the_type_lower = g_strdup (a->gtktype);
2082 g_strdown (the_type_lower);
2087 if (a->atype != NULL)
2088 cast = get_type (a->atype, TRUE);
2090 cast = g_strdup (get_cast (a->gtktype, FALSE));
2092 out_printf (out, "\t%s ARG = (%s) g_value_get_%s (VAL);\n",
2093 cast, cast, the_type_lower);
2096 } else if ( ! is_set) {
2099 if (a->atype != NULL)
2100 cast = get_type (a->atype, TRUE);
2102 cast = g_strdup (get_cast (a->gtktype, FALSE));
2103 out_printf (out, "\t%s ARG;\n"
2104 "\tmemset (&ARG, 0, sizeof (%s));\n",
2110 out_printf(out, "\t\t{\n");
2112 out_addline_infile (out, line_no);
2113 out_printf (out, "%s\n", cbuf);
2115 out_addline_outfile (out);
2116 out_printf (out, "\t\t}\n");
2118 if (strcmp (a->gtktype, "OBJECT") == 0)
2119 out_printf (out, "\t\tg_value_set_%s (VAL, G_OBJECT (ARG))\n",
2122 out_printf (out, "\t\t"
2123 "g_value_set_%s (VAL, ARG);\n",
2126 g_free (the_type_lower);
2129 out_printf (out, "\t\tif (&ARG) ;\n");
2132 out_printf (out, "\t\tbreak;\n");
2134 out_printf (out, "\t}\n");
2138 add_property (Property *p, gboolean is_set)
2141 char *the_type_lower;
2147 line_no = p->set_line;
2150 line_no = p->get_line;
2155 name_upper = g_strdup (p->name);
2156 g_strup (name_upper);
2157 the_type_lower = g_strdup (p->gtktype);
2158 g_strdown (the_type_lower);
2160 out_printf (out, "\tcase PROP_%s:\n", name_upper);
2162 out_printf(out, "\t\t{\n");
2164 out_addline_infile (out, line_no);
2165 out_printf (out, "%s\n", cbuf);
2167 out_addline_outfile (out);
2168 out_printf (out, "\t\t}\n");
2170 g_free (name_upper);
2171 g_free (the_type_lower);
2173 out_printf (out, "\t\tbreak;\n");
2177 add_getset_arg(Class *c, gboolean is_set)
2180 out_printf(out, "\nstatic void\n"
2181 "___object_%s_property (GObject *object,\n"
2182 "\tguint property_id,\n"
2183 "\t%sGValue *VAL,\n"
2184 "\tGParamSpec *pspec)\n"
2185 "#define __GOB_FUNCTION__ \"%s::%s_property\"\n"
2188 "\tself = %s (object);\n\n"
2189 "\tswitch (property_id) {\n",
2190 is_set ? "set" : "get",
2191 is_set ? "const " : "",
2192 c->otype, is_set ? "set" : "get",
2193 typebase, macrobase);
2195 for (li = c->nodes; li != NULL; li = li->next) {
2197 if (n->type == PROPERTY_NODE)
2198 add_property ((Property *)n, is_set);
2199 else if (n->type == ARGUMENT_NODE)
2200 add_argument ((Argument *)n, is_set);
2202 out_printf (out, "\tdefault:\n"
2203 "/* Apparently in g++ this is needed, glib is b0rk */\n"
2204 "#ifndef __PRETTY_FUNCTION__\n"
2205 "# undef G_STRLOC\n"
2206 "# define G_STRLOC __FILE__ \":\" G_STRINGIFY (__LINE__)\n"
2208 "\t\tG_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);\n"
2210 "\treturn;\n\tself = NULL;\n\tVAL = NULL;\n\tpspec = NULL;\n}\n"
2211 "#undef __GOB_FUNCTION__\n");
2215 print_checks (Method *m, FuncArg *fa)
2219 gboolean checked_null = FALSE;
2220 is_void = (strcmp(m->mtype->name, "void")==0 &&
2221 m->mtype->pointer == NULL);
2223 for(li = fa->checks; li != NULL; li = li->next) {
2224 Check *ch = li->data;
2226 /* point to the method prot in .gob for failed checks */
2228 out_addline_infile(out, m->line_no);
2230 out_printf(out, "\tg_return_if_fail (");
2232 out_printf(out, "\tg_return_val_if_fail (");
2233 switch(ch->chtype) {
2235 out_printf(out, "%s != NULL", fa->name);
2236 checked_null = TRUE;
2239 s = make_pre_macro(fa->atype->name, "IS");
2241 out_printf(out, "%s (%s)", s, fa->name);
2243 /* if not check null, null may be valid */
2244 out_printf(out, "!(%s) || %s (%s)", fa->name,
2249 out_printf(out, "%s < %s", fa->name, ch->number);
2252 out_printf(out, "%s > %s", fa->name, ch->number);
2255 out_printf(out, "%s <= %s", fa->name, ch->number);
2258 out_printf(out, "%s >= %s", fa->name, ch->number);
2261 out_printf(out, "%s == %s", fa->name, ch->number);
2264 out_printf(out, "%s != %s", fa->name, ch->number);
2268 out_printf(out, ");\n");
2270 out_printf(out, ", (");
2271 print_type(out, m->mtype, TRUE);
2272 out_printf(out, ")%s);\n",
2273 m->onerror?m->onerror:"0");
2279 print_preconditions(Method *m)
2283 for(li=m->args;li;li=g_list_next(li)) {
2284 FuncArg *fa = li->data;
2286 print_checks(m, fa);
2289 out_addline_outfile(out);
2293 print_method_body(Method *m, int pre)
2296 out_addline_outfile(out);
2297 out_printf(out, "{\n"
2298 "#define __GOB_FUNCTION__ \"%s::%s\"\n",
2299 ((Class *)class)->otype,
2302 print_preconditions(m);
2304 /* Note: the trailing }'s are on one line, this is so
2305 that we get the no return warning correctly and point to
2306 the correct line in the .gob file, yes this is slightly
2307 ugly in the .c file, but that is not supposed to be
2308 human readable anyway. */
2310 out_printf(out, "{\n");
2312 out_addline_infile(out, m->ccode_line);
2313 out_printf(out, "\t%s}", m->cbuf);
2316 /* Note, there is no \n between the last } and this } so that
2317 * errors/warnings reported on the end of the body get pointed to the
2318 * right line in the .gob source */
2319 out_printf(out, "}\n");
2322 out_addline_outfile(out);
2323 out_printf(out, "#undef __GOB_FUNCTION__\n");
2327 put_signal_args (Method *m)
2331 for (ali = m->gtktypes->next, li=m->args->next;
2332 li != NULL && ali != NULL;
2333 li = li->next, ali = ali->next) {
2334 FuncArg *fa = li->data;
2335 char *cast = g_strdup (get_cast (ali->data, FALSE));
2338 cast = get_type (fa->atype, TRUE);
2340 /* we should have already proved before that
2341 the we know all the types */
2342 g_assert (cast != NULL);
2344 out_printf (out, ",\n\t\t(%s)%s", cast,
2352 get_arg_names_for_macro(Method *m)
2356 GString *gs = g_string_new(NULL);
2358 for(li=m->args;li;li=g_list_next(li)) {
2359 FuncArg *arg = li->data;
2360 g_string_sprintfa(gs, "%s___%s", p, arg->name);
2364 g_string_free(gs, FALSE);
2369 put_method(Method *m)
2371 char *s, *args, *doc;
2373 is_void = (strcmp(m->mtype->name, "void")==0 &&
2374 m->mtype->pointer == NULL);
2375 out_printf(out, "\n");
2376 if(m->method != OVERRIDE_METHOD) {
2377 doc = get_gtk_doc(m->id);
2379 out_printf(out, "%s", doc);
2384 case REGULAR_METHOD:
2386 out_addline_infile(out, m->line_no);
2387 if(m->scope == PRIVATE_SCOPE)
2388 print_method(out, "static ", "\n", "", " ", "", "\n",
2389 m, FALSE, FALSE, TRUE);
2390 else /* PUBLIC, PROTECTED */
2391 print_method(out, "", "\n", "", " ", "", "\n",
2392 m, FALSE, FALSE, TRUE);
2393 print_method_body(m, TRUE);
2394 /* the outfile line was added above */
2396 case SIGNAL_FIRST_METHOD:
2397 case SIGNAL_LAST_METHOD:
2399 out_addline_infile(out, m->line_no);
2400 if(m->scope == PRIVATE_SCOPE)
2401 print_method(out, "static ", "\n", "", " ", "", "\n",
2402 m, FALSE, FALSE, TRUE);
2403 else /* PUBLIC, PROTECTED */
2404 print_method(out, "", "\n", "", " ", "", "\n",
2405 m, FALSE, FALSE, TRUE);
2406 out_addline_outfile(out);
2407 out_printf(out, "{\n");
2408 s = g_strdup(m->id);
2410 if(strcmp(m->mtype->name, "void") == 0 &&
2411 m->mtype->pointer == NULL) {
2412 print_preconditions(m);
2413 if(((FuncArg *)m->args->data)->name)
2414 out_printf(out, "\tg_signal_emit (G_OBJECT (%s),\n"
2415 "\t\tobject_signals[%s_SIGNAL], 0",
2416 ((FuncArg *)m->args->data)->name, s);
2417 put_signal_args (m);
2418 out_printf(out, ");\n}\n");
2420 out_printf(out, "\t");
2421 print_type(out, m->mtype, TRUE);
2422 out_printf(out, "return_val = (");
2423 print_type(out, m->mtype, TRUE);
2425 out_printf(out, ")(%s);\n", m->defreturn);
2427 out_printf(out, ")(%s);\n", m->onerror);
2429 out_printf(out, ")(0);\n");
2430 print_preconditions(m);
2431 out_printf(out, "\tg_signal_emit (G_OBJECT (%s),\n"
2432 "\t\tobject_signals[%s_SIGNAL], 0",
2433 ((FuncArg *)m->args->data)->name, s);
2435 out_printf(out, ",\n\t\t&return_val);\n"
2436 "\treturn return_val;\n}\n");
2442 out_addline_infile(out, m->line_no);
2443 print_method(out, "static ", "\n___real_", "", " ", "", "\n",
2444 m, FALSE, FALSE, TRUE);
2445 print_method_body(m, FALSE);
2446 /* the outfile line was added above */
2448 case VIRTUAL_METHOD:
2450 out_addline_infile(out, m->line_no);
2451 if(m->scope==PRIVATE_SCOPE)
2452 print_method(out, "static ", "\n", "", " ", "", "\n",
2453 m, FALSE, FALSE, TRUE);
2454 else /* PUBLIC, PROTECTED */
2455 print_method(out, "", "\n", "", " ", "", "\n",
2456 m, FALSE, FALSE, TRUE);
2457 out_addline_outfile(out);
2458 out_printf(out, "{\n"
2459 "\t%sClass *klass;\n", typebase);
2460 print_preconditions(m);
2461 out_printf(out, "\tklass = %s_GET_CLASS(%s);\n\n"
2462 "\tif(klass->%s)\n",
2463 macrobase, ((FuncArg *)m->args->data)->name,
2465 if(strcmp(m->mtype->name, "void") == 0 &&
2466 m->mtype->pointer == NULL) {
2468 out_printf(out, "\t\t(*klass->%s)(%s",
2470 ((FuncArg *)m->args->data)->name);
2471 for(li=m->args->next;li;li=g_list_next(li)) {
2472 FuncArg *fa = li->data;
2473 out_printf(out, ",%s", fa->name);
2475 out_printf(out, ");\n}\n");
2478 out_printf(out, "\t\treturn (*klass->%s)(%s",
2480 ((FuncArg *)m->args->data)->name);
2481 for(li=m->args->next;li;li=g_list_next(li)) {
2482 FuncArg *fa = li->data;
2483 out_printf(out, ",%s", fa->name);
2485 out_printf(out, ");\n"
2488 print_type(out, m->mtype, TRUE);
2490 out_printf(out, ")(%s);\n}\n", m->defreturn);
2492 out_printf(out, ")(%s);\n}\n", m->onerror);
2494 out_printf(out, ")(0);\n}\n");
2500 out_addline_infile(out, m->line_no);
2501 print_method(out, "static ", "\n___real_", "", " ", "", "\n",
2502 m, FALSE, FALSE, TRUE);
2503 print_method_body(m, FALSE);
2504 /* the outfile line was added above */
2506 case OVERRIDE_METHOD:
2510 out_addline_infile(out, m->line_no);
2511 s = g_strdup_printf("\n___%x_", (guint)m->unique_id);
2512 print_method(out, "static ", s, "", " ", "", "\n",
2513 m, FALSE, FALSE, FALSE);
2515 out_addline_outfile(out);
2516 s = replace_sep(m->otype, '_');
2518 args = get_arg_names_for_macro(m);
2520 out_printf(out, "#define PARENT_HANDLER(%s) \\\n"
2521 "\t{ if(%s_CLASS(parent_class)->%s) \\\n"
2522 "\t\t(* %s_CLASS(parent_class)->%s)(%s); }\n",
2523 args, s, m->id, s, m->id, args);
2525 out_printf(out, "#define PARENT_HANDLER(%s) \\\n"
2526 "\t((%s_CLASS(parent_class)->%s)? \\\n"
2527 "\t\t(* %s_CLASS(parent_class)->%s)(%s): \\\n"
2529 args, s, m->id, s, m->id, args);
2530 out_printf(out, "(");
2531 print_type(out, m->mtype, TRUE);
2532 out_printf(out, ")%s))\n",
2533 m->onerror?m->onerror:"0");
2537 print_method_body(m, TRUE);
2538 /* the outfile line was added above */
2539 out_printf(out, "#undef PARENT_HANDLER\n");
2549 char *outfile, *outfileh, *outfileph;
2552 outfile = g_strconcat (filebase, ".c", NULL);
2554 outfile = g_strconcat (filebase, ".cc", NULL);
2555 if (no_touch_headers)
2556 outfileh = g_strconcat ("#gob#", filebase, ".h#gob#", NULL);
2558 outfileh = g_strconcat (filebase, ".h", NULL);
2560 if ((privates > 0 || protecteds > 0 ||
2561 private_header == PRIVATE_HEADER_ALWAYS) &&
2562 private_header != PRIVATE_HEADER_NEVER)
2563 outfileph = g_strconcat (filebase, "-private.h", NULL);
2569 devnull = fopen ("/dev/null", "w");
2570 if (devnull == NULL)
2571 g_error ("Cannot open null device");
2574 if (outfileph != NULL)
2577 out = fopen (outfile, "w");
2579 g_error ("Cannot open outfile: %s", outfile);
2581 outh = fopen (outfileh, "w");
2583 g_error ("Cannot open outfile: %s", outfileh);
2584 if (outfileph != NULL) {
2585 outph = fopen (outfileph, "w");
2587 g_error ("Cannot open outfile: %s", outfileh);
2593 put_argument_nongnu_wrappers (Class *c)
2597 if (get_properties < 0 && set_properties < 0)
2600 for (li = c->nodes; li != NULL; li = li->next) {
2602 const char *name, *gtktype;
2608 if (n->type == ARGUMENT_NODE) {
2609 Argument *a = (Argument *)n;
2611 gtktype = a->gtktype;
2613 get = a->get != NULL;
2614 set = a->set != NULL;
2615 } else if (n->type == PROPERTY_NODE) {
2616 Property *p = (Property *)n;
2618 gtktype = p->gtktype;
2620 get = p->get != NULL;
2621 set = p->set != NULL;
2626 aname = g_strdup (name);
2630 cast = get_type (atype, TRUE);
2632 cast = g_strdup (get_cast (gtktype, TRUE));
2636 out_printf (outh, "#define %s_PROP_%s(arg) \t"
2637 "\"%s\",(%s)(arg)\n",
2638 macrobase, aname, name, cast);
2640 out_printf (outh, "#define %s_GET_PROP_%s(arg)\t"
2641 "\"%s\",(%s*)(arg)\n",
2642 macrobase, aname, name, cast);
2645 out_printf (outh, "#define %s_PROP_%s(arg) \t"
2647 macrobase, aname, name);
2649 out_printf (outh, "#define %s_GET_PROP_%s(arg)\t"
2651 macrobase, aname, name);
2659 put_argument_gnu_wrappers(Class *c)
2663 if(get_properties < 0 && set_properties < 0)
2666 for (li = c->nodes; li != NULL; li = li->next) {
2668 const char *name, *gtktype;
2674 if (n->type == ARGUMENT_NODE) {
2675 Argument *a = (Argument *)n;
2677 gtktype = a->gtktype;
2679 get = a->get != NULL;
2680 set = a->set != NULL;
2681 } else if (n->type == PROPERTY_NODE) {
2682 Property *p = (Property *)n;
2684 gtktype = p->gtktype;
2686 get = p->get != NULL;
2687 set = p->set != NULL;
2692 aname = g_strdup (name);
2696 cast = get_type (atype, TRUE);
2698 cast = g_strdup (get_cast (gtktype, TRUE));
2702 out_printf (outh, "#define %s_PROP_%s(arg) \t"
2703 "\"%s\",({%sz = (arg); z;})\n",
2704 macrobase, aname, name, cast);
2706 out_printf (outh, "#define %s_GET_PROP_%s(arg)\t"
2707 "\"%s\",({%s*z = (arg); z;})\n",
2708 macrobase, aname, name, cast);
2711 out_printf (outh, "#define %s_PROP_%s(arg) \t"
2713 macrobase, aname, name);
2715 out_printf (outh, "#define %s_GET_PROP_%s(arg)\t"
2717 macrobase, aname, name);
2725 print_ccode_block(CCode *cc)
2728 switch(cc->cctype) {
2730 /* HT code is printed exactly like normal header
2731 code but is printed before */
2734 out_printf(fp, "\n");
2737 /* AT code is printed exactly like normal 'all'
2738 code but is printed before */
2741 out_printf(outph, "\n");
2742 out_printf(outph, "%s\n", cc->cbuf);
2743 out_addline_infile(outph, cc->line_no);
2744 out_addline_outfile(outph);
2746 out_printf(outh, "\n");
2747 out_printf(outh, "%s\n", cc->cbuf);
2749 out_printf(fp, "\n");
2750 out_addline_infile(fp, cc->line_no);
2755 out_printf(fp, "\n");
2756 out_addline_infile(fp, cc->line_no);
2763 out_printf(fp, "\n");
2764 out_addline_infile(fp, cc->line_no);
2767 out_printf(fp, "%s\n", cc->cbuf);
2768 if(cc->cctype == C_CCODE ||
2769 cc->cctype == A_CCODE ||
2770 cc->cctype == AT_CCODE ||
2771 cc->cctype == PH_CCODE)
2772 out_addline_outfile(fp);
2776 print_class_block(Class *c)
2780 gboolean printed_private = FALSE;
2783 out_printf(out, "/* utility types we may need */\n");
2784 if(special_array[SPECIAL_2POINTER])
2785 out_printf(out, "typedef struct { "
2786 "gpointer a; gpointer b; "
2787 "} ___twopointertype;\n");
2788 if(special_array[SPECIAL_3POINTER])
2789 out_printf(out, "typedef struct { "
2790 "gpointer a; gpointer b; "
2792 "} ___threepointertype;\n");
2793 if(special_array[SPECIAL_INT_POINTER])
2794 out_printf(out, "typedef struct { "
2795 "gint a; gpointer b; "
2796 "} ___intpointertype;\n");
2797 out_printf(out, "\n");
2800 out_printf(outh, "\n/*\n"
2801 " * Type checking and casting macros\n"
2803 out_printf(outh, "#define %s\t"
2804 "(%s_get_type())\n",
2805 macrotype, funcbase);
2806 out_printf(outh, "#define %s(obj)\t"
2807 "G_TYPE_CHECK_INSTANCE_CAST((obj), %s_get_type(), %s)\n",
2808 macrobase, funcbase, typebase);
2809 out_printf(outh, "#define %s_CONST(obj)\t"
2810 "G_TYPE_CHECK_INSTANCE_CAST((obj), %s_get_type(), %s const)\n",
2811 macrobase, funcbase, typebase);
2812 out_printf(outh, "#define %s_CLASS(klass)\t"
2813 "G_TYPE_CHECK_CLASS_CAST((klass), %s_get_type(), %sClass)\n",
2814 macrobase, funcbase, typebase);
2815 out_printf(outh, "#define %s(obj)\t"
2816 "G_TYPE_CHECK_INSTANCE_TYPE((obj), %s_get_type ())\n\n",
2819 "#define %s_GET_CLASS(obj)\t"
2820 "G_TYPE_INSTANCE_GET_CLASS((obj), %s_get_type(), %sClass)\n",
2821 macrobase, funcbase, typebase);
2823 if ( ! no_self_alias) {
2824 out_printf(out, "/* self casting macros */\n");
2825 out_printf(out, "#define SELF(x) %s(x)\n", macrobase);
2826 out_printf(out, "#define SELF_CONST(x) %s_CONST(x)\n", macrobase);
2827 out_printf(out, "#define IS_SELF(x) %s(x)\n", macrois);
2828 out_printf(out, "#define TYPE_SELF %s\n", macrotype);
2829 out_printf(out, "#define SELF_CLASS(x) %s_CLASS(x)\n\n",
2831 out_printf(out, "#define SELF_GET_CLASS(x) %s_GET_CLASS(x)\n\n",
2834 out_printf(out, "/* self typedefs */\n");
2835 out_printf(out, "typedef %s Self;\n", typebase);
2836 out_printf(out, "typedef %sClass SelfClass;\n\n", typebase);
2840 always_private_struct) {
2841 out_printf (outh, "\n/* Private structure type */\n");
2842 out_printf (outh, "typedef struct _%sPrivate %sPrivate;\n",
2843 typebase, typebase);
2845 out_printf (outh, "/* There are no privates, this "
2846 "structure is thus never defined */\n");
2849 out_printf (outh, "\n/*\n"
2850 " * Main object structure\n"
2852 s = replace_sep (c->otype, '_');
2854 out_printf (outh, "#ifndef __TYPEDEF_%s__\n"
2855 "#define __TYPEDEF_%s__\n", s, s);
2857 out_printf (outh, "typedef struct _%s %s;\n"
2858 "#endif\n", typebase, typebase);
2859 out_printf (outh, "struct _%s {\n\t%s __parent__;\n",
2860 typebase, ptypebase);
2861 for (li = c->nodes; li; li=li->next) {
2862 static gboolean printed_public = FALSE;
2864 Variable *v = (Variable *)n;
2865 if(n->type == VARIABLE_NODE &&
2866 v->scope == PUBLIC_SCOPE) {
2867 if( ! printed_public) {
2868 out_printf(outh, "\t/*< public >*/\n");
2869 printed_public = TRUE;
2871 put_variable((Variable *)n, outh);
2874 /* put protecteds always AFTER publics */
2875 for (li = c->nodes; li != NULL; li = li->next) {
2877 Variable *v = (Variable *)n;
2878 if (n->type == VARIABLE_NODE &&
2879 v->scope == PROTECTED_SCOPE) {
2880 if ( ! printed_private) {
2881 out_printf (outh, "\t/*< private >*/\n");
2882 printed_private = TRUE;
2884 put_variable ((Variable *)n, outh);
2888 always_private_struct) {
2889 if ( ! printed_private)
2890 out_printf (outh, "\t/*< private >*/\n");
2891 out_printf (outh, "\t%sPrivate *_priv;\n", typebase);
2893 out_printf (outh, "};\n");
2898 /* if we are to stick this into the private
2899 header, if not stick it directly into the
2906 out_printf (outfp, "struct _%sPrivate {\n",
2908 for(li=c->nodes; li; li=li->next) {
2910 Variable *v = (Variable *)n;
2911 if(n->type == VARIABLE_NODE &&
2912 v->scope == PRIVATE_SCOPE) {
2913 out_addline_infile(outfp, v->line_no);
2914 put_variable(v, outfp);
2917 out_addline_outfile(outfp);
2918 out_printf(outfp, "};\n");
2921 out_printf(outh, "\n/*\n"
2922 " * Class definition\n"
2924 out_printf(outh, "typedef struct _%sClass %sClass;\n",
2925 typebase, typebase);
2927 "struct _%sClass {\n\t%sClass __parent__;\n",
2928 typebase, ptypebase);
2929 for(li = c->nodes; li != NULL; li = li->next) {
2931 if(n->type == METHOD_NODE)
2932 put_vs_method((Method *)n);
2934 /* If BonoboX type class put down the epv */
2935 if (c->bonobo_x_class != NULL) {
2937 "\t/* Bonobo object epv */\n"
2938 "\tPOA_%s__epv _epv;\n",
2941 /* put class scope variables */
2942 for (li = c->nodes; li != NULL; li = li->next) {
2944 Variable *v = (Variable *)n;
2945 if (n->type == VARIABLE_NODE &&
2946 v->scope == CLASS_SCOPE)
2947 put_variable ((Variable *)n, outh);
2949 out_printf (outh, "};\n\n");
2951 out_printf (out, "/* here are local prototypes */\n");
2952 if (set_properties > 0) {
2953 out_printf (out, "static void ___object_set_property "
2954 "(GObject *object, guint property_id, "
2955 "const GValue *value, GParamSpec *pspec);\n");
2957 if (get_properties > 0) {
2958 out_printf (out, "static void ___object_get_property "
2959 "(GObject *object, guint property_id, "
2960 "GValue *value, GParamSpec *pspec);\n");
2963 out_printf (outh, "\n/*\n"
2964 " * Public methods\n"
2967 if ( ! overrode_get_type) {
2968 out_printf (outh, "GType\t%s_get_type\t(void)", funcbase);
2970 out_printf (outh, " G_GNUC_CONST;\n");
2972 out_printf (outh, ";\n");
2976 for(li = c->nodes; li != NULL; li = li->next) {
2978 if(n->type == METHOD_NODE) {
2979 put_pub_method((Method *)n);
2980 put_prot_method((Method *)n);
2981 put_priv_method_prot((Method *)n);
2985 /* this idea is less and less apealing to me */
2987 out_printf (outh, "\n/*\n"
2988 " * Signal connection wrapper macros\n"
2991 out_printf(outh, "#if defined(__GNUC__) && !defined(__STRICT_ANSI__)\n");
2992 put_signal_macros (c, TRUE);
2993 out_printf(outh, "#else /* __GNUC__ && !__STRICT_ANSI__ */\n");
2994 put_signal_macros (c, FALSE);
2995 out_printf(outh, "#endif /* __GNUC__ && !__STRICT_ANSI__ */\n\n");
2997 put_signal_macros (c, FALSE);
3001 /* argument wrapping macros */
3002 if(get_properties > 0 || set_properties > 0) {
3003 out_printf(outh, "\n/*\n"
3004 " * Argument wrapping macros\n"
3007 out_printf(outh, "#if defined(__GNUC__) && !defined(__STRICT_ANSI__)\n");
3008 put_argument_gnu_wrappers(c);
3009 out_printf(outh, "#else /* __GNUC__ && !__STRICT_ANSI__ */\n");
3010 put_argument_nongnu_wrappers(c);
3011 out_printf(outh, "#endif /* __GNUC__ && !__STRICT_ANSI__ */\n\n");
3013 put_argument_nongnu_wrappers(c);
3018 for(li = c->nodes; li != NULL; li = li->next) {
3020 if(n->type == METHOD_NODE)
3021 add_signal_prots((Method *)n);
3027 if ( ! overrode_get_type) {
3028 if (c->bonobo_x_class != NULL)
3029 add_bonobo_x_get_type ();
3034 if(any_method_to_alias(c)) {
3036 out_printf(out, "/* Short form macros */\n");
3037 out_printf(out, "#if defined(__GNUC__) && !defined(__STRICT_ANSI__)\n");
3038 make_method_gnu_aliases(c);
3039 out_printf(out, "#endif /* __GNUC__ && !__STRICT_ANSI__ */\n");
3041 make_method_nongnu_aliases(c);
3044 out_printf (out, "/* a macro for creating a new object of our type */\n");
3046 "#define GET_NEW ((%s *)g_object_new(%s_get_type(), NULL))\n\n",
3047 typebase, funcbase);
3049 out_printf (out, "/* a function for creating a new object of our type */\n");
3050 out_printf (out, "#include <stdarg.h>\n");
3052 "static %s * GET_NEW_VARG (const char *first, ...)%s;\n"
3053 "static %s *\nGET_NEW_VARG (const char *first, ...)\n"
3054 "{\n\t%s *ret;\n\tva_list ap;\n"
3055 "\tva_start (ap, first);\n"
3056 "\tret = (%s *)g_object_new_valist (%s_get_type (), "
3059 "\treturn ret;\n}\n\n",
3061 no_gnu ? "" : " G_GNUC_UNUSED",
3062 typebase, typebase, typebase, funcbase);
3072 if(set_properties > 0) {
3073 add_getset_arg(c, TRUE);
3076 if(get_properties > 0) {
3077 add_getset_arg(c, FALSE);
3080 for(li = c->nodes; li != NULL; li = li->next) {
3082 if(n->type == METHOD_NODE)
3083 put_method((Method *)n);
3086 add_bad_hack_to_avoid_unused_warnings(c);
3090 print_useful_macros(void)
3092 int major = 0, minor = 0, pl = 0;
3095 sscanf (VERSION, "%d.%d.%d", &major, &minor, &pl);
3096 out_printf (out, "#define GOB_VERSION_MAJOR %d\n", major);
3097 out_printf (out, "#define GOB_VERSION_MINOR %d\n", minor);
3098 out_printf (out, "#define GOB_VERSION_PATCHLEVEL %d\n\n", pl);
3100 /* Useful priv macro thingie */
3101 /* FIXME: this should be done the same way that priv is, as a var,
3103 out_printf (out, "#define selfp (self->_priv)\n\n");
3107 print_file_comments(void)
3111 out_printf(outh, "/* Generated by GOB (v%s)"
3112 " (do not edit directly) */\n\n", VERSION);
3114 out_printf(outph, "/* Generated by GOB (v%s)"
3115 " (do not edit directly) */\n\n", VERSION);
3116 out_printf(out, "/* Generated by GOB (v%s) on %s"
3117 " (do not edit directly) */\n\n",
3118 VERSION, ctime(&curtime));
3120 out_printf(out, "/* End world hunger, donate to the World Food Programme, http://www.wfp.org */\n\n");
3124 print_includes(void)
3126 gboolean found_header;
3129 /* We may need string.h for memset */
3130 if(destructors > 0 &&
3131 ! g_list_find_custom(include_files, "string.h", (GCompareFunc)strcmp)) {
3132 out_printf(out, "#include <string.h> /* memset() */\n\n");
3135 p = g_strconcat(filebase, ".h", NULL);
3136 found_header = TRUE;
3137 if( ! g_list_find_custom(include_files, p, (GCompareFunc)strcmp)) {
3138 out_printf(out, "#include \"%s.h\"\n\n", filebase);
3139 found_header = FALSE;
3143 /* if we are creating a private header see if it was included */
3145 p = g_strconcat(filebase, "-private.h", NULL);
3146 if( ! g_list_find_custom(include_files, p,
3147 (GCompareFunc)strcmp)) {
3148 out_printf(out, "#include \"%s-private.h\"\n\n",
3151 error_printf(GOB_WARN, 0,
3152 "Implicit private header include "
3154 "\tsource file, while public "
3155 "header is at a custom location, "
3157 "\texplicitly include "
3158 "the private header below the "
3166 print_header_prefixes(void)
3170 p = replace_sep(((Class *)class)->otype, '_');
3172 out_printf(outh, "#ifndef __%s_H__\n#define __%s_H__\n\n", p, p);
3174 out_printf(outph, "#ifndef __%s_PRIVATE_H__\n"
3175 "#define __%s_PRIVATE_H__\n\n"
3176 "#include \"%s.h\"\n\n", p, p, filebase);
3179 if( ! no_extern_c) {
3180 out_printf(outh, "#ifdef __cplusplus\n"
3182 "#endif /* __cplusplus */\n\n");
3184 out_printf(outph, "#ifdef __cplusplus\n"
3186 "#endif /* __cplusplus */\n\n");
3191 print_header_postfixes(void)
3194 out_printf(outh, "\n#ifdef __cplusplus\n"
3196 "#endif /* __cplusplus */\n");
3197 out_printf(outh, "\n#endif\n");
3200 out_printf(outph, "\n#ifdef __cplusplus\n"
3202 "#endif /* __cplusplus */\n");
3203 out_printf(outph, "\n#endif\n");
3212 /* print the AT_CCODE blocks */
3213 for(li = nodes; li != NULL; li = li->next) {
3214 Node *node = li->data;
3215 if(node->type == CCODE_NODE) {
3216 CCode *cc = (CCode *)node;
3217 if(cc->cctype == AT_CCODE)
3218 print_ccode_block((CCode *)node);
3224 print_header_top(void)
3228 /* mandatory includes */
3229 out_printf(outh, "#include <glib.h>\n");
3230 out_printf(outh, "#include <gobject/gobject.h>\n");
3231 out_printf(outh, "#include <gobject/gvaluetypes.h>\n");
3232 out_printf(outh, "#include <gobject/genums.h>\n");
3233 out_printf(outh, "#include <gobject/gboxed.h>\n");
3234 out_printf(outh, "#include <gobject/gparamspecs.h>\n\n");
3236 /* print the HT_CCODE blocks */
3237 for (li = nodes; li != NULL; li = li->next) {
3238 Node *node = li->data;
3239 if(node->type == CCODE_NODE) {
3240 CCode *cc = (CCode *)node;
3241 if(cc->cctype == HT_CCODE)
3242 print_ccode_block((CCode *)node);
3248 generate_outfiles(void)
3252 print_file_comments();
3258 print_header_prefixes();
3260 print_useful_macros();
3264 for(li=nodes;li;li=g_list_next(li)) {
3265 Node *node = li->data;
3266 if(node->type == CCODE_NODE) {
3267 CCode *cc = (CCode *)node;
3268 if(cc->cctype != HT_CCODE &&
3269 cc->cctype != AT_CCODE)
3270 print_ccode_block((CCode *)node);
3271 } else if(node->type == CLASS_NODE) {
3272 print_class_block((Class *)node);
3274 g_assert_not_reached();
3277 print_header_postfixes();
3283 fprintf(stderr, "Gob version %s\n\n", VERSION);
3284 fprintf(stderr, "gob [options] file.gob\n\n");
3285 fprintf(stderr, "Options:\n"
3286 "\t--help,-h,-? Display this help\n"
3287 "\t--version Display version\n"
3288 "\t--exit-on-warn,-w Exit with an error on warnings\n"
3289 "\t--no-exit-on-warn Don't exit on warnings [default]\n"
3290 "\t--for-cpp Create C++ files\n"
3291 "\t--no-extern-c Never print extern \"C\" into the "
3293 "\t--no-gnu Never use GNU extentions\n"
3294 "\t--no-touch-headers Don't touch headers unless they "
3296 "\t--always-private-header Always create a private header "
3298 "\t even if it would be empty "
3300 "\t--ondemand-private-header Create private header only when "
3302 "\t--no-private-header Don't create a private header, "
3304 "\t structure and protected "
3305 "prototypes inside c file\n"
3306 "\t--always-private-struct Always create a private pointer "
3308 "\t the object structure\n"
3309 "\t--no-write,-n Don't write output files, just "
3311 "\t--no-lines Don't print '#line' to output\n"
3312 "\t--no-self-alias Don't create self type and macro "
3314 "\t--no-kill-underscores Ignored for compatibility\n");
3318 parse_options(int argc, char *argv[])
3321 int got_file = FALSE;
3322 int no_opts = FALSE;
3326 for(i = 1 ; i < argc; i++) {
3328 argv[i][0] != '-') {
3331 fprintf(stderr, "Specify only one file!\n");
3337 } else if(strcmp(argv[i], "--help")==0) {
3340 } else if(strcmp(argv[i], "--version")==0) {
3341 fprintf(stderr, "Gob version %s\n", VERSION);
3343 } else if(strcmp(argv[i], "--exit-on-warn")==0) {
3344 exit_on_warn = TRUE;
3345 } else if(strcmp(argv[i], "--no-exit-on-warn")==0) {
3346 exit_on_warn = FALSE;
3347 } else if(strcmp(argv[i], "--for-cpp")==0) {
3349 } else if(strcmp(argv[i], "--no-touch-headers")==0) {
3350 no_touch_headers = TRUE;
3351 } else if(strcmp(argv[i], "--ondemand-private-header")==0) {
3352 private_header = PRIVATE_HEADER_ONDEMAND;
3353 } else if(strcmp(argv[i], "--always-private-header")==0) {
3354 private_header = PRIVATE_HEADER_ALWAYS;
3355 } else if(strcmp(argv[i], "--no-private-header")==0) {
3356 private_header = PRIVATE_HEADER_NEVER;
3357 } else if(strcmp(argv[i], "--no-gnu")==0) {
3359 } else if(strcmp(argv[i], "--no-extern-c")==0) {
3361 } else if(strcmp(argv[i], "--no-write")==0) {
3363 } else if(strcmp(argv[i], "--no-lines")==0) {
3365 } else if(strcmp(argv[i], "--no-self-alias")==0) {
3366 no_self_alias = TRUE;
3367 } else if(strcmp(argv[i], "--no-kill-underscores")==0) {
3369 } else if(strcmp(argv[i], "--always-private-struct")==0) {
3370 always_private_struct = TRUE;
3371 } else if(strcmp(argv[i], "--")==0) {
3372 /*further arguments are files*/
3374 } else if(strncmp(argv[i], "--", 2)==0) {
3375 /*unknown long option*/
3376 fprintf(stderr, "Unknown option '%s'!\n", argv[i]);
3380 /*by now we know we have a string starting with
3381 - which is a short option string*/
3383 for(p = argv[i] + 1; *p; p++) {
3397 "Unknown option '%c'!\n", *p);
3406 /* this is a somewhat ugly hack, but it appears to work */
3408 compare_and_move_header(void)
3410 char *hfnew = g_strconcat("#gob#", filebase, ".h#gob#", NULL);
3411 char *hf = g_strconcat(filebase, ".h", NULL);
3413 if(stat(hf, &s) == 0) {
3415 s = g_strdup_printf("cmp '%s' '%s' > /dev/null", hf, hfnew);
3416 if(system(s) == 0) {
3417 if(unlink(hfnew) != 0)
3418 error_printf(GOB_ERROR, 0,
3419 "Can't remove new header file");
3427 error_printf(GOB_ERROR, 0,
3428 "Can't remove old header file");
3430 if(rename(hfnew, hf) != 0)
3431 error_printf(GOB_ERROR, 0,
3432 "Can't rename new header file");
3438 main(int argc, char *argv[])
3440 parse_options(argc, argv);
3443 yyin = fopen(filename, "r");
3445 fprintf(stderr, "Error: can't open file '%s'\n",
3452 /* This is where parsing is done */
3455 g_error("Parsing errors, quitting");
3458 error_print(GOB_ERROR, 0, " no class defined");
3461 exit_on_error = FALSE;
3463 signals = count_signals ((Class *)class);
3464 set_properties = count_set_properties ((Class *)class) +
3465 count_set_arguments ((Class *)class);
3466 get_properties = count_get_properties ((Class *)class) +
3467 count_get_arguments ((Class *)class);
3468 overrides = count_overrides ((Class *)class);
3469 privates = count_privates ((Class *)class);
3470 protecteds = count_protecteds ((Class *)class);
3471 unreftors = count_unreftors ((Class *)class);
3472 destructors = count_destructors ((Class *)class);
3473 initializers = count_initializers ((Class *)class);
3474 overrode_get_type = find_get_type ((Class *)class);
3477 make_inits ((Class *)class);
3479 need_shutdown = TRUE;
3480 find_shutdown ((Class *)class);
3482 if (destructors > 0 ||
3484 need_finalize = TRUE;
3485 find_finalize ((Class *)class);
3487 check_bad_symbols ((Class *)class);
3488 check_duplicate_symbols ((Class *)class);
3489 check_duplicate_overrides ((Class *)class);
3490 check_duplicate_signals_args ((Class *)class);
3491 check_public_new ((Class *)class);
3492 check_vararg ((Class *)class);
3493 check_firstarg ((Class *)class);
3494 check_nonvoidempty ((Class *)class);
3495 check_signal_args ((Class *)class);
3496 check_property_types ((Class *)class);
3497 check_argument_types ((Class *)class);
3498 check_func_arg_checks ((Class *)class);
3500 exit_on_error = TRUE;
3505 any_special = setup_special_array ((Class *)class, special_array);
3509 generate_outfiles ();
3520 if (no_touch_headers &&
3522 compare_and_move_header ();