2 * Copyright (C) 1999-2000 the Free Software Foundation.
3 * Copyright (C) 2000 Eazel, Inc.
4 * Copyright (C) 2001-2009 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,
31 #include "treefuncs.h"
35 /* FIXME: add gettext support */
40 static GList *class_nodes = NULL;
43 static GList *enum_vals = NULL;
44 static GList *flag_vals = NULL;
45 static GList *error_vals = NULL;
47 static gboolean abstract = FALSE;
48 static char *chunk_size = NULL;
49 static char *bonobo_object_class = NULL;
50 static int glade_xml = FALSE;
51 static GList *interfaces = NULL;
52 static GList *typestack = NULL;
53 static GList *funcargs = NULL;
54 static GList *checks = NULL;
55 static int has_self = FALSE;
56 static int vararg = FALSE;
57 static Method *last_added_method = NULL;
59 /* destructor and initializer for variables */
60 static gboolean destructor_unref = FALSE;
61 static char *destructor = NULL;
62 static int destructor_line = 0;
63 static gboolean destructor_simple = TRUE;
64 static char *initializer = NULL;
65 static int initializer_line = 0;
66 static int glade_widget = FALSE;
68 static char *funcattrs = NULL;
69 static char *onerror = NULL;
70 static char *defreturn = NULL;
72 static GList *gtktypes = NULL;
74 static Property *property = NULL;
76 /* this can be a global as we will only do one function at a time
78 static int the_scope = NO_SCOPE;
83 extern int ccode_line;
85 extern gboolean for_cpp;
95 if(strcmp(yytext,"\n")==0) {
96 out=g_strconcat("Error: ",str," before newline",NULL);
97 } else if(yytext[0]=='\0') {
98 out=g_strconcat("Error: ", str, " at end of input", NULL);
100 char *tmp = g_strdup(yytext);
101 while((p=strchr(tmp, '\n')))
104 out=g_strconcat("Error: ", str, " before '", tmp, "'", NULL);
108 fprintf(stderr, "%s:%d: %s\n", filename, line_no, out);
117 Type *type = typestack->data;
118 typestack = g_list_remove(typestack,typestack->data);
123 push_variable (char *name, int scope, int line_no, char *postfix)
126 Type *type = pop_type ();
128 type->postfix = postfix;
130 var = node_new (VARIABLE_NODE,
133 "glade_widget", glade_widget,
136 "destructor_unref", destructor_unref,
137 "destructor:steal", destructor,
138 "destructor_line", destructor_line,
139 "destructor_simple", destructor_simple,
140 "initializer:steal", initializer,
141 "initializer_line", initializer_line,
142 "initializer_simple", TRUE,
144 class_nodes = g_list_append(class_nodes, var);
145 glade_widget = FALSE;
149 push_function (int scope, int method, char *oid, char *id,
150 GString *cbuf, int line_no, int ccode_line,
151 gboolean vararg, GList *flags)
157 g_assert(scope != CLASS_SCOPE);
159 if(method == INIT_METHOD || method == CLASS_INIT_METHOD) {
160 type = (Type *)node_new (TYPE_NODE,
167 /* a complicated and ugly test to figure out if we have
168 the wrong number of types for a signal */
169 if((method == SIGNAL_FIRST_METHOD ||
170 method == SIGNAL_LAST_METHOD) &&
171 g_list_length(gtktypes) != g_list_length(funcargs) &&
172 !(g_list_length(funcargs) == 1 &&
173 g_list_length(gtktypes) == 2 &&
174 strcmp(gtktypes->next->data, "NONE")==0)) {
175 error_print(GOB_WARN, line_no,
176 _("The number of GTK arguments and "
177 "function arguments for a signal "
178 "don't seem to match"));
180 if(g_list_length(gtktypes) > 2) {
182 for(li = gtktypes->next; li; li = li->next) {
183 if(strcmp(li->data, "NONE")==0) {
184 error_print(GOB_ERROR, line_no,
185 _("NONE can only appear in an "
186 "argument list by itself"));
192 c_cbuf = p = cbuf->str;
193 while(p && *p && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
200 node = node_new (METHOD_NODE,
205 "gtktypes:steal", gtktypes,
206 "flags:steal", flags,
208 "args:steal", funcargs,
209 "funcattrs:steal", funcattrs,
210 "onerror:steal", onerror,
211 "defreturn:steal", defreturn,
212 "cbuf:steal", c_cbuf,
214 "ccode_line", ccode_line,
216 "unique_id", method_unique_id++,
219 last_added_method = (Method *)node;
223 /*only free segment if we haven't passed it
233 class_nodes = g_list_append(class_nodes, node);
237 free_all_global_state(void)
249 g_list_foreach(gtktypes, (GFunc)g_free, NULL);
250 g_list_free(gtktypes);
253 node_list_free (funcargs);
258 push_funcarg(char *name, char *postfix)
261 Type *type = pop_type();
263 type->postfix = postfix;
265 node = node_new (FUNCARG_NODE,
268 "checks:steal", checks,
272 funcargs = g_list_append(funcargs, node);
276 push_init_arg(char *name, int is_class)
283 tn = g_strconcat(((Class *)class)->otype,":Class",NULL);
285 tn = g_strdup(((Class *)class)->otype);
287 type = node_new (TYPE_NODE,
291 node = node_new (FUNCARG_NODE,
292 "atype:steal", (Type *)type,
295 funcargs = g_list_prepend(funcargs, node);
299 push_self(char *id, gboolean constant)
304 type = node_new (TYPE_NODE,
305 "name", ((Class *)class)->otype,
306 "pointer", constant ? "const *" : "*",
308 ch = g_list_append (ch, node_new (CHECK_NODE,
309 "chtype", NULL_CHECK,
311 ch = g_list_append (ch, node_new (CHECK_NODE,
312 "chtype", TYPE_CHECK,
314 node = node_new (FUNCARG_NODE,
315 "atype:steal", (Type *)type,
319 funcargs = g_list_prepend(funcargs, node);
323 find_var_or_die(const char *id, int line)
327 for(li = class_nodes; li != NULL; li = li->next) {
329 Node *node = li->data;
330 if(node->type != VARIABLE_NODE)
333 if(strcmp(var->id, id)==0)
337 error_printf(GOB_ERROR, line, _("Variable %s not defined here"), id);
339 g_assert_not_reached();
344 set_attr_value(char *type, char *val)
346 if(strcmp(type, "attr")==0) {
352 } else if(strcmp(type, "onerror")==0) {
358 } else if(strcmp(type, "defreturn")==0) {
369 export_accessors (const char *var_name,
381 the_type = (Type *)node_copy ((Node *)type);
383 the_type = get_tree_type (gtktype, TRUE);
385 if (the_type == NULL) {
386 error_print (GOB_ERROR, line_no,
387 _("Cannot determine type of property or argument"));
392 char *get_id = g_strdup_printf ("get_%s", var_name);
393 GString *get_cbuf = g_string_new (NULL);
394 Node *node1 = node_new (TYPE_NODE,
395 "name", the_type->name,
396 "pointer", the_type->pointer,
397 "postfix", the_type->postfix,
399 Node *node3 = node_new (TYPE_NODE,
400 "name", class->class.otype,
404 g_string_sprintf (get_cbuf,
406 "g_object_get (G_OBJECT (self), \"%s\", "
410 the_type->pointer ? the_type->pointer : "",
413 typestack = g_list_prepend (typestack, node1);
414 typestack = g_list_prepend (typestack, node3);
416 push_funcarg ("self", FALSE);
418 push_function (PUBLIC_SCOPE, REGULAR_METHOD, NULL,
419 get_id, get_cbuf, get_lineno,
420 lineno, FALSE, NULL);
424 char *set_id = g_strdup_printf ("set_%s", var_name);
425 GString *set_cbuf = g_string_new (NULL);
426 Node *node1 = node_new (TYPE_NODE,
427 "name", the_type->name,
428 "pointer", the_type->pointer,
429 "postfix", the_type->postfix,
431 Node *node2 = node_new (TYPE_NODE,
434 Node *node3 = node_new (TYPE_NODE,
435 "name", class->class.otype,
439 g_string_sprintf (set_cbuf,
440 "\tg_object_set (G_OBJECT (self), "
441 "\"%s\", val, NULL);\n",
444 typestack = g_list_prepend (typestack, node2);
445 typestack = g_list_prepend (typestack, node1);
446 typestack = g_list_prepend (typestack, node3);
448 push_funcarg ("self", FALSE);
449 push_funcarg ("val", FALSE);
451 typestack = g_list_prepend (typestack, node2);
452 push_function (PUBLIC_SCOPE, REGULAR_METHOD, NULL,
453 set_id, set_cbuf, set_lineno,
454 lineno, FALSE, NULL);
457 node_free ((Node *)the_type);
461 get_prop_enum_flag_cast (Property *prop)
464 if (prop->extra_gtktype == NULL ||
465 /* HACK! just in case someone made this
466 * work with 2.0.0 by using the TYPE
468 ((strstr (prop->extra_gtktype, "_TYPE_") != NULL ||
469 strstr (prop->extra_gtktype, "TYPE_") == prop->extra_gtktype) &&
470 strchr (prop->extra_gtktype, ':') == NULL)) {
471 if (prop->ptype != NULL)
472 return get_type (prop->ptype, TRUE);
474 return g_strdup ("");
476 tmp = remove_sep (prop->extra_gtktype);
477 ret = g_strdup_printf ("(%s) ", tmp);
483 add_construct_glade (char * file, char * root, char * domain)
488 type = (Type *)node_new (TYPE_NODE,
492 initializer = g_strdup_printf("\t{\n"
493 "\tGtkWidget * root;\n"
494 "\t%%1$s->_priv->_glade_xml = glade_xml_new(%s, %s, %s);\n"
495 "\troot = glade_xml_get_widget(%%1$s->_priv->_glade_xml, %s);\n"
496 "\tgtk_widget_show(root);\n"
497 "\tgtk_container_add(GTK_CONTAINER(%%1$s), root);\n"
498 "\tglade_xml_signal_autoconnect_full(%%1$s->_priv->_glade_xml, (GladeXMLConnectFunc)___glade_xml_connect_foreach, (gpointer)%%1$s);\n"
499 "}\n", file, root, domain ? domain : "NULL", root);
501 var = node_new (VARIABLE_NODE,
502 "scope", PRIVATE_SCOPE,
504 "glade_widget", FALSE,
505 "id:steal", "_glade_xml",
506 "destructor_unref", FALSE,
507 "destructor", "g_object_unref",
508 "destructor_simple", TRUE,
509 "initializer", initializer,
510 "initializer_simple", FALSE,
512 class_nodes = g_list_prepend(class_nodes, var);
516 property_link_and_export (Node *node)
518 Property *prop = (Property *)node;
522 char *get = NULL, *set = NULL;
525 if (prop->set != NULL ||
527 error_print (GOB_ERROR, prop->line_no,
528 _("Property linking requested, but "
529 "getters and setters exist"));
532 var = find_var_or_die (prop->name, prop->line_no);
533 if(var->scope == PRIVATE_SCOPE) {
534 root = "self->_priv";
535 } else if (var->scope == CLASS_SCOPE) {
536 root = "SELF_GET_CLASS(self)";
538 error_print (GOB_ERROR, prop->line_no,
539 _("Self aliases needed when autolinking to a classwide member"));
544 if (strcmp (prop->gtktype, "STRING") == 0) {
545 set = g_strdup_printf("{ char *old = %s->%s; "
546 "%s->%s = g_value_dup_string (VAL); g_free (old); }",
549 get = g_strdup_printf("g_value_set_string (VAL, %s->%s);",
551 } else if (strcmp (prop->gtktype, "OBJECT") == 0) {
553 if (prop->extra_gtktype != NULL) {
554 cast = remove_sep (prop->extra_gtktype);
556 cast = g_strdup ("void");
558 set = g_strdup_printf("{ GObject *___old = (GObject *)%s->%s; "
559 "%s->%s = (%s *)g_value_dup_object (VAL); "
560 "if (___old != NULL) { "
561 "g_object_unref (G_OBJECT (___old)); "
567 get = g_strdup_printf ("g_value_set_object (VAL, "
568 "(gpointer)%s->%s);",
571 } else if (strcmp (prop->gtktype, "BOXED") == 0) {
572 char *type = make_me_type (prop->extra_gtktype,
574 if (prop->extra_gtktype == NULL) {
575 error_print (GOB_ERROR, prop->line_no,
576 _("Property linking requested for BOXED, but "
577 "boxed_type not set"));
579 set = g_strdup_printf("{ gpointer ___old = (gpointer)%s->%s; "
580 "gpointer ___new = (gpointer)g_value_get_boxed (VAL); "
581 "if (___new != ___old) { "
582 "if (___old != NULL) g_boxed_free (%s, ___old); "
583 "if (___new != NULL) %s->%s = g_boxed_copy (%s, ___new); "
584 "else %s->%s = NULL;"
592 get = g_strdup_printf("g_value_set_boxed (VAL, %s->%s);",
598 const char *getcast = "";
599 const char *setcast = "";
600 char *to_free = NULL;
601 set_func = g_strdup_printf ("g_value_set_%s", prop->gtktype);
602 g_strdown (set_func);
603 get_func = g_strdup_printf ("g_value_get_%s", prop->gtktype);
604 g_strdown (get_func);
607 if (strcmp (prop->gtktype, "FLAGS") == 0) {
608 setcast = "(guint) ";
610 get_prop_enum_flag_cast (prop);
611 } else if (strcmp (prop->gtktype, "ENUM") == 0) {
614 get_prop_enum_flag_cast (prop);
615 } else if (strcmp (prop->gtktype, "POINTER") == 0) {
616 setcast = "(gpointer) ";
617 getcast = g_strdup_printf ("(%s%s) ",
619 prop->ptype->pointer ? prop->ptype->pointer : "");
623 set = g_strdup_printf("%s->%s = %s%s (VAL);",
627 get = g_strdup_printf("%s (VAL, %s%s->%s);",
639 "get_line", prop->line_no,
641 "set_line", prop->line_no,
646 export_accessors (prop->name,
647 prop->get != NULL, prop->get_line,
648 prop->set != NULL, prop->set_line,
659 if (strcmp (s, "BOOL") == 0) {
660 error_print (GOB_WARN, line_no,
661 _("BOOL type is deprecated, please use BOOLEAN"));
663 return g_strdup ("BOOLEAN");
670 ensure_property (void)
672 if (property == NULL)
673 property = (Property *)node_new (PROPERTY_NODE, NULL);
687 %token CONST VOID STRUCT UNION ENUM THREEDOTS
688 %token SIGNED UNSIGNED LONG SHORT INT FLOAT DOUBLE CHAR
690 %token <id> TOKEN NUMBER TYPETOKEN ARRAY_DIM SINGLE_CHAR
691 %token <cbuf> CCODE ADCODE HTCODE PHCODE HCODE ACODE ATCODE STRING
692 %token <line> PUBLIC PRIVATE PROTECTED CLASSWIDE PROPERTY ARGUMENT
693 %token <line> VIRTUAL SIGNAL OVERRIDE
694 %token <line> NICK BLURB MAXIMUM MINIMUM DEFAULT_VALUE ERROR FLAGS TYPE
695 %token <line> FLAGS_TYPE ENUM_TYPE PARAM_TYPE BOXED_TYPE OBJECT_TYPE
699 prog: ccodes class ccodes { ; }
706 Node *node = node_new (CCODE_NODE,
708 "cbuf:steal", ($<cbuf>1)->str,
709 "line_no", ccode_line,
711 nodes = g_list_append(nodes,node);
712 g_string_free($<cbuf>1,FALSE);
715 Node *node = node_new (CCODE_NODE,
717 "cbuf:steal", ($<cbuf>1)->str,
718 "line_no", ccode_line,
720 nodes = g_list_append(nodes,node);
721 g_string_free($<cbuf>1,FALSE);
724 Node *node = node_new (CCODE_NODE,
726 "cbuf:steal", ($<cbuf>1)->str,
727 "line_no", ccode_line,
729 nodes = g_list_append(nodes,node);
730 g_string_free($<cbuf>1,FALSE);
733 Node *node = node_new (CCODE_NODE,
735 "cbuf:steal", ($<cbuf>1)->str,
736 "line_no", ccode_line,
738 nodes = g_list_append(nodes,node);
739 g_string_free($<cbuf>1,FALSE);
742 Node *node = node_new (CCODE_NODE,
744 "cbuf:steal", ($<cbuf>1)->str,
745 "line_no", ccode_line,
747 nodes = g_list_append(nodes,node);
748 g_string_free($<cbuf>1,FALSE);
751 Node *node = node_new (CCODE_NODE,
753 "cbuf:steal", ($<cbuf>1)->str,
754 "line_no", ccode_line,
756 nodes = g_list_append(nodes,node);
757 g_string_free($<cbuf>1,FALSE);
760 Node *node = node_new (CCODE_NODE,
762 "cbuf:steal", ($<cbuf>1)->str,
763 "line_no", ccode_line,
765 nodes = g_list_append(nodes,node);
766 g_string_free($<cbuf>1,FALSE);
770 ccodes: ccodes ccode { ; }
771 | ccodes enumcode { ; }
772 | ccodes flagcode { ; }
773 | ccodes errorcode { ; }
780 class: classdec '{' classcode '}' {
781 ((Class *)class)->nodes = class_nodes;
783 nodes = g_list_append(nodes,class);
786 ((Class *)class)->nodes = NULL;
788 nodes = g_list_append(nodes,class);
792 classdec: CLASS TYPETOKEN FROM TYPETOKEN classflags {
793 class = node_new (CLASS_NODE,
794 "otype:steal", $<id>2,
795 "ptype:steal", $<id>4,
796 "bonobo_object_class:steal", bonobo_object_class,
797 "glade_xml", glade_xml,
798 "interfaces:steal", interfaces,
799 "chunk_size:steal", chunk_size,
800 "abstract", abstract,
802 bonobo_object_class = NULL;
810 | '(' TOKEN ')' classflags {
811 if(strcmp($<id>2,"abstract") == 0) {
814 yyerror(_("parse error"));
818 | '(' TOKEN TOKEN ')' classflags {
819 if(strcmp($<id>2,"chunks") == 0) {
821 chunk_size = g_strdup($<id>3);
822 } else if(strcmp($<id>2,"BonoboObject") == 0) {
823 g_free (bonobo_object_class);
824 bonobo_object_class = g_strdup($<id>3);
826 yyerror(_("parse error"));
830 | '(' TOKEN TYPETOKEN ')' classflags {
831 if (strcmp ($<id>2, "interface") == 0) {
832 interfaces = g_list_append (interfaces,
835 yyerror(_("parse error"));
839 | '(' TOKEN NUMBER ')' classflags {
840 if(strcmp($<id>2,"chunks") == 0) {
842 if(atoi($<id>3) != 0)
843 chunk_size = g_strdup($<id>3);
847 yyerror(_("parse error"));
851 | '(' TOKEN STRING STRING ')' classflags {
852 if (strcmp ($<id>2, "GladeXML") == 0) {
854 add_construct_glade($<id>3, $<id>4, NULL);
856 yyerror(_("parse error"));
860 | '(' TOKEN STRING STRING STRING ')' classflags {
861 if (strcmp ($<id>2, "GladeXML") == 0) {
863 add_construct_glade($<id>3, $<id>4, $<id>5);
865 yyerror(_("parse error"));
869 | '(' TOKEN TOKEN STRING ')' classflags {
870 if (strcmp ($<id>2, "GladeXML") == 0) {
872 add_construct_glade($<id>3, $<id>4, NULL);
874 yyerror(_("parse error"));
878 | '(' TOKEN TOKEN STRING STRING ')' classflags {
879 if (strcmp ($<id>2, "GladeXML") == 0) {
881 add_construct_glade($<id>3, $<id>4, $<id>5);
883 yyerror(_("parse error"));
889 classcode: classcode thing { ; }
895 if (strcmp ($<id>1, "BonoboObject") != 0) {
897 yyerror (_("parse error"));
901 last_added_method->bonobo_object_func = TRUE;
903 | TOKEN TYPETOKEN method {
904 if (strcmp ($<id>1, "interface") != 0) {
907 yyerror (_("parse error"));
911 node_set ((Node *)last_added_method,
912 "interface:steal", $<id>2,
921 scope: PUBLIC { the_scope = PUBLIC_SCOPE; }
922 | PRIVATE { the_scope = PRIVATE_SCOPE; }
923 | PROTECTED { the_scope = PROTECTED_SCOPE; }
924 | CLASSWIDE { the_scope = CLASS_SCOPE; }
927 destructor: TOKEN TOKEN {
928 if (strcmp ($<id>1, "destroywith") == 0) {
930 destructor_unref = FALSE;
932 destructor_line = line_no;
933 destructor_simple = TRUE;
934 } else if (strcmp ($<id>1, "unrefwith") == 0) {
936 destructor_unref = TRUE;
938 destructor_line = line_no;
939 destructor_simple = TRUE;
943 yyerror (_("parse error"));
948 if (strcmp ($<id>1, "destroy") == 0) {
950 destructor_unref = FALSE;
951 destructor = ($<cbuf>3)->str;
952 g_string_free($<cbuf>3, FALSE);
953 destructor_line = ccode_line;
954 destructor_simple = FALSE;
955 } else if (strcmp ($<id>1, "unref") == 0) {
957 destructor_unref = TRUE;
958 destructor = ($<cbuf>3)->str;
959 g_string_free ($<cbuf>3, FALSE);
960 destructor_line = ccode_line;
961 destructor_simple = FALSE;
964 g_string_free ($<cbuf>3, TRUE);
965 yyerror (_("parse error"));
971 initializer: '=' numtok {
972 initializer = $<id>2;
973 initializer_line = ccode_line;
976 initializer = ($<cbuf>3)->str;
977 initializer_line = ccode_line;
978 g_string_free($<cbuf>3, FALSE);
983 varoptions: destructor initializer { ; }
984 | initializer destructor { ; }
985 | initializer { destructor = NULL; }
986 | destructor { initializer = NULL; }
988 if (strcmp ($<id>1, "GladeXML") == 0) {
991 yyerror(_("parse error"));
1001 variable: scope type TOKEN varoptions ';' {
1002 push_variable($<id>3, the_scope,$<line>1, NULL);
1004 | scope type TOKEN ARRAY_DIM varoptions ';' {
1005 push_variable($<id>3, the_scope, $<line>1, $<id>4);
1009 argument: ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE TOKEN '{' CCODE ';' {
1011 if(strcmp($<id>6,"get")==0 &&
1012 strcmp($<id>9,"set")==0) {
1013 Type *type = pop_type();
1016 node = node_new (ARGUMENT_NODE,
1017 "gtktype:steal", $<id>3,
1018 "atype:steal", type,
1019 "flags:steal", $<list>2,
1020 "name:steal", $<id>4,
1021 "get:steal", ($<cbuf>8)->str,
1022 "get_line", $<line>7,
1023 "set:steal", ($<cbuf>11)->str,
1024 "set_line", $<line>10,
1025 "line_no", $<line>1,
1028 class_nodes = g_list_append(class_nodes,node);
1030 g_string_free ($<cbuf>8, FALSE);
1031 g_string_free ($<cbuf>11, FALSE);
1033 } else if(strcmp($<id>6,"set")==0 &&
1034 strcmp($<id>9,"get")==0) {
1035 Type *type = pop_type();
1038 node = node_new (ARGUMENT_NODE,
1039 "gtktype:steal", $<id>3,
1040 "atype:steal", type,
1041 "flags:steal", $<list>2,
1042 "name:steal", $<id>4,
1043 "get:steal", ($<cbuf>11)->str,
1044 "get_line", $<line>10,
1045 "set:steal", ($<cbuf>8)->str,
1046 "set_line", $<line>7,
1047 "line_no", $<line>1,
1049 g_string_free ($<cbuf>11, FALSE);
1050 g_string_free ($<cbuf>8, FALSE);
1051 class_nodes = g_list_append(class_nodes,node);
1057 g_list_foreach ($<list>2, (GFunc)g_free, NULL);
1058 g_list_free ($<list>2);
1059 g_string_free ($<cbuf>11, TRUE);
1060 g_string_free ($<cbuf>8, TRUE);
1061 yyerror (_("parse error"));
1065 if ($<id>5 != NULL) {
1066 Argument *arg = (Argument *)node;
1067 export_accessors (arg->name,
1068 arg->get != NULL, arg->get_line,
1069 arg->set != NULL, arg->set_line,
1077 | ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE ';' {
1079 if(strcmp($<id>6, "get") == 0) {
1080 Type *type = pop_type();
1082 node = node_new (ARGUMENT_NODE,
1083 "gtktype:steal", $<id>3,
1084 "atype:steal", type,
1085 "flags:steal", $<list>2,
1086 "name:steal", $<id>4,
1087 "get:steal", ($<cbuf>8)->str,
1088 "get_line", $<line>7,
1089 "line_no", $<line>1,
1092 g_string_free ($<cbuf>8, FALSE);
1093 class_nodes = g_list_append(class_nodes, node);
1094 } else if(strcmp($<id>6, "set") == 0) {
1095 Type *type = pop_type();
1097 node = node_new (ARGUMENT_NODE,
1098 "gtktype:steal", $<id>3,
1099 "atype:steal", type,
1100 "flags:steal", $<list>2,
1101 "name:steal", $<id>4,
1102 "set:steal", ($<cbuf>8)->str,
1103 "set_line", $<line>7,
1104 "line_no", $<line>1,
1107 g_string_free ($<cbuf>8, FALSE);
1108 class_nodes = g_list_append (class_nodes, node);
1113 g_list_foreach ($<list>2, (GFunc)g_free, NULL);
1114 g_list_free ($<list>2);
1115 g_string_free ($<cbuf>8, TRUE);
1116 yyerror(_("parse error"));
1120 if ($<id>5 != NULL) {
1121 Argument *arg = (Argument *)node;
1122 export_accessors (arg->name,
1123 arg->get != NULL, arg->get_line,
1124 arg->set != NULL, arg->set_line,
1131 | ARGUMENT flags argtype TOKEN export TOKEN {
1133 char *get, *set = NULL;
1138 if(strcmp($<id>6, "link")!=0 &&
1139 strcmp($<id>6, "stringlink")!=0 &&
1140 strcmp($<id>6, "objectlink")!=0) {
1144 g_list_foreach($<list>2,(GFunc)g_free,NULL);
1145 g_list_free($<list>2);
1146 yyerror(_("parse error"));
1152 var = find_var_or_die($<id>4, $<line>1);
1153 if(var->scope == PRIVATE_SCOPE) {
1154 root = "self->_priv";
1155 } else if(var->scope == CLASS_SCOPE) {
1156 root = "SELF_GET_CLASS(self)";
1158 error_print(GOB_ERROR, $<line>1,
1159 _("Self aliases needed when autolinking to a classwide member"));
1164 if(strcmp($<id>6, "link")==0) {
1165 set = g_strdup_printf("%s->%s = ARG;",
1167 } else if(strcmp($<id>6, "stringlink")==0) {
1168 set = g_strdup_printf("g_free (%s->%s); "
1169 "%s->%s = g_strdup (ARG);",
1172 } else if(strcmp($<id>6, "objectlink")==0) {
1173 set = g_strdup_printf(
1175 "g_object_ref (G_OBJECT (ARG)); "
1176 "if (%s->%s != NULL) "
1177 "g_object_unref (G_OBJECT (%s->%s)); "
1183 g_assert_not_reached();
1186 get = g_strdup_printf("ARG = %s->%s;", root, $<id>4);
1191 type = (Type *)node_copy ((Node *)var->vtype);
1193 node = node_new (ARGUMENT_NODE,
1194 "gtktype:steal", $<id>3,
1195 "atype:steal", type,
1196 "flags:steal", $<list>2,
1197 "name:steal", $<id>4,
1199 "get_line", $<line>1,
1201 "set_line", $<line>1,
1202 "line_no", $<line>1,
1205 if ($<id>5 != NULL) {
1206 Argument *arg = (Argument *)node;
1207 export_accessors (arg->name,
1208 arg->get != NULL, arg->get_line,
1209 arg->set != NULL, arg->set_line,
1216 class_nodes = g_list_append (class_nodes, node);
1220 export: '(' TOKEN ')' {
1221 if (strcmp ($<id>2, "export")!=0) {
1223 yyerror (_("parse error"));
1233 property: PROPERTY TOKEN TOKEN param_spec TOKEN '{' CCODE TOKEN '{' CCODE ';' {
1235 node_set ((Node *)property,
1236 "line_no", $<line>1,
1237 "gtktype:steal", debool ($<id>2),
1238 "name:steal", $<id>3,
1240 if (strcmp ($<id>5, "get") == 0 &&
1241 strcmp ($<id>8, "set") == 0) {
1242 node_set ((Node *)property,
1243 "get:steal", ($<cbuf>7)->str,
1244 "get_line", $<line>6,
1245 "set:steal", ($<cbuf>10)->str,
1246 "set_line", $<line>9,
1248 g_string_free ($<cbuf>7, FALSE);
1249 g_string_free ($<cbuf>10, FALSE);
1252 } else if (strcmp ($<id>5, "set") == 0 &&
1253 strcmp ($<id>8, "get") == 0) {
1254 node_set ((Node *)property,
1255 "get:steal", ($<cbuf>10)->str,
1256 "get_line", $<line>9,
1257 "set:steal", ($<cbuf>7)->str,
1258 "set_line", $<line>6,
1260 g_string_free ($<cbuf>7, FALSE);
1261 g_string_free ($<cbuf>10, FALSE);
1265 g_string_free ($<cbuf>7, TRUE);
1266 g_string_free ($<cbuf>10, TRUE);
1269 node_free ((Node *)property);
1271 yyerror (_("parse error"));
1274 property_link_and_export ((Node *)property);
1275 if (property != NULL) {
1276 class_nodes = g_list_append (class_nodes,
1281 | PROPERTY TOKEN TOKEN param_spec TOKEN '{' CCODE ';' {
1283 node_set ((Node *)property,
1284 "line_no", $<line>1,
1285 "gtktype:steal", debool ($<id>2),
1286 "name:steal", $<id>3,
1288 if (strcmp ($<id>5, "get") == 0) {
1289 node_set ((Node *)property,
1290 "get:steal", ($<cbuf>7)->str,
1291 "get_line", $<line>6,
1293 g_string_free ($<cbuf>7, FALSE);
1295 } else if (strcmp ($<id>5, "set") == 0) {
1296 node_set ((Node *)property,
1297 "set:steal", ($<cbuf>7)->str,
1298 "set_line", $<line>6,
1300 g_string_free ($<cbuf>7, FALSE);
1303 g_string_free ($<cbuf>7, TRUE);
1305 node_free ((Node *)property);
1307 yyerror (_("parse error"));
1310 property_link_and_export ((Node *)property);
1311 if (property != NULL) {
1312 class_nodes = g_list_append (class_nodes,
1317 | PROPERTY TOKEN TOKEN param_spec ';' {
1319 node_set ((Node *)property,
1320 "line_no", $<line>1,
1321 "gtktype:steal", debool ($<id>2),
1322 "name:steal", $<id>3,
1324 property_link_and_export ((Node *)property);
1325 if (property != NULL) {
1326 class_nodes = g_list_append (class_nodes,
1333 param_spec: '(' param_spec_list ')' { ; }
1337 param_spec_list: param_spec_list ',' param_spec_value { ; }
1338 | param_spec_value { ; }
1341 string: STRING { $<id>$ = $<id>1; }
1342 | TOKEN '(' STRING ')' {
1343 if (strcmp ($<id>1, "_") != 0) {
1345 yyerror(_("parse error"));
1349 $<id>$ = g_strconcat ("_(", $<id>3, ")", NULL);
1354 anyval: numtok { $<id>$ = $<id>1; }
1355 | string { $<id>$ = $<id>1; }
1358 param_spec_value: NICK '=' string {
1360 node_set ((Node *)property,
1361 "nick:steal", $<id>3,
1364 | BLURB '=' string {
1366 node_set ((Node *)property,
1367 "blurb:steal", $<id>3,
1370 | MAXIMUM '=' numtok {
1372 node_set ((Node *)property,
1373 "maximum:steal", $<id>3,
1376 | MINIMUM '=' numtok {
1378 node_set ((Node *)property,
1379 "minimum:steal", $<id>3,
1382 | DEFAULT_VALUE '=' anyval {
1384 node_set ((Node *)property,
1385 "default_value:steal", $<id>3,
1388 | FLAGS '=' flaglist {
1390 node_set ((Node *)property,
1391 "flags:steal", $<list>3,
1395 Type *type = pop_type ();
1397 node_set ((Node *)property,
1398 "ptype:steal", type,
1401 | FLAGS_TYPE '=' TYPETOKEN {
1403 node_set ((Node *)property,
1404 "extra_gtktype:steal", $<id>3,
1407 | FLAGS_TYPE '=' TOKEN {
1409 node_set ((Node *)property,
1410 "extra_gtktype:steal", $<id>3,
1413 | ENUM_TYPE '=' TYPETOKEN {
1415 node_set ((Node *)property,
1416 "extra_gtktype:steal", $<id>3,
1419 | ENUM_TYPE '=' TOKEN {
1421 node_set ((Node *)property,
1422 "extra_gtktype:steal", $<id>3,
1425 | PARAM_TYPE '=' TYPETOKEN {
1427 node_set ((Node *)property,
1428 "extra_gtktype:steal", $<id>3,
1431 | PARAM_TYPE '=' TOKEN {
1433 node_set ((Node *)property,
1434 "extra_gtktype:steal", $<id>3,
1437 | BOXED_TYPE '=' TYPETOKEN {
1439 node_set ((Node *)property,
1440 "extra_gtktype:steal", $<id>3,
1443 | BOXED_TYPE '=' TOKEN {
1445 node_set ((Node *)property,
1446 "extra_gtktype:steal", $<id>3,
1449 | OBJECT_TYPE '=' TYPETOKEN {
1451 node_set ((Node *)property,
1452 "extra_gtktype:steal", $<id>3,
1455 | OBJECT_TYPE '=' TOKEN {
1457 node_set ((Node *)property,
1458 "extra_gtktype:steal", $<id>3,
1463 if (strcmp ($<id>1, "override") == 0) {
1465 node_set ((Node *)property,
1468 } else if (strcmp ($<id>1, "link") == 0) {
1470 node_set ((Node *)property,
1473 } else if (strcmp ($<id>1, "export") == 0) {
1475 node_set ((Node *)property,
1480 yyerror(_("parse error"));
1486 argtype: TOKEN '(' TOKEN type ')' {
1487 if(strcmp($<id>3,"type")!=0) {
1490 yyerror(_("parse error"));
1493 $<id>$ = debool ($<id>1);
1496 $<id>$ = debool ($<id>1);
1497 typestack = g_list_prepend(typestack,NULL);
1501 flags: '(' flaglist ')' { $<list>$ = $<list>2; }
1502 | { $<list>$ = NULL; }
1505 flaglist: TOKEN '|' flaglist {
1506 $<list>$ = g_list_append($<list>3,$<id>1);
1509 $<list>$ = g_list_append(NULL,$<id>1);
1514 type: specifier_list pointer {
1515 Node *node = node_new (TYPE_NODE,
1516 "name:steal", $<id>1,
1517 "pointer:steal", $<id>2,
1519 typestack = g_list_prepend(typestack,node);
1522 Node *node = node_new (TYPE_NODE,
1523 "name:steal", $<id>1,
1525 typestack = g_list_prepend(typestack,node);
1529 /* The special cases are neccessary to avoid conflicts */
1530 specifier_list: spec_list {
1537 $<id>$ = g_strconcat("const ", $<id>2, NULL);
1541 $<id>$ = g_strconcat($<id>1, " const", NULL);
1544 | strunionenum TOKEN {
1545 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1548 | CONST strunionenum TOKEN {
1549 $<id>$ = g_strconcat("const ", $<id>2, " ",
1553 | strunionenum TOKEN CONST {
1554 $<id>$ = g_strconcat($<id>1, " ",
1555 $<id>2, " const", NULL);
1560 /* The special const cases take care of conflicts ! */
1561 spec_list: specifier spec_list {
1562 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1565 | TYPETOKEN spec_list {
1566 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1571 $<id>$ = g_strconcat("const ", $<id>2, NULL);
1578 $<id>$ = g_strconcat($<id>1, " const", NULL);
1582 $<id>$ = g_strdup($<id>1);
1585 $<id>$ = g_strconcat($<id>1, " const", NULL);
1589 specifier: VOID { $<id>$ = "void"; }
1590 | CHAR { $<id>$ = "char"; }
1591 | SHORT { $<id>$ = "short"; }
1592 | INT { $<id>$ = "int"; }
1593 | LONG { $<id>$ = "long"; }
1594 | FLOAT { $<id>$ = "float"; }
1595 | DOUBLE { $<id>$ = "double"; }
1596 | SIGNED { $<id>$ = "signed"; }
1597 | UNSIGNED { $<id>$ = "unsigned"; }
1600 strunionenum: STRUCT { $<id>$ = "struct"; }
1601 | UNION { $<id>$ = "union"; }
1602 | ENUM { $<id>$ = "enum"; }
1605 pointer: '*' { $<id>$ = g_strdup("*"); }
1606 | '*' CONST { $<id>$ = g_strdup("* const"); }
1608 $<id>$ = g_strconcat("*", $<id>2, NULL);
1611 | '*' CONST pointer {
1612 $<id>$ = g_strconcat("* const", $<id>3, NULL);
1617 /* this never sets the_scope */
1618 simplesigtype: TOKEN sigtype {
1619 if(strcmp($<id>1, "first")==0)
1620 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1621 else if(strcmp($<id>1, "last")==0)
1622 $<sigtype>$ = SIGNAL_LAST_METHOD;
1624 yyerror(_("signal must be 'first' or 'last'"));
1631 $<sigtype>$ = SIGNAL_LAST_METHOD;
1635 /* this always sets the_scope */
1636 fullsigtype: scope TOKEN sigtype {
1637 if(strcmp($<id>2,"first")==0)
1638 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1639 else if(strcmp($<id>2,"last")==0)
1640 $<sigtype>$ = SIGNAL_LAST_METHOD;
1642 yyerror(_("signal must be 'first' or 'last'"));
1648 | TOKEN scope sigtype {
1649 if(strcmp($<id>1,"first")==0)
1650 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1651 else if(strcmp($<id>1,"last")==0)
1652 $<sigtype>$ = SIGNAL_LAST_METHOD;
1654 yyerror(_("signal must be 'first' or 'last'"));
1661 $<sigtype>$ = SIGNAL_LAST_METHOD;
1664 /* the_scope was default thus public */
1665 the_scope = PUBLIC_SCOPE;
1669 sigtype: TOKEN '(' tokenlist ')' {
1670 gtktypes = g_list_prepend(gtktypes, debool ($<id>1));
1674 tokenlist: tokenlist ',' TOKEN {
1675 gtktypes = g_list_append(gtktypes, debool ($<id>3));
1678 gtktypes = g_list_append(gtktypes, debool ($<id>1));
1682 codenocode: '{' CCODE { $<cbuf>$ = $<cbuf>2; }
1683 | ';' { $<cbuf>$ = NULL; }
1686 /*here CCODE will include the ending '}' */
1687 method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenocode {
1689 yyerror(_("signal without 'self' as "
1690 "first parameter"));
1691 free_all_global_state();
1694 if(the_scope == CLASS_SCOPE) {
1695 yyerror(_("a method cannot be of class scope"));
1696 free_all_global_state();
1699 if (funcattrs != NULL) {
1700 char *error = g_strdup_printf
1701 (_("function attribute macros ('%s' in this case) may not be used with signal methods"),
1706 push_function(the_scope, $<sigtype>3,NULL,
1707 $<id>5, $<cbuf>10,$<line>1,
1708 ccode_line, vararg, $<list>2);
1710 | scope SIGNAL flags simplesigtype type TOKEN '(' funcargs ')' methodmods codenocode {
1712 yyerror(_("signal without 'self' as "
1713 "first parameter"));
1714 free_all_global_state();
1717 if(the_scope == CLASS_SCOPE) {
1718 yyerror(_("a method cannot be of class scope"));
1719 free_all_global_state();
1722 if (funcattrs != NULL) {
1723 char *error = g_strdup_printf
1724 (_("function attribute macros ('%s' in this case) may not be used with signal methods"),
1729 push_function(the_scope, $<sigtype>4, NULL,
1730 $<id>6, $<cbuf>11, $<line>2,
1731 ccode_line, vararg, $<list>3);
1733 | VIRTUAL scope type TOKEN '(' funcargs ')' methodmods codenocode {
1735 yyerror(_("virtual method without 'self' as "
1736 "first parameter"));
1737 free_all_global_state();
1740 if(the_scope == CLASS_SCOPE) {
1741 yyerror(_("a method cannot be of class scope"));
1742 free_all_global_state();
1745 if (funcattrs != NULL) {
1746 char *error = g_strdup_printf
1747 (_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
1752 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
1754 ccode_line, vararg, NULL);
1756 | scope VIRTUAL type TOKEN '(' funcargs ')' methodmods codenocode {
1758 yyerror(_("virtual method without 'self' as "
1759 "first parameter"));
1760 free_all_global_state();
1763 if(the_scope == CLASS_SCOPE) {
1764 yyerror(_("a method cannot be of class scope"));
1765 free_all_global_state();
1768 if (funcattrs != NULL) {
1769 char *error = g_strdup_printf
1770 (_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
1775 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
1777 ccode_line, vararg, NULL);
1779 | VIRTUAL type TOKEN '(' funcargs ')' methodmods codenocode {
1781 yyerror(_("virtual method without 'szelf' as "
1782 "first parameter"));
1783 free_all_global_state();
1786 if (funcattrs != NULL) {
1787 char *error = g_strdup_printf
1788 (_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
1793 push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL,
1794 $<id>3, $<cbuf>8, $<line>1,
1795 ccode_line, vararg, NULL);
1797 | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' methodmods codenocode {
1798 if (funcattrs != NULL) {
1799 char *error = g_strdup_printf
1800 (_("function attribute macros ('%s' in this case) may not be used with override methods"),
1805 push_function(NO_SCOPE, OVERRIDE_METHOD, $<id>3,
1807 $<line>1, ccode_line,
1810 | scope type TOKEN '(' funcargs ')' methodmods codenocode {
1811 if(the_scope == CLASS_SCOPE) {
1812 yyerror(_("a method cannot be of class scope"));
1813 free_all_global_state();
1816 push_function(the_scope, REGULAR_METHOD, NULL, $<id>3,
1817 $<cbuf>8, $<line>1, ccode_line,
1820 | TOKEN '(' TOKEN ')' codenocode {
1821 if(strcmp($<id>1, "init")==0) {
1822 push_init_arg($<id>3,FALSE);
1823 push_function(NO_SCOPE, INIT_METHOD, NULL,
1824 $<id>1, $<cbuf>5, $<line>2,
1825 ccode_line, FALSE, NULL);
1826 } else if(strcmp($<id>1, "class_init")==0) {
1827 push_init_arg($<id>3,TRUE);
1828 push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL,
1829 $<id>1, $<cbuf>5, $<line>2,
1830 ccode_line, FALSE, NULL);
1831 } else if(strcmp($<id>1, "constructor")==0) {
1832 push_init_arg($<id>3, FALSE);
1833 push_function(NO_SCOPE, CONSTRUCTOR_METHOD, NULL,
1834 $<id>1, $<cbuf>5, $<line>2,
1835 ccode_line, FALSE, NULL);
1836 } else if(strcmp($<id>1, "dispose")==0) {
1837 push_init_arg($<id>3, FALSE);
1838 push_function(NO_SCOPE, DISPOSE_METHOD, NULL,
1839 $<id>1, $<cbuf>5, $<line>2,
1840 ccode_line, FALSE, NULL);
1841 } else if(strcmp($<id>1, "finalize")==0) {
1842 push_init_arg($<id>3, FALSE);
1843 push_function(NO_SCOPE, FINALIZE_METHOD, NULL,
1844 $<id>1, $<cbuf>5, $<line>2,
1845 ccode_line, FALSE, NULL);
1850 g_string_free($<cbuf>5,TRUE);
1851 yyerror(_("parse error "
1852 "(untyped blocks must be init, "
1853 "class_init, constructor, dispose "
1860 methodmods: TOKEN retcode {
1861 g_free(funcattrs); funcattrs = NULL;
1862 g_free(onerror); onerror = NULL;
1863 g_free(defreturn); defreturn = NULL;
1864 if(!set_attr_value($<id>1, $<id>2)) {
1867 yyerror(_("parse error"));
1872 | TOKEN retcode TOKEN retcode {
1873 g_free(funcattrs); funcattrs = NULL;
1874 g_free(onerror); onerror = NULL;
1875 g_free(defreturn); defreturn = NULL;
1876 if(!set_attr_value($<id>1, $<id>2)) {
1877 g_free($<id>1); g_free($<id>2);
1878 g_free($<id>3); g_free($<id>4);
1879 yyerror(_("parse error"));
1882 if(!set_attr_value($<id>3, $<id>4)) {
1883 funcattrs = onerror = defreturn = NULL;
1884 g_free($<id>1); g_free($<id>2);
1885 g_free($<id>3); g_free($<id>4);
1886 yyerror(_("parse error"));
1892 | TOKEN retcode TOKEN retcode TOKEN retcode {
1893 g_free(funcattrs); funcattrs = NULL;
1894 g_free(onerror); onerror = NULL;
1895 g_free(defreturn); defreturn = NULL;
1896 if(!set_attr_value($<id>1, $<id>2)) {
1897 g_free($<id>1); g_free($<id>2);
1898 g_free($<id>3); g_free($<id>4);
1899 g_free($<id>5); g_free($<id>6);
1900 yyerror(_("parse error"));
1903 if(!set_attr_value($<id>3, $<id>4)) {
1904 funcattrs = onerror = defreturn = NULL;
1905 g_free($<id>1); g_free($<id>2);
1906 g_free($<id>3); g_free($<id>4);
1907 g_free($<id>5); g_free($<id>6);
1908 yyerror(_("parse error"));
1911 if(!set_attr_value($<id>5, $<id>6)) {
1912 funcattrs = onerror = defreturn = NULL;
1913 g_free($<id>1); g_free($<id>2);
1914 g_free($<id>3); g_free($<id>4);
1915 g_free($<id>5); g_free($<id>6);
1916 yyerror(_("parse error"));
1924 g_free(funcattrs); funcattrs = NULL;
1925 g_free(onerror); onerror = NULL;
1926 g_free(defreturn); defreturn = NULL;
1930 retcode: numtok { $<id>$ = $<id>1; }
1932 $<id>$ = ($<cbuf>2)->str;
1933 g_string_free($<cbuf>2, FALSE);
1937 funcargs: VOID { vararg = FALSE; has_self = FALSE; }
1941 if(strcmp($<id>1,"self")==0)
1942 push_self($<id>1, FALSE);
1945 yyerror(_("parse error"));
1952 if(strcmp($<id>1,"self")==0)
1953 push_self($<id>1, TRUE);
1956 yyerror(_("parse error"));
1963 if(strcmp($<id>2,"self")==0)
1964 push_self($<id>2, TRUE);
1967 yyerror(_("parse error"));
1971 | TOKEN ',' arglist {
1973 if(strcmp($<id>1,"self")==0)
1974 push_self($<id>1, FALSE);
1977 yyerror(_("parse error"));
1981 | TOKEN CONST ',' arglist {
1983 if(strcmp($<id>1,"self")==0)
1984 push_self($<id>1, TRUE);
1987 yyerror(_("parse error"));
1991 | CONST TOKEN ',' arglist {
1993 if(strcmp($<id>2,"self")==0)
1994 push_self($<id>2, TRUE);
1997 yyerror(_("parse error"));
2001 | arglist { has_self = FALSE; }
2004 arglist: arglist1 ',' THREEDOTS { vararg = TRUE; }
2005 | arglist1 { vararg = FALSE; }
2008 arglist1: arglist1 ',' arg { ; }
2013 push_funcarg($<id>2,NULL);
2015 | type TOKEN ARRAY_DIM {
2016 push_funcarg($<id>2,$<id>3);
2018 | type TOKEN '(' TOKEN checklist ')' {
2019 if(strcmp($<id>4,"check")!=0) {
2020 yyerror(_("parse error"));
2024 push_funcarg($<id>2,NULL);
2026 | type TOKEN ARRAY_DIM '(' TOKEN checklist ')' {
2027 if(strcmp($<id>5,"check")!=0) {
2028 yyerror(_("parse error"));
2032 push_funcarg($<id>2,$<id>3);
2036 checklist: checklist check { ; }
2041 if(strcmp($<id>1,"type")==0) {
2042 Node *node = node_new (CHECK_NODE,
2043 "chtype", TYPE_CHECK,
2045 checks = g_list_append(checks,node);
2046 } else if(strcmp($<id>1,"null")==0) {
2047 Node *node = node_new (CHECK_NODE,
2048 "chtype", NULL_CHECK,
2050 checks = g_list_append(checks,node);
2052 yyerror(_("parse error"));
2058 Node *node = node_new (CHECK_NODE,
2060 "number:steal", $<id>2,
2062 checks = g_list_append(checks,node);
2065 Node *node = node_new (CHECK_NODE,
2067 "number:steal", $<id>2,
2069 checks = g_list_append(checks,node);
2072 Node *node = node_new (CHECK_NODE,
2074 "number:steal", $<id>3,
2076 checks = g_list_append(checks,node);
2079 Node *node = node_new (CHECK_NODE,
2081 "number:steal", $<id>3,
2083 checks = g_list_append(checks,node);
2086 Node *node = node_new (CHECK_NODE,
2088 "number:steal", $<id>3,
2090 checks = g_list_append(checks,node);
2093 Node *node = node_new (CHECK_NODE,
2095 "number:steal", $<id>3,
2097 checks = g_list_append(checks,node);
2101 enumcode: ENUM TOKEN '{' enumvals '}' TYPETOKEN ';' {
2102 Node *node = node_new (ENUMDEF_NODE,
2103 "etype:steal", $<id>6,
2104 "prefix:steal", $<id>2,
2105 "values:steal", enum_vals,
2108 nodes = g_list_append (nodes, node);
2110 | ENUM TOKEN '{' enumvals ',' '}' TYPETOKEN ';' {
2111 Node *node = node_new (ENUMDEF_NODE,
2112 "etype:steal", $<id>7,
2113 "prefix:steal", $<id>2,
2114 "values:steal", enum_vals,
2117 nodes = g_list_append (nodes, node);
2121 enumvals: enumvals ',' enumval {;}
2125 enumval: TOKEN '=' numtok {
2129 /* A float value, that's a bad enum */
2130 if (num[0] >= '0' &&
2132 strchr (num, '.') != NULL) {
2135 yyerror(_("parse error (enumerator value not integer constant)"));
2139 node = node_new (ENUMVALUE_NODE,
2140 "name:steal", $<id>1,
2143 enum_vals = g_list_append (enum_vals, node);
2148 node = node_new (ENUMVALUE_NODE,
2149 "name:steal", $<id>1,
2151 enum_vals = g_list_append (enum_vals, node);
2155 flagcode: FLAGS TOKEN '{' flagvals '}' TYPETOKEN ';' {
2156 Node *node = node_new (FLAGS_NODE,
2157 "ftype:steal", $<id>6,
2158 "prefix:steal", $<id>2,
2159 "values:steal", flag_vals,
2162 nodes = g_list_append (nodes, node);
2164 | FLAGS TOKEN '{' flagvals ',' '}' TYPETOKEN ';' {
2165 Node *node = node_new (FLAGS_NODE,
2166 "ftype:steal", $<id>7,
2167 "prefix:steal", $<id>2,
2168 "values:steal", flag_vals,
2171 nodes = g_list_append (nodes, node);
2175 flagvals: flagvals ',' TOKEN {
2176 flag_vals = g_list_append (flag_vals, $<id>3);
2179 flag_vals = g_list_append (flag_vals, $<id>1);
2183 errorcode: ERROR TOKEN '{' errorvals '}' TYPETOKEN ';' {
2184 Node *node = node_new (ERROR_NODE,
2185 "etype:steal", $<id>6,
2186 "prefix:steal", $<id>2,
2187 "values:steal", error_vals,
2190 nodes = g_list_append (nodes, node);
2192 | ERROR TOKEN '{' errorvals ',' '}' TYPETOKEN ';' {
2193 Node *node = node_new (ERROR_NODE,
2194 "etype:steal", $<id>7,
2195 "prefix:steal", $<id>2,
2196 "values:steal", error_vals,
2199 nodes = g_list_append (nodes, node);
2203 errorvals: errorvals ',' TOKEN {
2204 error_vals = g_list_append (error_vals, $<id>3);
2207 error_vals = g_list_append (error_vals, $<id>1);
2212 numtok: NUMBER { $<id>$ = $<id>1; }
2214 $<id>$ = g_strconcat("-",$<id>2,NULL);
2217 | SINGLE_CHAR { $<id>$ = $<id>1; }
2218 | TOKEN { $<id>$ = $<id>1; }