2 * Copyright (C) 1999,2000 the Free Software Foundation.
3 * Copyright (C) 2000 Eazel, Inc.
4 * Copyright (C) 2001-2004 George (Jiri) Lebl
6 * Author: George (Jiri) 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;
51 extern GList *include_files;
53 extern GHashTable *gtk_doc_hash;
57 static char *funcbase;
58 static char *pfuncbase;
59 static char *macrobase;
61 static char *pmacrois;
62 static char *macrotype;
63 static char *pmacrotype;
64 static char *typebase;
65 static char *ptypebase;
67 char *output_dir = NULL;
69 static char file_sep = '-';
71 static int signals = 0; /* number of signals */
72 static int set_properties = 0; /* number of named (set) properties */
73 static int get_properties = 0; /* number of named (get) properties */
74 static int overrides = 0; /* number of override methods */
75 static int privates = 0; /* number of private data members */
76 static int protecteds = 0; /* number of protected methods */
77 static int unreftors = 0; /* number of variable unreffing destructors */
78 static int destructors = 0; /* number of variable non-unreffing destructors */
79 static int initializers = 0; /* number of variable initializers */
80 static int glade_widgets = 0; /* number of glade widgets */
81 static gboolean overrode_get_type = FALSE; /* provided your won _get_type */
83 static gboolean made_aliases = FALSE; /* if we made any shorthand aliases
84 and need the REALLY UGLY HACK to
87 /* the special variable types we need to define */
88 static gboolean special_array[SPECIAL_LAST] = {0};
89 static gboolean any_special = FALSE;
91 static gboolean need_dispose = FALSE;
92 static Method * dispose_handler = NULL;
94 static gboolean need_finalize = FALSE;
95 static Method * finalize_handler = NULL;
100 FILE *devnull = NULL;
102 gboolean no_touch_headers = FALSE;
103 gboolean for_cpp = FALSE;
104 gboolean no_gnu = FALSE;
105 gboolean exit_on_warn = FALSE;
106 gboolean exit_on_error = TRUE;
107 gboolean got_error = FALSE;
108 gint private_header = PRIVATE_HEADER_ONDEMAND;
109 gboolean no_extern_c = FALSE;
110 gboolean no_write = FALSE;
111 gboolean no_lines = FALSE;
112 gboolean no_self_alias = FALSE;
113 gboolean always_private_struct = FALSE;
116 gboolean use_m4 = FALSE; /* preprocess sources with m4 */
117 gboolean use_m4_clean = FALSE; /* preprocess sources with m4, no m4 flags */
118 char *m4_commandline = NULL;
119 #define M4_INCLUDE_DIR PKGDATADIR "/m4"
120 #define M4_BASE_FILENAME "gobm4.m4"
121 #define M4_FLAGS "-P -s -I" M4_INCLUDE_DIR " -DGOBM4_GOB_VERSION=" VERSION " " M4_BASE_FILENAME
122 #define M4_COMMANDLINE "m4"
124 int method_unique_id = 1;
129 filebase = replace_sep (((Class *)class)->otype, file_sep);
130 gob_strdown (filebase);
132 if (output_dir != NULL &&
133 output_dir[0] != '\0') {
134 fullfilebase = g_build_filename (output_dir, filebase, NULL);
136 fullfilebase = g_strdup (filebase);
139 funcbase = replace_sep (((Class *)class)->otype, '_');
140 gob_strdown (funcbase);
142 pfuncbase = replace_sep (((Class *)class)->ptype, '_');
143 gob_strdown (pfuncbase);
145 macrobase = replace_sep (((Class *)class)->otype, '_');
146 gob_strup (macrobase);
148 macrois = make_pre_macro (((Class *)class)->otype, "IS");
149 pmacrois = make_pre_macro (((Class *)class)->ptype, "IS");
151 macrotype = make_pre_macro (((Class *)class)->otype, "TYPE");
152 pmacrotype = make_pre_macro (((Class *)class)->ptype, "TYPE");
154 typebase = remove_sep (((Class *)class)->otype);
156 ptypebase = remove_sep (((Class *)class)->ptype);
160 get_gtk_doc (const char *id)
167 val = g_hash_table_lookup(gtk_doc_hash, id);
169 return g_strdup_printf("/**\n * %s_%s:\n%s **/\n",
171 val = g_hash_table_lookup(gtk_doc_hash, id);
173 return g_strdup_printf("/**\n * %s_%s:\n%s **/\n",
179 print_type(FILE *fp, const Type *t, gboolean postfix_to_stars)
183 s = get_type(t, postfix_to_stars);
184 out_printf(fp, "%s", s);
190 print_method (FILE *fp,
191 const char *typeprefix,
192 const char *nameprefix,
193 const char *subnameprefix,
194 const char *namepostfix,
195 const char *afterargs,
198 gboolean one_arg_per_line,
199 gboolean no_funcbase,
200 gboolean kill_underscore,
201 gboolean first_unused,
207 out_printf(fp, "%s", typeprefix);
208 print_type(fp, m->mtype, TRUE);
213 out_printf(fp, "%s%s%s%s(",
214 nameprefix, subnameprefix, id, namepostfix);
216 out_printf(fp, "%s%s_%s%s%s(",
217 nameprefix, funcbase, subnameprefix, id,
221 for(li=m->args; li; li=g_list_next(li)) {
222 FuncArg *arg = li->data;
223 const char *unused = "";
226 ! for_cpp && /* g++ has a cow with this */
229 unused = " G_GNUC_UNUSED";
232 print_type(fp, arg->atype, FALSE);
234 out_printf (fp, "___fake___");
236 out_printf(fp, "%s%s%s,%s", arg->name,
237 arg->atype->postfix ?
238 arg->atype->postfix : "",
240 one_arg_per_line ? "\n\t\t\t\t\t" : " ");
242 out_printf(fp, "%s%s%s", arg->name,
243 arg->atype->postfix ?
244 arg->atype->postfix : "",
248 out_printf(fp, ",%s...",
249 one_arg_per_line ? "\n\t\t\t\t\t" : " ");
251 out_printf(fp, "void");
253 out_printf(fp, "%s)%s", afterargs, postfix);
257 any_method_to_alias(Class *c)
261 for(li=c->nodes;li;li=g_list_next(li)) {
262 Node *node = li->data;
263 if(node->type == METHOD_NODE) {
264 Method *m = (Method *)node;
266 if(m->method == INIT_METHOD ||
267 m->method == CLASS_INIT_METHOD ||
268 m->method == OVERRIDE_METHOD)
279 make_method_aliases (Class *c)
283 for(li = c->nodes; li != NULL; li = li->next) {
284 Node *node = li->data;
285 if(node->type == METHOD_NODE) {
286 Method *m = (Method *)node;
288 if(m->method == INIT_METHOD ||
289 m->method == CLASS_INIT_METHOD ||
290 m->method == OVERRIDE_METHOD)
293 out_printf (out, "#define self_%s %s_%s\n",
302 add_bad_hack_to_avoid_unused_warnings(const Class *c)
306 /* if we haven't had any methods, just return */
311 out_printf(out, "\n\n#if (!defined __GNUC__) || (defined __GNUC__ && defined __STRICT_ANSI__)\n");
313 "/*REALLY BAD HACK\n"
314 " This is to avoid unused warnings if you don't call\n"
315 " some method. I need to find a better way to do\n"
316 " this, not needed in GCC since we use some gcc\n"
317 " extentions to make saner, faster code */\n"
319 "___%s_really_bad_hack_to_avoid_warnings(void)\n"
321 out_printf(out, "\t((void (*)(void))GET_NEW_VARG)();\n");
322 for(li=c->nodes;li;li=g_list_next(li)) {
323 Node *node = li->data;
324 if(node->type == METHOD_NODE) {
325 Method *m = (Method *)node;
327 if(m->method == INIT_METHOD ||
328 m->method == CLASS_INIT_METHOD ||
329 m->method == OVERRIDE_METHOD)
332 /* in C++ mode we don't alias new */
333 if(for_cpp && strcmp(m->id, "new")==0)
336 out_printf(out, "\t((void (*)(void))self_%s)();\n", m->id);
339 out_printf(out, "\t___%s_really_bad_hack_to_avoid_warnings();\n",
342 out_printf(out, "}\n#endif /* !__GNUC__ || (__GNUC__ && __STRICT_ANSI__) */\n\n");
344 out_printf(out, "}\n\n");
348 put_variable(const Variable *v, FILE *fp)
350 out_printf(fp, "\t");
351 print_type(fp, v->vtype, FALSE);
352 out_printf(fp, "%s%s;", v->id,
354 v->vtype->postfix:"");
355 if(v->scope == PROTECTED_SCOPE)
356 out_printf(fp, " /* protected */");
357 out_printf(fp, "\n");
361 put_vs_method(const Method *m)
363 if(m->method != SIGNAL_LAST_METHOD &&
364 m->method != SIGNAL_FIRST_METHOD &&
365 m->method != VIRTUAL_METHOD)
368 /* if a signal mark it as such */
369 if(m->method != VIRTUAL_METHOD)
370 print_method(outh, "\t/*signal*/", "(* ", "", ") ", "", ";\n",
371 m, FALSE, TRUE, TRUE, FALSE, FALSE);
373 print_method(outh, "\t", "(* ", "", ") ", "", ";\n",
374 m, FALSE, TRUE, TRUE, FALSE, FALSE);
378 put_pub_method(const Method *m)
380 if(m->scope != PUBLIC_SCOPE)
383 print_method(outh, "", "\t", "", "\t", "", ";\n", m,
384 TRUE, FALSE, TRUE, FALSE, FALSE);
388 put_signal_macro (const Method *m, gboolean gnu)
390 if(m->method != SIGNAL_LAST_METHOD &&
391 m->method != SIGNAL_FIRST_METHOD)
396 out_printf (outh, "#define %s_connect__%s(object,func,data)\t"
397 "g_signal_connect(%s(object),\"%s\","
398 "(GCallback)(func),(data))\n",
399 funcbase, m->id, macrobase, m->id);
402 out_printf (outh, "#define %s_connect_after__%s(object,func,data)\t"
403 "g_signal_connect_after(%s(object),\"%s\","
404 "(GCallback)(func),(data))\n",
405 funcbase, m->id, macrobase, m->id);
408 out_printf (outh, "#define %s_connect_data__%s"
409 "(object,func,data,destroy_data,flags)\t"
410 "g_signal_connect_data(%s(object),\"%s\","
411 "(GCallback)(func),(data),(destroy_data),(GConnectFlags)(flags))\n",
412 funcbase, m->id, macrobase, m->id);
415 out_printf (outh, "#define %s_connect__%s(object,func,data)\t"
417 "%s(__extension__ ({%s *___object = (object); ___object; })),"
419 "(GCallback) __extension__ ({",
420 funcbase, m->id, macrobase, typebase, m->id);
421 print_method (outh, "", "(* ___", "", ") ", ", gpointer ___data ",
422 " = (func); ", m, FALSE, TRUE, TRUE, FALSE, TRUE);
423 out_printf (outh, "___%s; }), (data))\n", m->id);
426 out_printf (outh, "#define %s_connect_after__%s(object,func,data)\t"
427 "g_signal_connect_after("
428 "%s(__extension__ ({%s *___object = (object); ___object; })),"
430 "(GCallback) __extension__ ({",
431 funcbase, m->id, macrobase, typebase, m->id);
432 print_method (outh, "", "(* ___", "", ") ", ", gpointer ___data ",
433 " = (func); ", m, FALSE, TRUE, TRUE, FALSE, TRUE);
434 out_printf (outh, "___%s; }), (data))\n", m->id);
437 out_printf (outh, "#define %s_connect_data__%s"
438 "(object,func,data,destroy_data,flags)\t"
439 "g_signal_connect_data("
440 "%s(__extension__ ({%s *___object = (object); ___object; })),"
442 "(GCallback) __extension__ ({",
443 funcbase, m->id, macrobase, typebase, m->id);
444 print_method (outh, "", "(* ___", "", ") ", ", gpointer ___data ",
445 " = (func); ", m, FALSE, TRUE, TRUE, FALSE, TRUE);
446 out_printf (outh, "___%s; }), (data), (destroy_data), (GConnectFlags)(flags))\n", m->id);
451 put_signal_macros (const Class *c, gboolean gnu)
458 for (li = c->nodes; li != NULL; li = li->next) {
459 const Node *n = li->data;
460 if (n->type == METHOD_NODE)
461 put_signal_macro ((Method *)n, gnu);
466 put_local_signal_macro (const Method *m)
468 if(m->method != SIGNAL_LAST_METHOD &&
469 m->method != SIGNAL_FIRST_METHOD)
473 out_printf (out, "#define self_connect__%s(object,func,data)\t"
474 "%s_connect__%s((object),(func),(data))\n",
475 m->id, funcbase, m->id);
478 out_printf (out, "#define self_connect_after__%s(object,func,data)\t"
479 "%s_connect_after__%s((object),(func),(data))\n",
480 m->id, funcbase, m->id);
483 out_printf (out, "#define self_connect_data__%s(object,func,data,destroy_data,flags)\t"
484 "%s_connect_data__%s((object),(func),(data),(destroy_data),(flags))\n",
485 m->id, funcbase, m->id);
489 put_local_signal_macros (const Class *c)
496 for (li = c->nodes; li != NULL; li = li->next) {
497 const Node *n = li->data;
498 if (n->type == METHOD_NODE)
499 put_local_signal_macro ((Method *)n);
505 put_prot_method(const Method *m)
507 if(m->scope != PROTECTED_SCOPE)
511 print_method(outph, "", "\t", "", "\t", "", ";\n",
512 m, FALSE, FALSE, TRUE, FALSE, FALSE);
514 print_method(out, "", "\t", "", "\t", "", ";\n",
515 m, FALSE, FALSE, TRUE, FALSE, FALSE);
519 put_priv_method_prot(const Method *m)
521 if(m->method == SIGNAL_LAST_METHOD ||
522 m->method == SIGNAL_FIRST_METHOD ||
523 m->method == VIRTUAL_METHOD) {
526 "static ", "___real_", "", " ", "", ";\n",
527 m, FALSE, FALSE, TRUE, FALSE, FALSE);
529 /* no else, here, it might still have a private prototype, it's not
532 if((m->method == OVERRIDE_METHOD &&
535 char *s = g_strdup_printf("___%x_", (guint)m->unique_id);
536 print_method(out, "static ", s, "", " ", "",
537 no_gnu?";\n":" G_GNUC_UNUSED;\n",
538 m, FALSE, FALSE, FALSE, FALSE, FALSE);
540 } else if(m->scope == PRIVATE_SCOPE ||
541 m->method == INIT_METHOD ||
542 m->method == CLASS_INIT_METHOD) {
543 print_method(out, "static ", "", "", " ", "",
544 no_gnu?";\n":" G_GNUC_UNUSED;\n",
545 m, FALSE, FALSE, TRUE, FALSE, FALSE);
550 make_func_arg (const char *typename, gboolean is_class, const char *name)
557 tn = g_strconcat (typename, ":Class", NULL);
559 tn = g_strdup (typename);
561 type = node_new (TYPE_NODE,
565 node = node_new (FUNCARG_NODE,
566 "atype:steal", (Type *)type,
569 return g_list_prepend (NULL, node);
573 make_inits(Class *cl)
575 int got_class_init = FALSE;
576 int got_init = FALSE;
579 for(li=cl->nodes;li;li=g_list_next(li)) {
581 if(n->type == METHOD_NODE) {
582 Method *m = (Method *)n;
583 if(m->method == INIT_METHOD) {
585 error_print(GOB_ERROR, m->line_no, "init defined more then once");
587 } else if(m->method == CLASS_INIT_METHOD) {
589 error_print(GOB_ERROR, m->line_no, "class_init defined more then once");
590 got_class_init = TRUE;
594 if(!got_class_init) {
595 Type *type = (Type *)node_new (TYPE_NODE,
598 node = node_new (METHOD_NODE,
600 "method", CLASS_INIT_METHOD,
603 "args:steal", make_func_arg (cl->otype,
606 "unique_id", method_unique_id++,
608 cl->nodes = g_list_prepend(cl->nodes, node);
611 Type *type = (Type *)node_new (TYPE_NODE,
614 node = node_new (METHOD_NODE,
616 "method", INIT_METHOD,
619 "args:steal", make_func_arg (cl->otype,
620 FALSE /* is_class */,
622 "unique_id", method_unique_id++,
624 cl->nodes = g_list_prepend(cl->nodes, node);
629 find_dispose(const Class *cl)
633 dispose_handler = NULL;
634 for(li=cl->nodes;li;li=g_list_next(li)) {
636 if(n->type == METHOD_NODE) {
637 Method *m = (Method *)n;
638 if(m->method == OVERRIDE_METHOD &&
639 strcmp(m->id, "dispose")==0) {
640 if(strcmp(m->otype, "G:Object") != 0) {
641 error_print(GOB_ERROR, m->line_no,
642 "dispose method override "
643 "of class other then "
646 if(g_list_length(m->args) != 1) {
647 error_print(GOB_ERROR, m->line_no,
648 "dispose method override "
649 "with more then one "
660 find_finalize(const Class *cl)
664 finalize_handler = NULL;
665 for(li=cl->nodes;li;li=g_list_next(li)) {
667 if(n->type == METHOD_NODE) {
668 Method *m = (Method *)n;
669 if(m->method == OVERRIDE_METHOD &&
670 strcmp(m->id, "finalize")==0) {
671 if(strcmp(m->otype, "G:Object") != 0) {
672 error_print(GOB_ERROR, m->line_no,
673 "finalize method override "
674 "of class other then "
677 if(g_list_length(m->args) != 1) {
678 error_print(GOB_ERROR, m->line_no,
679 "finalize method override "
680 "with more then one "
683 finalize_handler = m;
691 /* hash of method -> name of signal prototype */
692 static GHashTable *marsh = NULL;
694 /* list of methods with different signal prototypes,
695 we check this list if we can use a signal prototype of a
696 previous signal method, there are only uniques here */
697 static GList *eq_signal_methods = NULL;
699 /* compare a list of strings */
701 is_list_equal(const GList *a, const GList *b)
703 for(;a && b; a=a->next, b=b->next) {
704 if(strcmp(a->data, b->data)!=0) {
708 /* the the lists were different length */
715 find_same_type_signal(const Method *m)
718 for(li=eq_signal_methods;li;li=li->next) {
719 Method *mm = li->data;
720 if(is_list_equal(mm->gtktypes, m->gtktypes))
727 print_signal_marsal_args (const Method *m)
729 if (strcmp (m->gtktypes->next->data, "NONE") != 0) {
732 for (i = 0, li = m->gtktypes->next;
734 i++, li = li->next) {
737 if (strcmp (li->data, "UNICHAR") == 0)
738 /* hack because glib is braindamaged */
739 get_func = g_strdup ("g_value_get_uint");
741 get_func = g_strdup_printf
742 ("g_value_get_%s", (char *)li->data);
744 gob_strdown (get_func);
745 out_printf (out, ",\n\t\t(%s) "
746 "%s (param_values + %d)",
747 get_cast (li->data, FALSE),
752 out_printf (out, ",\n\t\tdata2);\n");
757 add_signal_prots(Method *m)
763 gboolean ret_none = FALSE;
764 gboolean arglist_none = FALSE;
766 const char *unused = "";
768 if ( ! no_gnu && ! for_cpp /* g++ has a cow with this */) {
769 unused = " G_GNUC_UNUSED";
772 if (m->method != SIGNAL_LAST_METHOD &&
773 m->method != SIGNAL_FIRST_METHOD)
777 marsh = g_hash_table_new(NULL, NULL);
779 g_assert (m->gtktypes->next != NULL);
781 ret_none = strcmp(m->gtktypes->data, "NONE") == 0;
782 arglist_none = strcmp(m->gtktypes->next->data, "NONE") == 0;
784 if (ret_none && arglist_none)
787 /* if we already did a signal prototype just use that */
788 mm = find_same_type_signal (m);
790 s = g_hash_table_lookup (marsh, mm);
791 g_hash_table_insert (marsh, m, s);
798 retcast = get_cast (m->gtktypes->data, FALSE);
800 s = g_strdup_printf("Sig%d", sig++);
802 g_hash_table_insert(marsh, m, s);
803 eq_signal_methods = g_list_prepend(eq_signal_methods, m);
805 /* we know that we'll know all the gtktypes (so get_cast can't fail) */
806 out_printf(out, "\ntypedef %s (*___%s) (%s *, ",
807 get_cast(m->gtktypes->data, FALSE), s, typebase);
809 if ( ! arglist_none) {
810 for (li = m->gtktypes->next; li != NULL; li = li->next)
811 out_printf (out, "%s, ", get_cast (li->data, FALSE));
813 out_printf (out, "gpointer);\n");
815 out_printf (out, "\nstatic void\n"
816 "___marshal_%s (GClosure *closure,\n"
817 "\tGValue *return_value%s,\n"
818 "\tguint n_param_values,\n"
819 "\tconst GValue *param_values,\n"
820 "\tgpointer invocation_hint%s,\n"
821 "\tgpointer marshal_data)\n"
828 out_printf (out, "\t%s v_return;\n", retcast);
830 out_printf (out, "\tregister ___%s callback;\n"
831 "\tregister GCClosure *cc = (GCClosure*) closure;\n"
832 "\tregister gpointer data1, data2;\n\n",
835 out_printf (out, "\tg_return_if_fail (n_param_values == %d);\n\n",
836 arglist_none ? 1 : g_list_length (m->gtktypes));
839 "\tif (G_CCLOSURE_SWAP_DATA (closure)) {\n"
840 "\t\tdata1 = closure->data;\n"
841 "\t\tdata2 = g_value_peek_pointer (param_values + 0);\n"
843 "\t\tdata1 = g_value_peek_pointer (param_values + 0);\n"
844 "\t\tdata2 = closure->data;\n"
847 out_printf (out, "\tcallback = (___%s) "
848 "(marshal_data != NULL ? marshal_data : cc->callback);"
852 out_printf (out, "\tcallback ((%s *)data1", typebase);
854 out_printf (out, "\tv_return = callback ((%s *)data1",
858 print_signal_marsal_args (m);
861 /* FIXME: This code is so fucking ugly it hurts */
862 gboolean take_ownership =
863 (strcmp ((char *)m->gtktypes->data, "STRING") == 0 ||
864 strcmp ((char *)m->gtktypes->data, "BOXED") == 0);
868 if (strcmp (m->gtktypes->data, "UNICHAR") == 0)
869 /* hack because glib is braindamaged */
870 set_func = g_strdup ("g_value_set_uint");
872 set_func = g_strdup_printf ("g_value_set_%s%s",
873 (char *)m->gtktypes->data,
875 "_take_ownership" : "");
876 gob_strdown (set_func);
878 out_printf (out, "\n\t%s (return_value, v_return);\n",
883 if (no_gnu || for_cpp /* g++ has a cow with G_GNUC_UNUSED */) {
885 out_printf (out, "\n\treturn_value = NULL;\n");
886 out_printf (out, "\tinvocation_hint = NULL;\n");
889 out_printf (out, "}\n\n");
896 out_printf(out, "\n");
898 out_printf(out, "enum {\n");
899 for(li=c->nodes;li;li=g_list_next(li)) {
901 if(n->type == METHOD_NODE) {
902 Method *m = (Method *)n;
903 if(m->method == SIGNAL_LAST_METHOD ||
904 m->method == SIGNAL_FIRST_METHOD) {
905 char *s = g_strdup(m->id);
907 out_printf(out, "\t%s_SIGNAL,\n", s);
912 out_printf(out, "\tLAST_SIGNAL\n};\n\n");
914 if (set_properties > 0 ||
915 get_properties > 0) {
916 out_printf(out, "enum {\n\tPROP_0");
917 for(li=c->nodes;li;li=g_list_next(li)) {
919 if (n->type == PROPERTY_NODE) {
920 Property *p = (Property *)n;
921 char *s = g_strdup (p->name);
923 out_printf (out, ",\n\tPROP_%s", s);
925 } else if (n->type == ARGUMENT_NODE) {
926 Argument *a = (Argument *)n;
927 char *s = g_strdup(a->name);
929 out_printf(out, ",\n\tPROP_%s", s);
933 out_printf(out, "\n};\n\n");
938 "static guint object_signals[LAST_SIGNAL] = {0};\n\n");
940 out_printf(out, "/* pointer to the class of our parent */\n");
941 out_printf(out, "static %sClass *parent_class = NULL;\n\n", ptypebase);
945 add_interface_methods (Class *c, const char *interface)
948 gboolean added_line = FALSE;
950 for (li = c->nodes; li != NULL; li = li->next) {
952 Method *m = (Method *)n;
953 if (n->type != METHOD_NODE ||
954 m->method == OVERRIDE_METHOD ||
955 m->interface == NULL ||
956 strcmp (m->interface, interface) != 0)
959 if (m->line_no > 0) {
960 out_addline_infile (out, m->line_no);
962 } else if (m->line_no == 0 &&
964 out_addline_outfile (out);
967 out_printf (out, "\tiface->%s = self_%s;\n",
971 out_addline_outfile (out);
975 add_interface_inits (Class *c)
979 if (c->interfaces == NULL)
982 out_printf(out, "\n");
984 for (li = c->interfaces; li != NULL; li = li->next) {
985 const char *interface = li->data;
987 char *name = replace_sep (interface, '_');
988 char *type = remove_sep (interface);
990 /* EEEK! evil, we should have some sort of option
991 * to force this for arbitrary interfaces, since
992 * some are Class and some are Iface. Glib is shite
994 if (strcmp (type, "GtkEditable") == 0 ||
995 strcmp (type, "GTypePlugin") == 0)
998 /* We'll assume Iface is the standard ending */
1001 out_printf (out, "\nstatic void\n"
1002 "___%s_init (%s%s *iface)\n"
1006 add_interface_methods (c, interface);
1008 out_printf (out, "}\n\n");
1016 add_interface_infos (void)
1019 for (li = ((Class *)class)->interfaces;
1022 char *name = replace_sep (li->data, '_');
1024 "\t\tstatic const GInterfaceInfo %s_info = {\n"
1025 "\t\t\t(GInterfaceInitFunc) ___%s_init,\n"
1035 add_interfaces (void)
1038 for (li = ((Class *)class)->interfaces;
1041 char *name = replace_sep (li->data, '_');
1042 char *type = make_pre_macro (li->data, "TYPE");
1045 "\t\tg_type_add_interface_static (type,\n"
1047 "\t\t\t&%s_info);\n",
1059 /*char *chunk_size = ((Class*)class)->chunk_size;*/
1063 "%s_get_type (void)\n"
1065 "\tstatic GType type = 0;\n\n"
1066 "\tif ___GOB_UNLIKELY(type == 0) {\n"
1067 "\t\tstatic const GTypeInfo info = {\n"
1068 "\t\t\tsizeof (%sClass),\n"
1069 "\t\t\t(GBaseInitFunc) NULL,\n"
1070 "\t\t\t(GBaseFinalizeFunc) NULL,\n"
1071 "\t\t\t(GClassInitFunc) %s_class_init,\n"
1072 "\t\t\t(GClassFinalizeFunc) NULL,\n"
1073 "\t\t\tNULL /* class_data */,\n"
1074 "\t\t\tsizeof (%s),\n"
1075 "\t\t\t%d /* n_preallocs */,\n"
1076 "\t\t\t(GInstanceInitFunc) %s_init,\n"
1079 funcbase, typebase, funcbase, typebase, prealloc, funcbase);
1081 add_interface_infos ();
1084 "\t\ttype = g_type_register_static (%s, \"%s\", &info, (GTypeFlags)0);\n",
1085 pmacrotype, typebase);
1093 "\t\tgtk_type_set_chunk_alloc(type, %s);\n"
1095 chunk_size, chunk_size);
1105 add_bonobo_object_get_type (void)
1107 /* char *chunk_size = ((Class*)class)->chunk_size; */
1108 /* _vicious_ spanks seth with a rusty nail
1110 "\n#warning \"Bonobo isn't fully ported to glib 2.0 and "
1111 "gob2 doesn't officially support it yet. It'd be safer "
1112 "and a lot more fun to blow goats.\"\n");
1117 "%s_get_type (void)\n" /* 1 */
1119 "\tstatic GType type = 0;\n\n"
1120 "\tif ___GOB_UNLIKELY(type == 0) {\n"
1121 "\t\tstatic const GTypeInfo info = {\n"
1122 "\t\t\tsizeof (%sClass),\n" /* 2 */
1123 "\t\t\t(GBaseInitFunc) NULL,\n"
1124 "\t\t\t(GBaseFinalizeFunc) NULL,\n"
1125 "\t\t\t(GClassInitFunc) %s_class_init,\n" /* 3 */
1126 "\t\t\tNULL, /* class_finalize */\n"
1127 "\t\t\tNULL, /* class_data */\n"
1128 "\t\t\tsizeof (%s),\n" /* 4 */
1129 "\t\t\t0, /* n_preallocs */\n"
1130 "\t\t\t(GInstanceInitFunc) %s_init,\n" /* 5 */
1139 add_interface_infos ();
1142 "\t\ttype = bonobo_type_unique (\n"
1143 "\t\t\tBONOBO_OBJECT_TYPE,\n"
1144 "\t\t\tPOA_%s__init, NULL,\n" /* 1 */
1145 "\t\t\tG_STRUCT_OFFSET (%sClass, _epv),\n" /* 2 */
1146 "\t\t\t&info, \"%s\");\n", /* 3 */
1147 ((Class*)class)->bonobo_object_class /* 1 */,
1156 "\t\tgtk_type_set_chunk_alloc(type, %s);\n"
1158 chunk_size, chunk_size);
1167 add_overrides(Class *c, const char *oname,
1168 gboolean did_base_obj)
1174 done = g_hash_table_new (g_str_hash, g_str_equal);
1176 s = g_strdup ("GObject");
1177 g_hash_table_insert (done, s, s);
1179 for (li = c->nodes; li != NULL; li = li->next) {
1182 Method *m = (Method *)n;
1183 if(n->type != METHOD_NODE ||
1184 m->method != OVERRIDE_METHOD)
1187 s = remove_sep(m->otype);
1189 if(g_hash_table_lookup(done, s)) {
1193 g_hash_table_insert(done, s, s);
1195 f = replace_sep(m->otype, '_');
1198 out_printf(out, "\t%sClass *%s_class = (%sClass *)%s;\n",
1203 g_hash_table_foreach (done, (GHFunc)g_free, NULL);
1204 g_hash_table_destroy (done);
1208 make_run_signal_flags(Method *m, gboolean last)
1223 gs = g_string_new(NULL);
1226 g_string_assign(gs, "G_SIGNAL_RUN_LAST");
1228 g_string_assign(gs, "G_SIGNAL_RUN_FIRST");
1230 if(m->scope == PUBLIC_SCOPE)
1231 g_string_append(gs, " | G_SIGNAL_ACTION");
1233 for(li = m->flags; li; li = li->next) {
1234 char *flag = li->data;
1236 for(i=0;flags[i];i++) {
1237 if(strcmp(flags[i], flag)==0)
1240 /* if we haven't found it in our list */
1242 error_printf(GOB_WARN, m->line_no,
1243 "Unknown flag '%s' used, "
1244 "perhaps it was misspelled",
1247 g_string_sprintfa(gs, " | G_SIGNAL_%s", flag);
1251 char *ret = gs->str;
1252 g_string_free(gs, FALSE);
1259 add_signals(Class *c)
1263 out_printf(out, "\n");
1264 for(li=c->nodes;li;li=g_list_next(li)) {
1266 char *mar, *sig, *flags;
1267 gboolean is_none, last = FALSE;
1268 Method *m = (Method *)n;
1270 if(n->type != METHOD_NODE ||
1271 (m->method != SIGNAL_FIRST_METHOD &&
1272 m->method != SIGNAL_LAST_METHOD))
1275 if(m->method == SIGNAL_FIRST_METHOD)
1280 if(g_hash_table_lookup(marsh, m))
1281 mar = g_strconcat("___marshal_",
1282 (char *)g_hash_table_lookup(marsh, m),
1285 mar = g_strdup("g_cclosure_marshal_VOID__VOID");
1287 is_none = (strcmp(m->gtktypes->next->data, "NONE")==0);
1289 sig = g_strdup (m->id);
1291 flags = make_run_signal_flags (m, last);
1292 out_printf (out, "\tobject_signals[%s_SIGNAL] =\n"
1293 "\t\tg_signal_new (\"%s\",\n"
1294 "\t\t\tG_TYPE_FROM_CLASS (g_object_class),\n"
1295 "\t\t\t(GSignalFlags)(%s),\n"
1296 "\t\t\tG_STRUCT_OFFSET (%sClass, %s),\n"
1297 "\t\t\tNULL, NULL,\n"
1299 "\t\t\tG_TYPE_%s, %d",
1302 typebase, m->id, mar,
1303 (char *)m->gtktypes->data,
1304 is_none ? 0 : g_list_length(m->gtktypes->next));
1311 for(l = m->gtktypes->next; l != NULL; l = l->next)
1312 out_printf(out, ",\n\t\t\tG_TYPE_%s",
1316 out_printf(out, ");\n");
1318 if(strcmp(m->gtktypes->data, "NONE") != 0 ||
1321 out_printf(out, "\tif ___GOB_UNLIKELY(");
1322 if(strcmp(m->gtktypes->data, "NONE") != 0) {
1323 out_printf(out, "sizeof(");
1324 print_type(out, m->mtype, FALSE);
1325 out_printf(out, "%s",
1327 m->mtype->postfix : "");
1328 out_printf(out, ") != sizeof(%s) || ",
1329 get_cast(m->gtktypes->data, FALSE));
1332 for(al = m->args->next, gl = m->gtktypes->next;
1333 al != NULL && gl != NULL;
1334 al = al->next, gl = gl->next) {
1335 FuncArg *arg = al->data;
1336 char *gtkarg = gl->data;
1338 out_printf(out, "sizeof(");
1339 print_type(out, arg->atype, FALSE);
1340 out_printf(out, "%s",
1341 arg->atype->postfix ?
1342 arg->atype->postfix : "");
1343 out_printf(out, ") != sizeof(%s) || ",
1344 get_cast(gtkarg, FALSE));
1348 "parent_class == NULL /* avoid warning */");
1350 out_printf(out, ") {\n"
1351 "\t\tg_error(\"%s line %d: Type mismatch "
1352 "of \\\"%s\\\" signal signature\");\n"
1354 filename, m->line_no, m->id);
1361 set_def_handlers(Class *c, const char *oname)
1364 gboolean set_line = FALSE;
1366 out_printf(out, "\n");
1367 for(li = c->nodes; li; li = g_list_next(li)) {
1369 Method *m = (Method *)n;
1371 if(n->type != METHOD_NODE ||
1372 (m->method != SIGNAL_FIRST_METHOD &&
1373 m->method != SIGNAL_LAST_METHOD &&
1374 m->method != VIRTUAL_METHOD &&
1375 m->method != OVERRIDE_METHOD))
1378 if(m->line_no > 0 && m->cbuf) {
1379 out_addline_infile(out, m->line_no);
1381 } else if(set_line) {
1382 out_addline_outfile(out);
1387 if (m->method == OVERRIDE_METHOD) {
1389 s = replace_sep (m->otype, '_');
1393 dispose_handler != NULL &&
1394 strcmp (m->id, "dispose") == 0)
1395 out_printf (out, "\tg_object_class->dispose "
1397 else if (need_finalize &&
1399 strcmp(m->id, "finalize") == 0)
1401 "\tg_object_class->finalize = ___finalize;\n");
1402 else if (m->cbuf != NULL)
1404 "\t%s_class->%s = ___%x_%s_%s;\n",
1405 s, m->id, (guint)m->unique_id,
1408 out_printf(out, "\t%s_class->%s = NULL;\n",
1412 out_printf(out, "\t%s->%s = ___real_%s_%s;\n",
1416 out_printf(out, "\t%s->%s = NULL;\n",
1421 out_addline_outfile(out);
1425 make_argument (Argument *a)
1430 char *argflags[] = {
1438 flags = g_string_new ("(GParamFlags)(");
1440 if(a->get && a->set)
1441 g_string_append (flags, "G_PARAM_READABLE | G_PARAM_WRITABLE");
1443 g_string_append (flags, "G_PARAM_READABLE");
1445 g_string_append (flags, "G_PARAM_WRITABLE");
1447 g_assert(a->get || a->set);
1449 for (l = a->flags; l != NULL; l = l->next) {
1450 char *flag = l->data;
1452 if(strcmp (flag, "READABLE") == 0 ||
1453 strcmp (flag, "WRITABLE") == 0) {
1454 error_print(GOB_WARN, a->line_no,
1456 "WRITABLE argument flags are "
1457 "set automatically");
1460 for(i = 0; argflags[i]; i++) {
1461 if(strcmp(argflags[i], flag)==0)
1464 g_string_sprintfa(flags, " | %s%s", argflags[i] ? "G_PARAM_" : "", flag);
1467 g_string_append (flags, ")");
1469 s = g_strdup(a->name);
1471 if (!strcmp (a->gtktype, "ENUM"))
1472 out_printf(out, "\tparam_spec = g_param_spec_enum (\"%s\", NULL, NULL,\n"
1473 "\t\tG_TYPE_ENUM, 0,\n"
1475 a->name, flags->str);
1476 if (!strcmp (a->gtktype, "FLAGS"))
1477 out_printf(out, "\tparam_spec = g_param_spec_flags (\"%s\", NULL, NULL,\n"
1478 "\t\tG_TYPE_FLAGS, 0,\n"
1480 a->name, flags->str);
1481 else if (!strcmp (a->gtktype, "OBJECT"))
1482 out_printf(out, "\tparam_spec = g_param_spec_object (\"%s\", NULL, NULL,\n"
1483 "\t\tG_TYPE_OBJECT,\n"
1485 a->name, flags->str);
1486 else if (!strcmp (a->gtktype, "STRING"))
1487 out_printf(out, "\tparam_spec = g_param_spec_string (\"%s\", NULL, NULL,\n"
1490 a->name, flags->str);
1491 else if (!strcmp (a->gtktype, "INT"))
1492 out_printf(out, "\tparam_spec = g_param_spec_int (\"%s\", NULL, NULL,\n"
1493 "\t\tG_MININT, G_MAXINT,\n"
1496 a->name, flags->str);
1497 else if (!strcmp (a->gtktype, "UINT"))
1498 out_printf(out, "\tparam_spec = g_param_spec_uint (\"%s\", NULL, NULL,\n"
1499 "\t\t0, G_MAXUINT,\n"
1502 a->name, flags->str);
1503 else if (!strcmp (a->gtktype, "INT"))
1504 out_printf(out, "\tparam_spec = g_param_spec_int (\"%s\", NULL, NULL,\n"
1505 "\t\tG_MININT, G_MAXINT,\n"
1508 a->name, flags->str);
1509 else if (!strcmp (a->gtktype, "CHAR"))
1510 out_printf(out, "\tparam_spec = g_param_spec_char (\"%s\", NULL, NULL,\n"
1514 a->name, flags->str);
1515 else if (!strcmp (a->gtktype, "UCHAR"))
1516 out_printf(out, "\tparam_spec = g_param_spec_uchar (\"%s\", NULL, NULL,\n"
1520 a->name, flags->str);
1521 else if (!strcmp (a->gtktype, "BOOL") ||
1522 !strcmp (a->gtktype, "BOOLEAN"))
1523 out_printf(out, "\tparam_spec = g_param_spec_boolean (\"%s\", NULL, NULL,\n"
1526 a->name, flags->str);
1527 else if (!strcmp (a->gtktype, "LONG"))
1528 out_printf(out, "\tparam_spec = g_param_spec_long (\"%s\", NULL, NULL,\n"
1529 "\t\tG_MINLONG, G_MAXLONG,\n"
1532 a->name, flags->str);
1533 else if (!strcmp (a->gtktype, "ULONG"))
1534 out_printf(out, "\tparam_spec = g_param_spec_ulong (\"%s\", NULL, NULL,\n"
1535 "\t\t0, G_MAXULONG,\n"
1538 a->name, flags->str);
1539 else if (!strcmp (a->gtktype, "INT64"))
1540 out_printf(out, "\tparam_spec = g_param_spec_int64 (\"%s\", NULL, NULL,\n"
1541 "\t\tG_MININT64, G_MAXINT64,\n"
1544 a->name, flags->str);
1545 else if (!strcmp (a->gtktype, "UINT64"))
1546 out_printf(out, "\tparam_spec = g_param_spec_uint64 (\"%s\", NULL, NULL,\n"
1547 "\t\t0, G_MAXUINT64,\n"
1550 a->name, flags->str);
1551 else if (!strcmp (a->gtktype, "FLOAT"))
1552 out_printf(out, "\tparam_spec = g_param_spec_float (\"%s\", NULL, NULL,\n"
1553 "\t\tG_MINFLOAT, G_MAXFLOAT,\n"
1556 a->name, flags->str);
1557 else if (!strcmp (a->gtktype, "DOUBLE"))
1558 out_printf(out, "\tparam_spec = g_param_spec_double (\"%s\", NULL, NULL,\n"
1559 "\t\tG_MINDOUBLE, G_MAXDOUBLE,\n"
1562 a->name, flags->str);
1563 else if (!strcmp (a->gtktype, "POINTER"))
1564 out_printf(out, "\tparam_spec = g_param_spec_pointer (\"%s\", NULL, NULL,\n"
1566 a->name, flags->str);
1568 error_printf (GOB_ERROR, a->line_no,
1569 "%s type is not supported for arguments, try using properties",
1572 out_printf(out, "\tg_object_class_install_property (g_object_class,\n"
1573 "\t\tPROP_%s, param_spec);\n", s);
1577 g_string_free(flags, TRUE);
1580 #define value_for_print(str, alt) (str != NULL ? str : alt)
1583 make_property (Property *p)
1587 if (p->get == NULL && p->set == NULL) {
1588 error_print (GOB_ERROR, p->line_no,
1589 "Property has no getter nor setter");
1593 if (p->flags != NULL)
1594 error_print (GOB_WARN, p->line_no,
1595 "Overriden property, flags ignored");
1596 if (p->nick != NULL)
1597 error_print (GOB_WARN, p->line_no,
1598 "Overriden property, nick ignored");
1599 if (p->blurb != NULL)
1600 error_print (GOB_WARN, p->line_no,
1601 "Overriden property, blurb ignored");
1602 if (p->minimum != NULL)
1603 error_print (GOB_WARN, p->line_no,
1604 "Overriden property, minimum ignored");
1605 if (p->maximum != NULL)
1606 error_print (GOB_WARN, p->line_no,
1607 "Overriden property, maximum ignored");
1608 if (p->default_value != NULL)
1609 error_print (GOB_WARN, p->line_no,
1610 "Overriden property, default_value ignored");
1612 s = g_strdup (p->name);
1614 out_printf (out, "\tg_object_class_override_property (g_object_class,\n"
1616 "\t\t\"%s\");\n", s, p->name);
1621 char *argflags[] = {
1629 flags = g_string_new ("(GParamFlags)(");
1631 if (p->get != NULL && p->set != NULL)
1632 g_string_append (flags, "G_PARAM_READABLE | G_PARAM_WRITABLE");
1633 else if (p->get != NULL)
1634 g_string_append (flags, "G_PARAM_READABLE");
1636 g_string_append (flags, "G_PARAM_WRITABLE");
1639 for (l = p->flags; l != NULL; l = l->next) {
1640 char *flag = l->data;
1642 if(strcmp (flag, "READABLE") == 0 ||
1643 strcmp (flag, "WRITABLE") == 0) {
1644 error_print(GOB_WARN, p->line_no,
1646 "WRITABLE argument flags are "
1647 "set automatically");
1650 for(i = 0; argflags[i]; i++) {
1651 if(strcmp(argflags[i], flag)==0)
1654 g_string_sprintfa(flags, " | %s%s", argflags[i] ? "G_PARAM_" : "", flag);
1657 g_string_append (flags, ")");
1659 if (strcmp (p->gtktype, "CHAR") == 0) {
1660 out_printf (out, "\tparam_spec = g_param_spec_char\n"
1661 "\t\t(\"%s\" /* name */,\n"
1662 "\t\t %s /* nick */,\n"
1663 "\t\t %s /* blurb */,\n"
1664 "\t\t %s /* minimum */,\n"
1665 "\t\t %s /* maximum */,\n"
1666 "\t\t %s /* default_value */,\n"
1669 value_for_print (p->nick, "NULL"),
1670 value_for_print (p->blurb, "NULL"),
1671 value_for_print (p->minimum, "-128"),
1672 value_for_print (p->maximum, "127"),
1673 value_for_print (p->default_value, "0"),
1675 } else if (strcmp (p->gtktype, "UCHAR") == 0) {
1676 out_printf (out, "\tparam_spec = g_param_spec_uchar\n"
1677 "\t\t(\"%s\" /* name */,\n"
1678 "\t\t %s /* nick */,\n"
1679 "\t\t %s /* blurb */,\n"
1680 "\t\t %s /* minimum */,\n"
1681 "\t\t %s /* maximum */,\n"
1682 "\t\t %s /* default_value */,\n"
1685 value_for_print (p->nick, "NULL"),
1686 value_for_print (p->blurb, "NULL"),
1687 value_for_print (p->minimum, "0"),
1688 value_for_print (p->maximum, "0xFF"),
1689 value_for_print (p->default_value, "0"),
1691 } else if (strcmp (p->gtktype, "BOOLEAN") == 0) {
1692 out_printf (out, "\tparam_spec = g_param_spec_boolean\n"
1693 "\t\t(\"%s\" /* name */,\n"
1694 "\t\t %s /* nick */,\n"
1695 "\t\t %s /* blurb */,\n"
1696 "\t\t %s /* default_value */,\n"
1699 value_for_print (p->nick, "NULL"),
1700 value_for_print (p->blurb, "NULL"),
1701 value_for_print (p->default_value, "FALSE"),
1703 } else if (strcmp (p->gtktype, "INT") == 0) {
1704 out_printf (out, "\tparam_spec = g_param_spec_int\n"
1705 "\t\t(\"%s\" /* name */,\n"
1706 "\t\t %s /* nick */,\n"
1707 "\t\t %s /* blurb */,\n"
1708 "\t\t %s /* minimum */,\n"
1709 "\t\t %s /* maximum */,\n"
1710 "\t\t %s /* default_value */,\n"
1713 value_for_print (p->nick, "NULL"),
1714 value_for_print (p->blurb, "NULL"),
1715 value_for_print (p->minimum, "G_MININT"),
1716 value_for_print (p->maximum, "G_MAXINT"),
1717 value_for_print (p->default_value, "0"),
1719 } else if (strcmp (p->gtktype, "UINT") == 0) {
1720 out_printf (out, "\tparam_spec = g_param_spec_uint\n"
1721 "\t\t(\"%s\" /* name */,\n"
1722 "\t\t %s /* nick */,\n"
1723 "\t\t %s /* blurb */,\n"
1724 "\t\t %s /* minimum */,\n"
1725 "\t\t %s /* maximum */,\n"
1726 "\t\t %s /* default_value */,\n"
1729 value_for_print (p->nick, "NULL"),
1730 value_for_print (p->blurb, "NULL"),
1731 value_for_print (p->minimum, "0"),
1732 value_for_print (p->maximum, "G_MAXUINT"),
1733 value_for_print (p->default_value, "0"),
1735 } else if (strcmp (p->gtktype, "LONG") == 0) {
1736 out_printf (out, "\tparam_spec = g_param_spec_long\n"
1737 "\t\t(\"%s\" /* name */,\n"
1738 "\t\t %s /* nick */,\n"
1739 "\t\t %s /* blurb */,\n"
1740 "\t\t %s /* minimum */,\n"
1741 "\t\t %s /* maximum */,\n"
1742 "\t\t %s /* default_value */,\n"
1745 value_for_print (p->nick, "NULL"),
1746 value_for_print (p->blurb, "NULL"),
1747 value_for_print (p->minimum, "G_MINLONG"),
1748 value_for_print (p->maximum, "G_MAXLONG"),
1749 value_for_print (p->default_value, "0"),
1751 } else if (strcmp (p->gtktype, "ULONG") == 0) {
1752 out_printf (out, "\tparam_spec = g_param_spec_ulong\n"
1753 "\t\t(\"%s\" /* name */,\n"
1754 "\t\t %s /* nick */,\n"
1755 "\t\t %s /* blurb */,\n"
1756 "\t\t %s /* minimum */,\n"
1757 "\t\t %s /* maximum */,\n"
1758 "\t\t %s /* default_value */,\n"
1761 value_for_print (p->nick, "NULL"),
1762 value_for_print (p->blurb, "NULL"),
1763 value_for_print (p->minimum, "0"),
1764 value_for_print (p->maximum, "G_MAXULONG"),
1765 value_for_print (p->default_value, "0"),
1767 } else if (strcmp (p->gtktype, "INT64") == 0) {
1768 out_printf (out, "\tparam_spec = g_param_spec_int64\n"
1769 "\t\t(\"%s\" /* name */,\n"
1770 "\t\t %s /* nick */,\n"
1771 "\t\t %s /* blurb */,\n"
1772 "\t\t %s /* minimum */,\n"
1773 "\t\t %s /* maximum */,\n"
1774 "\t\t %s /* default_value */,\n"
1777 value_for_print (p->nick, "NULL"),
1778 value_for_print (p->blurb, "NULL"),
1779 value_for_print (p->minimum, "G_MININT64"),
1780 value_for_print (p->maximum, "G_MAXINT64"),
1781 value_for_print (p->default_value, "0"),
1783 } else if (strcmp (p->gtktype, "UINT64") == 0) {
1784 out_printf (out, "\tparam_spec = g_param_spec_uint64\n"
1785 "\t\t(\"%s\" /* name */,\n"
1786 "\t\t %s /* nick */,\n"
1787 "\t\t %s /* blurb */,\n"
1788 "\t\t %s /* minimum */,\n"
1789 "\t\t %s /* maximum */,\n"
1790 "\t\t %s /* default_value */,\n"
1793 value_for_print (p->nick, "NULL"),
1794 value_for_print (p->blurb, "NULL"),
1795 value_for_print (p->minimum, "0"),
1796 value_for_print (p->maximum, "G_MAXUINT64"),
1797 value_for_print (p->default_value, "0"),
1799 } else if (strcmp (p->gtktype, "UNICHAR") == 0) {
1800 out_printf (out, "\tparam_spec = g_param_spec_unichar\n"
1801 "\t\t(\"%s\" /* name */,\n"
1802 "\t\t %s /* nick */,\n"
1803 "\t\t %s /* blurb */,\n"
1804 "\t\t %s /* default_value */,\n"
1807 value_for_print (p->nick, "NULL"),
1808 value_for_print (p->blurb, "NULL"),
1809 value_for_print (p->default_value, "0"),
1811 } else if (strcmp (p->gtktype, "ENUM") == 0) {
1812 char *type = make_me_type (p->extra_gtktype,
1814 out_printf (out, "\tparam_spec = g_param_spec_enum\n"
1815 "\t\t(\"%s\" /* name */,\n"
1816 "\t\t %s /* nick */,\n"
1817 "\t\t %s /* blurb */,\n"
1818 "\t\t %s /* enum_type */,\n"
1819 "\t\t %s /* default_value */,\n"
1822 value_for_print (p->nick, "NULL"),
1823 value_for_print (p->blurb, "NULL"),
1825 value_for_print (p->default_value, "0"),
1828 } else if (strcmp (p->gtktype, "FLAGS") == 0) {
1829 char *type = make_me_type (p->extra_gtktype,
1831 out_printf (out, "\tparam_spec = g_param_spec_flags\n"
1832 "\t\t(\"%s\" /* name */,\n"
1833 "\t\t %s /* nick */,\n"
1834 "\t\t %s /* blurb */,\n"
1835 "\t\t %s /* flags_type */,\n"
1836 "\t\t %s /* default_value */,\n"
1839 value_for_print (p->nick, "NULL"),
1840 value_for_print (p->blurb, "NULL"),
1842 value_for_print (p->default_value, "0"),
1845 } else if (strcmp (p->gtktype, "FLOAT") == 0) {
1846 out_printf (out, "\tparam_spec = g_param_spec_float\n"
1847 "\t\t(\"%s\" /* name */,\n"
1848 "\t\t %s /* nick */,\n"
1849 "\t\t %s /* blurb */,\n"
1850 "\t\t %s /* minimum */,\n"
1851 "\t\t %s /* maximum */,\n"
1852 "\t\t %s /* default_value */,\n"
1855 value_for_print (p->nick, "NULL"),
1856 value_for_print (p->blurb, "NULL"),
1857 value_for_print (p->minimum, "G_MINFLOAT"),
1858 value_for_print (p->maximum, "G_MAXFLOAT"),
1859 value_for_print (p->default_value, "0.0"),
1861 } else if (strcmp (p->gtktype, "DOUBLE") == 0) {
1862 out_printf (out, "\tparam_spec = g_param_spec_double\n"
1863 "\t\t(\"%s\" /* name */,\n"
1864 "\t\t %s /* nick */,\n"
1865 "\t\t %s /* blurb */,\n"
1866 "\t\t %s /* minimum */,\n"
1867 "\t\t %s /* maximum */,\n"
1868 "\t\t %s /* default_value */,\n"
1871 value_for_print (p->nick, "NULL"),
1872 value_for_print (p->blurb, "NULL"),
1873 value_for_print (p->minimum, "G_MINDOUBLE"),
1874 value_for_print (p->maximum, "G_MAXDOUBLE"),
1875 value_for_print (p->default_value, "0.0"),
1877 } else if (strcmp (p->gtktype, "STRING") == 0) {
1878 out_printf (out, "\tparam_spec = g_param_spec_string\n"
1879 "\t\t(\"%s\" /* name */,\n"
1880 "\t\t %s /* nick */,\n"
1881 "\t\t %s /* blurb */,\n"
1882 "\t\t %s /* default_value */,\n"
1885 value_for_print (p->nick, "NULL"),
1886 value_for_print (p->blurb, "NULL"),
1887 value_for_print (p->default_value, "NULL"),
1889 } else if (strcmp (p->gtktype, "PARAM") == 0) {
1890 char *type = make_me_type (p->extra_gtktype,
1892 out_printf (out, "\tparam_spec = g_param_spec_param\n"
1893 "\t\t(\"%s\" /* name */,\n"
1894 "\t\t %s /* nick */,\n"
1895 "\t\t %s /* blurb */,\n"
1896 "\t\t %s /* param_type */,\n"
1899 value_for_print (p->nick, "NULL"),
1900 value_for_print (p->blurb, "NULL"),
1904 } else if (strcmp (p->gtktype, "BOXED") == 0) {
1905 char *type = make_me_type (p->extra_gtktype,
1907 out_printf (out, "\tparam_spec = g_param_spec_boxed\n"
1908 "\t\t(\"%s\" /* name */,\n"
1909 "\t\t %s /* nick */,\n"
1910 "\t\t %s /* blurb */,\n"
1911 "\t\t %s /* boxed_type */,\n"
1914 value_for_print (p->nick, "NULL"),
1915 value_for_print (p->blurb, "NULL"),
1919 } else if (strcmp (p->gtktype, "POINTER") == 0) {
1920 out_printf (out, "\tparam_spec = g_param_spec_pointer\n"
1921 "\t\t(\"%s\" /* name */,\n"
1922 "\t\t %s /* nick */,\n"
1923 "\t\t %s /* blurb */,\n"
1926 value_for_print (p->nick, "NULL"),
1927 value_for_print (p->blurb, "NULL"),
1929 /* FIXME: VALUE_ARRAY */
1930 } else if (strcmp (p->gtktype, "CLOSURE") == 0) {
1931 out_printf (out, "\tparam_spec = g_param_spec_pointer\n"
1932 "\t\t(\"%s\" /* name */,\n"
1933 "\t\t %s /* nick */,\n"
1934 "\t\t %s /* blurb */,\n"
1937 value_for_print (p->nick, "NULL"),
1938 value_for_print (p->blurb, "NULL"),
1940 } else if (strcmp (p->gtktype, "OBJECT") == 0) {
1941 char *type = make_me_type (p->extra_gtktype,
1943 out_printf (out, "\tparam_spec = g_param_spec_object\n"
1944 "\t\t(\"%s\" /* name */,\n"
1945 "\t\t %s /* nick */,\n"
1946 "\t\t %s /* blurb */,\n"
1947 "\t\t %s /* object_type */,\n"
1950 value_for_print (p->nick, "NULL"),
1951 value_for_print (p->blurb, "NULL"),
1956 error_printf (GOB_ERROR, p->line_no,
1957 "%s type is not supported by properties",
1961 s = g_strdup (p->name);
1963 out_printf (out, "\tg_object_class_install_property (g_object_class,\n"
1965 "\t\tparam_spec);\n", s);
1968 g_string_free (flags, TRUE);
1973 make_arguments(Class *c)
1976 if (get_properties > 0)
1977 out_printf(out, "\tg_object_class->get_property = ___object_get_property;\n");
1978 if (set_properties > 0)
1979 out_printf(out, "\tg_object_class->set_property = ___object_set_property;\n");
1980 out_printf (out, " {\n");
1981 for (li = c->nodes; li != NULL; li = li->next) {
1983 if ((n->type == PROPERTY_NODE && ! ((Property *) n)->override)
1984 || n->type == ARGUMENT_NODE) {
1985 out_printf(out, "\tGParamSpec *param_spec;\n\n");
1990 for (li = c->nodes; li != NULL; li = li->next) {
1992 if (n->type == PROPERTY_NODE)
1993 make_property ((Property *)n);
1994 else if (n->type == ARGUMENT_NODE)
1995 make_argument ((Argument *)n);
1997 out_printf(out, " }\n");
2001 print_initializer(Method *m, Variable *v)
2005 if(v->initializer == NULL)
2008 if(v->scope == PRIVATE_SCOPE)
2009 root = g_strconcat(((FuncArg *)m->args->data)->name,
2012 root = g_strdup(((FuncArg *)m->args->data)->name);
2014 if(v->initializer_line > 0)
2015 out_addline_infile(out, v->initializer_line);
2017 if (v->initializer_simple)
2018 out_printf(out, "\t%s->%s = %s;\n",
2019 root, v->id, v->initializer);
2021 out_printf(out,v->initializer);
2023 if(v->initializer_line > 0)
2024 out_addline_outfile(out);
2030 print_glade_widget(Method *m, Variable *v)
2035 if(!v->glade_widget)
2038 if(v->scope == PRIVATE_SCOPE)
2039 root = g_strconcat(((FuncArg *)m->args->data)->name,
2042 root = g_strdup(((FuncArg *)m->args->data)->name);
2044 cast = get_type(v->vtype, FALSE);
2045 out_printf(out, "\t%s->%s = (%s)glade_xml_get_widget(%s->_glade_xml, \"%s\");\n",
2046 root, v->id, cast, root, v->id);
2052 print_destructor (Variable *v)
2056 if(v->destructor == NULL)
2059 if(v->scope == PRIVATE_SCOPE)
2060 root = "self->_priv";
2064 if(v->destructor_simple) {
2065 if(v->destructor_line > 0)
2066 out_addline_infile(out, v->destructor_line);
2069 out_printf(out, "\tif(%s->%s) { "
2070 "(reinterpret_cast<void (*)(void *)>(%s)) ((gpointer)%s->%s); "
2071 "%s->%s = NULL; }\n",
2072 root, v->id, v->destructor, root, v->id,
2075 out_printf(out, "\tif(%s->%s) { "
2076 "%s ((gpointer) %s->%s); "
2077 "%s->%s = NULL; }\n",
2078 root, v->id, v->destructor, root, v->id,
2082 if(v->destructor_line > 0)
2083 out_addline_outfile(out);
2085 out_printf(out, "#define %s (%s->%s)\n", v->id, root, v->id);
2086 out_printf(out, "#define VAR %s\n", v->id);
2087 out_printf(out, "\t{\n");
2088 if(v->destructor_line > 0)
2089 out_addline_infile(out, v->destructor_line);
2091 out_printf(out, "\t%s}\n", v->destructor);
2093 if(v->destructor_line > 0)
2094 out_addline_outfile(out);
2095 out_printf(out, "\tmemset(&%s, 0, sizeof(%s));\n",
2097 out_printf(out, "#undef VAR\n");
2098 out_printf(out, "#undef %s\n", v->id);
2103 add_dispose (Class *c)
2105 out_printf(out, "\nstatic void\n"
2106 "___dispose (GObject *obj_self)\n"
2109 "#define __GOB_FUNCTION__ \"%s::dispose\"\n",
2112 if (unreftors > 0) {
2113 out_printf (out, "\t%s *self%s = %s (obj_self);\n",
2115 ! no_gnu ? " G_GNUC_UNUSED" : "",
2119 if (dispose_handler != NULL) {
2120 /* so we get possible bad argument warning */
2121 if (dispose_handler->line_no > 0)
2122 out_addline_infile (out, dispose_handler->line_no);
2123 out_printf (out, "\t___%x_%s_dispose(obj_self);\n",
2124 (guint)dispose_handler->unique_id, funcbase);
2125 if (dispose_handler->line_no > 0)
2126 out_addline_outfile (out);
2129 "\tif (G_OBJECT_CLASS (parent_class)->dispose) \\\n"
2130 "\t\t(* G_OBJECT_CLASS (parent_class)->dispose) (obj_self);\n");
2133 if (unreftors > 0) {
2135 for(li = ((Class *)class)->nodes;
2139 Variable *v = (Variable *)n;
2140 if (n->type == VARIABLE_NODE &&
2141 v->scope != CLASS_SCOPE &&
2142 v->destructor_unref)
2143 print_destructor (v);
2147 out_printf(out, "}\n"
2148 "#undef __GOB_FUNCTION__\n\n");
2152 add_finalize (Class *c)
2156 "___finalize(GObject *obj_self)\n"
2159 "#define __GOB_FUNCTION__ \"%s::finalize\"\n",
2164 const char *unused = "";
2166 unused = " G_GNUC_UNUSED";
2167 out_printf(out, "\t%s *self%s = %s (obj_self);\n",
2168 typebase, unused, macrobase);
2171 const char *unused = "";
2173 unused = " G_GNUC_UNUSED";
2174 out_printf(out, "\tgpointer priv%s = self->_priv;\n",
2178 if(finalize_handler) {
2179 /* so we get possible bad argument warning */
2180 if(finalize_handler->line_no > 0)
2181 out_addline_infile(out, finalize_handler->line_no);
2182 out_printf(out, "\t___%x_%s_finalize(obj_self);\n",
2183 (guint)finalize_handler->unique_id, funcbase);
2184 if(finalize_handler->line_no > 0)
2185 out_addline_outfile(out);
2188 "\tif(G_OBJECT_CLASS(parent_class)->finalize) \\\n"
2189 "\t\t(* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);\n");
2192 if (destructors > 0) {
2194 for (li = ((Class *)class)->nodes;
2198 Variable *v = (Variable *)n;
2199 if (n->type == VARIABLE_NODE &&
2200 v->scope != CLASS_SCOPE &&
2201 ! v->destructor_unref)
2202 print_destructor (v);
2206 out_printf(out, "}\n"
2207 "#undef __GOB_FUNCTION__\n\n");
2211 make_bonobo_object_epv (Class *c, const char *classname)
2214 gboolean added_line = FALSE;
2216 for (li = c->nodes; li != NULL; li = li->next) {
2218 Method *m = (Method *)n;
2219 if(n->type != METHOD_NODE ||
2220 m->method == OVERRIDE_METHOD)
2223 if (m->bonobo_object_func) {
2224 if(m->line_no > 0) {
2225 out_addline_infile(out, m->line_no);
2227 } else if (m->line_no == 0 &&
2229 out_addline_outfile(out);
2232 out_printf (out, "\t%s->_epv.%s = self_%s;\n",
2233 classname, m->id, m->id);
2237 out_addline_outfile(out);
2243 const char *unused = "";
2247 unused = " G_GNUC_UNUSED";
2249 for(li=c->nodes;li;li=g_list_next(li)) {
2253 if(n->type != METHOD_NODE)
2256 if(m->method == INIT_METHOD) {
2258 out_addline_infile(out, m->line_no);
2259 print_method(out, "static ", "\n", "", " ", "", "\n",
2260 m, FALSE, FALSE, TRUE, TRUE, FALSE);
2262 out_addline_outfile(out);
2263 out_printf(out, "{\n"
2264 "#define __GOB_FUNCTION__ \"%s::init\"\n",
2267 out_printf(out, "\t%s->_priv = "
2268 "G_TYPE_INSTANCE_GET_PRIVATE(%s,%s,%sPrivate);\n",
2269 ((FuncArg *)m->args->data)->name,
2270 ((FuncArg *)m->args->data)->name,
2273 } else if(always_private_struct) {
2274 out_printf(out, "\t%s->_priv = NULL;\n",
2275 ((FuncArg *)m->args->data)->name);
2277 if(initializers > 0) {
2279 for(li = ((Class *)class)->nodes;
2283 Variable *v = (Variable *)n;
2284 if(n->type != VARIABLE_NODE ||
2285 v->scope == CLASS_SCOPE)
2287 print_initializer(m, v);
2290 if(glade_widgets > 0) {
2292 for(li = ((Class *)class)->nodes;
2296 Variable *v = (Variable *)n;
2297 if(n->type != VARIABLE_NODE ||
2298 v->scope == CLASS_SCOPE)
2300 print_glade_widget(m, v);
2303 } else if(m->method == CLASS_INIT_METHOD) {
2304 gboolean did_base_obj = FALSE;
2307 out_addline_infile(out, m->line_no);
2308 print_method(out, "static ", "\n", "", " ", "", "\n",
2309 m, FALSE, FALSE, TRUE, TRUE, FALSE);
2311 out_addline_outfile(out);
2312 out_printf(out, "{\n"
2313 "#define __GOB_FUNCTION__ \"%s::class_init\"\n",
2315 if (set_properties > 0 ||
2316 get_properties > 0 ||
2322 "g_object_class%s = "
2323 "(GObjectClass*) %s;\n",
2325 ((FuncArg *)m->args->data)->name);
2326 did_base_obj = TRUE;
2331 ((FuncArg *)m->args->data)->name,
2336 "\n\tg_type_class_add_private(%s,sizeof(%sPrivate));\n",
2337 ((FuncArg *)m->args->data)->name,
2340 if (initializers > 0) {
2342 for(li = ((Class *)class)->nodes;
2346 Variable *v = (Variable *)n;
2347 if(n->type == VARIABLE_NODE &&
2348 v->scope == CLASS_SCOPE)
2349 print_initializer(m, v);
2353 out_printf(out, "\n\tparent_class = ");
2355 out_printf(out, "(%sClass *)", ptypebase);
2356 out_printf(out, "g_type_class_ref (%s);\n",
2362 set_def_handlers(c, ((FuncArg *)m->args->data)->name);
2364 /* if there are no handlers for these things, we
2365 * need to set them up here */
2366 if(need_dispose && !dispose_handler)
2367 out_printf(out, "\tg_object_class->dispose "
2369 if(need_finalize && !finalize_handler)
2370 out_printf(out, "\tg_object_class->finalize = "
2373 if(get_properties > 0 || set_properties > 0)
2376 if (c->bonobo_object_class != NULL) {
2377 make_bonobo_object_epv (c, ((FuncArg *)m->args->data)->name);
2383 out_printf(out, " {\n");
2384 out_addline_infile(out, m->ccode_line);
2385 out_printf(out, "%s\n", m->cbuf);
2386 out_addline_outfile(out);
2387 out_printf(out, " }\n");
2389 out_printf(out, "}\n"
2390 "#undef __GOB_FUNCTION__\n");
2395 add_argument (Argument *a, gboolean is_set)
2399 char *the_type_lower;
2404 line_no = a->set_line;
2407 line_no = a->get_line;
2411 s = g_strdup(a->name);
2413 out_printf(out, "\tcase PROP_%s:\n\t{", s);
2415 the_type_lower = g_strdup (a->gtktype);
2416 gob_strdown (the_type_lower);
2418 /* HACK because there is no g_value_set/get for unichar */
2419 if (strcmp (the_type_lower, "unichar") == 0) {
2420 g_free (the_type_lower);
2421 the_type_lower = g_strdup ("uint");
2426 const char *unused = "";
2428 if ( ! no_gnu && ! for_cpp /* g++ has a cow with this */) {
2429 unused = " G_GNUC_UNUSED";
2432 if (a->atype != NULL &&
2433 /* gcc -Wbad-function-cast is wanking stupid, moronic
2434 and otherwise evil so we should just use a (gint)
2435 or (guint) cast, not the specific type cast */
2437 (strcmp (a->gtktype, "ENUM") != 0 &&
2438 strcmp (a->gtktype, "FLAGS") != 0)))
2439 cast = get_type (a->atype, TRUE);
2441 cast = g_strdup (get_cast (a->gtktype, FALSE));
2443 out_printf (out, "\t%s ARG%s = (%s) g_value_get_%s (VAL);\n",
2444 cast, unused, cast, the_type_lower);
2447 } else if ( ! is_set) {
2450 if (a->atype != NULL)
2451 cast = get_type (a->atype, TRUE);
2453 cast = g_strdup (get_cast (a->gtktype, FALSE));
2454 out_printf (out, "\t%s ARG;\n"
2455 "\tmemset (&ARG, 0, sizeof (%s));\n",
2461 out_printf(out, "\t\t{\n");
2463 out_addline_infile (out, line_no);
2464 out_printf (out, "%s\n", cbuf);
2466 out_addline_outfile (out);
2467 out_printf (out, "\t\t}\n");
2469 if (strcmp (a->gtktype, "OBJECT") == 0)
2470 out_printf (out, "\t\tg_value_set_%s (VAL, G_OBJECT (ARG));\n",
2473 out_printf (out, "\t\t"
2474 "g_value_set_%s (VAL, ARG);\n",
2477 g_free (the_type_lower);
2480 (no_gnu || for_cpp /* g++ has a cow with G_GNUC_UNUSED */)) {
2481 out_printf (out, "\t\tif (&ARG) break;\n");
2484 out_printf (out, "\t\tbreak;\n");
2486 out_printf (out, "\t}\n");
2490 add_property (Property *p, gboolean is_set)
2493 char *the_type_lower;
2499 line_no = p->set_line;
2502 line_no = p->get_line;
2507 name_upper = g_strdup (p->name);
2508 gob_strup (name_upper);
2509 the_type_lower = g_strdup (p->gtktype);
2510 gob_strdown (the_type_lower);
2512 out_printf (out, "\tcase PROP_%s:\n", name_upper);
2514 out_printf(out, "\t\t{\n");
2516 out_addline_infile (out, line_no);
2517 out_printf (out, "%s\n", cbuf);
2519 out_addline_outfile (out);
2520 out_printf (out, "\t\t}\n");
2522 g_free (name_upper);
2523 g_free (the_type_lower);
2525 out_printf (out, "\t\tbreak;\n");
2529 add_getset_arg(Class *c, gboolean is_set)
2532 const char *unused = "";
2533 const char *hack_unused = "";
2535 if ( ! no_gnu && ! for_cpp /* g++ has a cow with this */) {
2536 unused = " G_GNUC_UNUSED";
2538 hack_unused = "if (&VAL || &pspec) break;\n\t\t";
2541 out_printf(out, "\nstatic void\n"
2542 "___object_%s_property (GObject *object,\n"
2543 "\tguint property_id,\n"
2544 "\t%sGValue *VAL%s,\n"
2545 "\tGParamSpec *pspec%s)\n"
2546 "#define __GOB_FUNCTION__ \"%s::%s_property\"\n"
2549 "\tself = %s (object);\n\n"
2550 "\tswitch (property_id) {\n",
2551 is_set ? "set" : "get",
2552 is_set ? "const " : "",
2556 is_set ? "set" : "get",
2561 for (li = c->nodes; li != NULL; li = li->next) {
2563 if (n->type == PROPERTY_NODE)
2564 add_property ((Property *)n, is_set);
2565 else if (n->type == ARGUMENT_NODE)
2566 add_argument ((Argument *)n, is_set);
2568 out_printf (out, "\tdefault:\n"
2569 "/* Apparently in g++ this is needed, glib is b0rk */\n"
2570 "#ifndef __PRETTY_FUNCTION__\n"
2571 "# undef G_STRLOC\n"
2572 "# define G_STRLOC __FILE__ \":\" G_STRINGIFY (__LINE__)\n"
2574 "\t\tG_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);\n"
2575 "\t\t%sbreak;\n\t}\n"
2577 "#undef __GOB_FUNCTION__\n", hack_unused);
2581 print_checks (Method *m, FuncArg *fa)
2585 gboolean checked_null = FALSE;
2586 is_void = (strcmp(m->mtype->name, "void")==0 &&
2587 m->mtype->pointer == NULL);
2589 for(li = fa->checks; li != NULL; li = li->next) {
2590 Check *ch = li->data;
2592 /* point to the method prot in .gob for failed checks */
2594 out_addline_infile(out, m->line_no);
2596 out_printf(out, "\tg_return_if_fail (");
2598 out_printf(out, "\tg_return_val_if_fail (");
2599 switch(ch->chtype) {
2601 out_printf(out, "%s != NULL", fa->name);
2602 checked_null = TRUE;
2605 s = make_pre_macro(fa->atype->name, "IS");
2607 out_printf(out, "%s (%s)", s, fa->name);
2609 /* if not check null, null may be valid */
2610 out_printf(out, "!(%s) || %s (%s)", fa->name,
2615 out_printf(out, "%s < %s", fa->name, ch->number);
2618 out_printf(out, "%s > %s", fa->name, ch->number);
2621 out_printf(out, "%s <= %s", fa->name, ch->number);
2624 out_printf(out, "%s >= %s", fa->name, ch->number);
2627 out_printf(out, "%s == %s", fa->name, ch->number);
2630 out_printf(out, "%s != %s", fa->name, ch->number);
2634 out_printf(out, ");\n");
2636 out_printf(out, ", (");
2637 print_type(out, m->mtype, TRUE);
2638 out_printf(out, ")%s);\n",
2639 m->onerror?m->onerror:"0");
2645 print_preconditions(Method *m)
2649 for(li=m->args;li;li=g_list_next(li)) {
2650 FuncArg *fa = li->data;
2652 print_checks(m, fa);
2655 out_addline_outfile(out);
2659 print_method_body (Method *m, gboolean pre, gboolean unused_self)
2662 out_addline_outfile(out);
2663 out_printf(out, "{\n"
2664 "#define __GOB_FUNCTION__ \"%s::%s\"\n",
2665 ((Class *)class)->otype,
2668 print_preconditions(m);
2672 (no_gnu || for_cpp) &&
2674 ((FuncArg *)(m->args->data))->name != NULL &&
2675 strcmp (((FuncArg *)(m->args->data))->name, "self") == 0) {
2676 out_printf (out, "\tif (&self) { ; }\n");
2679 /* Note: the trailing }'s are on one line, this is so
2680 that we get the no return warning correctly and point to
2681 the correct line in the .gob file, yes this is slightly
2682 ugly in the .c file, but that is not supposed to be
2683 human readable anyway. */
2685 out_printf(out, "{\n");
2687 out_addline_infile(out, m->ccode_line);
2688 out_printf(out, "\t%s}", m->cbuf);
2691 /* Note, there is no \n between the last } and this } so that
2692 * errors/warnings reported on the end of the body get pointed to the
2693 * right line in the .gob source */
2694 out_printf(out, "}\n");
2697 out_addline_outfile(out);
2698 out_printf(out, "#undef __GOB_FUNCTION__\n");
2702 put_signal_args (Method *m)
2708 if (m->args->next == NULL)
2711 for (ali = m->gtktypes->next, li = m->args->next, i = 1;
2712 li != NULL && ali != NULL;
2713 li = li->next, ali = ali->next, i++) {
2714 FuncArg *fa = li->data;
2715 char *cast = g_strdup (get_cast (ali->data, FALSE));
2716 /* FIXME: This code is so fucking ugly it hurts */
2717 gboolean do_static =
2718 (strcmp ((char *)ali->data, "STRING") == 0 ||
2719 strcmp ((char *)ali->data, "BOXED") == 0);
2723 cast = get_type (fa->atype, TRUE);
2725 /* we should have already proved before that
2726 the we know all the types */
2727 g_assert (cast != NULL);
2730 "\t___param_values[%d].g_type = 0;\n"
2731 "\tg_value_init (&___param_values[%d], G_TYPE_%s);\n",
2732 i, i, (char *)ali->data);
2734 if (strcmp (ali->data, "UNICHAR") == 0)
2735 /* hack because glib is braindamaged */
2736 set_func = g_strdup ("g_value_set_uint");
2738 set_func = g_strdup_printf ("g_value_set%s_%s",
2739 do_static ? "_static" : "",
2741 gob_strdown (set_func);
2743 out_printf (out, "\t%s (&___param_values[%d], (%s) %s);\n\n",
2744 set_func, i, cast, fa->name);
2752 clear_signal_args (Method *m)
2757 out_printf (out, "\n\tg_value_unset (&___param_values[0]);\n");
2759 if (m->args->next == NULL)
2762 for (li = m->args->next, i = 1;
2764 li = li->next, i++) {
2766 "\tg_value_unset (&___param_values[%d]);\n", i);
2771 get_arg_names_for_macro (Method *m)
2775 GString *gs = g_string_new(NULL);
2777 for(li=m->args;li;li=g_list_next(li)) {
2778 FuncArg *arg = li->data;
2779 g_string_sprintfa (gs, "%s___%s", sep, arg->name);
2782 return g_string_free (gs, FALSE);
2786 put_method(Method *m)
2788 char *s, *args, *doc;
2790 is_void = (strcmp(m->mtype->name, "void")==0 &&
2791 m->mtype->pointer == NULL);
2792 out_printf(out, "\n");
2793 if(m->method != OVERRIDE_METHOD) {
2794 doc = get_gtk_doc(m->id);
2796 out_printf(out, "%s", doc);
2801 case REGULAR_METHOD:
2803 out_addline_infile(out, m->line_no);
2804 if(m->scope == PRIVATE_SCOPE)
2805 print_method(out, "static ", "\n", "", " ", "", "\n",
2806 m, FALSE, FALSE, TRUE, FALSE, FALSE);
2807 else /* PUBLIC, PROTECTED */
2808 print_method(out, "", "\n", "", " ", "", "\n",
2809 m, FALSE, FALSE, TRUE, FALSE, FALSE);
2810 print_method_body(m, TRUE, TRUE);
2811 /* the outfile line was added above */
2813 case SIGNAL_FIRST_METHOD:
2814 case SIGNAL_LAST_METHOD:
2816 out_addline_infile(out, m->line_no);
2817 if(m->scope == PRIVATE_SCOPE)
2818 print_method(out, "static ", "\n", "", " ", "", "\n",
2819 m, FALSE, FALSE, TRUE, FALSE, FALSE);
2820 else /* PUBLIC, PROTECTED */
2821 print_method(out, "", "\n", "", " ", "", "\n",
2822 m, FALSE, FALSE, TRUE, FALSE, FALSE);
2823 out_addline_outfile (out);
2825 out_printf (out, "{\n");
2828 "\tGValue ___param_values[%d];\n"
2829 "\tGValue ___return_val;\n\n"
2830 "memset (&___return_val, 0, "
2831 "sizeof (___return_val));\n"
2832 "memset (&___param_values, 0, "
2833 "sizeof (___param_values));\n\n",
2834 g_list_length (m->args));
2836 print_preconditions (m);
2839 "\n\t___param_values[0].g_type = 0;\n"
2840 "\tg_value_init (&___param_values[0], G_TYPE_FROM_INSTANCE (%s));\n"
2841 "\tg_value_set_instance (&___param_values[0], (gpointer) %s);\n\n",
2842 ((FuncArg *)m->args->data)->name,
2843 ((FuncArg *)m->args->data)->name);
2845 put_signal_args (m);
2847 if (strcmp (m->gtktypes->data, "NONE") != 0) {
2848 const char *defret = NULL;
2850 out_printf (out, "\tg_value_init (&___return_val, G_TYPE_%s);\n",
2851 (char *)m->gtktypes->data);
2853 if (m->defreturn != NULL)
2854 defret = m->defreturn;
2855 else if (m->onerror != NULL)
2856 defret = m->onerror;
2858 if (defret != NULL) {
2860 /* FIXME: This code is so fucking ugly it hurts */
2861 gboolean do_static =
2862 (strcmp ((char *)m->gtktypes->data, "STRING") == 0 ||
2863 strcmp ((char *)m->gtktypes->data, "BOXED") == 0);
2864 char *cast = g_strdup (get_cast (m->gtktypes->data, FALSE));
2866 cast = get_type (m->mtype, TRUE);
2868 if (strcmp (m->gtktypes->data, "UNICHAR") == 0)
2869 /* hack because glib is braindamaged */
2870 set_func = g_strdup ("g_value_set_uint");
2872 set_func = g_strdup_printf ("g_value_set%s_%s",
2873 do_static ? "_static" : "",
2874 (char *)m->gtktypes->data);
2875 gob_strdown (set_func);
2877 out_printf (out, "\t%s (&___return_val, (%s) (%s));\n",
2878 set_func, cast, defret);
2883 out_printf (out, "\n");
2886 s = g_strdup (m->id);
2889 out_printf(out, "\tg_signal_emitv (___param_values,\n"
2890 "\t\tobject_signals[%s_SIGNAL],\n"
2891 "\t\t0 /* detail */,\n"
2892 "\t\t&___return_val);\n", s);
2896 clear_signal_args (m);
2898 if (strcmp (m->gtktypes->data, "NONE") != 0) {
2899 char *cast = g_strdup (get_cast (m->gtktypes->data, FALSE));
2901 /* Hack because glib is very very braindead */
2903 (strcmp ((char *)m->gtktypes->data, "STRING") == 0 ||
2904 strcmp ((char *)m->gtktypes->data, "BOXED") == 0 ||
2905 strcmp ((char *)m->gtktypes->data, "OBJECT") == 0 ||
2906 strcmp ((char *)m->gtktypes->data, "PARAM") == 0);
2908 if (strcmp (m->gtktypes->data, "UNICHAR") == 0)
2909 /* hack because glib is braindamaged */
2910 getfunc = g_strdup ("g_value_get_uint");
2912 getfunc = g_strdup_printf ("g_value_%s_%s",
2913 do_dup ? "dup" : "get",
2914 (char *)m->gtktypes->data);
2915 gob_strdown (getfunc);
2918 cast = get_type (m->mtype, TRUE);
2923 print_type (out, m->mtype, TRUE);
2925 " ___ret = (%s) %s (&___return_val);\n"
2926 "\t\tg_value_unset (&___return_val);\n"
2927 "\t\treturn ___ret;\n"
2934 out_printf(out, "}\n");
2939 out_addline_infile(out, m->line_no);
2940 print_method(out, "static ", "\n___real_", "", " ", "", "\n",
2941 m, FALSE, FALSE, TRUE, TRUE, FALSE);
2942 print_method_body(m, FALSE, TRUE);
2943 /* the outfile line was added above */
2945 case VIRTUAL_METHOD:
2947 out_addline_infile(out, m->line_no);
2948 if(m->scope==PRIVATE_SCOPE)
2949 print_method(out, "static ", "\n", "", " ", "", "\n",
2950 m, FALSE, FALSE, TRUE, FALSE, FALSE);
2951 else /* PUBLIC, PROTECTED */
2952 print_method(out, "", "\n", "", " ", "", "\n",
2953 m, FALSE, FALSE, TRUE, FALSE, FALSE);
2954 out_addline_outfile(out);
2955 out_printf(out, "{\n"
2956 "\t%sClass *klass;\n", typebase);
2957 print_preconditions(m);
2958 out_printf(out, "\tklass = %s_GET_CLASS(%s);\n\n"
2959 "\tif(klass->%s)\n",
2960 macrobase, ((FuncArg *)m->args->data)->name,
2962 if(strcmp(m->mtype->name, "void") == 0 &&
2963 m->mtype->pointer == NULL) {
2965 out_printf(out, "\t\t(*klass->%s)(%s",
2967 ((FuncArg *)m->args->data)->name);
2968 for(li=m->args->next;li;li=g_list_next(li)) {
2969 FuncArg *fa = li->data;
2970 out_printf(out, ",%s", fa->name);
2972 out_printf(out, ");\n}\n");
2975 out_printf(out, "\t\treturn (*klass->%s)(%s",
2977 ((FuncArg *)m->args->data)->name);
2978 for(li=m->args->next;li;li=g_list_next(li)) {
2979 FuncArg *fa = li->data;
2980 out_printf(out, ",%s", fa->name);
2982 out_printf(out, ");\n"
2985 print_type(out, m->mtype, TRUE);
2987 out_printf(out, ")(%s);\n}\n", m->defreturn);
2989 out_printf(out, ")(%s);\n}\n", m->onerror);
2991 out_printf(out, ")(0);\n}\n");
2997 out_addline_infile(out, m->line_no);
2998 print_method(out, "static ", "\n___real_", "", " ", "", "\n",
2999 m, FALSE, FALSE, TRUE, TRUE, FALSE);
3000 print_method_body(m, FALSE, TRUE);
3001 /* the outfile line was added above */
3003 case OVERRIDE_METHOD:
3007 out_addline_infile(out, m->line_no);
3008 s = g_strdup_printf("\n___%x_", (guint)m->unique_id);
3009 print_method(out, "static ", s, "", " ", "", "\n",
3010 m, FALSE, FALSE, FALSE, TRUE, FALSE);
3012 out_addline_outfile(out);
3013 s = replace_sep(m->otype, '_');
3015 args = get_arg_names_for_macro(m);
3017 out_printf(out, "#define PARENT_HANDLER(%s) \\\n"
3018 "\t{ if(%s_CLASS(parent_class)->%s) \\\n"
3019 "\t\t(* %s_CLASS(parent_class)->%s)(%s); }\n",
3020 args, s, m->id, s, m->id, args);
3022 out_printf(out, "#define PARENT_HANDLER(%s) \\\n"
3023 "\t((%s_CLASS(parent_class)->%s)? \\\n"
3024 "\t\t(* %s_CLASS(parent_class)->%s)(%s): \\\n"
3026 args, s, m->id, s, m->id, args);
3027 out_printf(out, "(");
3028 print_type(out, m->mtype, TRUE);
3029 out_printf(out, ")%s))\n",
3030 m->onerror?m->onerror:"0");
3034 print_method_body(m, TRUE, TRUE);
3035 /* the outfile line was added above */
3036 out_printf(out, "#undef PARENT_HANDLER\n");
3046 char *outfile, *outfileh, *outfileph;
3049 outfile = g_strconcat (fullfilebase, ".c", NULL);
3051 outfile = g_strconcat (fullfilebase, ".cc", NULL);
3052 if (no_touch_headers)
3053 outfileh = g_strconcat (fullfilebase, ".h#gob#", NULL);
3055 outfileh = g_strconcat (fullfilebase, ".h", NULL);
3057 if ((privates > 0 || protecteds > 0 ||
3058 private_header == PRIVATE_HEADER_ALWAYS) &&
3059 private_header != PRIVATE_HEADER_NEVER) {
3060 char sep[2] = {0,0};
3063 outfileph = g_strconcat (fullfilebase, sep, "private.h", NULL);
3070 devnull = fopen ("/dev/null", "w");
3071 if (devnull == NULL)
3072 error_print (GOB_ERROR, 0, "Cannot open null device");
3075 if (outfileph != NULL)
3078 out = fopen (outfile, "w");
3080 error_printf (GOB_ERROR, 0,
3081 "Cannot open outfile: %s", outfile);
3083 outh = fopen (outfileh, "w");
3085 error_printf (GOB_ERROR, 0,
3086 "Cannot open outfile: %s", outfileh);
3088 if (outfileph != NULL) {
3089 outph = fopen (outfileph, "w");
3090 if (outph == NULL) {
3091 error_printf (GOB_ERROR, 0,
3092 "Cannot open outfile: %s",
3100 put_argument_nongnu_wrappers (Class *c)
3104 if (get_properties < 0 && set_properties < 0)
3107 for (li = c->nodes; li != NULL; li = li->next) {
3109 const char *name, *gtktype;
3115 if (n->type == ARGUMENT_NODE) {
3116 Argument *a = (Argument *)n;
3118 gtktype = a->gtktype;
3120 get = a->get != NULL;
3121 set = a->set != NULL;
3122 } else if (n->type == PROPERTY_NODE) {
3123 Property *p = (Property *)n;
3125 gtktype = p->gtktype;
3127 get = p->get != NULL;
3128 set = p->set != NULL;
3133 aname = g_strdup (name);
3137 cast = get_type (atype, TRUE);
3139 cast = g_strdup (get_cast (gtktype, TRUE));
3143 out_printf (outh, "#define %s_PROP_%s(arg) \t"
3144 "\"%s\",(%s)(arg)\n",
3145 macrobase, aname, name, cast);
3147 out_printf (outh, "#define %s_GET_PROP_%s(arg)\t"
3148 "\"%s\",(%s*)(arg)\n",
3149 macrobase, aname, name, cast);
3152 out_printf (outh, "#define %s_PROP_%s(arg) \t"
3154 macrobase, aname, name);
3156 out_printf (outh, "#define %s_GET_PROP_%s(arg)\t"
3158 macrobase, aname, name);
3166 put_argument_gnu_wrappers(Class *c)
3170 if(get_properties < 0 && set_properties < 0)
3173 for (li = c->nodes; li != NULL; li = li->next) {
3175 const char *name, *gtktype;
3181 if (n->type == ARGUMENT_NODE) {
3182 Argument *a = (Argument *)n;
3184 gtktype = a->gtktype;
3186 get = a->get != NULL;
3187 set = a->set != NULL;
3188 } else if (n->type == PROPERTY_NODE) {
3189 Property *p = (Property *)n;
3191 gtktype = p->gtktype;
3193 get = p->get != NULL;
3194 set = p->set != NULL;
3199 aname = g_strdup (name);
3203 cast = get_type (atype, TRUE);
3205 cast = g_strdup (get_cast (gtktype, TRUE));
3209 out_printf (outh, "#define %s_PROP_%s(arg) \t"
3210 "\"%s\", __extension__ ({%sz = (arg); z;})\n",
3211 macrobase, aname, name, cast);
3213 out_printf (outh, "#define %s_GET_PROP_%s(arg)\t"
3214 "\"%s\", __extension__ ({%s*z = (arg); z;})\n",
3215 macrobase, aname, name, cast);
3218 out_printf (outh, "#define %s_PROP_%s(arg) \t"
3220 macrobase, aname, name);
3222 out_printf (outh, "#define %s_GET_PROP_%s(arg)\t"
3224 macrobase, aname, name);
3232 print_ccode_block(CCode *cc)
3235 switch(cc->cctype) {
3237 /* HT code is printed exactly like normal header
3238 code but is printed before */
3241 out_printf(fp, "\n");
3244 /* AT code is printed exactly like normal 'all'
3245 code but is printed before */
3248 out_printf(outph, "\n");
3249 out_printf(outph, "%s\n", cc->cbuf);
3250 out_addline_infile(outph, cc->line_no);
3251 out_addline_outfile(outph);
3253 out_printf(outh, "\n");
3254 out_printf(outh, "%s\n", cc->cbuf);
3256 out_printf(fp, "\n");
3257 out_addline_infile(fp, cc->line_no);
3262 out_printf(fp, "\n");
3263 out_addline_infile(fp, cc->line_no);
3270 out_printf(fp, "\n");
3271 out_addline_infile(fp, cc->line_no);
3274 out_printf(fp, "%s\n", cc->cbuf);
3275 if(cc->cctype == C_CCODE ||
3276 cc->cctype == A_CCODE ||
3277 cc->cctype == AT_CCODE ||
3278 cc->cctype == PH_CCODE)
3279 out_addline_outfile(fp);
3283 print_class_block(Class *c)
3287 gboolean printed_private = FALSE;
3291 out_printf(outph ? outph : outh, "#include <gtk/gtk.h>\n");
3292 out_printf(outph ? outph : outh, "#include <glade/glade-xml.h>\n\n");
3296 out_printf(out, "/* utility types we may need */\n");
3297 if(special_array[SPECIAL_2POINTER])
3298 out_printf(out, "typedef struct { "
3299 "gpointer a; gpointer b; "
3300 "} ___twopointertype;\n");
3301 if(special_array[SPECIAL_3POINTER])
3302 out_printf(out, "typedef struct { "
3303 "gpointer a; gpointer b; "
3305 "} ___threepointertype;\n");
3306 if(special_array[SPECIAL_INT_POINTER])
3307 out_printf(out, "typedef struct { "
3308 "gint a; gpointer b; "
3309 "} ___intpointertype;\n");
3310 out_printf(out, "\n");
3313 out_printf(outh, "\n/*\n"
3314 " * Type checking and casting macros\n"
3316 out_printf(outh, "#define %s\t"
3317 "(%s_get_type())\n",
3318 macrotype, funcbase);
3319 out_printf(outh, "#define %s(obj)\t"
3320 "G_TYPE_CHECK_INSTANCE_CAST((obj), %s_get_type(), %s)\n",
3321 macrobase, funcbase, typebase);
3322 out_printf(outh, "#define %s_CONST(obj)\t"
3323 "G_TYPE_CHECK_INSTANCE_CAST((obj), %s_get_type(), %s const)\n",
3324 macrobase, funcbase, typebase);
3325 out_printf(outh, "#define %s_CLASS(klass)\t"
3326 "G_TYPE_CHECK_CLASS_CAST((klass), %s_get_type(), %sClass)\n",
3327 macrobase, funcbase, typebase);
3328 out_printf(outh, "#define %s(obj)\t"
3329 "G_TYPE_CHECK_INSTANCE_TYPE((obj), %s_get_type ())\n\n",
3332 "#define %s_GET_CLASS(obj)\t"
3333 "G_TYPE_INSTANCE_GET_CLASS((obj), %s_get_type(), %sClass)\n",
3334 macrobase, funcbase, typebase);
3336 if ( ! no_self_alias) {
3337 out_printf(out, "/* self casting macros */\n");
3338 out_printf(out, "#define SELF(x) %s(x)\n", macrobase);
3339 out_printf(out, "#define SELF_CONST(x) %s_CONST(x)\n", macrobase);
3340 out_printf(out, "#define IS_SELF(x) %s(x)\n", macrois);
3341 out_printf(out, "#define TYPE_SELF %s\n", macrotype);
3342 out_printf(out, "#define SELF_CLASS(x) %s_CLASS(x)\n\n",
3344 out_printf(out, "#define SELF_GET_CLASS(x) %s_GET_CLASS(x)\n\n",
3347 out_printf(out, "/* self typedefs */\n");
3348 out_printf(out, "typedef %s Self;\n", typebase);
3349 out_printf(out, "typedef %sClass SelfClass;\n\n", typebase);
3353 always_private_struct) {
3354 out_printf (outh, "\n/* Private structure type */\n");
3355 out_printf (outh, "typedef struct _%sPrivate %sPrivate;\n",
3356 typebase, typebase);
3358 out_printf (outh, "/* There are no privates, this "
3359 "structure is thus never defined */\n");
3362 out_printf (outh, "\n/*\n"
3363 " * Main object structure\n"
3365 s = replace_sep (c->otype, '_');
3367 out_printf (outh, "#ifndef __TYPEDEF_%s__\n"
3368 "#define __TYPEDEF_%s__\n", s, s);
3370 out_printf (outh, "typedef struct _%s %s;\n"
3371 "#endif\n", typebase, typebase);
3372 out_printf (outh, "struct _%s {\n\t%s __parent__;\n",
3373 typebase, ptypebase);
3374 for (li = c->nodes; li; li=li->next) {
3375 static gboolean printed_public = FALSE;
3377 Variable *v = (Variable *)n;
3378 if(n->type == VARIABLE_NODE &&
3379 v->scope == PUBLIC_SCOPE) {
3380 if( ! printed_public) {
3381 out_printf(outh, "\t/*< public >*/\n");
3382 printed_public = TRUE;
3384 put_variable((Variable *)n, outh);
3387 /* put protecteds always AFTER publics */
3388 for (li = c->nodes; li != NULL; li = li->next) {
3390 Variable *v = (Variable *)n;
3391 if (n->type == VARIABLE_NODE &&
3392 v->scope == PROTECTED_SCOPE) {
3393 if ( ! printed_private) {
3394 out_printf (outh, "\t/*< private >*/\n");
3395 printed_private = TRUE;
3397 put_variable ((Variable *)n, outh);
3401 always_private_struct) {
3402 if ( ! printed_private)
3403 out_printf (outh, "\t/*< private >*/\n");
3404 out_printf (outh, "\t%sPrivate *_priv;\n", typebase);
3406 out_printf (outh, "};\n");
3411 /* if we are to stick this into the private
3412 header, if not stick it directly into the
3419 out_printf (outfp, "struct _%sPrivate {\n",
3423 for(li=c->nodes; li; li=li->next) {
3425 Variable *v = (Variable *)n;
3426 if(n->type == VARIABLE_NODE &&
3427 v->scope == PRIVATE_SCOPE) {
3428 out_addline_infile(outfp, v->line_no);
3429 put_variable(v, outfp);
3432 out_addline_outfile(outfp);
3434 out_printf(outfp, "};\n");
3437 out_printf(outh, "\n/*\n"
3438 " * Class definition\n"
3440 out_printf(outh, "typedef struct _%sClass %sClass;\n",
3441 typebase, typebase);
3443 "struct _%sClass {\n\t%sClass __parent__;\n",
3444 typebase, ptypebase);
3445 for(li = c->nodes; li != NULL; li = li->next) {
3447 if(n->type == METHOD_NODE)
3448 put_vs_method((Method *)n);
3450 /* If BonoboX type class put down the epv */
3451 if (c->bonobo_object_class != NULL) {
3453 "\t/* Bonobo object epv */\n"
3454 "\tPOA_%s__epv _epv;\n",
3455 c->bonobo_object_class);
3457 /* put class scope variables */
3458 for (li = c->nodes; li != NULL; li = li->next) {
3460 Variable *v = (Variable *)n;
3461 if (n->type == VARIABLE_NODE &&
3462 v->scope == CLASS_SCOPE)
3463 put_variable ((Variable *)n, outh);
3465 out_printf (outh, "};\n\n");
3467 out_printf (out, "/* here are local prototypes */\n");
3468 if (set_properties > 0) {
3469 out_printf (out, "static void ___object_set_property "
3470 "(GObject *object, guint property_id, "
3471 "const GValue *value, GParamSpec *pspec);\n");
3473 if (get_properties > 0) {
3474 out_printf (out, "static void ___object_get_property "
3475 "(GObject *object, guint property_id, "
3476 "GValue *value, GParamSpec *pspec);\n");
3479 out_printf (outh, "\n/*\n"
3480 " * Public methods\n"
3483 if ( ! overrode_get_type) {
3484 out_printf (outh, "GType\t%s_get_type\t(void);\n", funcbase);
3487 for(li = c->nodes; li != NULL; li = li->next) {
3489 if(n->type == METHOD_NODE) {
3490 put_pub_method((Method *)n);
3491 put_prot_method((Method *)n);
3492 put_priv_method_prot((Method *)n);
3496 /* this idea is less and less apealing to me */
3498 out_printf (outh, "\n/*\n"
3499 " * Signal connection wrapper macros\n"
3502 out_printf(outh, "#if defined(__GNUC__) && !defined(__STRICT_ANSI__)\n");
3503 put_signal_macros (c, TRUE);
3504 out_printf(outh, "#else /* __GNUC__ && !__STRICT_ANSI__ */\n");
3505 put_signal_macros (c, FALSE);
3506 out_printf(outh, "#endif /* __GNUC__ && !__STRICT_ANSI__ */\n");
3508 put_signal_macros (c, FALSE);
3509 out_printf(outh, "\n");
3512 out_printf (out, "\n/*\n"
3513 " * Signal connection wrapper macro shortcuts\n"
3515 put_local_signal_macros (c);
3516 out_printf(outh, "\n");
3519 /* argument wrapping macros */
3520 if(get_properties > 0 || set_properties > 0) {
3521 out_printf(outh, "\n/*\n"
3522 " * Argument wrapping macros\n"
3525 out_printf(outh, "#if defined(__GNUC__) && !defined(__STRICT_ANSI__)\n");
3526 put_argument_gnu_wrappers(c);
3527 out_printf(outh, "#else /* __GNUC__ && !__STRICT_ANSI__ */\n");
3528 put_argument_nongnu_wrappers(c);
3529 out_printf(outh, "#endif /* __GNUC__ && !__STRICT_ANSI__ */\n\n");
3531 put_argument_nongnu_wrappers(c);
3536 for(li = c->nodes; li != NULL; li = li->next) {
3538 if(n->type == METHOD_NODE)
3539 add_signal_prots((Method *)n);
3545 if(any_method_to_alias(c)) {
3546 out_printf (out, "/* Short form macros */\n");
3547 make_method_aliases (c);
3550 add_interface_inits (c);
3552 if ( ! overrode_get_type) {
3553 if (c->bonobo_object_class != NULL)
3554 add_bonobo_object_get_type ();
3559 out_printf (out, "/* a macro for creating a new object of our type */\n");
3561 "#define GET_NEW ((%s *)g_object_new(%s_get_type(), NULL))\n\n",
3562 typebase, funcbase);
3564 out_printf (out, "/* a function for creating a new object of our type */\n");
3565 out_printf (out, "#include <stdarg.h>\n");
3567 "static %s * GET_NEW_VARG (const char *first, ...)%s;\n"
3568 "static %s *\nGET_NEW_VARG (const char *first, ...)\n"
3569 "{\n\t%s *ret;\n\tva_list ap;\n"
3570 "\tva_start (ap, first);\n"
3571 "\tret = (%s *)g_object_new_valist (%s_get_type (), "
3574 "\treturn ret;\n}\n\n",
3576 no_gnu ? "" : " G_GNUC_UNUSED",
3577 typebase, typebase, typebase, funcbase);
3581 out_printf (out, "/* a function to connect glade callback */\n");
3582 out_printf (out,"static void\n"
3583 "___glade_xml_connect_foreach(const gchar *handler_name,\n"
3584 "GObject *object,\n"
3585 "const gchar *signal_name,\n"
3586 "const gchar *signal_data,\n"
3587 "GObject *connect_object,\n"
3589 "gpointer user_data)\n"
3591 "\tstatic GModule * allsymbols = NULL;\n"
3593 "\tif (!allsymbols) allsymbols = g_module_open(NULL, 0);\n"
3594 "\tif (allsymbols) {\n"
3595 "\t\tgchar * func_name = g_strdup_printf(\"%s_%%s\", handler_name);\n"
3596 "\t\tGCallback func;\n"
3598 "\t\tif (!g_module_symbol(allsymbols, func_name, (gpointer)&func)){\n"
3599 "\t\t\tif (!g_module_symbol(allsymbols, handler_name, (gpointer)&func)) {\n"
3600 "\t\t\t\tg_warning(\"could not find signal handler '%%s'.\", func_name);\n"
3601 "\t\t\t\tg_free(func_name);\n"
3606 "\t\t\tg_signal_connect_data(object, signal_name, func, user_data, NULL, G_CONNECT_AFTER | G_CONNECT_SWAPPED);\n"
3608 "\t\t\tg_signal_connect_data(object, signal_name, func, user_data, NULL, G_CONNECT_SWAPPED);\n"
3609 "\t\tg_free(func_name);\n"
3624 if(set_properties > 0) {
3625 add_getset_arg(c, TRUE);
3628 if(get_properties > 0) {
3629 add_getset_arg(c, FALSE);
3632 for(li = c->nodes; li != NULL; li = li->next) {
3634 if(n->type == METHOD_NODE)
3635 put_method((Method *)n);
3638 add_bad_hack_to_avoid_unused_warnings(c);
3642 print_useful_macros(void)
3644 int major = 0, minor = 0, pl = 0;
3647 sscanf (VERSION, "%d.%d.%d", &major, &minor, &pl);
3648 out_printf (out, "#define GOB_VERSION_MAJOR %d\n", major);
3649 out_printf (out, "#define GOB_VERSION_MINOR %d\n", minor);
3650 out_printf (out, "#define GOB_VERSION_PATCHLEVEL %d\n\n", pl);
3652 /* Useful priv macro thingie */
3653 /* FIXME: this should be done the same way that priv is, as a var,
3655 out_printf (out, "#define selfp (self->_priv)\n\n");
3659 print_more_useful_macros (void)
3662 out_printf (out, "#define ___GOB_LIKELY(expr) (expr)\n");
3663 out_printf (out, "#define ___GOB_UNLIKELY(expr) (expr)\n");
3665 out_printf (out, "#ifdef G_LIKELY\n");
3666 out_printf (out, "#define ___GOB_LIKELY(expr) G_LIKELY(expr)\n");
3667 out_printf (out, "#define ___GOB_UNLIKELY(expr) G_UNLIKELY(expr)\n");
3668 out_printf (out, "#else /* ! G_LIKELY */\n");
3669 out_printf (out, "#define ___GOB_LIKELY(expr) (expr)\n");
3670 out_printf (out, "#define ___GOB_UNLIKELY(expr) (expr)\n");
3671 out_printf (out, "#endif /* G_LIKELY */\n");
3676 print_file_comments(void)
3680 out_printf(outh, "/* Generated by GOB (v%s)"
3681 " (do not edit directly) */\n\n", VERSION);
3683 out_printf(outph, "/* Generated by GOB (v%s)"
3684 " (do not edit directly) */\n\n", VERSION);
3685 out_printf(out, "/* Generated by GOB (v%s) on %s"
3686 " (do not edit directly) */\n\n",
3687 VERSION, ctime(&curtime));
3689 out_printf(out, "/* End world hunger, donate to the World Food Programme, http://www.wfp.org */\n\n");
3693 print_includes(void)
3695 gboolean found_header;
3698 /* We may need string.h for memset */
3699 if ( ! g_list_find_custom(include_files, "string.h", (GCompareFunc)strcmp)) {
3700 out_printf(out, "#include <string.h> /* memset() */\n\n");
3703 p = g_strconcat(filebase, ".h", NULL);
3704 found_header = TRUE;
3705 if( ! g_list_find_custom(include_files, p, (GCompareFunc)strcmp)) {
3706 out_printf(out, "#include \"%s.h\"\n\n", filebase);
3707 found_header = FALSE;
3711 /* if we are creating a private header see if it was included */
3713 p = g_strconcat(filebase, "-private.h", NULL);
3714 if( ! g_list_find_custom(include_files, p,
3715 (GCompareFunc)strcmp)) {
3716 out_printf(out, "#include \"%s-private.h\"\n\n",
3719 error_printf(GOB_WARN, 0,
3720 "Implicit private header include "
3722 "\tsource file, while public "
3723 "header is at a custom location, "
3725 "\texplicitly include "
3726 "the private header below the "
3734 print_header_prefixes(void)
3738 p = replace_sep(((Class *)class)->otype, '_');
3740 out_printf(outh, "#ifndef __%s_H__\n#define __%s_H__\n\n", p, p);
3742 out_printf(outph, "#ifndef __%s_PRIVATE_H__\n"
3743 "#define __%s_PRIVATE_H__\n\n"
3744 "#include \"%s.h\"\n\n", p, p, filebase);
3747 if( ! no_extern_c) {
3748 out_printf(outh, "#ifdef __cplusplus\n"
3750 "#endif /* __cplusplus */\n\n");
3752 out_printf(outph, "#ifdef __cplusplus\n"
3754 "#endif /* __cplusplus */\n\n");
3759 print_header_postfixes(void)
3762 out_printf(outh, "\n#ifdef __cplusplus\n"
3764 "#endif /* __cplusplus */\n");
3765 out_printf(outh, "\n#endif\n");
3768 out_printf(outph, "\n#ifdef __cplusplus\n"
3770 "#endif /* __cplusplus */\n");
3771 out_printf(outph, "\n#endif\n");
3780 /* print the AT_CCODE blocks */
3781 for(li = nodes; li != NULL; li = li->next) {
3782 Node *node = li->data;
3783 if(node->type == CCODE_NODE) {
3784 CCode *cc = (CCode *)node;
3785 if(cc->cctype == AT_CCODE)
3786 print_ccode_block((CCode *)node);
3792 print_header_top(void)
3796 /* mandatory includes */
3797 out_printf (outh, "#include <glib.h>\n");
3798 out_printf (outh, "#include <glib-object.h>\n");
3800 /* print the HT_CCODE blocks */
3801 for (li = nodes; li != NULL; li = li->next) {
3802 Node *node = li->data;
3803 if (node->type == CCODE_NODE) {
3804 CCode *cc = (CCode *)node;
3805 if (cc->cctype == HT_CCODE)
3806 print_ccode_block ((CCode *)node);
3812 print_enum (EnumDef *enode)
3819 funcprefix = replace_sep (enode->etype, '_');
3820 gob_strdown (funcprefix);
3821 out_printf (out, "static const GEnumValue _%s_values[] = {\n",
3823 type = remove_sep (enode->etype);
3825 out_printf (outh, "\ntypedef enum {\n");
3827 for (li = enode->values; li != NULL; li = li->next) {
3828 EnumValue *value = li->data;
3830 char *sname = gob_strdown (g_strdup (value->name));
3832 while ((p = strchr (sname, '_')) != NULL)
3835 out_printf (outh, "\t%s_%s", enode->prefix, value->name);
3836 if (value->value != NULL)
3837 out_printf (outh, " = %s", value->value);
3838 if (li->next != NULL)
3839 out_printf (outh, ",\n");
3841 out_printf (outh, "\n");
3843 out_printf (out, "\t{ %s_%s, (char *)\"%s_%s\", (char *)\"%s\" },\n",
3844 enode->prefix, value->name,
3845 enode->prefix, value->name,
3851 out_printf (out, "\t{ 0, NULL, NULL }\n};\n\n");
3853 out_printf (outh, "} %s;\n", type);
3855 str = make_pre_macro (enode->etype, "TYPE");
3856 out_printf (outh, "#define %s ", str);
3859 out_printf (outh, "%s_get_type()\n", funcprefix);
3860 out_printf (outh, "GType %s_get_type (void);\n\n", funcprefix);
3863 "GType\n%s_get_type (void)\n"
3865 "\tstatic GType type = 0;\n"
3866 "\tif ___GOB_UNLIKELY(type == 0)\n"
3867 "\t\ttype = g_enum_register_static (\"%s\", _%s_values);\n"
3870 funcprefix, type, funcprefix);
3872 g_free (funcprefix);
3877 print_flags (Flags *fnode)
3885 funcprefix = replace_sep (fnode->ftype, '_');
3886 gob_strdown (funcprefix);
3887 out_printf (out, "static const GFlagsValue _%s_values[] = {\n",
3889 type = remove_sep (fnode->ftype);
3891 out_printf (outh, "\ntypedef enum {\n");
3893 for (i = 0, li = fnode->values; li != NULL; i++, li = li->next) {
3894 const char *name = li->data;
3896 char *sname = gob_strdown (g_strdup (name));
3898 while ((p = strchr (sname, '_')) != NULL)
3901 out_printf (outh, "\t%s_%s = 1<<%d",
3902 fnode->prefix, name, i);
3903 if (li->next != NULL)
3904 out_printf (outh, ",\n");
3906 out_printf (outh, "\n");
3908 out_printf (out, "\t{ %s_%s, (char *)\"%s_%s\", (char *)\"%s\" },\n",
3909 fnode->prefix, name,
3910 fnode->prefix, name,
3916 out_printf (out, "\t{ 0, NULL, NULL }\n};\n\n");
3918 out_printf (outh, "} %s;\n", type);
3920 str = make_pre_macro (fnode->ftype, "TYPE");
3921 out_printf (outh, "#define %s ", str);
3924 out_printf (outh, "%s_get_type()\n", funcprefix);
3925 out_printf (outh, "GType %s_get_type (void);\n\n", funcprefix);
3928 "GType\n%s_get_type (void)\n"
3930 "\tstatic GType type = 0;\n"
3931 "\tif ___GOB_UNLIKELY(type == 0)\n"
3932 "\t\ttype = g_flags_register_static (\"%s\", _%s_values);\n"
3935 funcprefix, type, funcprefix);
3937 g_free (funcprefix);
3942 print_error (Error *enode)
3949 funcprefix = replace_sep (enode->etype, '_');
3950 gob_strdown (funcprefix);
3951 out_printf (out, "static const GEnumValue _%s_values[] = {\n",
3953 type = remove_sep (enode->etype);
3955 out_printf (outh, "\ntypedef enum {\n");
3957 for (li = enode->values; li != NULL; li = li->next) {
3958 const char *name = li->data;
3960 char *sname = gob_strdown (g_strdup (name));
3962 while ((p = strchr (sname, '_')) != NULL)
3965 out_printf (outh, "\t%s_%s", enode->prefix, name);
3966 if (li->next != NULL)
3967 out_printf (outh, ",\n");
3969 out_printf (outh, "\n");
3971 out_printf (out, "\t{ %s_%s, (char *)\"%s_%s\", (char *)\"%s\" },\n",
3972 enode->prefix, name,
3973 enode->prefix, name,
3979 out_printf (out, "\t{ 0, NULL, NULL }\n};\n\n");
3981 out_printf (outh, "} %s;\n", type);
3983 str = make_pre_macro (enode->etype, "TYPE");
3984 out_printf (outh, "#define %s ", str);
3987 out_printf (outh, "%s_get_type ()\n", funcprefix);
3988 out_printf (outh, "GType %s_get_type (void);\n\n", funcprefix);
3991 "GType\n%s_get_type (void)\n"
3993 "\tstatic GType type = 0;\n"
3994 "\tif ___GOB_UNLIKELY(type == 0)\n"
3995 "\t\ttype = g_enum_register_static (\"%s\", _%s_values);\n"
3998 funcprefix, type, funcprefix);
4000 out_printf (outh, "#define %s %s_quark ()\n", enode->prefix, funcprefix);
4001 out_printf (outh, "GQuark %s_quark (void);\n\n", funcprefix);
4003 str = replace_sep (enode->etype, '-');
4007 "GQuark\n%s_quark (void)\n"
4009 "\tstatic GQuark q = 0;\n"
4011 "\t\tq = g_quark_from_static_string (\"%s\");\n"
4018 g_free (funcprefix);
4023 generate_outfiles(void)
4027 print_file_comments();
4033 print_header_prefixes();
4035 print_useful_macros();
4039 print_more_useful_macros ();
4041 for (li = nodes; li != NULL; li = li->next) {
4042 Node *node = li->data;
4043 if (node->type == CCODE_NODE) {
4044 CCode *cc = (CCode *)node;
4045 if (cc->cctype != HT_CCODE &&
4046 cc->cctype != AT_CCODE)
4047 print_ccode_block ((CCode *)node);
4048 } else if (node->type == CLASS_NODE) {
4049 print_class_block ((Class *)node);
4050 } else if (node->type == ENUMDEF_NODE) {
4051 print_enum ((EnumDef *)node);
4052 } else if (node->type == FLAGS_NODE) {
4053 print_flags ((Flags *)node);
4054 } else if (node->type == ERROR_NODE) {
4055 print_error ((Error *)node);
4057 g_assert_not_reached();
4061 print_header_postfixes();
4067 fprintf(stderr, "Gob version %s\n\n", VERSION);
4068 fprintf(stderr, "gob [options] file.gob\n\n");
4069 fprintf(stderr, "Options:\n"
4070 "\t--help,-h,-? Display this help\n"
4071 "\t--version Display version\n"
4072 "\t--exit-on-warn,-w Exit with an error on warnings\n"
4073 "\t--no-exit-on-warn Don't exit on warnings [default]\n"
4074 "\t--for-cpp Create C++ files\n"
4075 "\t--no-extern-c Never print extern \"C\" into the "
4077 "\t--no-gnu Never use GNU extentions\n"
4078 "\t--no-touch-headers Don't touch headers unless they "
4080 "\t--always-private-header Always create a private header "
4082 "\t even if it would be empty\n"
4083 "\t--ondemand-private-header Create private header only when "
4086 "\t--no-private-header Don't create a private header, "
4088 "\t structure and protected "
4089 "prototypes inside c file\n"
4090 "\t--always-private-struct Always create a private pointer "
4092 "\t the object structure\n"
4093 "\t--m4 Preprocess source with m4. "
4094 "Following args will\n"
4095 "\t be passed to m4\n"
4096 "\t--m4-dir Print directory that will be "
4099 "\t--no-write,-n Don't write output files, just "
4101 "\t--no-lines Don't print '#line' to output\n"
4102 "\t--no-self-alias Don't create self type and macro "
4104 "\t--no-kill-underscores Ignored for compatibility\n"
4105 "\t-o,--output-dir The directory where output "
4106 "should be placed\n"
4107 "\t--file-sep[=c] replace default \'-\' file "
4108 "name separator\n");
4112 parse_options(int argc, char *argv[])
4115 int got_file = FALSE;
4116 int no_opts = FALSE;
4117 int m4_opts = FALSE; /* if we are just passing on args to m4 */
4121 for(i = 1 ; i < argc; i++) {
4123 char *new_commandline;
4124 g_assert(m4_commandline!=NULL);
4126 /* check whether this one looks like the filename */
4127 if((!strcmp(argv[i],"-") || argv[i][0] != '-')
4129 const gchar *m4_flags=use_m4_clean?"":M4_FLAGS;
4133 /* insert flags before the filename */
4134 new_commandline=g_strconcat(m4_commandline,
4142 /* just an ordinary option */
4144 new_commandline=g_strconcat(m4_commandline,
4149 /* free old commandline */
4150 g_free(m4_commandline);
4151 m4_commandline=new_commandline;
4153 } else if(no_opts ||
4154 argv[i][0] != '-') {
4157 fprintf(stderr, "Specify only one file!\n");
4163 } else if(strcmp(argv[i], "--help")==0) {
4166 } else if(strcmp(argv[i], "--version")==0) {
4167 fprintf(stderr, "Gob version %s\n", VERSION);
4169 } else if(strcmp(argv[i], "--exit-on-warn")==0) {
4170 exit_on_warn = TRUE;
4171 } else if(strcmp(argv[i], "--no-exit-on-warn")==0) {
4172 exit_on_warn = FALSE;
4173 } else if(strcmp(argv[i], "--for-cpp")==0) {
4175 } else if(strcmp(argv[i], "--no-touch-headers")==0) {
4176 no_touch_headers = TRUE;
4177 } else if(strcmp(argv[i], "--ondemand-private-header")==0) {
4178 private_header = PRIVATE_HEADER_ONDEMAND;
4179 } else if(strcmp(argv[i], "--always-private-header")==0) {
4180 private_header = PRIVATE_HEADER_ALWAYS;
4181 } else if(strcmp(argv[i], "--no-private-header")==0) {
4182 private_header = PRIVATE_HEADER_NEVER;
4183 } else if(strcmp(argv[i], "--no-gnu")==0) {
4185 } else if(strcmp(argv[i], "--no-extern-c")==0) {
4187 } else if(strcmp(argv[i], "--no-write")==0) {
4189 } else if(strcmp(argv[i], "--no-lines")==0) {
4191 } else if(strcmp(argv[i], "--no-self-alias")==0) {
4192 no_self_alias = TRUE;
4193 } else if(strcmp(argv[i], "--no-kill-underscores")==0) {
4195 } else if(strcmp(argv[i], "--always-private-struct")==0) {
4196 always_private_struct = TRUE;
4197 } else if(strcmp(argv[i], "--m4-dir")==0) {
4198 printf("%s\n",M4_INCLUDE_DIR);
4200 } else if(strcmp(argv[i], "--m4")==0) {
4204 m4_commandline=g_strdup(M4_COMMANDLINE);
4205 } else if(strcmp(argv[i], "--m4-clean")==0) {
4209 m4_commandline=g_strdup(M4_COMMANDLINE);
4210 } else if (strcmp (argv[i], "-o") == 0 ||
4211 strcmp (argv[i], "--output-dir") == 0) {
4213 output_dir = g_strdup (argv[i+1]);
4218 } else if (strncmp (argv[i], "-o=", strlen ("-o=")) == 0 ||
4221 strlen ("--output-dir=")) == 0) {
4222 char *p = strchr (argv[i], '=');
4223 g_assert (p != NULL);
4224 output_dir = g_strdup (p+1);
4225 } else if (strncmp (argv[i], "--file-sep=",
4226 strlen ("--file-sep=")) == 0) {
4227 char *p = strchr (argv[i], '=');
4228 g_assert (p != NULL);
4230 } else if (strncmp (argv[i], "--file-sep",
4231 strlen ("--file-sep")) == 0) {
4233 file_sep = (argv[i+1])[0];
4238 } else if(strcmp(argv[i], "--")==0) {
4239 /*further arguments are files*/
4241 } else if(strncmp(argv[i], "--", 2)==0) {
4242 /*unknown long option*/
4243 fprintf(stderr, "Unknown option '%s'!\n", argv[i]);
4247 /*by now we know we have a string starting with
4248 - which is a short option string*/
4250 for(p = argv[i] + 1; *p; p++) {
4264 "Unknown option '%c'!\n", *p);
4273 /* if we are using m4, and got no filename, append m4 flags now */
4274 if(!got_file && use_m4 && !use_m4_clean) {
4275 char *new_commandline;
4276 new_commandline=g_strconcat(m4_commandline,
4280 g_free(m4_commandline);
4281 m4_commandline=new_commandline;
4286 /* this is a somewhat ugly hack, but it appears to work */
4288 compare_and_move_header(void)
4290 char *hfnew = g_strconcat(fullfilebase, ".h#gob#", NULL);
4291 char *hf = g_strconcat(fullfilebase, ".h", NULL);
4293 if(stat(hf, &s) == 0) {
4295 s = g_strdup_printf("cmp '%s' '%s' > /dev/null", hf, hfnew);
4296 if(system(s) == 0) {
4297 if(unlink(hfnew) != 0)
4298 error_printf(GOB_ERROR, 0,
4299 "Can't remove new header file");
4307 error_printf(GOB_ERROR, 0,
4308 "Can't remove old header file");
4310 if(rename(hfnew, hf) != 0)
4311 error_printf(GOB_ERROR, 0,
4312 "Can't rename new header file");
4318 main(int argc, char *argv[])
4320 parse_options(argc, argv);
4323 yyin = popen(m4_commandline, "r");
4325 fprintf(stderr, "Error: can't open pipe from '%s'\n",
4329 } else if(filename) {
4330 yyin = fopen(filename, "r");
4332 fprintf(stderr, "Error: can't open file '%s'\n",
4341 /* This is where parsing is done */
4344 error_print (GOB_ERROR, 0, "Parsing errors, quitting");
4346 /* close input file */
4347 if(use_m4) pclose(yyin);
4352 error_print (GOB_ERROR, 0, "no class defined");
4355 exit_on_error = FALSE;
4357 signals = count_signals ((Class *)class);
4358 set_properties = count_set_properties ((Class *)class) +
4359 count_set_arguments ((Class *)class);
4360 get_properties = count_get_properties ((Class *)class) +
4361 count_get_arguments ((Class *)class);
4362 overrides = count_overrides ((Class *)class);
4363 privates = count_privates ((Class *)class);
4364 protecteds = count_protecteds ((Class *)class);
4365 unreftors = count_unreftors ((Class *)class);
4366 destructors = count_destructors ((Class *)class);
4367 initializers = count_initializers ((Class *)class);
4368 glade_widgets = count_glade_widgets ((Class *)class);
4369 overrode_get_type = find_get_type ((Class *)class);
4372 make_inits ((Class *)class);
4374 need_dispose = TRUE;
4375 find_dispose ((Class *)class);
4377 if (destructors > 0 ||
4379 need_finalize = TRUE;
4380 find_finalize ((Class *)class);
4382 check_bad_symbols ((Class *)class);
4383 check_duplicate_symbols ((Class *)class);
4384 check_duplicate_overrides ((Class *)class);
4385 check_duplicate_signals_args ((Class *)class);
4386 check_public_new ((Class *)class);
4387 check_vararg ((Class *)class);
4388 check_firstarg ((Class *)class);
4389 check_nonvoidempty ((Class *)class);
4390 check_signal_args ((Class *)class);
4391 check_property_types ((Class *)class);
4392 check_argument_types ((Class *)class);
4393 check_func_arg_checks ((Class *)class);
4394 check_for_class_destructors ((Class *)class);
4396 exit_on_error = TRUE;
4401 any_special = setup_special_array ((Class *)class, special_array);
4405 generate_outfiles ();
4416 if (no_touch_headers &&
4418 compare_and_move_header ();