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 strcmp (yytext, "\r") == 0) {
97 out = g_strconcat ("Error: ", str, " before end of line", NULL);
98 } else if (yytext[0] == '\0') {
99 out=g_strconcat("Error: ", str, " at end of input", NULL);
101 char *tmp = g_strdup(yytext);
102 while((p=strchr(tmp, '\n')))
105 out=g_strconcat("Error: ", str, " before '", tmp, "'", NULL);
109 fprintf(stderr, "%s:%d: %s\n", filename, line_no, out);
118 Type *type = typestack->data;
119 typestack = g_list_remove(typestack,typestack->data);
124 push_variable (char *name, int scope, int line_no, char *postfix)
127 Type *type = pop_type ();
129 type->postfix = postfix;
131 var = node_new (VARIABLE_NODE,
134 "glade_widget", glade_widget,
137 "destructor_unref", destructor_unref,
138 "destructor:steal", destructor,
139 "destructor_line", destructor_line,
140 "destructor_simple", destructor_simple,
141 "initializer:steal", initializer,
142 "initializer_line", initializer_line,
143 "initializer_simple", TRUE,
145 class_nodes = g_list_append(class_nodes, var);
146 glade_widget = FALSE;
150 push_function (int scope, int method, char *oid, char *id,
151 GString *cbuf, int line_no, int ccode_line,
152 gboolean vararg, GList *flags)
158 g_assert(scope != CLASS_SCOPE);
160 if(method == INIT_METHOD ||
161 method == CLASS_INIT_METHOD ||
162 method == CONSTRUCTOR_METHOD ||
163 method == DISPOSE_METHOD ||
164 method == FINALIZE_METHOD) {
165 type = (Type *)node_new (TYPE_NODE,
172 /* a complicated and ugly test to figure out if we have
173 the wrong number of types for a signal */
174 if((method == SIGNAL_FIRST_METHOD ||
175 method == SIGNAL_LAST_METHOD) &&
176 g_list_length(gtktypes) != g_list_length(funcargs) &&
177 !(g_list_length(funcargs) == 1 &&
178 g_list_length(gtktypes) == 2 &&
179 strcmp(gtktypes->next->data, "NONE")==0)) {
180 error_print(GOB_WARN, line_no,
181 _("The number of GTK arguments and "
182 "function arguments for a signal "
183 "don't seem to match"));
185 if(g_list_length(gtktypes) > 2) {
187 for(li = gtktypes->next; li; li = li->next) {
188 if(strcmp(li->data, "NONE")==0) {
189 error_print(GOB_ERROR, line_no,
190 _("NONE can only appear in an "
191 "argument list by itself"));
197 c_cbuf = p = cbuf->str;
198 while(p && *p && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
205 node = node_new (METHOD_NODE,
210 "gtktypes:steal", gtktypes,
211 "flags:steal", flags,
213 "args:steal", funcargs,
214 "funcattrs:steal", funcattrs,
215 "onerror:steal", onerror,
216 "defreturn:steal", defreturn,
217 "cbuf:steal", c_cbuf,
219 "ccode_line", ccode_line,
221 "unique_id", method_unique_id++,
224 last_added_method = (Method *)node;
228 /*only free segment if we haven't passed it
238 class_nodes = g_list_append(class_nodes, node);
242 free_all_global_state(void)
254 g_list_foreach(gtktypes, (GFunc)g_free, NULL);
255 g_list_free(gtktypes);
258 node_list_free (funcargs);
263 push_funcarg(char *name, char *postfix)
266 Type *type = pop_type();
268 type->postfix = postfix;
270 node = node_new (FUNCARG_NODE,
273 "checks:steal", checks,
277 funcargs = g_list_append(funcargs, node);
281 push_init_arg(char *name, int is_class)
288 tn = g_strconcat(((Class *)class)->otype,":Class",NULL);
290 tn = g_strdup(((Class *)class)->otype);
292 type = node_new (TYPE_NODE,
296 node = node_new (FUNCARG_NODE,
297 "atype:steal", (Type *)type,
300 funcargs = g_list_prepend(funcargs, node);
304 push_self(char *id, gboolean constant)
309 type = node_new (TYPE_NODE,
310 "name", ((Class *)class)->otype,
311 "pointer", constant ? "const *" : "*",
313 ch = g_list_append (ch, node_new (CHECK_NODE,
314 "chtype", NULL_CHECK,
316 ch = g_list_append (ch, node_new (CHECK_NODE,
317 "chtype", TYPE_CHECK,
319 node = node_new (FUNCARG_NODE,
320 "atype:steal", (Type *)type,
324 funcargs = g_list_prepend(funcargs, node);
328 find_var_or_die(const char *id, int line)
332 for(li = class_nodes; li != NULL; li = li->next) {
334 Node *node = li->data;
335 if(node->type != VARIABLE_NODE)
338 if(strcmp(var->id, id)==0)
342 error_printf(GOB_ERROR, line, _("Variable %s not defined here"), id);
344 g_assert_not_reached();
349 set_attr_value(char *type, char *val)
351 if(strcmp(type, "attr")==0) {
357 } else if(strcmp(type, "onerror")==0) {
363 } else if(strcmp(type, "defreturn")==0) {
374 export_accessors (const char *var_name,
386 the_type = (Type *)node_copy ((Node *)type);
388 the_type = get_tree_type (gtktype, TRUE);
390 if (the_type == NULL) {
391 error_print (GOB_ERROR, line_no,
392 _("Cannot determine type of property or argument"));
397 char *get_id = g_strdup_printf ("get_%s", var_name);
398 GString *get_cbuf = g_string_new (NULL);
399 Node *node1 = node_new (TYPE_NODE,
400 "name", the_type->name,
401 "pointer", the_type->pointer,
402 "postfix", the_type->postfix,
404 Node *node3 = node_new (TYPE_NODE,
405 "name", class->class.otype,
409 g_string_sprintf (get_cbuf,
411 "g_object_get (G_OBJECT (self), \"%s\", "
415 the_type->pointer ? the_type->pointer : "",
418 typestack = g_list_prepend (typestack, node1);
419 typestack = g_list_prepend (typestack, node3);
421 push_funcarg ("self", FALSE);
423 push_function (PUBLIC_SCOPE, REGULAR_METHOD, NULL,
424 get_id, get_cbuf, get_lineno,
425 lineno, FALSE, NULL);
429 char *set_id = g_strdup_printf ("set_%s", var_name);
430 GString *set_cbuf = g_string_new (NULL);
431 Node *node1 = node_new (TYPE_NODE,
432 "name", the_type->name,
433 "pointer", the_type->pointer,
434 "postfix", the_type->postfix,
436 Node *node2 = node_new (TYPE_NODE,
439 Node *node3 = node_new (TYPE_NODE,
440 "name", class->class.otype,
444 g_string_sprintf (set_cbuf,
445 "\tg_object_set (G_OBJECT (self), "
446 "\"%s\", val, NULL);\n",
449 typestack = g_list_prepend (typestack, node2);
450 typestack = g_list_prepend (typestack, node1);
451 typestack = g_list_prepend (typestack, node3);
453 push_funcarg ("self", FALSE);
454 push_funcarg ("val", FALSE);
456 typestack = g_list_prepend (typestack, node2);
457 push_function (PUBLIC_SCOPE, REGULAR_METHOD, NULL,
458 set_id, set_cbuf, set_lineno,
459 lineno, FALSE, NULL);
462 node_free ((Node *)the_type);
466 get_prop_enum_flag_cast (Property *prop)
469 if (prop->extra_gtktype == NULL ||
470 /* HACK! just in case someone made this
471 * work with 2.0.0 by using the TYPE
473 ((strstr (prop->extra_gtktype, "_TYPE_") != NULL ||
474 strstr (prop->extra_gtktype, "TYPE_") == prop->extra_gtktype) &&
475 strchr (prop->extra_gtktype, ':') == NULL)) {
476 if (prop->ptype != NULL)
477 return get_type (prop->ptype, TRUE);
479 return g_strdup ("");
481 tmp = remove_sep (prop->extra_gtktype);
482 ret = g_strdup_printf ("(%s) ", tmp);
488 add_construct_glade (char * file, char * root, char * domain)
493 type = (Type *)node_new (TYPE_NODE,
497 initializer = g_strdup_printf("\t{\n"
498 "\tGtkWidget * root;\n"
499 "\t%%1$s->_priv->_glade_xml = glade_xml_new(%s, %s, %s);\n"
500 "\troot = glade_xml_get_widget(%%1$s->_priv->_glade_xml, %s);\n"
501 "\tgtk_widget_show(root);\n"
502 "\tgtk_container_add(GTK_CONTAINER(%%1$s), root);\n"
503 "\tglade_xml_signal_autoconnect_full(%%1$s->_priv->_glade_xml, (GladeXMLConnectFunc)___glade_xml_connect_foreach, (gpointer)%%1$s);\n"
504 "}\n", file, root, domain ? domain : "NULL", root);
506 var = node_new (VARIABLE_NODE,
507 "scope", PRIVATE_SCOPE,
509 "glade_widget", FALSE,
510 "id:steal", "_glade_xml",
511 "destructor_unref", FALSE,
512 "destructor", "g_object_unref",
513 "destructor_simple", TRUE,
514 "initializer", initializer,
515 "initializer_simple", FALSE,
517 class_nodes = g_list_prepend(class_nodes, var);
521 property_link_and_export (Node *node)
523 Property *prop = (Property *)node;
527 char *get = NULL, *set = NULL;
530 if (prop->set != NULL ||
532 error_print (GOB_ERROR, prop->line_no,
533 _("Property linking requested, but "
534 "getters and setters exist"));
537 var = find_var_or_die (prop->name, prop->line_no);
538 if(var->scope == PRIVATE_SCOPE) {
539 root = "self->_priv";
540 } else if (var->scope == CLASS_SCOPE) {
541 root = "SELF_GET_CLASS(self)";
543 error_print (GOB_ERROR, prop->line_no,
544 _("Self aliases needed when autolinking to a classwide member"));
549 if (strcmp (prop->gtktype, "STRING") == 0) {
550 set = g_strdup_printf("{ char *old = %s->%s; "
551 "%s->%s = g_value_dup_string (VAL); g_free (old); }",
554 get = g_strdup_printf("g_value_set_string (VAL, %s->%s);",
556 } else if (strcmp (prop->gtktype, "OBJECT") == 0) {
558 if (prop->extra_gtktype != NULL) {
559 cast = remove_sep (prop->extra_gtktype);
561 cast = g_strdup ("void");
563 set = g_strdup_printf("{ GObject *___old = (GObject *)%s->%s; "
564 "%s->%s = (%s *)g_value_dup_object (VAL); "
565 "if (___old != NULL) { "
566 "g_object_unref (G_OBJECT (___old)); "
572 get = g_strdup_printf ("g_value_set_object (VAL, "
573 "(gpointer)%s->%s);",
576 } else if (strcmp (prop->gtktype, "BOXED") == 0) {
577 char *type = make_me_type (prop->extra_gtktype,
579 if (prop->extra_gtktype == NULL) {
580 error_print (GOB_ERROR, prop->line_no,
581 _("Property linking requested for BOXED, but "
582 "boxed_type not set"));
584 set = g_strdup_printf("{ gpointer ___old = (gpointer)%s->%s; "
585 "gpointer ___new = (gpointer)g_value_get_boxed (VAL); "
586 "if (___new != ___old) { "
587 "if (___old != NULL) g_boxed_free (%s, ___old); "
588 "if (___new != NULL) %s->%s = g_boxed_copy (%s, ___new); "
589 "else %s->%s = NULL;"
597 get = g_strdup_printf("g_value_set_boxed (VAL, %s->%s);",
603 const char *getcast = "";
604 const char *setcast = "";
605 char *to_free = NULL;
606 set_func = g_strdup_printf ("g_value_set_%s", prop->gtktype);
607 g_strdown (set_func);
608 get_func = g_strdup_printf ("g_value_get_%s", prop->gtktype);
609 g_strdown (get_func);
612 if (strcmp (prop->gtktype, "FLAGS") == 0) {
613 setcast = "(guint) ";
615 get_prop_enum_flag_cast (prop);
616 } else if (strcmp (prop->gtktype, "ENUM") == 0) {
619 get_prop_enum_flag_cast (prop);
620 } else if (strcmp (prop->gtktype, "POINTER") == 0) {
621 setcast = "(gpointer) ";
622 getcast = g_strdup_printf ("(%s%s) ",
624 prop->ptype->pointer ? prop->ptype->pointer : "");
628 set = g_strdup_printf("%s->%s = %s%s (VAL);",
632 get = g_strdup_printf("%s (VAL, %s%s->%s);",
644 "get_line", prop->line_no,
646 "set_line", prop->line_no,
651 export_accessors (prop->name,
652 prop->get != NULL, prop->get_line,
653 prop->set != NULL, prop->set_line,
664 if (strcmp (s, "BOOL") == 0) {
665 error_print (GOB_WARN, line_no,
666 _("BOOL type is deprecated, please use BOOLEAN"));
668 return g_strdup ("BOOLEAN");
675 ensure_property (void)
677 if (property == NULL)
678 property = (Property *)node_new (PROPERTY_NODE, NULL);
692 %token CONST VOID STRUCT UNION ENUM THREEDOTS
693 %token SIGNED UNSIGNED LONG SHORT INT FLOAT DOUBLE CHAR
695 %token <id> TOKEN NUMBER TYPETOKEN ARRAY_DIM SINGLE_CHAR
696 %token <cbuf> CCODE CTCODE ADCODE HTCODE PHCODE HCODE ACODE ATCODE STRING
697 %token <line> PUBLIC PRIVATE PROTECTED CLASSWIDE PROPERTY ARGUMENT
698 %token <line> VIRTUAL SIGNAL OVERRIDE
699 %token <line> NICK BLURB MAXIMUM MINIMUM DEFAULT_VALUE ERROR FLAGS TYPE
700 %token <line> FLAGS_TYPE ENUM_TYPE PARAM_TYPE BOXED_TYPE OBJECT_TYPE
704 prog: ccodes class ccodes { ; }
711 Node *node = node_new (CCODE_NODE,
713 "cbuf:steal", ($<cbuf>1)->str,
714 "line_no", ccode_line,
716 nodes = g_list_append(nodes,node);
717 g_string_free($<cbuf>1,FALSE);
720 Node *node = node_new (CCODE_NODE,
722 "cbuf:steal", ($<cbuf>1)->str,
723 "line_no", ccode_line,
725 nodes = g_list_append(nodes,node);
726 g_string_free($<cbuf>1,FALSE);
729 Node *node = node_new (CCODE_NODE,
731 "cbuf:steal", ($<cbuf>1)->str,
732 "line_no", ccode_line,
734 nodes = g_list_append(nodes,node);
735 g_string_free($<cbuf>1,FALSE);
738 Node *node = node_new (CCODE_NODE,
740 "cbuf:steal", ($<cbuf>1)->str,
741 "line_no", ccode_line,
743 nodes = g_list_append(nodes,node);
744 g_string_free($<cbuf>1,FALSE);
747 Node *node = node_new (CCODE_NODE,
749 "cbuf:steal", ($<cbuf>1)->str,
750 "line_no", ccode_line,
752 nodes = g_list_append(nodes,node);
753 g_string_free($<cbuf>1,FALSE);
756 Node *node = node_new (CCODE_NODE,
758 "cbuf:steal", ($<cbuf>1)->str,
759 "line_no", ccode_line,
761 nodes = g_list_append(nodes,node);
762 g_string_free($<cbuf>1,FALSE);
765 Node *node = node_new (CCODE_NODE,
767 "cbuf:steal", ($<cbuf>1)->str,
768 "line_no", ccode_line,
770 nodes = g_list_append(nodes,node);
771 g_string_free($<cbuf>1,FALSE);
774 Node *node = node_new (CCODE_NODE,
776 "cbuf:steal", ($<cbuf>1)->str,
777 "line_no", ccode_line,
779 nodes = g_list_append(nodes,node);
780 g_string_free($<cbuf>1,FALSE);
784 ccodes: ccodes ccode { ; }
785 | ccodes enumcode { ; }
786 | ccodes flagcode { ; }
787 | ccodes errorcode { ; }
794 class: classdec '{' classcode '}' {
795 ((Class *)class)->nodes = class_nodes;
797 nodes = g_list_append(nodes,class);
800 ((Class *)class)->nodes = NULL;
802 nodes = g_list_append(nodes,class);
806 classdec: CLASS TYPETOKEN FROM TYPETOKEN classflags {
807 class = node_new (CLASS_NODE,
808 "otype:steal", $<id>2,
809 "ptype:steal", $<id>4,
810 "bonobo_object_class:steal", bonobo_object_class,
811 "glade_xml", glade_xml,
812 "interfaces:steal", interfaces,
813 "chunk_size:steal", chunk_size,
814 "abstract", abstract,
816 bonobo_object_class = NULL;
824 | '(' TOKEN ')' classflags {
825 if(strcmp($<id>2,"abstract") == 0) {
828 yyerror(_("parse error"));
832 | '(' TOKEN TOKEN ')' classflags {
833 if(strcmp($<id>2,"chunks") == 0) {
835 chunk_size = g_strdup($<id>3);
836 } else if(strcmp($<id>2,"BonoboObject") == 0) {
837 g_free (bonobo_object_class);
838 bonobo_object_class = g_strdup($<id>3);
840 yyerror(_("parse error"));
844 | '(' TOKEN TYPETOKEN ')' classflags {
845 if (strcmp ($<id>2, "interface") == 0) {
846 interfaces = g_list_append (interfaces,
849 yyerror(_("parse error"));
853 | '(' TOKEN NUMBER ')' classflags {
854 if(strcmp($<id>2,"chunks") == 0) {
856 if(atoi($<id>3) != 0)
857 chunk_size = g_strdup($<id>3);
861 yyerror(_("parse error"));
865 | '(' TOKEN STRING STRING ')' classflags {
866 if (strcmp ($<id>2, "GladeXML") == 0) {
868 add_construct_glade($<id>3, $<id>4, NULL);
870 yyerror(_("parse error"));
874 | '(' TOKEN STRING STRING STRING ')' classflags {
875 if (strcmp ($<id>2, "GladeXML") == 0) {
877 add_construct_glade($<id>3, $<id>4, $<id>5);
879 yyerror(_("parse error"));
883 | '(' TOKEN TOKEN STRING ')' classflags {
884 if (strcmp ($<id>2, "GladeXML") == 0) {
886 add_construct_glade($<id>3, $<id>4, NULL);
888 yyerror(_("parse error"));
892 | '(' TOKEN TOKEN STRING STRING ')' classflags {
893 if (strcmp ($<id>2, "GladeXML") == 0) {
895 add_construct_glade($<id>3, $<id>4, $<id>5);
897 yyerror(_("parse error"));
903 classcode: classcode thing { ; }
909 if (strcmp ($<id>1, "BonoboObject") != 0) {
911 yyerror (_("parse error"));
915 last_added_method->bonobo_object_func = TRUE;
917 | TOKEN TYPETOKEN method {
918 if (strcmp ($<id>1, "interface") != 0) {
921 yyerror (_("parse error"));
925 node_set ((Node *)last_added_method,
926 "interface:steal", $<id>2,
935 scope: PUBLIC { the_scope = PUBLIC_SCOPE; }
936 | PRIVATE { the_scope = PRIVATE_SCOPE; }
937 | PROTECTED { the_scope = PROTECTED_SCOPE; }
938 | CLASSWIDE { the_scope = CLASS_SCOPE; }
941 destructor: TOKEN TOKEN {
942 if (strcmp ($<id>1, "destroywith") == 0) {
944 destructor_unref = FALSE;
946 destructor_line = line_no;
947 destructor_simple = TRUE;
948 } else if (strcmp ($<id>1, "unrefwith") == 0) {
950 destructor_unref = TRUE;
952 destructor_line = line_no;
953 destructor_simple = TRUE;
957 yyerror (_("parse error"));
962 if (strcmp ($<id>1, "destroy") == 0) {
964 destructor_unref = FALSE;
965 destructor = ($<cbuf>3)->str;
966 g_string_free($<cbuf>3, FALSE);
967 destructor_line = ccode_line;
968 destructor_simple = FALSE;
969 } else if (strcmp ($<id>1, "unref") == 0) {
971 destructor_unref = TRUE;
972 destructor = ($<cbuf>3)->str;
973 g_string_free ($<cbuf>3, FALSE);
974 destructor_line = ccode_line;
975 destructor_simple = FALSE;
978 g_string_free ($<cbuf>3, TRUE);
979 yyerror (_("parse error"));
985 initializer: '=' numtok {
986 initializer = $<id>2;
987 initializer_line = ccode_line;
990 initializer = ($<cbuf>3)->str;
991 initializer_line = ccode_line;
992 g_string_free($<cbuf>3, FALSE);
997 varoptions: destructor initializer { ; }
998 | initializer destructor { ; }
999 | initializer { destructor = NULL; }
1000 | destructor { initializer = NULL; }
1002 if (strcmp ($<id>1, "GladeXML") == 0) {
1003 glade_widget = TRUE;
1005 yyerror(_("parse error"));
1015 variable: scope type TOKEN varoptions ';' {
1016 push_variable($<id>3, the_scope,$<line>1, NULL);
1018 | scope type TOKEN ARRAY_DIM varoptions ';' {
1019 push_variable($<id>3, the_scope, $<line>1, $<id>4);
1023 argument: ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE TOKEN '{' CCODE ';' {
1025 if(strcmp($<id>6,"get")==0 &&
1026 strcmp($<id>9,"set")==0) {
1027 Type *type = pop_type();
1030 node = node_new (ARGUMENT_NODE,
1031 "gtktype:steal", $<id>3,
1032 "atype:steal", type,
1033 "flags:steal", $<list>2,
1034 "name:steal", $<id>4,
1035 "get:steal", ($<cbuf>8)->str,
1036 "get_line", $<line>7,
1037 "set:steal", ($<cbuf>11)->str,
1038 "set_line", $<line>10,
1039 "line_no", $<line>1,
1042 class_nodes = g_list_append(class_nodes,node);
1044 g_string_free ($<cbuf>8, FALSE);
1045 g_string_free ($<cbuf>11, FALSE);
1047 } else if(strcmp($<id>6,"set")==0 &&
1048 strcmp($<id>9,"get")==0) {
1049 Type *type = pop_type();
1052 node = node_new (ARGUMENT_NODE,
1053 "gtktype:steal", $<id>3,
1054 "atype:steal", type,
1055 "flags:steal", $<list>2,
1056 "name:steal", $<id>4,
1057 "get:steal", ($<cbuf>11)->str,
1058 "get_line", $<line>10,
1059 "set:steal", ($<cbuf>8)->str,
1060 "set_line", $<line>7,
1061 "line_no", $<line>1,
1063 g_string_free ($<cbuf>11, FALSE);
1064 g_string_free ($<cbuf>8, FALSE);
1065 class_nodes = g_list_append(class_nodes,node);
1071 g_list_foreach ($<list>2, (GFunc)g_free, NULL);
1072 g_list_free ($<list>2);
1073 g_string_free ($<cbuf>11, TRUE);
1074 g_string_free ($<cbuf>8, TRUE);
1075 yyerror (_("parse error"));
1079 if ($<id>5 != NULL) {
1080 Argument *arg = (Argument *)node;
1081 export_accessors (arg->name,
1082 arg->get != NULL, arg->get_line,
1083 arg->set != NULL, arg->set_line,
1091 | ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE ';' {
1093 if(strcmp($<id>6, "get") == 0) {
1094 Type *type = pop_type();
1096 node = node_new (ARGUMENT_NODE,
1097 "gtktype:steal", $<id>3,
1098 "atype:steal", type,
1099 "flags:steal", $<list>2,
1100 "name:steal", $<id>4,
1101 "get:steal", ($<cbuf>8)->str,
1102 "get_line", $<line>7,
1103 "line_no", $<line>1,
1106 g_string_free ($<cbuf>8, FALSE);
1107 class_nodes = g_list_append(class_nodes, node);
1108 } else if(strcmp($<id>6, "set") == 0) {
1109 Type *type = pop_type();
1111 node = node_new (ARGUMENT_NODE,
1112 "gtktype:steal", $<id>3,
1113 "atype:steal", type,
1114 "flags:steal", $<list>2,
1115 "name:steal", $<id>4,
1116 "set:steal", ($<cbuf>8)->str,
1117 "set_line", $<line>7,
1118 "line_no", $<line>1,
1121 g_string_free ($<cbuf>8, FALSE);
1122 class_nodes = g_list_append (class_nodes, node);
1127 g_list_foreach ($<list>2, (GFunc)g_free, NULL);
1128 g_list_free ($<list>2);
1129 g_string_free ($<cbuf>8, TRUE);
1130 yyerror(_("parse error"));
1134 if ($<id>5 != NULL) {
1135 Argument *arg = (Argument *)node;
1136 export_accessors (arg->name,
1137 arg->get != NULL, arg->get_line,
1138 arg->set != NULL, arg->set_line,
1145 | ARGUMENT flags argtype TOKEN export TOKEN {
1147 char *get, *set = NULL;
1152 if(strcmp($<id>6, "link")!=0 &&
1153 strcmp($<id>6, "stringlink")!=0 &&
1154 strcmp($<id>6, "objectlink")!=0) {
1158 g_list_foreach($<list>2,(GFunc)g_free,NULL);
1159 g_list_free($<list>2);
1160 yyerror(_("parse error"));
1166 var = find_var_or_die($<id>4, $<line>1);
1167 if(var->scope == PRIVATE_SCOPE) {
1168 root = "self->_priv";
1169 } else if(var->scope == CLASS_SCOPE) {
1170 root = "SELF_GET_CLASS(self)";
1172 error_print(GOB_ERROR, $<line>1,
1173 _("Self aliases needed when autolinking to a classwide member"));
1178 if(strcmp($<id>6, "link")==0) {
1179 set = g_strdup_printf("%s->%s = ARG;",
1181 } else if(strcmp($<id>6, "stringlink")==0) {
1182 set = g_strdup_printf("g_free (%s->%s); "
1183 "%s->%s = g_strdup (ARG);",
1186 } else if(strcmp($<id>6, "objectlink")==0) {
1187 set = g_strdup_printf(
1189 "g_object_ref (G_OBJECT (ARG)); "
1190 "if (%s->%s != NULL) "
1191 "g_object_unref (G_OBJECT (%s->%s)); "
1197 g_assert_not_reached();
1200 get = g_strdup_printf("ARG = %s->%s;", root, $<id>4);
1205 type = (Type *)node_copy ((Node *)var->vtype);
1207 node = node_new (ARGUMENT_NODE,
1208 "gtktype:steal", $<id>3,
1209 "atype:steal", type,
1210 "flags:steal", $<list>2,
1211 "name:steal", $<id>4,
1213 "get_line", $<line>1,
1215 "set_line", $<line>1,
1216 "line_no", $<line>1,
1219 if ($<id>5 != NULL) {
1220 Argument *arg = (Argument *)node;
1221 export_accessors (arg->name,
1222 arg->get != NULL, arg->get_line,
1223 arg->set != NULL, arg->set_line,
1230 class_nodes = g_list_append (class_nodes, node);
1234 export: '(' TOKEN ')' {
1235 if (strcmp ($<id>2, "export")!=0) {
1237 yyerror (_("parse error"));
1247 property: PROPERTY TOKEN TOKEN param_spec TOKEN '{' CCODE TOKEN '{' CCODE ';' {
1249 node_set ((Node *)property,
1250 "line_no", $<line>1,
1251 "gtktype:steal", debool ($<id>2),
1252 "name:steal", $<id>3,
1254 if (strcmp ($<id>5, "get") == 0 &&
1255 strcmp ($<id>8, "set") == 0) {
1256 node_set ((Node *)property,
1257 "get:steal", ($<cbuf>7)->str,
1258 "get_line", $<line>6,
1259 "set:steal", ($<cbuf>10)->str,
1260 "set_line", $<line>9,
1262 g_string_free ($<cbuf>7, FALSE);
1263 g_string_free ($<cbuf>10, FALSE);
1266 } else if (strcmp ($<id>5, "set") == 0 &&
1267 strcmp ($<id>8, "get") == 0) {
1268 node_set ((Node *)property,
1269 "get:steal", ($<cbuf>10)->str,
1270 "get_line", $<line>9,
1271 "set:steal", ($<cbuf>7)->str,
1272 "set_line", $<line>6,
1274 g_string_free ($<cbuf>7, FALSE);
1275 g_string_free ($<cbuf>10, FALSE);
1279 g_string_free ($<cbuf>7, TRUE);
1280 g_string_free ($<cbuf>10, TRUE);
1283 node_free ((Node *)property);
1285 yyerror (_("parse error"));
1288 property_link_and_export ((Node *)property);
1289 if (property != NULL) {
1290 class_nodes = g_list_append (class_nodes,
1295 | PROPERTY TOKEN TOKEN param_spec TOKEN '{' CCODE ';' {
1297 node_set ((Node *)property,
1298 "line_no", $<line>1,
1299 "gtktype:steal", debool ($<id>2),
1300 "name:steal", $<id>3,
1302 if (strcmp ($<id>5, "get") == 0) {
1303 node_set ((Node *)property,
1304 "get:steal", ($<cbuf>7)->str,
1305 "get_line", $<line>6,
1307 g_string_free ($<cbuf>7, FALSE);
1309 } else if (strcmp ($<id>5, "set") == 0) {
1310 node_set ((Node *)property,
1311 "set:steal", ($<cbuf>7)->str,
1312 "set_line", $<line>6,
1314 g_string_free ($<cbuf>7, FALSE);
1317 g_string_free ($<cbuf>7, TRUE);
1319 node_free ((Node *)property);
1321 yyerror (_("parse error"));
1324 property_link_and_export ((Node *)property);
1325 if (property != NULL) {
1326 class_nodes = g_list_append (class_nodes,
1331 | PROPERTY TOKEN TOKEN param_spec ';' {
1333 node_set ((Node *)property,
1334 "line_no", $<line>1,
1335 "gtktype:steal", debool ($<id>2),
1336 "name:steal", $<id>3,
1338 property_link_and_export ((Node *)property);
1339 if (property != NULL) {
1340 class_nodes = g_list_append (class_nodes,
1347 param_spec: '(' param_spec_list ')' { ; }
1351 param_spec_list: param_spec_list ',' param_spec_value { ; }
1352 | param_spec_value { ; }
1355 string: STRING { $<id>$ = $<id>1; }
1356 | TOKEN '(' STRING ')' {
1357 if (strcmp ($<id>1, "_") != 0) {
1359 yyerror(_("parse error"));
1363 $<id>$ = g_strconcat ("_(", $<id>3, ")", NULL);
1368 anyval: numtok { $<id>$ = $<id>1; }
1369 | string { $<id>$ = $<id>1; }
1372 param_spec_value: NICK '=' string {
1374 node_set ((Node *)property,
1375 "nick:steal", $<id>3,
1378 | BLURB '=' string {
1380 node_set ((Node *)property,
1381 "blurb:steal", $<id>3,
1384 | MAXIMUM '=' numtok {
1386 node_set ((Node *)property,
1387 "maximum:steal", $<id>3,
1390 | MINIMUM '=' numtok {
1392 node_set ((Node *)property,
1393 "minimum:steal", $<id>3,
1396 | DEFAULT_VALUE '=' anyval {
1398 node_set ((Node *)property,
1399 "default_value:steal", $<id>3,
1402 | FLAGS '=' flaglist {
1404 node_set ((Node *)property,
1405 "flags:steal", $<list>3,
1409 Type *type = pop_type ();
1411 node_set ((Node *)property,
1412 "ptype:steal", type,
1415 | FLAGS_TYPE '=' TYPETOKEN {
1417 node_set ((Node *)property,
1418 "extra_gtktype:steal", $<id>3,
1421 | FLAGS_TYPE '=' TOKEN {
1423 node_set ((Node *)property,
1424 "extra_gtktype:steal", $<id>3,
1427 | ENUM_TYPE '=' TYPETOKEN {
1429 node_set ((Node *)property,
1430 "extra_gtktype:steal", $<id>3,
1433 | ENUM_TYPE '=' TOKEN {
1435 node_set ((Node *)property,
1436 "extra_gtktype:steal", $<id>3,
1439 | PARAM_TYPE '=' TYPETOKEN {
1441 node_set ((Node *)property,
1442 "extra_gtktype:steal", $<id>3,
1445 | PARAM_TYPE '=' TOKEN {
1447 node_set ((Node *)property,
1448 "extra_gtktype:steal", $<id>3,
1451 | BOXED_TYPE '=' TYPETOKEN {
1453 node_set ((Node *)property,
1454 "extra_gtktype:steal", $<id>3,
1457 | BOXED_TYPE '=' TOKEN {
1459 node_set ((Node *)property,
1460 "extra_gtktype:steal", $<id>3,
1463 | OBJECT_TYPE '=' TYPETOKEN {
1465 node_set ((Node *)property,
1466 "extra_gtktype:steal", $<id>3,
1469 | OBJECT_TYPE '=' TOKEN {
1471 node_set ((Node *)property,
1472 "extra_gtktype:steal", $<id>3,
1477 if (strcmp ($<id>1, "override") == 0) {
1479 node_set ((Node *)property,
1482 } else if (strcmp ($<id>1, "link") == 0) {
1484 node_set ((Node *)property,
1487 } else if (strcmp ($<id>1, "export") == 0) {
1489 node_set ((Node *)property,
1494 yyerror(_("parse error"));
1500 argtype: TOKEN '(' TOKEN type ')' {
1501 if(strcmp($<id>3,"type")!=0) {
1504 yyerror(_("parse error"));
1507 $<id>$ = debool ($<id>1);
1510 $<id>$ = debool ($<id>1);
1511 typestack = g_list_prepend(typestack,NULL);
1515 flags: '(' flaglist ')' { $<list>$ = $<list>2; }
1516 | { $<list>$ = NULL; }
1519 flaglist: TOKEN '|' flaglist {
1520 $<list>$ = g_list_append($<list>3,$<id>1);
1523 $<list>$ = g_list_append(NULL,$<id>1);
1528 type: specifier_list pointer {
1529 Node *node = node_new (TYPE_NODE,
1530 "name:steal", $<id>1,
1531 "pointer:steal", $<id>2,
1533 typestack = g_list_prepend(typestack,node);
1536 Node *node = node_new (TYPE_NODE,
1537 "name:steal", $<id>1,
1539 typestack = g_list_prepend(typestack,node);
1543 /* The special cases are neccessary to avoid conflicts */
1544 specifier_list: spec_list {
1551 $<id>$ = g_strconcat("const ", $<id>2, NULL);
1555 $<id>$ = g_strconcat($<id>1, " const", NULL);
1558 | strunionenum TOKEN {
1559 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1562 | CONST strunionenum TOKEN {
1563 $<id>$ = g_strconcat("const ", $<id>2, " ",
1567 | strunionenum TOKEN CONST {
1568 $<id>$ = g_strconcat($<id>1, " ",
1569 $<id>2, " const", NULL);
1574 /* The special const cases take care of conflicts ! */
1575 spec_list: specifier spec_list {
1576 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1579 | TYPETOKEN spec_list {
1580 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1585 $<id>$ = g_strconcat("const ", $<id>2, NULL);
1592 $<id>$ = g_strconcat($<id>1, " const", NULL);
1596 $<id>$ = g_strdup($<id>1);
1599 $<id>$ = g_strconcat($<id>1, " const", NULL);
1603 specifier: VOID { $<id>$ = "void"; }
1604 | CHAR { $<id>$ = "char"; }
1605 | SHORT { $<id>$ = "short"; }
1606 | INT { $<id>$ = "int"; }
1607 | LONG { $<id>$ = "long"; }
1608 | FLOAT { $<id>$ = "float"; }
1609 | DOUBLE { $<id>$ = "double"; }
1610 | SIGNED { $<id>$ = "signed"; }
1611 | UNSIGNED { $<id>$ = "unsigned"; }
1614 strunionenum: STRUCT { $<id>$ = "struct"; }
1615 | UNION { $<id>$ = "union"; }
1616 | ENUM { $<id>$ = "enum"; }
1619 pointer: '*' { $<id>$ = g_strdup("*"); }
1620 | '*' CONST { $<id>$ = g_strdup("* const"); }
1622 $<id>$ = g_strconcat("*", $<id>2, NULL);
1625 | '*' CONST pointer {
1626 $<id>$ = g_strconcat("* const", $<id>3, NULL);
1631 /* this never sets the_scope */
1632 simplesigtype: TOKEN sigtype {
1633 if(strcmp($<id>1, "first")==0)
1634 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1635 else if(strcmp($<id>1, "last")==0)
1636 $<sigtype>$ = SIGNAL_LAST_METHOD;
1638 yyerror(_("signal must be 'first' or 'last'"));
1645 $<sigtype>$ = SIGNAL_LAST_METHOD;
1649 /* this always sets the_scope */
1650 fullsigtype: scope TOKEN sigtype {
1651 if(strcmp($<id>2,"first")==0)
1652 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1653 else if(strcmp($<id>2,"last")==0)
1654 $<sigtype>$ = SIGNAL_LAST_METHOD;
1656 yyerror(_("signal must be 'first' or 'last'"));
1662 | TOKEN scope sigtype {
1663 if(strcmp($<id>1,"first")==0)
1664 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1665 else if(strcmp($<id>1,"last")==0)
1666 $<sigtype>$ = SIGNAL_LAST_METHOD;
1668 yyerror(_("signal must be 'first' or 'last'"));
1675 $<sigtype>$ = SIGNAL_LAST_METHOD;
1678 /* the_scope was default thus public */
1679 the_scope = PUBLIC_SCOPE;
1683 sigtype: TOKEN '(' tokenlist ')' {
1684 gtktypes = g_list_prepend(gtktypes, debool ($<id>1));
1688 tokenlist: tokenlist ',' TOKEN {
1689 gtktypes = g_list_append(gtktypes, debool ($<id>3));
1692 gtktypes = g_list_append(gtktypes, debool ($<id>1));
1696 codenocode: '{' CCODE { $<cbuf>$ = $<cbuf>2; }
1697 | ';' { $<cbuf>$ = NULL; }
1700 /*here CCODE will include the ending '}' */
1701 method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenocode {
1703 yyerror(_("signal without 'self' as "
1704 "first parameter"));
1705 free_all_global_state();
1708 if(the_scope == CLASS_SCOPE) {
1709 yyerror(_("a method cannot be of class scope"));
1710 free_all_global_state();
1713 if (funcattrs != NULL) {
1714 char *error = g_strdup_printf
1715 (_("function attribute macros ('%s' in this case) may not be used with signal methods"),
1720 push_function(the_scope, $<sigtype>3,NULL,
1721 $<id>5, $<cbuf>10,$<line>1,
1722 ccode_line, vararg, $<list>2);
1724 | scope SIGNAL flags simplesigtype type TOKEN '(' funcargs ')' methodmods codenocode {
1726 yyerror(_("signal without 'self' as "
1727 "first parameter"));
1728 free_all_global_state();
1731 if(the_scope == CLASS_SCOPE) {
1732 yyerror(_("a method cannot be of class scope"));
1733 free_all_global_state();
1736 if (funcattrs != NULL) {
1737 char *error = g_strdup_printf
1738 (_("function attribute macros ('%s' in this case) may not be used with signal methods"),
1743 push_function(the_scope, $<sigtype>4, NULL,
1744 $<id>6, $<cbuf>11, $<line>2,
1745 ccode_line, vararg, $<list>3);
1747 | VIRTUAL scope type TOKEN '(' funcargs ')' methodmods codenocode {
1749 yyerror(_("virtual method without 'self' as "
1750 "first parameter"));
1751 free_all_global_state();
1754 if(the_scope == CLASS_SCOPE) {
1755 yyerror(_("a method cannot be of class scope"));
1756 free_all_global_state();
1759 if (funcattrs != NULL) {
1760 char *error = g_strdup_printf
1761 (_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
1766 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
1768 ccode_line, vararg, NULL);
1770 | scope VIRTUAL type TOKEN '(' funcargs ')' methodmods codenocode {
1772 yyerror(_("virtual method without 'self' as "
1773 "first parameter"));
1774 free_all_global_state();
1777 if(the_scope == CLASS_SCOPE) {
1778 yyerror(_("a method cannot be of class scope"));
1779 free_all_global_state();
1782 if (funcattrs != NULL) {
1783 char *error = g_strdup_printf
1784 (_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
1789 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
1791 ccode_line, vararg, NULL);
1793 | VIRTUAL type TOKEN '(' funcargs ')' methodmods codenocode {
1795 yyerror(_("virtual method without 'szelf' as "
1796 "first parameter"));
1797 free_all_global_state();
1800 if (funcattrs != NULL) {
1801 char *error = g_strdup_printf
1802 (_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
1807 push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL,
1808 $<id>3, $<cbuf>8, $<line>1,
1809 ccode_line, vararg, NULL);
1811 | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' methodmods codenocode {
1812 if (funcattrs != NULL) {
1813 char *error = g_strdup_printf
1814 (_("function attribute macros ('%s' in this case) may not be used with override methods"),
1819 push_function(NO_SCOPE, OVERRIDE_METHOD, $<id>3,
1821 $<line>1, ccode_line,
1824 | scope type TOKEN '(' funcargs ')' methodmods codenocode {
1825 if(the_scope == CLASS_SCOPE) {
1826 yyerror(_("a method cannot be of class scope"));
1827 free_all_global_state();
1830 push_function(the_scope, REGULAR_METHOD, NULL, $<id>3,
1831 $<cbuf>8, $<line>1, ccode_line,
1834 | TOKEN '(' TOKEN ')' codenocode {
1835 if(strcmp($<id>1, "init")==0) {
1836 push_init_arg($<id>3,FALSE);
1837 push_function(NO_SCOPE, INIT_METHOD, NULL,
1838 $<id>1, $<cbuf>5, $<line>2,
1839 ccode_line, FALSE, NULL);
1840 } else if(strcmp($<id>1, "class_init")==0) {
1841 push_init_arg($<id>3,TRUE);
1842 push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL,
1843 $<id>1, $<cbuf>5, $<line>2,
1844 ccode_line, FALSE, NULL);
1845 } else if(strcmp($<id>1, "constructor")==0) {
1846 push_init_arg($<id>3, FALSE);
1847 push_function(NO_SCOPE, CONSTRUCTOR_METHOD, NULL,
1848 $<id>1, $<cbuf>5, $<line>2,
1849 ccode_line, FALSE, NULL);
1850 } else if(strcmp($<id>1, "dispose")==0) {
1851 push_init_arg($<id>3, FALSE);
1852 push_function(NO_SCOPE, DISPOSE_METHOD, NULL,
1853 $<id>1, $<cbuf>5, $<line>2,
1854 ccode_line, FALSE, NULL);
1855 } else if(strcmp($<id>1, "finalize")==0) {
1856 push_init_arg($<id>3, FALSE);
1857 push_function(NO_SCOPE, FINALIZE_METHOD, NULL,
1858 $<id>1, $<cbuf>5, $<line>2,
1859 ccode_line, FALSE, NULL);
1864 g_string_free($<cbuf>5,TRUE);
1865 yyerror(_("parse error "
1866 "(untyped blocks must be init, "
1867 "class_init, constructor, dispose "
1874 methodmods: TOKEN retcode {
1875 g_free(funcattrs); funcattrs = NULL;
1876 g_free(onerror); onerror = NULL;
1877 g_free(defreturn); defreturn = NULL;
1878 if(!set_attr_value($<id>1, $<id>2)) {
1881 yyerror(_("parse error"));
1886 | TOKEN retcode TOKEN retcode {
1887 g_free(funcattrs); funcattrs = NULL;
1888 g_free(onerror); onerror = NULL;
1889 g_free(defreturn); defreturn = NULL;
1890 if(!set_attr_value($<id>1, $<id>2)) {
1891 g_free($<id>1); g_free($<id>2);
1892 g_free($<id>3); g_free($<id>4);
1893 yyerror(_("parse error"));
1896 if(!set_attr_value($<id>3, $<id>4)) {
1897 funcattrs = onerror = defreturn = NULL;
1898 g_free($<id>1); g_free($<id>2);
1899 g_free($<id>3); g_free($<id>4);
1900 yyerror(_("parse error"));
1906 | TOKEN retcode TOKEN retcode TOKEN retcode {
1907 g_free(funcattrs); funcattrs = NULL;
1908 g_free(onerror); onerror = NULL;
1909 g_free(defreturn); defreturn = NULL;
1910 if(!set_attr_value($<id>1, $<id>2)) {
1911 g_free($<id>1); g_free($<id>2);
1912 g_free($<id>3); g_free($<id>4);
1913 g_free($<id>5); g_free($<id>6);
1914 yyerror(_("parse error"));
1917 if(!set_attr_value($<id>3, $<id>4)) {
1918 funcattrs = onerror = defreturn = NULL;
1919 g_free($<id>1); g_free($<id>2);
1920 g_free($<id>3); g_free($<id>4);
1921 g_free($<id>5); g_free($<id>6);
1922 yyerror(_("parse error"));
1925 if(!set_attr_value($<id>5, $<id>6)) {
1926 funcattrs = onerror = defreturn = NULL;
1927 g_free($<id>1); g_free($<id>2);
1928 g_free($<id>3); g_free($<id>4);
1929 g_free($<id>5); g_free($<id>6);
1930 yyerror(_("parse error"));
1938 g_free(funcattrs); funcattrs = NULL;
1939 g_free(onerror); onerror = NULL;
1940 g_free(defreturn); defreturn = NULL;
1944 retcode: numtok { $<id>$ = $<id>1; }
1946 $<id>$ = ($<cbuf>2)->str;
1947 g_string_free($<cbuf>2, FALSE);
1951 funcargs: VOID { vararg = FALSE; has_self = FALSE; }
1955 if(strcmp($<id>1,"self")==0)
1956 push_self($<id>1, FALSE);
1959 yyerror(_("parse error"));
1966 if(strcmp($<id>1,"self")==0)
1967 push_self($<id>1, TRUE);
1970 yyerror(_("parse error"));
1977 if(strcmp($<id>2,"self")==0)
1978 push_self($<id>2, TRUE);
1981 yyerror(_("parse error"));
1985 | TOKEN ',' arglist {
1987 if(strcmp($<id>1,"self")==0)
1988 push_self($<id>1, FALSE);
1991 yyerror(_("parse error"));
1995 | TOKEN CONST ',' arglist {
1997 if(strcmp($<id>1,"self")==0)
1998 push_self($<id>1, TRUE);
2001 yyerror(_("parse error"));
2005 | CONST TOKEN ',' arglist {
2007 if(strcmp($<id>2,"self")==0)
2008 push_self($<id>2, TRUE);
2011 yyerror(_("parse error"));
2015 | arglist { has_self = FALSE; }
2018 arglist: arglist1 ',' THREEDOTS { vararg = TRUE; }
2019 | arglist1 { vararg = FALSE; }
2022 arglist1: arglist1 ',' arg { ; }
2027 push_funcarg($<id>2,NULL);
2029 | type TOKEN ARRAY_DIM {
2030 push_funcarg($<id>2,$<id>3);
2032 | type TOKEN '(' TOKEN checklist ')' {
2033 if(strcmp($<id>4,"check")!=0) {
2034 yyerror(_("parse error"));
2038 push_funcarg($<id>2,NULL);
2040 | type TOKEN ARRAY_DIM '(' TOKEN checklist ')' {
2041 if(strcmp($<id>5,"check")!=0) {
2042 yyerror(_("parse error"));
2046 push_funcarg($<id>2,$<id>3);
2050 checklist: checklist check { ; }
2055 if(strcmp($<id>1,"type")==0) {
2056 Node *node = node_new (CHECK_NODE,
2057 "chtype", TYPE_CHECK,
2059 checks = g_list_append(checks,node);
2060 } else if(strcmp($<id>1,"null")==0) {
2061 Node *node = node_new (CHECK_NODE,
2062 "chtype", NULL_CHECK,
2064 checks = g_list_append(checks,node);
2066 yyerror(_("parse error"));
2072 Node *node = node_new (CHECK_NODE,
2074 "number:steal", $<id>2,
2076 checks = g_list_append(checks,node);
2079 Node *node = node_new (CHECK_NODE,
2081 "number:steal", $<id>2,
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);
2100 Node *node = node_new (CHECK_NODE,
2102 "number:steal", $<id>3,
2104 checks = g_list_append(checks,node);
2107 Node *node = node_new (CHECK_NODE,
2109 "number:steal", $<id>3,
2111 checks = g_list_append(checks,node);
2115 enumcode: ENUM TOKEN '{' enumvals '}' TYPETOKEN ';' {
2116 Node *node = node_new (ENUMDEF_NODE,
2117 "etype:steal", $<id>6,
2118 "prefix:steal", $<id>2,
2119 "values:steal", enum_vals,
2122 nodes = g_list_append (nodes, node);
2124 | ENUM TOKEN '{' enumvals ',' '}' TYPETOKEN ';' {
2125 Node *node = node_new (ENUMDEF_NODE,
2126 "etype:steal", $<id>7,
2127 "prefix:steal", $<id>2,
2128 "values:steal", enum_vals,
2131 nodes = g_list_append (nodes, node);
2135 enumvals: enumvals ',' enumval {;}
2139 enumval: TOKEN '=' numtok {
2143 /* A float value, that's a bad enum */
2144 if (num[0] >= '0' &&
2146 strchr (num, '.') != NULL) {
2149 yyerror(_("parse error (enumerator value not integer constant)"));
2153 node = node_new (ENUMVALUE_NODE,
2154 "name:steal", $<id>1,
2157 enum_vals = g_list_append (enum_vals, node);
2162 node = node_new (ENUMVALUE_NODE,
2163 "name:steal", $<id>1,
2165 enum_vals = g_list_append (enum_vals, node);
2169 flagcode: FLAGS TOKEN '{' flagvals '}' TYPETOKEN ';' {
2170 Node *node = node_new (FLAGS_NODE,
2171 "ftype:steal", $<id>6,
2172 "prefix:steal", $<id>2,
2173 "values:steal", flag_vals,
2176 nodes = g_list_append (nodes, node);
2178 | FLAGS TOKEN '{' flagvals ',' '}' TYPETOKEN ';' {
2179 Node *node = node_new (FLAGS_NODE,
2180 "ftype:steal", $<id>7,
2181 "prefix:steal", $<id>2,
2182 "values:steal", flag_vals,
2185 nodes = g_list_append (nodes, node);
2189 flagvals: flagvals ',' TOKEN {
2190 flag_vals = g_list_append (flag_vals, $<id>3);
2193 flag_vals = g_list_append (flag_vals, $<id>1);
2197 errorcode: ERROR TOKEN '{' errorvals '}' TYPETOKEN ';' {
2198 Node *node = node_new (ERROR_NODE,
2199 "etype:steal", $<id>6,
2200 "prefix:steal", $<id>2,
2201 "values:steal", error_vals,
2204 nodes = g_list_append (nodes, node);
2206 | ERROR TOKEN '{' errorvals ',' '}' TYPETOKEN ';' {
2207 Node *node = node_new (ERROR_NODE,
2208 "etype:steal", $<id>7,
2209 "prefix:steal", $<id>2,
2210 "values:steal", error_vals,
2213 nodes = g_list_append (nodes, node);
2217 errorvals: errorvals ',' TOKEN {
2218 error_vals = g_list_append (error_vals, $<id>3);
2221 error_vals = g_list_append (error_vals, $<id>1);
2226 numtok: NUMBER { $<id>$ = $<id>1; }
2228 $<id>$ = g_strconcat("-",$<id>2,NULL);
2231 | SINGLE_CHAR { $<id>$ = $<id>1; }
2232 | TOKEN { $<id>$ = $<id>1; }