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;
73 static char *signal_name=NULL;
75 static Property *property = NULL;
77 /* this can be a global as we will only do one function at a time
79 static int the_scope = NO_SCOPE;
84 extern int ccode_line;
86 extern gboolean for_cpp;
96 if (strcmp (yytext, "\n") == 0 ||
97 strcmp (yytext, "\r") == 0) {
98 out = g_strconcat ("Error: ", str, " before end of line", NULL);
99 } else if (yytext[0] == '\0') {
100 out=g_strconcat("Error: ", str, " at end of input", NULL);
102 char *tmp = g_strdup(yytext);
103 while((p=strchr(tmp, '\n')))
106 out=g_strconcat("Error: ", str, " before '", tmp, "'", NULL);
110 fprintf(stderr, "%s:%d: %s\n", filename, line_no, out);
119 Type *type = typestack->data;
120 typestack = g_list_remove(typestack,typestack->data);
125 push_variable (char *name, int scope, int line_no, char *postfix)
128 Type *type = pop_type ();
130 type->postfix = postfix;
132 var = node_new (VARIABLE_NODE,
135 "glade_widget", glade_widget,
138 "destructor_unref", destructor_unref,
139 "destructor:steal", destructor,
140 "destructor_line", destructor_line,
141 "destructor_simple", destructor_simple,
142 "initializer:steal", initializer,
143 "initializer_line", initializer_line,
144 "initializer_simple", TRUE,
146 class_nodes = g_list_append(class_nodes, var);
147 glade_widget = FALSE;
151 push_function (int scope, int method, char *oid, char *id,
152 GString *cbuf, int line_no, int ccode_line,
153 gboolean vararg, GList *flags)
159 g_assert(scope != CLASS_SCOPE);
161 if(method == INIT_METHOD ||
162 method == CLASS_INIT_METHOD ||
163 method == CONSTRUCTOR_METHOD ||
164 method == DISPOSE_METHOD ||
165 method == FINALIZE_METHOD) {
166 type = (Type *)node_new (TYPE_NODE,
173 /* a complicated and ugly test to figure out if we have
174 the wrong number of types for a signal */
175 if((method == SIGNAL_FIRST_METHOD ||
176 method == SIGNAL_LAST_METHOD) &&
177 g_list_length(gtktypes) != g_list_length(funcargs) &&
178 !(g_list_length(funcargs) == 1 &&
179 g_list_length(gtktypes) == 2 &&
180 strcmp(gtktypes->next->data, "NONE")==0)) {
181 error_print(GOB_WARN, line_no,
182 _("The number of GTK arguments and "
183 "function arguments for a signal "
184 "don't seem to match"));
186 if(g_list_length(gtktypes) > 2) {
188 for(li = gtktypes->next; li; li = li->next) {
189 if(strcmp(li->data, "NONE")==0) {
190 error_print(GOB_ERROR, line_no,
191 _("NONE can only appear in an "
192 "argument list by itself"));
198 c_cbuf = p = cbuf->str;
199 while(p && *p && (*p==' ' || *p=='\t' || *p=='\n' || *p=='\r'))
206 if (signal_name == NULL )
208 GString * buffer=g_string_new("");
209 g_string_printf(buffer, "\"%s\"", id);
210 signal_name = buffer->str;
211 g_string_free(buffer, FALSE);
213 node = node_new (METHOD_NODE,
218 "gtktypes:steal", gtktypes,
219 "flags:steal", flags,
221 "signal_name:steal", signal_name,
222 "args:steal", funcargs,
223 "funcattrs:steal", funcattrs,
224 "onerror:steal", onerror,
225 "defreturn:steal", defreturn,
226 "cbuf:steal", c_cbuf,
228 "ccode_line", ccode_line,
230 "unique_id", method_unique_id++,
233 last_added_method = (Method *)node;
237 /*only free segment if we haven't passed it
247 class_nodes = g_list_append(class_nodes, node);
251 free_all_global_state(void)
263 g_list_foreach(gtktypes, (GFunc)g_free, NULL);
264 g_list_free(gtktypes);
267 node_list_free (funcargs);
272 push_funcarg(char *name, char *postfix)
275 Type *type = pop_type();
277 type->postfix = postfix;
279 node = node_new (FUNCARG_NODE,
282 "checks:steal", checks,
286 funcargs = g_list_append(funcargs, node);
290 push_init_arg(char *name, int is_class)
297 tn = g_strconcat(((Class *)class)->otype,":Class",NULL);
299 tn = g_strdup(((Class *)class)->otype);
301 type = node_new (TYPE_NODE,
305 node = node_new (FUNCARG_NODE,
306 "atype:steal", (Type *)type,
309 funcargs = g_list_prepend(funcargs, node);
313 push_self(char *id, gboolean constant)
318 type = node_new (TYPE_NODE,
319 "name", ((Class *)class)->otype,
320 "pointer", constant ? "const *" : "*",
322 ch = g_list_append (ch, node_new (CHECK_NODE,
323 "chtype", NULL_CHECK,
325 ch = g_list_append (ch, node_new (CHECK_NODE,
326 "chtype", TYPE_CHECK,
328 node = node_new (FUNCARG_NODE,
329 "atype:steal", (Type *)type,
333 funcargs = g_list_prepend(funcargs, node);
337 find_var_or_die(const char *id, int line)
341 for(li = class_nodes; li != NULL; li = li->next) {
343 Node *node = li->data;
344 if(node->type != VARIABLE_NODE)
347 if(strcmp(var->id, id)==0)
351 error_printf(GOB_ERROR, line, _("Variable %s not defined here"), id);
353 g_assert_not_reached();
358 set_attr_value(char *type, char *val)
360 if(strcmp(type, "attr")==0) {
366 } else if(strcmp(type, "onerror")==0) {
372 } else if(strcmp(type, "defreturn")==0) {
383 export_accessors (const char *var_name,
395 the_type = (Type *)node_copy ((Node *)type);
397 the_type = get_tree_type (gtktype, TRUE);
399 if (the_type == NULL) {
400 error_print (GOB_ERROR, line_no,
401 _("Cannot determine type of property or argument"));
406 char *get_id = g_strdup_printf ("get_%s", var_name);
407 GString *get_cbuf = g_string_new (NULL);
408 Node *node1 = node_new (TYPE_NODE,
409 "name", the_type->name,
410 "pointer", the_type->pointer,
411 "postfix", the_type->postfix,
413 Node *node3 = node_new (TYPE_NODE,
414 "name", class->class.otype,
418 g_string_sprintf (get_cbuf,
420 "g_object_get (G_OBJECT (self), \"%s\", "
424 the_type->pointer ? the_type->pointer : "",
427 typestack = g_list_prepend (typestack, node1);
428 typestack = g_list_prepend (typestack, node3);
430 push_funcarg ("self", FALSE);
432 push_function (PUBLIC_SCOPE, REGULAR_METHOD, NULL,
433 get_id, get_cbuf, get_lineno,
434 lineno, FALSE, NULL);
438 char *set_id = g_strdup_printf ("set_%s", var_name);
439 GString *set_cbuf = g_string_new (NULL);
440 Node *node1 = node_new (TYPE_NODE,
441 "name", the_type->name,
442 "pointer", the_type->pointer,
443 "postfix", the_type->postfix,
445 Node *node2 = node_new (TYPE_NODE,
448 Node *node3 = node_new (TYPE_NODE,
449 "name", class->class.otype,
453 g_string_sprintf (set_cbuf,
454 "\tg_object_set (G_OBJECT (self), "
455 "\"%s\", val, NULL);\n",
458 typestack = g_list_prepend (typestack, node2);
459 typestack = g_list_prepend (typestack, node1);
460 typestack = g_list_prepend (typestack, node3);
462 push_funcarg ("self", FALSE);
463 push_funcarg ("val", FALSE);
465 typestack = g_list_prepend (typestack, node2);
466 push_function (PUBLIC_SCOPE, REGULAR_METHOD, NULL,
467 set_id, set_cbuf, set_lineno,
468 lineno, FALSE, NULL);
471 node_free ((Node *)the_type);
475 get_prop_enum_flag_cast (Property *prop)
478 if (prop->extra_gtktype == NULL ||
479 /* HACK! just in case someone made this
480 * work with 2.0.0 by using the TYPE
482 ((strstr (prop->extra_gtktype, "_TYPE_") != NULL ||
483 strstr (prop->extra_gtktype, "TYPE_") == prop->extra_gtktype) &&
484 strchr (prop->extra_gtktype, ':') == NULL)) {
485 if (prop->ptype != NULL)
486 return get_type (prop->ptype, TRUE);
488 return g_strdup ("");
490 tmp = remove_sep (prop->extra_gtktype);
491 ret = g_strdup_printf ("(%s) ", tmp);
497 add_construct_glade (char * file, char * root, char * domain)
502 type = (Type *)node_new (TYPE_NODE,
506 initializer = g_strdup_printf("\t{\n"
507 "\tGtkWidget * root;\n"
508 "\t%%1$s->_priv->_glade_xml = glade_xml_new(%s, %s, %s);\n"
509 "\troot = glade_xml_get_widget(%%1$s->_priv->_glade_xml, %s);\n"
510 "\tgtk_widget_show(root);\n"
511 "\tgtk_container_add(GTK_CONTAINER(%%1$s), root);\n"
512 "\tglade_xml_signal_autoconnect_full(%%1$s->_priv->_glade_xml, (GladeXMLConnectFunc)___glade_xml_connect_foreach, (gpointer)%%1$s);\n"
513 "}\n", file, root, domain ? domain : "NULL", root);
515 var = node_new (VARIABLE_NODE,
516 "scope", PRIVATE_SCOPE,
518 "glade_widget", FALSE,
519 "id:steal", "_glade_xml",
520 "destructor_unref", FALSE,
521 "destructor", "g_object_unref",
522 "destructor_simple", TRUE,
523 "initializer", initializer,
524 "initializer_simple", FALSE,
526 class_nodes = g_list_prepend(class_nodes, var);
530 property_link_and_export (Node *node)
532 Property *prop = (Property *)node;
536 char *get = NULL, *set = NULL;
539 if (prop->set != NULL ||
541 error_print (GOB_ERROR, prop->line_no,
542 _("Property linking requested, but "
543 "getters and setters exist"));
546 var = find_var_or_die (prop->name, prop->line_no);
547 if(var->scope == PRIVATE_SCOPE) {
548 root = "self->_priv";
549 } else if (var->scope == CLASS_SCOPE) {
550 root = "SELF_GET_CLASS(self)";
552 error_print (GOB_ERROR, prop->line_no,
553 _("Self aliases needed when autolinking to a classwide member"));
558 if (strcmp (prop->gtktype, "STRING") == 0) {
559 set = g_strdup_printf("{ char *old = %s->%s; "
560 "%s->%s = g_value_dup_string (VAL); g_free (old); }",
563 get = g_strdup_printf("g_value_set_string (VAL, %s->%s);",
565 } else if (strcmp (prop->gtktype, "OBJECT") == 0) {
567 if (prop->extra_gtktype != NULL) {
568 cast = remove_sep (prop->extra_gtktype);
570 cast = g_strdup ("void");
572 set = g_strdup_printf("{ GObject *___old = (GObject *)%s->%s; "
573 "%s->%s = (%s *)g_value_dup_object (VAL); "
574 "if (___old != NULL) { "
575 "g_object_unref (G_OBJECT (___old)); "
581 get = g_strdup_printf ("g_value_set_object (VAL, "
582 "(gpointer)%s->%s);",
585 } else if (strcmp (prop->gtktype, "BOXED") == 0) {
586 char *type = make_me_type (prop->extra_gtktype,
588 if (prop->extra_gtktype == NULL) {
589 error_print (GOB_ERROR, prop->line_no,
590 _("Property linking requested for BOXED, but "
591 "boxed_type not set"));
593 set = g_strdup_printf("{ gpointer ___old = (gpointer)%s->%s; "
594 "gpointer ___new = (gpointer)g_value_get_boxed (VAL); "
595 "if (___new != ___old) { "
596 "if (___old != NULL) g_boxed_free (%s, ___old); "
597 "if (___new != NULL) %s->%s = g_boxed_copy (%s, ___new); "
598 "else %s->%s = NULL;"
606 get = g_strdup_printf("g_value_set_boxed (VAL, %s->%s);",
612 const char *getcast = "";
613 const char *setcast = "";
614 char *to_free = NULL;
615 set_func = g_strdup_printf ("g_value_set_%s", prop->gtktype);
616 g_strdown (set_func);
617 get_func = g_strdup_printf ("g_value_get_%s", prop->gtktype);
618 g_strdown (get_func);
621 if (strcmp (prop->gtktype, "FLAGS") == 0) {
622 setcast = "(guint) ";
624 get_prop_enum_flag_cast (prop);
625 } else if (strcmp (prop->gtktype, "ENUM") == 0) {
628 get_prop_enum_flag_cast (prop);
629 } else if (strcmp (prop->gtktype, "POINTER") == 0) {
630 setcast = "(gpointer) ";
631 getcast = g_strdup_printf ("(%s%s) ",
633 prop->ptype->pointer ? prop->ptype->pointer : "");
637 set = g_strdup_printf("%s->%s = %s%s (VAL);",
641 get = g_strdup_printf("%s (VAL, %s%s->%s);",
653 "get_line", prop->line_no,
655 "set_line", prop->line_no,
660 export_accessors (prop->name,
661 prop->get != NULL, prop->get_line,
662 prop->set != NULL, prop->set_line,
673 if (strcmp (s, "BOOL") == 0) {
674 error_print (GOB_WARN, line_no,
675 _("BOOL type is deprecated, please use BOOLEAN"));
677 return g_strdup ("BOOLEAN");
684 ensure_property (void)
686 if (property == NULL)
687 property = (Property *)node_new (PROPERTY_NODE, NULL);
701 %token CONST VOID STRUCT UNION ENUM THREEDOTS
702 %token SIGNED UNSIGNED LONG SHORT INT FLOAT DOUBLE CHAR
704 %token <id> TOKEN NUMBER TYPETOKEN ARRAY_DIM SINGLE_CHAR
705 %token <cbuf> CCODE CTCODE ADCODE HTCODE PHCODE HCODE ACODE ATCODE STRING
706 %token <line> PUBLIC PRIVATE PROTECTED CLASSWIDE PROPERTY ARGUMENT
707 %token <line> VIRTUAL SIGNAL OVERRIDE
708 %token <line> NAME NICK BLURB MAXIMUM MINIMUM DEFAULT_VALUE ERROR FLAGS TYPE
709 %token <line> FLAGS_TYPE ENUM_TYPE PARAM_TYPE BOXED_TYPE OBJECT_TYPE
713 prog: ccodes class ccodes { ; }
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);
783 Node *node = node_new (CCODE_NODE,
785 "cbuf:steal", ($<cbuf>1)->str,
786 "line_no", ccode_line,
788 nodes = g_list_append(nodes,node);
789 g_string_free($<cbuf>1,FALSE);
793 ccodes: ccodes ccode { ; }
794 | ccodes enumcode { ; }
795 | ccodes flagcode { ; }
796 | ccodes errorcode { ; }
803 class: classdec '{' classcode '}' {
804 ((Class *)class)->nodes = class_nodes;
806 nodes = g_list_append(nodes,class);
809 ((Class *)class)->nodes = NULL;
811 nodes = g_list_append(nodes,class);
815 classdec: CLASS TYPETOKEN FROM TYPETOKEN classflags {
816 class = node_new (CLASS_NODE,
817 "otype:steal", $<id>2,
818 "ptype:steal", $<id>4,
819 "bonobo_object_class:steal", bonobo_object_class,
820 "glade_xml", glade_xml,
821 "interfaces:steal", interfaces,
822 "chunk_size:steal", chunk_size,
823 "abstract", abstract,
825 bonobo_object_class = NULL;
833 | '(' TOKEN ')' classflags {
834 if(strcmp($<id>2,"abstract") == 0) {
837 yyerror(_("parse error"));
841 | '(' TOKEN TOKEN ')' classflags {
842 if(strcmp($<id>2,"chunks") == 0) {
844 chunk_size = g_strdup($<id>3);
845 } else if(strcmp($<id>2,"BonoboObject") == 0) {
846 g_free (bonobo_object_class);
847 bonobo_object_class = g_strdup($<id>3);
849 yyerror(_("parse error"));
853 | '(' TOKEN TYPETOKEN ')' classflags {
854 if (strcmp ($<id>2, "interface") == 0) {
855 interfaces = g_list_append (interfaces,
858 yyerror(_("parse error"));
862 | '(' TOKEN NUMBER ')' classflags {
863 if(strcmp($<id>2,"chunks") == 0) {
865 if(atoi($<id>3) != 0)
866 chunk_size = g_strdup($<id>3);
870 yyerror(_("parse error"));
874 | '(' TOKEN STRING STRING ')' classflags {
875 if (strcmp ($<id>2, "GladeXML") == 0) {
877 add_construct_glade($<id>3, $<id>4, NULL);
879 yyerror(_("parse error"));
883 | '(' TOKEN STRING STRING STRING ')' classflags {
884 if (strcmp ($<id>2, "GladeXML") == 0) {
886 add_construct_glade($<id>3, $<id>4, $<id>5);
888 yyerror(_("parse error"));
892 | '(' TOKEN TOKEN STRING ')' classflags {
893 if (strcmp ($<id>2, "GladeXML") == 0) {
895 add_construct_glade($<id>3, $<id>4, NULL);
897 yyerror(_("parse error"));
901 | '(' TOKEN TOKEN STRING STRING ')' classflags {
902 if (strcmp ($<id>2, "GladeXML") == 0) {
904 add_construct_glade($<id>3, $<id>4, $<id>5);
906 yyerror(_("parse error"));
912 classcode: classcode thing { ; }
918 if (strcmp ($<id>1, "BonoboObject") != 0) {
920 yyerror (_("parse error"));
924 last_added_method->bonobo_object_func = TRUE;
926 | TOKEN TYPETOKEN method {
927 if (strcmp ($<id>1, "interface") != 0) {
930 yyerror (_("parse error"));
934 node_set ((Node *)last_added_method,
935 "interface:steal", $<id>2,
944 scope: PUBLIC { the_scope = PUBLIC_SCOPE; }
945 | PRIVATE { the_scope = PRIVATE_SCOPE; }
946 | PROTECTED { the_scope = PROTECTED_SCOPE; }
947 | CLASSWIDE { the_scope = CLASS_SCOPE; }
950 destructor: TOKEN TOKEN {
951 if (strcmp ($<id>1, "destroywith") == 0) {
953 destructor_unref = FALSE;
955 destructor_line = line_no;
956 destructor_simple = TRUE;
957 } else if (strcmp ($<id>1, "unrefwith") == 0) {
959 destructor_unref = TRUE;
961 destructor_line = line_no;
962 destructor_simple = TRUE;
966 yyerror (_("parse error"));
971 if (strcmp ($<id>1, "destroy") == 0) {
973 destructor_unref = FALSE;
974 destructor = ($<cbuf>3)->str;
975 g_string_free($<cbuf>3, FALSE);
976 destructor_line = ccode_line;
977 destructor_simple = FALSE;
978 } else if (strcmp ($<id>1, "unref") == 0) {
980 destructor_unref = TRUE;
981 destructor = ($<cbuf>3)->str;
982 g_string_free ($<cbuf>3, FALSE);
983 destructor_line = ccode_line;
984 destructor_simple = FALSE;
987 g_string_free ($<cbuf>3, TRUE);
988 yyerror (_("parse error"));
994 initializer: '=' numtok {
995 initializer = $<id>2;
996 initializer_line = ccode_line;
999 initializer = ($<cbuf>3)->str;
1000 initializer_line = ccode_line;
1001 g_string_free($<cbuf>3, FALSE);
1006 varoptions: destructor initializer { ; }
1007 | initializer destructor { ; }
1008 | initializer { destructor = NULL; }
1009 | destructor { initializer = NULL; }
1011 if (strcmp ($<id>1, "GladeXML") == 0) {
1012 glade_widget = TRUE;
1014 yyerror(_("parse error"));
1024 variable: scope type TOKEN varoptions ';' {
1025 push_variable($<id>3, the_scope,$<line>1, NULL);
1027 | scope type TOKEN ARRAY_DIM varoptions ';' {
1028 push_variable($<id>3, the_scope, $<line>1, $<id>4);
1032 argument: ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE TOKEN '{' CCODE ';' {
1034 if(strcmp($<id>6,"get")==0 &&
1035 strcmp($<id>9,"set")==0) {
1036 Type *type = pop_type();
1039 node = node_new (ARGUMENT_NODE,
1040 "gtktype:steal", $<id>3,
1041 "atype:steal", type,
1042 "flags:steal", $<list>2,
1043 "name:steal", $<id>4,
1044 "get:steal", ($<cbuf>8)->str,
1045 "get_line", $<line>7,
1046 "set:steal", ($<cbuf>11)->str,
1047 "set_line", $<line>10,
1048 "line_no", $<line>1,
1051 class_nodes = g_list_append(class_nodes,node);
1053 g_string_free ($<cbuf>8, FALSE);
1054 g_string_free ($<cbuf>11, FALSE);
1056 } else if(strcmp($<id>6,"set")==0 &&
1057 strcmp($<id>9,"get")==0) {
1058 Type *type = pop_type();
1061 node = node_new (ARGUMENT_NODE,
1062 "gtktype:steal", $<id>3,
1063 "atype:steal", type,
1064 "flags:steal", $<list>2,
1065 "name:steal", $<id>4,
1066 "get:steal", ($<cbuf>11)->str,
1067 "get_line", $<line>10,
1068 "set:steal", ($<cbuf>8)->str,
1069 "set_line", $<line>7,
1070 "line_no", $<line>1,
1072 g_string_free ($<cbuf>11, FALSE);
1073 g_string_free ($<cbuf>8, FALSE);
1074 class_nodes = g_list_append(class_nodes,node);
1080 g_list_foreach ($<list>2, (GFunc)g_free, NULL);
1081 g_list_free ($<list>2);
1082 g_string_free ($<cbuf>11, TRUE);
1083 g_string_free ($<cbuf>8, TRUE);
1084 yyerror (_("parse error"));
1088 if ($<id>5 != NULL) {
1089 Argument *arg = (Argument *)node;
1090 export_accessors (arg->name,
1091 arg->get != NULL, arg->get_line,
1092 arg->set != NULL, arg->set_line,
1100 | ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE ';' {
1102 if(strcmp($<id>6, "get") == 0) {
1103 Type *type = pop_type();
1105 node = node_new (ARGUMENT_NODE,
1106 "gtktype:steal", $<id>3,
1107 "atype:steal", type,
1108 "flags:steal", $<list>2,
1109 "name:steal", $<id>4,
1110 "get:steal", ($<cbuf>8)->str,
1111 "get_line", $<line>7,
1112 "line_no", $<line>1,
1115 g_string_free ($<cbuf>8, FALSE);
1116 class_nodes = g_list_append(class_nodes, node);
1117 } else if(strcmp($<id>6, "set") == 0) {
1118 Type *type = pop_type();
1120 node = node_new (ARGUMENT_NODE,
1121 "gtktype:steal", $<id>3,
1122 "atype:steal", type,
1123 "flags:steal", $<list>2,
1124 "name:steal", $<id>4,
1125 "set:steal", ($<cbuf>8)->str,
1126 "set_line", $<line>7,
1127 "line_no", $<line>1,
1130 g_string_free ($<cbuf>8, FALSE);
1131 class_nodes = g_list_append (class_nodes, node);
1136 g_list_foreach ($<list>2, (GFunc)g_free, NULL);
1137 g_list_free ($<list>2);
1138 g_string_free ($<cbuf>8, TRUE);
1139 yyerror(_("parse error"));
1143 if ($<id>5 != NULL) {
1144 Argument *arg = (Argument *)node;
1145 export_accessors (arg->name,
1146 arg->get != NULL, arg->get_line,
1147 arg->set != NULL, arg->set_line,
1154 | ARGUMENT flags argtype TOKEN export TOKEN {
1156 char *get, *set = NULL;
1161 if(strcmp($<id>6, "link")!=0 &&
1162 strcmp($<id>6, "stringlink")!=0 &&
1163 strcmp($<id>6, "objectlink")!=0) {
1167 g_list_foreach($<list>2,(GFunc)g_free,NULL);
1168 g_list_free($<list>2);
1169 yyerror(_("parse error"));
1175 var = find_var_or_die($<id>4, $<line>1);
1176 if(var->scope == PRIVATE_SCOPE) {
1177 root = "self->_priv";
1178 } else if(var->scope == CLASS_SCOPE) {
1179 root = "SELF_GET_CLASS(self)";
1181 error_print(GOB_ERROR, $<line>1,
1182 _("Self aliases needed when autolinking to a classwide member"));
1187 if(strcmp($<id>6, "link")==0) {
1188 set = g_strdup_printf("%s->%s = ARG;",
1190 } else if(strcmp($<id>6, "stringlink")==0) {
1191 set = g_strdup_printf("g_free (%s->%s); "
1192 "%s->%s = g_strdup (ARG);",
1195 } else if(strcmp($<id>6, "objectlink")==0) {
1196 set = g_strdup_printf(
1198 "g_object_ref (G_OBJECT (ARG)); "
1199 "if (%s->%s != NULL) "
1200 "g_object_unref (G_OBJECT (%s->%s)); "
1206 g_assert_not_reached();
1209 get = g_strdup_printf("ARG = %s->%s;", root, $<id>4);
1214 type = (Type *)node_copy ((Node *)var->vtype);
1216 node = node_new (ARGUMENT_NODE,
1217 "gtktype:steal", $<id>3,
1218 "atype:steal", type,
1219 "flags:steal", $<list>2,
1220 "name:steal", $<id>4,
1222 "get_line", $<line>1,
1224 "set_line", $<line>1,
1225 "line_no", $<line>1,
1228 if ($<id>5 != NULL) {
1229 Argument *arg = (Argument *)node;
1230 export_accessors (arg->name,
1231 arg->get != NULL, arg->get_line,
1232 arg->set != NULL, arg->set_line,
1239 class_nodes = g_list_append (class_nodes, node);
1243 export: '(' TOKEN ')' {
1244 if (strcmp ($<id>2, "export")!=0) {
1246 yyerror (_("parse error"));
1256 property: PROPERTY TOKEN TOKEN param_spec TOKEN '{' CCODE TOKEN '{' CCODE ';' {
1258 node_set ((Node *)property,
1259 "line_no", $<line>1,
1260 "gtktype:steal", debool ($<id>2),
1261 "name:steal", $<id>3,
1263 if (strcmp ($<id>5, "get") == 0 &&
1264 strcmp ($<id>8, "set") == 0) {
1265 node_set ((Node *)property,
1266 "get:steal", ($<cbuf>7)->str,
1267 "get_line", $<line>6,
1268 "set:steal", ($<cbuf>10)->str,
1269 "set_line", $<line>9,
1271 g_string_free ($<cbuf>7, FALSE);
1272 g_string_free ($<cbuf>10, FALSE);
1275 } else if (strcmp ($<id>5, "set") == 0 &&
1276 strcmp ($<id>8, "get") == 0) {
1277 node_set ((Node *)property,
1278 "get:steal", ($<cbuf>10)->str,
1279 "get_line", $<line>9,
1280 "set:steal", ($<cbuf>7)->str,
1281 "set_line", $<line>6,
1283 g_string_free ($<cbuf>7, FALSE);
1284 g_string_free ($<cbuf>10, FALSE);
1288 g_string_free ($<cbuf>7, TRUE);
1289 g_string_free ($<cbuf>10, TRUE);
1292 node_free ((Node *)property);
1294 yyerror (_("parse error"));
1297 property_link_and_export ((Node *)property);
1298 if (property != NULL) {
1299 class_nodes = g_list_append (class_nodes,
1304 | PROPERTY TOKEN TOKEN param_spec TOKEN '{' CCODE ';' {
1306 node_set ((Node *)property,
1307 "line_no", $<line>1,
1308 "gtktype:steal", debool ($<id>2),
1309 "name:steal", $<id>3,
1311 if (strcmp ($<id>5, "get") == 0) {
1312 node_set ((Node *)property,
1313 "get:steal", ($<cbuf>7)->str,
1314 "get_line", $<line>6,
1316 g_string_free ($<cbuf>7, FALSE);
1318 } else if (strcmp ($<id>5, "set") == 0) {
1319 node_set ((Node *)property,
1320 "set:steal", ($<cbuf>7)->str,
1321 "set_line", $<line>6,
1323 g_string_free ($<cbuf>7, FALSE);
1326 g_string_free ($<cbuf>7, TRUE);
1328 node_free ((Node *)property);
1330 yyerror (_("parse error"));
1333 property_link_and_export ((Node *)property);
1334 if (property != NULL) {
1335 class_nodes = g_list_append (class_nodes,
1340 | PROPERTY TOKEN TOKEN param_spec ';' {
1342 node_set ((Node *)property,
1343 "line_no", $<line>1,
1344 "gtktype:steal", debool ($<id>2),
1345 "name:steal", $<id>3,
1347 property_link_and_export ((Node *)property);
1348 if (property != NULL) {
1349 class_nodes = g_list_append (class_nodes,
1356 param_spec: '(' param_spec_list ')' { ; }
1360 param_spec_list: param_spec_list ',' param_spec_value { ; }
1361 | param_spec_value { ; }
1364 string: STRING { $<id>$ = $<id>1; }
1365 | TOKEN '(' STRING ')' {
1366 if (strcmp ($<id>1, "_") != 0) {
1368 yyerror(_("parse error"));
1372 $<id>$ = g_strconcat ("_(", $<id>3, ")", NULL);
1377 anyval: numtok { $<id>$ = $<id>1; }
1378 | string { $<id>$ = $<id>1; }
1381 param_spec_value: NAME '=' string {
1383 node_set ((Node *)property,
1384 "canonical_name:steal", gob_str_delete_quotes($<id>3),
1389 node_set ((Node *)property,
1390 "nick:steal", $<id>3,
1393 | BLURB '=' string {
1395 node_set ((Node *)property,
1396 "blurb:steal", $<id>3,
1399 | MAXIMUM '=' numtok {
1401 node_set ((Node *)property,
1402 "maximum:steal", $<id>3,
1405 | MINIMUM '=' numtok {
1407 node_set ((Node *)property,
1408 "minimum:steal", $<id>3,
1411 | DEFAULT_VALUE '=' anyval {
1413 node_set ((Node *)property,
1414 "default_value:steal", $<id>3,
1417 | FLAGS '=' flaglist {
1419 node_set ((Node *)property,
1420 "flags:steal", $<list>3,
1424 Type *type = pop_type ();
1426 node_set ((Node *)property,
1427 "ptype:steal", type,
1430 | FLAGS_TYPE '=' TYPETOKEN {
1432 node_set ((Node *)property,
1433 "extra_gtktype:steal", $<id>3,
1436 | FLAGS_TYPE '=' TOKEN {
1438 node_set ((Node *)property,
1439 "extra_gtktype:steal", $<id>3,
1442 | ENUM_TYPE '=' TYPETOKEN {
1444 node_set ((Node *)property,
1445 "extra_gtktype:steal", $<id>3,
1448 | ENUM_TYPE '=' TOKEN {
1450 node_set ((Node *)property,
1451 "extra_gtktype:steal", $<id>3,
1454 | PARAM_TYPE '=' TYPETOKEN {
1456 node_set ((Node *)property,
1457 "extra_gtktype:steal", $<id>3,
1460 | PARAM_TYPE '=' TOKEN {
1462 node_set ((Node *)property,
1463 "extra_gtktype:steal", $<id>3,
1466 | BOXED_TYPE '=' TYPETOKEN {
1468 node_set ((Node *)property,
1469 "extra_gtktype:steal", $<id>3,
1472 | BOXED_TYPE '=' TOKEN {
1474 node_set ((Node *)property,
1475 "extra_gtktype:steal", $<id>3,
1478 | OBJECT_TYPE '=' TYPETOKEN {
1480 node_set ((Node *)property,
1481 "extra_gtktype:steal", $<id>3,
1484 | OBJECT_TYPE '=' TOKEN {
1486 node_set ((Node *)property,
1487 "extra_gtktype:steal", $<id>3,
1492 if (strcmp ($<id>1, "override") == 0) {
1494 node_set ((Node *)property,
1497 } else if (strcmp ($<id>1, "link") == 0) {
1499 node_set ((Node *)property,
1502 } else if (strcmp ($<id>1, "export") == 0) {
1504 node_set ((Node *)property,
1509 yyerror(_("parse error"));
1515 argtype: TOKEN '(' TOKEN type ')' {
1516 if(strcmp($<id>3,"type")!=0) {
1519 yyerror(_("parse error"));
1522 $<id>$ = debool ($<id>1);
1525 $<id>$ = debool ($<id>1);
1526 typestack = g_list_prepend(typestack,NULL);
1530 flags: '(' flaglist ')' { $<list>$ = $<list>2; }
1531 | { $<list>$ = NULL; }
1534 flaglist: TOKEN '|' flaglist {
1535 $<list>$ = g_list_append($<list>3,$<id>1);
1538 $<list>$ = g_list_append(NULL,$<id>1);
1543 type: specifier_list pointer {
1544 Node *node = node_new (TYPE_NODE,
1545 "name:steal", $<id>1,
1546 "pointer:steal", $<id>2,
1548 typestack = g_list_prepend(typestack,node);
1551 Node *node = node_new (TYPE_NODE,
1552 "name:steal", $<id>1,
1554 typestack = g_list_prepend(typestack,node);
1558 /* The special cases are neccessary to avoid conflicts */
1559 specifier_list: spec_list {
1566 $<id>$ = g_strconcat("const ", $<id>2, NULL);
1570 $<id>$ = g_strconcat($<id>1, " const", NULL);
1573 | strunionenum TOKEN {
1574 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1577 | CONST strunionenum TOKEN {
1578 $<id>$ = g_strconcat("const ", $<id>2, " ",
1582 | strunionenum TOKEN CONST {
1583 $<id>$ = g_strconcat($<id>1, " ",
1584 $<id>2, " const", NULL);
1589 /* The special const cases take care of conflicts ! */
1590 spec_list: specifier spec_list {
1591 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1594 | TYPETOKEN spec_list {
1595 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1600 $<id>$ = g_strconcat("const ", $<id>2, NULL);
1607 $<id>$ = g_strconcat($<id>1, " const", NULL);
1611 $<id>$ = g_strdup($<id>1);
1614 $<id>$ = g_strconcat($<id>1, " const", NULL);
1618 specifier: VOID { $<id>$ = "void"; }
1619 | CHAR { $<id>$ = "char"; }
1620 | SHORT { $<id>$ = "short"; }
1621 | INT { $<id>$ = "int"; }
1622 | LONG { $<id>$ = "long"; }
1623 | FLOAT { $<id>$ = "float"; }
1624 | DOUBLE { $<id>$ = "double"; }
1625 | SIGNED { $<id>$ = "signed"; }
1626 | UNSIGNED { $<id>$ = "unsigned"; }
1629 strunionenum: STRUCT { $<id>$ = "struct"; }
1630 | UNION { $<id>$ = "union"; }
1631 | ENUM { $<id>$ = "enum"; }
1634 pointer: '*' { $<id>$ = g_strdup("*"); }
1635 | '*' CONST { $<id>$ = g_strdup("* const"); }
1637 $<id>$ = g_strconcat("*", $<id>2, NULL);
1640 | '*' CONST pointer {
1641 $<id>$ = g_strconcat("* const", $<id>3, NULL);
1646 /* this never sets the_scope */
1647 simplesigtype: TOKEN sigtype {
1648 if(strcmp($<id>1, "first")==0)
1649 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1650 else if(strcmp($<id>1, "last")==0)
1651 $<sigtype>$ = SIGNAL_LAST_METHOD;
1653 yyerror(_("signal must be 'first' or 'last'"));
1660 $<sigtype>$ = SIGNAL_LAST_METHOD;
1664 /* this always sets the_scope */
1665 fullsigtype: scope TOKEN sigtype {
1666 if(strcmp($<id>2,"first")==0)
1667 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1668 else if(strcmp($<id>2,"last")==0)
1669 $<sigtype>$ = SIGNAL_LAST_METHOD;
1671 yyerror(_("signal must be 'first' or 'last'"));
1677 | TOKEN scope sigtype {
1678 if(strcmp($<id>1,"first")==0)
1679 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1680 else if(strcmp($<id>1,"last")==0)
1681 $<sigtype>$ = SIGNAL_LAST_METHOD;
1683 yyerror(_("signal must be 'first' or 'last'"));
1690 $<sigtype>$ = SIGNAL_LAST_METHOD;
1693 /* the_scope was default thus public */
1694 the_scope = PUBLIC_SCOPE;
1698 sigtype: TOKEN '(' tokenlist ')' {
1699 gtktypes = g_list_prepend(gtktypes, debool ($<id>1));
1701 | TOKEN STRING '(' tokenlist ')' {
1702 gtktypes = g_list_prepend(gtktypes, debool ($<id>1));
1707 tokenlist: tokenlist ',' TOKEN {
1708 gtktypes = g_list_append(gtktypes, debool ($<id>3));
1711 gtktypes = g_list_append(gtktypes, debool ($<id>1));
1715 codenocode: '{' CCODE { $<cbuf>$ = $<cbuf>2; }
1716 | ';' { $<cbuf>$ = NULL; }
1719 /*here CCODE will include the ending '}' */
1720 method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenocode {
1722 yyerror(_("signal without 'self' as "
1723 "first parameter"));
1724 free_all_global_state();
1727 if(the_scope == CLASS_SCOPE) {
1728 yyerror(_("a method cannot be of class scope"));
1729 free_all_global_state();
1732 if (funcattrs != NULL) {
1733 char *error = g_strdup_printf
1734 (_("function attribute macros ('%s' in this case) may not be used with signal methods"),
1739 push_function(the_scope, $<sigtype>3,NULL,
1740 $<id>5, $<cbuf>10,$<line>1,
1741 ccode_line, vararg, $<list>2);
1743 | scope SIGNAL flags simplesigtype type TOKEN '(' funcargs ')' methodmods codenocode {
1745 yyerror(_("signal without 'self' as "
1746 "first parameter"));
1747 free_all_global_state();
1750 if(the_scope == CLASS_SCOPE) {
1751 yyerror(_("a method cannot be of class scope"));
1752 free_all_global_state();
1755 if (funcattrs != NULL) {
1756 char *error = g_strdup_printf
1757 (_("function attribute macros ('%s' in this case) may not be used with signal methods"),
1762 push_function(the_scope, $<sigtype>4, NULL,
1763 $<id>6, $<cbuf>11, $<line>2,
1764 ccode_line, vararg, $<list>3);
1766 | VIRTUAL scope type TOKEN '(' funcargs ')' methodmods codenocode {
1768 yyerror(_("virtual method without 'self' as "
1769 "first parameter"));
1770 free_all_global_state();
1773 if(the_scope == CLASS_SCOPE) {
1774 yyerror(_("a method cannot be of class scope"));
1775 free_all_global_state();
1778 if (funcattrs != NULL) {
1779 char *error = g_strdup_printf
1780 (_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
1785 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
1787 ccode_line, vararg, NULL);
1789 | scope VIRTUAL type TOKEN '(' funcargs ')' methodmods codenocode {
1791 yyerror(_("virtual method without 'self' as "
1792 "first parameter"));
1793 free_all_global_state();
1796 if(the_scope == CLASS_SCOPE) {
1797 yyerror(_("a method cannot be of class scope"));
1798 free_all_global_state();
1801 if (funcattrs != NULL) {
1802 char *error = g_strdup_printf
1803 (_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
1808 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
1810 ccode_line, vararg, NULL);
1812 | VIRTUAL type TOKEN '(' funcargs ')' methodmods codenocode {
1814 yyerror(_("virtual method without 'szelf' as "
1815 "first parameter"));
1816 free_all_global_state();
1819 if (funcattrs != NULL) {
1820 char *error = g_strdup_printf
1821 (_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
1826 push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL,
1827 $<id>3, $<cbuf>8, $<line>1,
1828 ccode_line, vararg, NULL);
1830 | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' methodmods codenocode {
1831 if (funcattrs != NULL) {
1832 char *error = g_strdup_printf
1833 (_("function attribute macros ('%s' in this case) may not be used with override methods"),
1838 push_function(NO_SCOPE, OVERRIDE_METHOD, $<id>3,
1840 $<line>1, ccode_line,
1843 | scope type TOKEN '(' funcargs ')' methodmods codenocode {
1844 if(the_scope == CLASS_SCOPE) {
1845 yyerror(_("a method cannot be of class scope"));
1846 free_all_global_state();
1849 push_function(the_scope, REGULAR_METHOD, NULL, $<id>3,
1850 $<cbuf>8, $<line>1, ccode_line,
1853 | TOKEN '(' TOKEN ')' codenocode {
1854 if(strcmp($<id>1, "init")==0) {
1855 push_init_arg($<id>3,FALSE);
1856 push_function(NO_SCOPE, INIT_METHOD, NULL,
1857 $<id>1, $<cbuf>5, $<line>2,
1858 ccode_line, FALSE, NULL);
1859 } else if(strcmp($<id>1, "class_init")==0) {
1860 push_init_arg($<id>3,TRUE);
1861 push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL,
1862 $<id>1, $<cbuf>5, $<line>2,
1863 ccode_line, FALSE, NULL);
1864 } else if(strcmp($<id>1, "constructor")==0) {
1865 push_init_arg($<id>3, FALSE);
1866 push_function(NO_SCOPE, CONSTRUCTOR_METHOD, NULL,
1867 $<id>1, $<cbuf>5, $<line>2,
1868 ccode_line, FALSE, NULL);
1869 } else if(strcmp($<id>1, "dispose")==0) {
1870 push_init_arg($<id>3, FALSE);
1871 push_function(NO_SCOPE, DISPOSE_METHOD, NULL,
1872 $<id>1, $<cbuf>5, $<line>2,
1873 ccode_line, FALSE, NULL);
1874 } else if(strcmp($<id>1, "finalize")==0) {
1875 push_init_arg($<id>3, FALSE);
1876 push_function(NO_SCOPE, FINALIZE_METHOD, NULL,
1877 $<id>1, $<cbuf>5, $<line>2,
1878 ccode_line, FALSE, NULL);
1883 g_string_free($<cbuf>5,TRUE);
1884 yyerror(_("parse error "
1885 "(untyped blocks must be init, "
1886 "class_init, constructor, dispose "
1893 methodmods: TOKEN retcode {
1894 g_free(funcattrs); funcattrs = NULL;
1895 g_free(onerror); onerror = NULL;
1896 g_free(defreturn); defreturn = NULL;
1897 if(!set_attr_value($<id>1, $<id>2)) {
1900 yyerror(_("parse error"));
1905 | TOKEN retcode TOKEN retcode {
1906 g_free(funcattrs); funcattrs = NULL;
1907 g_free(onerror); onerror = NULL;
1908 g_free(defreturn); defreturn = NULL;
1909 if(!set_attr_value($<id>1, $<id>2)) {
1910 g_free($<id>1); g_free($<id>2);
1911 g_free($<id>3); g_free($<id>4);
1912 yyerror(_("parse error"));
1915 if(!set_attr_value($<id>3, $<id>4)) {
1916 funcattrs = onerror = defreturn = NULL;
1917 g_free($<id>1); g_free($<id>2);
1918 g_free($<id>3); g_free($<id>4);
1919 yyerror(_("parse error"));
1925 | TOKEN retcode TOKEN retcode TOKEN retcode {
1926 g_free(funcattrs); funcattrs = NULL;
1927 g_free(onerror); onerror = NULL;
1928 g_free(defreturn); defreturn = NULL;
1929 if(!set_attr_value($<id>1, $<id>2)) {
1930 g_free($<id>1); g_free($<id>2);
1931 g_free($<id>3); g_free($<id>4);
1932 g_free($<id>5); g_free($<id>6);
1933 yyerror(_("parse error"));
1936 if(!set_attr_value($<id>3, $<id>4)) {
1937 funcattrs = onerror = defreturn = NULL;
1938 g_free($<id>1); g_free($<id>2);
1939 g_free($<id>3); g_free($<id>4);
1940 g_free($<id>5); g_free($<id>6);
1941 yyerror(_("parse error"));
1944 if(!set_attr_value($<id>5, $<id>6)) {
1945 funcattrs = onerror = defreturn = NULL;
1946 g_free($<id>1); g_free($<id>2);
1947 g_free($<id>3); g_free($<id>4);
1948 g_free($<id>5); g_free($<id>6);
1949 yyerror(_("parse error"));
1957 g_free(funcattrs); funcattrs = NULL;
1958 g_free(onerror); onerror = NULL;
1959 g_free(defreturn); defreturn = NULL;
1963 retcode: numtok { $<id>$ = $<id>1; }
1965 $<id>$ = ($<cbuf>2)->str;
1966 g_string_free($<cbuf>2, FALSE);
1970 funcargs: VOID { vararg = FALSE; has_self = FALSE; }
1974 if(strcmp($<id>1,"self")==0)
1975 push_self($<id>1, FALSE);
1978 yyerror(_("parse error"));
1985 if(strcmp($<id>1,"self")==0)
1986 push_self($<id>1, TRUE);
1989 yyerror(_("parse error"));
1996 if(strcmp($<id>2,"self")==0)
1997 push_self($<id>2, TRUE);
2000 yyerror(_("parse error"));
2004 | TOKEN ',' arglist {
2006 if(strcmp($<id>1,"self")==0)
2007 push_self($<id>1, FALSE);
2010 yyerror(_("parse error"));
2014 | TOKEN CONST ',' arglist {
2016 if(strcmp($<id>1,"self")==0)
2017 push_self($<id>1, TRUE);
2020 yyerror(_("parse error"));
2024 | CONST TOKEN ',' arglist {
2026 if(strcmp($<id>2,"self")==0)
2027 push_self($<id>2, TRUE);
2030 yyerror(_("parse error"));
2034 | arglist { has_self = FALSE; }
2037 arglist: arglist1 ',' THREEDOTS { vararg = TRUE; }
2038 | arglist1 { vararg = FALSE; }
2041 arglist1: arglist1 ',' arg { ; }
2046 push_funcarg($<id>2,NULL);
2048 | type TOKEN ARRAY_DIM {
2049 push_funcarg($<id>2,$<id>3);
2051 | type TOKEN '(' TOKEN checklist ')' {
2052 if(strcmp($<id>4,"check")!=0) {
2053 yyerror(_("parse error"));
2057 push_funcarg($<id>2,NULL);
2059 | type TOKEN ARRAY_DIM '(' TOKEN checklist ')' {
2060 if(strcmp($<id>5,"check")!=0) {
2061 yyerror(_("parse error"));
2065 push_funcarg($<id>2,$<id>3);
2069 checklist: checklist check { ; }
2074 if(strcmp($<id>1,"type")==0) {
2075 Node *node = node_new (CHECK_NODE,
2076 "chtype", TYPE_CHECK,
2078 checks = g_list_append(checks,node);
2079 } else if(strcmp($<id>1,"null")==0) {
2080 Node *node = node_new (CHECK_NODE,
2081 "chtype", NULL_CHECK,
2083 checks = g_list_append(checks,node);
2085 yyerror(_("parse error"));
2091 Node *node = node_new (CHECK_NODE,
2093 "number:steal", $<id>2,
2095 checks = g_list_append(checks,node);
2098 Node *node = node_new (CHECK_NODE,
2100 "number:steal", $<id>2,
2102 checks = g_list_append(checks,node);
2105 Node *node = node_new (CHECK_NODE,
2107 "number:steal", $<id>3,
2109 checks = g_list_append(checks,node);
2112 Node *node = node_new (CHECK_NODE,
2114 "number:steal", $<id>3,
2116 checks = g_list_append(checks,node);
2119 Node *node = node_new (CHECK_NODE,
2121 "number:steal", $<id>3,
2123 checks = g_list_append(checks,node);
2126 Node *node = node_new (CHECK_NODE,
2128 "number:steal", $<id>3,
2130 checks = g_list_append(checks,node);
2134 enumcode: ENUM TOKEN '{' enumvals '}' TYPETOKEN ';' {
2135 Node *node = node_new (ENUMDEF_NODE,
2136 "etype:steal", $<id>6,
2137 "prefix:steal", $<id>2,
2138 "values:steal", enum_vals,
2141 nodes = g_list_append (nodes, node);
2143 | ENUM TOKEN '{' enumvals ',' '}' TYPETOKEN ';' {
2144 Node *node = node_new (ENUMDEF_NODE,
2145 "etype:steal", $<id>7,
2146 "prefix:steal", $<id>2,
2147 "values:steal", enum_vals,
2150 nodes = g_list_append (nodes, node);
2154 enumvals: enumvals ',' enumval {;}
2158 enumval: TOKEN '=' numtok {
2162 /* A float value, that's a bad enum */
2163 if (num[0] >= '0' &&
2165 strchr (num, '.') != NULL) {
2168 yyerror(_("parse error (enumerator value not integer constant)"));
2172 node = node_new (ENUMVALUE_NODE,
2173 "name:steal", $<id>1,
2176 enum_vals = g_list_append (enum_vals, node);
2181 node = node_new (ENUMVALUE_NODE,
2182 "name:steal", $<id>1,
2184 enum_vals = g_list_append (enum_vals, node);
2188 flagcode: FLAGS TOKEN '{' flagvals '}' TYPETOKEN ';' {
2189 Node *node = node_new (FLAGS_NODE,
2190 "ftype:steal", $<id>6,
2191 "prefix:steal", $<id>2,
2192 "values:steal", flag_vals,
2195 nodes = g_list_append (nodes, node);
2197 | FLAGS TOKEN '{' flagvals ',' '}' TYPETOKEN ';' {
2198 Node *node = node_new (FLAGS_NODE,
2199 "ftype:steal", $<id>7,
2200 "prefix:steal", $<id>2,
2201 "values:steal", flag_vals,
2204 nodes = g_list_append (nodes, node);
2208 flagvals: flagvals ',' TOKEN {
2209 flag_vals = g_list_append (flag_vals, $<id>3);
2212 flag_vals = g_list_append (flag_vals, $<id>1);
2216 errorcode: ERROR TOKEN '{' errorvals '}' TYPETOKEN ';' {
2217 Node *node = node_new (ERROR_NODE,
2218 "etype:steal", $<id>6,
2219 "prefix:steal", $<id>2,
2220 "values:steal", error_vals,
2223 nodes = g_list_append (nodes, node);
2225 | ERROR TOKEN '{' errorvals ',' '}' TYPETOKEN ';' {
2226 Node *node = node_new (ERROR_NODE,
2227 "etype:steal", $<id>7,
2228 "prefix:steal", $<id>2,
2229 "values:steal", error_vals,
2232 nodes = g_list_append (nodes, node);
2236 errorvals: errorvals ',' TOKEN {
2237 error_vals = g_list_append (error_vals, $<id>3);
2240 error_vals = g_list_append (error_vals, $<id>1);
2245 numtok: NUMBER { $<id>$ = $<id>1; }
2247 $<id>$ = g_strconcat("-",$<id>2,NULL);
2250 | SINGLE_CHAR { $<id>$ = $<id>1; }
2251 | TOKEN { $<id>$ = $<id>1; }