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 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);
775 ccodes: ccodes ccode { ; }
776 | ccodes enumcode { ; }
777 | ccodes flagcode { ; }
778 | ccodes errorcode { ; }
785 class: classdec '{' classcode '}' {
786 ((Class *)class)->nodes = class_nodes;
788 nodes = g_list_append(nodes,class);
791 ((Class *)class)->nodes = NULL;
793 nodes = g_list_append(nodes,class);
797 classdec: CLASS TYPETOKEN FROM TYPETOKEN classflags {
798 class = node_new (CLASS_NODE,
799 "otype:steal", $<id>2,
800 "ptype:steal", $<id>4,
801 "bonobo_object_class:steal", bonobo_object_class,
802 "glade_xml", glade_xml,
803 "interfaces:steal", interfaces,
804 "chunk_size:steal", chunk_size,
805 "abstract", abstract,
807 bonobo_object_class = NULL;
815 | '(' TOKEN ')' classflags {
816 if(strcmp($<id>2,"abstract") == 0) {
819 yyerror(_("parse error"));
823 | '(' TOKEN TOKEN ')' classflags {
824 if(strcmp($<id>2,"chunks") == 0) {
826 chunk_size = g_strdup($<id>3);
827 } else if(strcmp($<id>2,"BonoboObject") == 0) {
828 g_free (bonobo_object_class);
829 bonobo_object_class = g_strdup($<id>3);
831 yyerror(_("parse error"));
835 | '(' TOKEN TYPETOKEN ')' classflags {
836 if (strcmp ($<id>2, "interface") == 0) {
837 interfaces = g_list_append (interfaces,
840 yyerror(_("parse error"));
844 | '(' TOKEN NUMBER ')' classflags {
845 if(strcmp($<id>2,"chunks") == 0) {
847 if(atoi($<id>3) != 0)
848 chunk_size = g_strdup($<id>3);
852 yyerror(_("parse error"));
856 | '(' TOKEN STRING STRING ')' classflags {
857 if (strcmp ($<id>2, "GladeXML") == 0) {
859 add_construct_glade($<id>3, $<id>4, NULL);
861 yyerror(_("parse error"));
865 | '(' TOKEN STRING STRING STRING ')' classflags {
866 if (strcmp ($<id>2, "GladeXML") == 0) {
868 add_construct_glade($<id>3, $<id>4, $<id>5);
870 yyerror(_("parse error"));
874 | '(' TOKEN TOKEN STRING ')' classflags {
875 if (strcmp ($<id>2, "GladeXML") == 0) {
877 add_construct_glade($<id>3, $<id>4, NULL);
879 yyerror(_("parse error"));
883 | '(' TOKEN TOKEN STRING STRING ')' classflags {
884 if (strcmp ($<id>2, "GladeXML") == 0) {
886 add_construct_glade($<id>3, $<id>4, $<id>5);
888 yyerror(_("parse error"));
894 classcode: classcode thing { ; }
900 if (strcmp ($<id>1, "BonoboObject") != 0) {
902 yyerror (_("parse error"));
906 last_added_method->bonobo_object_func = TRUE;
908 | TOKEN TYPETOKEN method {
909 if (strcmp ($<id>1, "interface") != 0) {
912 yyerror (_("parse error"));
916 node_set ((Node *)last_added_method,
917 "interface:steal", $<id>2,
926 scope: PUBLIC { the_scope = PUBLIC_SCOPE; }
927 | PRIVATE { the_scope = PRIVATE_SCOPE; }
928 | PROTECTED { the_scope = PROTECTED_SCOPE; }
929 | CLASSWIDE { the_scope = CLASS_SCOPE; }
932 destructor: TOKEN TOKEN {
933 if (strcmp ($<id>1, "destroywith") == 0) {
935 destructor_unref = FALSE;
937 destructor_line = line_no;
938 destructor_simple = TRUE;
939 } else if (strcmp ($<id>1, "unrefwith") == 0) {
941 destructor_unref = TRUE;
943 destructor_line = line_no;
944 destructor_simple = TRUE;
948 yyerror (_("parse error"));
953 if (strcmp ($<id>1, "destroy") == 0) {
955 destructor_unref = FALSE;
956 destructor = ($<cbuf>3)->str;
957 g_string_free($<cbuf>3, FALSE);
958 destructor_line = ccode_line;
959 destructor_simple = FALSE;
960 } else if (strcmp ($<id>1, "unref") == 0) {
962 destructor_unref = TRUE;
963 destructor = ($<cbuf>3)->str;
964 g_string_free ($<cbuf>3, FALSE);
965 destructor_line = ccode_line;
966 destructor_simple = FALSE;
969 g_string_free ($<cbuf>3, TRUE);
970 yyerror (_("parse error"));
976 initializer: '=' numtok {
977 initializer = $<id>2;
978 initializer_line = ccode_line;
981 initializer = ($<cbuf>3)->str;
982 initializer_line = ccode_line;
983 g_string_free($<cbuf>3, FALSE);
988 varoptions: destructor initializer { ; }
989 | initializer destructor { ; }
990 | initializer { destructor = NULL; }
991 | destructor { initializer = NULL; }
993 if (strcmp ($<id>1, "GladeXML") == 0) {
996 yyerror(_("parse error"));
1006 variable: scope type TOKEN varoptions ';' {
1007 push_variable($<id>3, the_scope,$<line>1, NULL);
1009 | scope type TOKEN ARRAY_DIM varoptions ';' {
1010 push_variable($<id>3, the_scope, $<line>1, $<id>4);
1014 argument: ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE TOKEN '{' CCODE ';' {
1016 if(strcmp($<id>6,"get")==0 &&
1017 strcmp($<id>9,"set")==0) {
1018 Type *type = pop_type();
1021 node = node_new (ARGUMENT_NODE,
1022 "gtktype:steal", $<id>3,
1023 "atype:steal", type,
1024 "flags:steal", $<list>2,
1025 "name:steal", $<id>4,
1026 "get:steal", ($<cbuf>8)->str,
1027 "get_line", $<line>7,
1028 "set:steal", ($<cbuf>11)->str,
1029 "set_line", $<line>10,
1030 "line_no", $<line>1,
1033 class_nodes = g_list_append(class_nodes,node);
1035 g_string_free ($<cbuf>8, FALSE);
1036 g_string_free ($<cbuf>11, FALSE);
1038 } else if(strcmp($<id>6,"set")==0 &&
1039 strcmp($<id>9,"get")==0) {
1040 Type *type = pop_type();
1043 node = node_new (ARGUMENT_NODE,
1044 "gtktype:steal", $<id>3,
1045 "atype:steal", type,
1046 "flags:steal", $<list>2,
1047 "name:steal", $<id>4,
1048 "get:steal", ($<cbuf>11)->str,
1049 "get_line", $<line>10,
1050 "set:steal", ($<cbuf>8)->str,
1051 "set_line", $<line>7,
1052 "line_no", $<line>1,
1054 g_string_free ($<cbuf>11, FALSE);
1055 g_string_free ($<cbuf>8, FALSE);
1056 class_nodes = g_list_append(class_nodes,node);
1062 g_list_foreach ($<list>2, (GFunc)g_free, NULL);
1063 g_list_free ($<list>2);
1064 g_string_free ($<cbuf>11, TRUE);
1065 g_string_free ($<cbuf>8, TRUE);
1066 yyerror (_("parse error"));
1070 if ($<id>5 != NULL) {
1071 Argument *arg = (Argument *)node;
1072 export_accessors (arg->name,
1073 arg->get != NULL, arg->get_line,
1074 arg->set != NULL, arg->set_line,
1082 | ARGUMENT flags argtype TOKEN export TOKEN '{' CCODE ';' {
1084 if(strcmp($<id>6, "get") == 0) {
1085 Type *type = pop_type();
1087 node = node_new (ARGUMENT_NODE,
1088 "gtktype:steal", $<id>3,
1089 "atype:steal", type,
1090 "flags:steal", $<list>2,
1091 "name:steal", $<id>4,
1092 "get:steal", ($<cbuf>8)->str,
1093 "get_line", $<line>7,
1094 "line_no", $<line>1,
1097 g_string_free ($<cbuf>8, FALSE);
1098 class_nodes = g_list_append(class_nodes, node);
1099 } else if(strcmp($<id>6, "set") == 0) {
1100 Type *type = pop_type();
1102 node = node_new (ARGUMENT_NODE,
1103 "gtktype:steal", $<id>3,
1104 "atype:steal", type,
1105 "flags:steal", $<list>2,
1106 "name:steal", $<id>4,
1107 "set:steal", ($<cbuf>8)->str,
1108 "set_line", $<line>7,
1109 "line_no", $<line>1,
1112 g_string_free ($<cbuf>8, FALSE);
1113 class_nodes = g_list_append (class_nodes, node);
1118 g_list_foreach ($<list>2, (GFunc)g_free, NULL);
1119 g_list_free ($<list>2);
1120 g_string_free ($<cbuf>8, TRUE);
1121 yyerror(_("parse error"));
1125 if ($<id>5 != NULL) {
1126 Argument *arg = (Argument *)node;
1127 export_accessors (arg->name,
1128 arg->get != NULL, arg->get_line,
1129 arg->set != NULL, arg->set_line,
1136 | ARGUMENT flags argtype TOKEN export TOKEN {
1138 char *get, *set = NULL;
1143 if(strcmp($<id>6, "link")!=0 &&
1144 strcmp($<id>6, "stringlink")!=0 &&
1145 strcmp($<id>6, "objectlink")!=0) {
1149 g_list_foreach($<list>2,(GFunc)g_free,NULL);
1150 g_list_free($<list>2);
1151 yyerror(_("parse error"));
1157 var = find_var_or_die($<id>4, $<line>1);
1158 if(var->scope == PRIVATE_SCOPE) {
1159 root = "self->_priv";
1160 } else if(var->scope == CLASS_SCOPE) {
1161 root = "SELF_GET_CLASS(self)";
1163 error_print(GOB_ERROR, $<line>1,
1164 _("Self aliases needed when autolinking to a classwide member"));
1169 if(strcmp($<id>6, "link")==0) {
1170 set = g_strdup_printf("%s->%s = ARG;",
1172 } else if(strcmp($<id>6, "stringlink")==0) {
1173 set = g_strdup_printf("g_free (%s->%s); "
1174 "%s->%s = g_strdup (ARG);",
1177 } else if(strcmp($<id>6, "objectlink")==0) {
1178 set = g_strdup_printf(
1180 "g_object_ref (G_OBJECT (ARG)); "
1181 "if (%s->%s != NULL) "
1182 "g_object_unref (G_OBJECT (%s->%s)); "
1188 g_assert_not_reached();
1191 get = g_strdup_printf("ARG = %s->%s;", root, $<id>4);
1196 type = (Type *)node_copy ((Node *)var->vtype);
1198 node = node_new (ARGUMENT_NODE,
1199 "gtktype:steal", $<id>3,
1200 "atype:steal", type,
1201 "flags:steal", $<list>2,
1202 "name:steal", $<id>4,
1204 "get_line", $<line>1,
1206 "set_line", $<line>1,
1207 "line_no", $<line>1,
1210 if ($<id>5 != NULL) {
1211 Argument *arg = (Argument *)node;
1212 export_accessors (arg->name,
1213 arg->get != NULL, arg->get_line,
1214 arg->set != NULL, arg->set_line,
1221 class_nodes = g_list_append (class_nodes, node);
1225 export: '(' TOKEN ')' {
1226 if (strcmp ($<id>2, "export")!=0) {
1228 yyerror (_("parse error"));
1238 property: PROPERTY TOKEN TOKEN param_spec TOKEN '{' CCODE TOKEN '{' CCODE ';' {
1240 node_set ((Node *)property,
1241 "line_no", $<line>1,
1242 "gtktype:steal", debool ($<id>2),
1243 "name:steal", $<id>3,
1245 if (strcmp ($<id>5, "get") == 0 &&
1246 strcmp ($<id>8, "set") == 0) {
1247 node_set ((Node *)property,
1248 "get:steal", ($<cbuf>7)->str,
1249 "get_line", $<line>6,
1250 "set:steal", ($<cbuf>10)->str,
1251 "set_line", $<line>9,
1253 g_string_free ($<cbuf>7, FALSE);
1254 g_string_free ($<cbuf>10, FALSE);
1257 } else if (strcmp ($<id>5, "set") == 0 &&
1258 strcmp ($<id>8, "get") == 0) {
1259 node_set ((Node *)property,
1260 "get:steal", ($<cbuf>10)->str,
1261 "get_line", $<line>9,
1262 "set:steal", ($<cbuf>7)->str,
1263 "set_line", $<line>6,
1265 g_string_free ($<cbuf>7, FALSE);
1266 g_string_free ($<cbuf>10, FALSE);
1270 g_string_free ($<cbuf>7, TRUE);
1271 g_string_free ($<cbuf>10, TRUE);
1274 node_free ((Node *)property);
1276 yyerror (_("parse error"));
1279 property_link_and_export ((Node *)property);
1280 if (property != NULL) {
1281 class_nodes = g_list_append (class_nodes,
1286 | PROPERTY TOKEN TOKEN param_spec TOKEN '{' CCODE ';' {
1288 node_set ((Node *)property,
1289 "line_no", $<line>1,
1290 "gtktype:steal", debool ($<id>2),
1291 "name:steal", $<id>3,
1293 if (strcmp ($<id>5, "get") == 0) {
1294 node_set ((Node *)property,
1295 "get:steal", ($<cbuf>7)->str,
1296 "get_line", $<line>6,
1298 g_string_free ($<cbuf>7, FALSE);
1300 } else if (strcmp ($<id>5, "set") == 0) {
1301 node_set ((Node *)property,
1302 "set:steal", ($<cbuf>7)->str,
1303 "set_line", $<line>6,
1305 g_string_free ($<cbuf>7, FALSE);
1308 g_string_free ($<cbuf>7, TRUE);
1310 node_free ((Node *)property);
1312 yyerror (_("parse error"));
1315 property_link_and_export ((Node *)property);
1316 if (property != NULL) {
1317 class_nodes = g_list_append (class_nodes,
1322 | PROPERTY TOKEN TOKEN param_spec ';' {
1324 node_set ((Node *)property,
1325 "line_no", $<line>1,
1326 "gtktype:steal", debool ($<id>2),
1327 "name:steal", $<id>3,
1329 property_link_and_export ((Node *)property);
1330 if (property != NULL) {
1331 class_nodes = g_list_append (class_nodes,
1338 param_spec: '(' param_spec_list ')' { ; }
1342 param_spec_list: param_spec_list ',' param_spec_value { ; }
1343 | param_spec_value { ; }
1346 string: STRING { $<id>$ = $<id>1; }
1347 | TOKEN '(' STRING ')' {
1348 if (strcmp ($<id>1, "_") != 0) {
1350 yyerror(_("parse error"));
1354 $<id>$ = g_strconcat ("_(", $<id>3, ")", NULL);
1359 anyval: numtok { $<id>$ = $<id>1; }
1360 | string { $<id>$ = $<id>1; }
1363 param_spec_value: NICK '=' string {
1365 node_set ((Node *)property,
1366 "nick:steal", $<id>3,
1369 | BLURB '=' string {
1371 node_set ((Node *)property,
1372 "blurb:steal", $<id>3,
1375 | MAXIMUM '=' numtok {
1377 node_set ((Node *)property,
1378 "maximum:steal", $<id>3,
1381 | MINIMUM '=' numtok {
1383 node_set ((Node *)property,
1384 "minimum:steal", $<id>3,
1387 | DEFAULT_VALUE '=' anyval {
1389 node_set ((Node *)property,
1390 "default_value:steal", $<id>3,
1393 | FLAGS '=' flaglist {
1395 node_set ((Node *)property,
1396 "flags:steal", $<list>3,
1400 Type *type = pop_type ();
1402 node_set ((Node *)property,
1403 "ptype:steal", type,
1406 | FLAGS_TYPE '=' TYPETOKEN {
1408 node_set ((Node *)property,
1409 "extra_gtktype:steal", $<id>3,
1412 | FLAGS_TYPE '=' TOKEN {
1414 node_set ((Node *)property,
1415 "extra_gtktype:steal", $<id>3,
1418 | ENUM_TYPE '=' TYPETOKEN {
1420 node_set ((Node *)property,
1421 "extra_gtktype:steal", $<id>3,
1424 | ENUM_TYPE '=' TOKEN {
1426 node_set ((Node *)property,
1427 "extra_gtktype:steal", $<id>3,
1430 | PARAM_TYPE '=' TYPETOKEN {
1432 node_set ((Node *)property,
1433 "extra_gtktype:steal", $<id>3,
1436 | PARAM_TYPE '=' TOKEN {
1438 node_set ((Node *)property,
1439 "extra_gtktype:steal", $<id>3,
1442 | BOXED_TYPE '=' TYPETOKEN {
1444 node_set ((Node *)property,
1445 "extra_gtktype:steal", $<id>3,
1448 | BOXED_TYPE '=' TOKEN {
1450 node_set ((Node *)property,
1451 "extra_gtktype:steal", $<id>3,
1454 | OBJECT_TYPE '=' TYPETOKEN {
1456 node_set ((Node *)property,
1457 "extra_gtktype:steal", $<id>3,
1460 | OBJECT_TYPE '=' TOKEN {
1462 node_set ((Node *)property,
1463 "extra_gtktype:steal", $<id>3,
1468 if (strcmp ($<id>1, "override") == 0) {
1470 node_set ((Node *)property,
1473 } else if (strcmp ($<id>1, "link") == 0) {
1475 node_set ((Node *)property,
1478 } else if (strcmp ($<id>1, "export") == 0) {
1480 node_set ((Node *)property,
1485 yyerror(_("parse error"));
1491 argtype: TOKEN '(' TOKEN type ')' {
1492 if(strcmp($<id>3,"type")!=0) {
1495 yyerror(_("parse error"));
1498 $<id>$ = debool ($<id>1);
1501 $<id>$ = debool ($<id>1);
1502 typestack = g_list_prepend(typestack,NULL);
1506 flags: '(' flaglist ')' { $<list>$ = $<list>2; }
1507 | { $<list>$ = NULL; }
1510 flaglist: TOKEN '|' flaglist {
1511 $<list>$ = g_list_append($<list>3,$<id>1);
1514 $<list>$ = g_list_append(NULL,$<id>1);
1519 type: specifier_list pointer {
1520 Node *node = node_new (TYPE_NODE,
1521 "name:steal", $<id>1,
1522 "pointer:steal", $<id>2,
1524 typestack = g_list_prepend(typestack,node);
1527 Node *node = node_new (TYPE_NODE,
1528 "name:steal", $<id>1,
1530 typestack = g_list_prepend(typestack,node);
1534 /* The special cases are neccessary to avoid conflicts */
1535 specifier_list: spec_list {
1542 $<id>$ = g_strconcat("const ", $<id>2, NULL);
1546 $<id>$ = g_strconcat($<id>1, " const", NULL);
1549 | strunionenum TOKEN {
1550 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1553 | CONST strunionenum TOKEN {
1554 $<id>$ = g_strconcat("const ", $<id>2, " ",
1558 | strunionenum TOKEN CONST {
1559 $<id>$ = g_strconcat($<id>1, " ",
1560 $<id>2, " const", NULL);
1565 /* The special const cases take care of conflicts ! */
1566 spec_list: specifier spec_list {
1567 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1570 | TYPETOKEN spec_list {
1571 $<id>$ = g_strconcat($<id>1, " ", $<id>2, NULL);
1576 $<id>$ = g_strconcat("const ", $<id>2, NULL);
1583 $<id>$ = g_strconcat($<id>1, " const", NULL);
1587 $<id>$ = g_strdup($<id>1);
1590 $<id>$ = g_strconcat($<id>1, " const", NULL);
1594 specifier: VOID { $<id>$ = "void"; }
1595 | CHAR { $<id>$ = "char"; }
1596 | SHORT { $<id>$ = "short"; }
1597 | INT { $<id>$ = "int"; }
1598 | LONG { $<id>$ = "long"; }
1599 | FLOAT { $<id>$ = "float"; }
1600 | DOUBLE { $<id>$ = "double"; }
1601 | SIGNED { $<id>$ = "signed"; }
1602 | UNSIGNED { $<id>$ = "unsigned"; }
1605 strunionenum: STRUCT { $<id>$ = "struct"; }
1606 | UNION { $<id>$ = "union"; }
1607 | ENUM { $<id>$ = "enum"; }
1610 pointer: '*' { $<id>$ = g_strdup("*"); }
1611 | '*' CONST { $<id>$ = g_strdup("* const"); }
1613 $<id>$ = g_strconcat("*", $<id>2, NULL);
1616 | '*' CONST pointer {
1617 $<id>$ = g_strconcat("* const", $<id>3, NULL);
1622 /* this never sets the_scope */
1623 simplesigtype: TOKEN sigtype {
1624 if(strcmp($<id>1, "first")==0)
1625 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1626 else if(strcmp($<id>1, "last")==0)
1627 $<sigtype>$ = SIGNAL_LAST_METHOD;
1629 yyerror(_("signal must be 'first' or 'last'"));
1636 $<sigtype>$ = SIGNAL_LAST_METHOD;
1640 /* this always sets the_scope */
1641 fullsigtype: scope TOKEN sigtype {
1642 if(strcmp($<id>2,"first")==0)
1643 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1644 else if(strcmp($<id>2,"last")==0)
1645 $<sigtype>$ = SIGNAL_LAST_METHOD;
1647 yyerror(_("signal must be 'first' or 'last'"));
1653 | TOKEN scope sigtype {
1654 if(strcmp($<id>1,"first")==0)
1655 $<sigtype>$ = SIGNAL_FIRST_METHOD;
1656 else if(strcmp($<id>1,"last")==0)
1657 $<sigtype>$ = SIGNAL_LAST_METHOD;
1659 yyerror(_("signal must be 'first' or 'last'"));
1666 $<sigtype>$ = SIGNAL_LAST_METHOD;
1669 /* the_scope was default thus public */
1670 the_scope = PUBLIC_SCOPE;
1674 sigtype: TOKEN '(' tokenlist ')' {
1675 gtktypes = g_list_prepend(gtktypes, debool ($<id>1));
1679 tokenlist: tokenlist ',' TOKEN {
1680 gtktypes = g_list_append(gtktypes, debool ($<id>3));
1683 gtktypes = g_list_append(gtktypes, debool ($<id>1));
1687 codenocode: '{' CCODE { $<cbuf>$ = $<cbuf>2; }
1688 | ';' { $<cbuf>$ = NULL; }
1691 /*here CCODE will include the ending '}' */
1692 method: SIGNAL flags fullsigtype type TOKEN '(' funcargs ')' methodmods codenocode {
1694 yyerror(_("signal without 'self' as "
1695 "first parameter"));
1696 free_all_global_state();
1699 if(the_scope == CLASS_SCOPE) {
1700 yyerror(_("a method cannot be of class scope"));
1701 free_all_global_state();
1704 if (funcattrs != NULL) {
1705 char *error = g_strdup_printf
1706 (_("function attribute macros ('%s' in this case) may not be used with signal methods"),
1711 push_function(the_scope, $<sigtype>3,NULL,
1712 $<id>5, $<cbuf>10,$<line>1,
1713 ccode_line, vararg, $<list>2);
1715 | scope SIGNAL flags simplesigtype type TOKEN '(' funcargs ')' methodmods codenocode {
1717 yyerror(_("signal without 'self' as "
1718 "first parameter"));
1719 free_all_global_state();
1722 if(the_scope == CLASS_SCOPE) {
1723 yyerror(_("a method cannot be of class scope"));
1724 free_all_global_state();
1727 if (funcattrs != NULL) {
1728 char *error = g_strdup_printf
1729 (_("function attribute macros ('%s' in this case) may not be used with signal methods"),
1734 push_function(the_scope, $<sigtype>4, NULL,
1735 $<id>6, $<cbuf>11, $<line>2,
1736 ccode_line, vararg, $<list>3);
1738 | VIRTUAL scope type TOKEN '(' funcargs ')' methodmods codenocode {
1740 yyerror(_("virtual method without 'self' as "
1741 "first parameter"));
1742 free_all_global_state();
1745 if(the_scope == CLASS_SCOPE) {
1746 yyerror(_("a method cannot be of class scope"));
1747 free_all_global_state();
1750 if (funcattrs != NULL) {
1751 char *error = g_strdup_printf
1752 (_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
1757 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
1759 ccode_line, vararg, NULL);
1761 | scope VIRTUAL type TOKEN '(' funcargs ')' methodmods codenocode {
1763 yyerror(_("virtual method without 'self' as "
1764 "first parameter"));
1765 free_all_global_state();
1768 if(the_scope == CLASS_SCOPE) {
1769 yyerror(_("a method cannot be of class scope"));
1770 free_all_global_state();
1773 if (funcattrs != NULL) {
1774 char *error = g_strdup_printf
1775 (_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
1780 push_function(the_scope, VIRTUAL_METHOD, NULL, $<id>4,
1782 ccode_line, vararg, NULL);
1784 | VIRTUAL type TOKEN '(' funcargs ')' methodmods codenocode {
1786 yyerror(_("virtual method without 'szelf' as "
1787 "first parameter"));
1788 free_all_global_state();
1791 if (funcattrs != NULL) {
1792 char *error = g_strdup_printf
1793 (_("function attribute macros ('%s' in this case) may not be used with virtual methods"),
1798 push_function(PUBLIC_SCOPE, VIRTUAL_METHOD, NULL,
1799 $<id>3, $<cbuf>8, $<line>1,
1800 ccode_line, vararg, NULL);
1802 | OVERRIDE '(' TYPETOKEN ')' type TOKEN '(' funcargs ')' methodmods codenocode {
1803 if (funcattrs != NULL) {
1804 char *error = g_strdup_printf
1805 (_("function attribute macros ('%s' in this case) may not be used with override methods"),
1810 push_function(NO_SCOPE, OVERRIDE_METHOD, $<id>3,
1812 $<line>1, ccode_line,
1815 | scope type TOKEN '(' funcargs ')' methodmods codenocode {
1816 if(the_scope == CLASS_SCOPE) {
1817 yyerror(_("a method cannot be of class scope"));
1818 free_all_global_state();
1821 push_function(the_scope, REGULAR_METHOD, NULL, $<id>3,
1822 $<cbuf>8, $<line>1, ccode_line,
1825 | TOKEN '(' TOKEN ')' codenocode {
1826 if(strcmp($<id>1, "init")==0) {
1827 push_init_arg($<id>3,FALSE);
1828 push_function(NO_SCOPE, INIT_METHOD, NULL,
1829 $<id>1, $<cbuf>5, $<line>2,
1830 ccode_line, FALSE, NULL);
1831 } else if(strcmp($<id>1, "class_init")==0) {
1832 push_init_arg($<id>3,TRUE);
1833 push_function(NO_SCOPE, CLASS_INIT_METHOD, NULL,
1834 $<id>1, $<cbuf>5, $<line>2,
1835 ccode_line, FALSE, NULL);
1836 } else if(strcmp($<id>1, "constructor")==0) {
1837 push_init_arg($<id>3, FALSE);
1838 push_function(NO_SCOPE, CONSTRUCTOR_METHOD, NULL,
1839 $<id>1, $<cbuf>5, $<line>2,
1840 ccode_line, FALSE, NULL);
1841 } else if(strcmp($<id>1, "dispose")==0) {
1842 push_init_arg($<id>3, FALSE);
1843 push_function(NO_SCOPE, DISPOSE_METHOD, NULL,
1844 $<id>1, $<cbuf>5, $<line>2,
1845 ccode_line, FALSE, NULL);
1846 } else if(strcmp($<id>1, "finalize")==0) {
1847 push_init_arg($<id>3, FALSE);
1848 push_function(NO_SCOPE, FINALIZE_METHOD, NULL,
1849 $<id>1, $<cbuf>5, $<line>2,
1850 ccode_line, FALSE, NULL);
1855 g_string_free($<cbuf>5,TRUE);
1856 yyerror(_("parse error "
1857 "(untyped blocks must be init, "
1858 "class_init, constructor, dispose "
1865 methodmods: TOKEN retcode {
1866 g_free(funcattrs); funcattrs = NULL;
1867 g_free(onerror); onerror = NULL;
1868 g_free(defreturn); defreturn = NULL;
1869 if(!set_attr_value($<id>1, $<id>2)) {
1872 yyerror(_("parse error"));
1877 | TOKEN retcode TOKEN retcode {
1878 g_free(funcattrs); funcattrs = NULL;
1879 g_free(onerror); onerror = NULL;
1880 g_free(defreturn); defreturn = NULL;
1881 if(!set_attr_value($<id>1, $<id>2)) {
1882 g_free($<id>1); g_free($<id>2);
1883 g_free($<id>3); g_free($<id>4);
1884 yyerror(_("parse error"));
1887 if(!set_attr_value($<id>3, $<id>4)) {
1888 funcattrs = onerror = defreturn = NULL;
1889 g_free($<id>1); g_free($<id>2);
1890 g_free($<id>3); g_free($<id>4);
1891 yyerror(_("parse error"));
1897 | TOKEN retcode TOKEN retcode TOKEN retcode {
1898 g_free(funcattrs); funcattrs = NULL;
1899 g_free(onerror); onerror = NULL;
1900 g_free(defreturn); defreturn = NULL;
1901 if(!set_attr_value($<id>1, $<id>2)) {
1902 g_free($<id>1); g_free($<id>2);
1903 g_free($<id>3); g_free($<id>4);
1904 g_free($<id>5); g_free($<id>6);
1905 yyerror(_("parse error"));
1908 if(!set_attr_value($<id>3, $<id>4)) {
1909 funcattrs = onerror = defreturn = NULL;
1910 g_free($<id>1); g_free($<id>2);
1911 g_free($<id>3); g_free($<id>4);
1912 g_free($<id>5); g_free($<id>6);
1913 yyerror(_("parse error"));
1916 if(!set_attr_value($<id>5, $<id>6)) {
1917 funcattrs = onerror = defreturn = NULL;
1918 g_free($<id>1); g_free($<id>2);
1919 g_free($<id>3); g_free($<id>4);
1920 g_free($<id>5); g_free($<id>6);
1921 yyerror(_("parse error"));
1929 g_free(funcattrs); funcattrs = NULL;
1930 g_free(onerror); onerror = NULL;
1931 g_free(defreturn); defreturn = NULL;
1935 retcode: numtok { $<id>$ = $<id>1; }
1937 $<id>$ = ($<cbuf>2)->str;
1938 g_string_free($<cbuf>2, FALSE);
1942 funcargs: VOID { vararg = FALSE; has_self = FALSE; }
1946 if(strcmp($<id>1,"self")==0)
1947 push_self($<id>1, FALSE);
1950 yyerror(_("parse error"));
1957 if(strcmp($<id>1,"self")==0)
1958 push_self($<id>1, TRUE);
1961 yyerror(_("parse error"));
1968 if(strcmp($<id>2,"self")==0)
1969 push_self($<id>2, TRUE);
1972 yyerror(_("parse error"));
1976 | TOKEN ',' arglist {
1978 if(strcmp($<id>1,"self")==0)
1979 push_self($<id>1, FALSE);
1982 yyerror(_("parse error"));
1986 | TOKEN CONST ',' arglist {
1988 if(strcmp($<id>1,"self")==0)
1989 push_self($<id>1, TRUE);
1992 yyerror(_("parse error"));
1996 | CONST TOKEN ',' arglist {
1998 if(strcmp($<id>2,"self")==0)
1999 push_self($<id>2, TRUE);
2002 yyerror(_("parse error"));
2006 | arglist { has_self = FALSE; }
2009 arglist: arglist1 ',' THREEDOTS { vararg = TRUE; }
2010 | arglist1 { vararg = FALSE; }
2013 arglist1: arglist1 ',' arg { ; }
2018 push_funcarg($<id>2,NULL);
2020 | type TOKEN ARRAY_DIM {
2021 push_funcarg($<id>2,$<id>3);
2023 | type TOKEN '(' TOKEN checklist ')' {
2024 if(strcmp($<id>4,"check")!=0) {
2025 yyerror(_("parse error"));
2029 push_funcarg($<id>2,NULL);
2031 | type TOKEN ARRAY_DIM '(' TOKEN checklist ')' {
2032 if(strcmp($<id>5,"check")!=0) {
2033 yyerror(_("parse error"));
2037 push_funcarg($<id>2,$<id>3);
2041 checklist: checklist check { ; }
2046 if(strcmp($<id>1,"type")==0) {
2047 Node *node = node_new (CHECK_NODE,
2048 "chtype", TYPE_CHECK,
2050 checks = g_list_append(checks,node);
2051 } else if(strcmp($<id>1,"null")==0) {
2052 Node *node = node_new (CHECK_NODE,
2053 "chtype", NULL_CHECK,
2055 checks = g_list_append(checks,node);
2057 yyerror(_("parse error"));
2063 Node *node = node_new (CHECK_NODE,
2065 "number:steal", $<id>2,
2067 checks = g_list_append(checks,node);
2070 Node *node = node_new (CHECK_NODE,
2072 "number:steal", $<id>2,
2074 checks = g_list_append(checks,node);
2077 Node *node = node_new (CHECK_NODE,
2079 "number:steal", $<id>3,
2081 checks = g_list_append(checks,node);
2084 Node *node = node_new (CHECK_NODE,
2086 "number:steal", $<id>3,
2088 checks = g_list_append(checks,node);
2091 Node *node = node_new (CHECK_NODE,
2093 "number:steal", $<id>3,
2095 checks = g_list_append(checks,node);
2098 Node *node = node_new (CHECK_NODE,
2100 "number:steal", $<id>3,
2102 checks = g_list_append(checks,node);
2106 enumcode: ENUM TOKEN '{' enumvals '}' TYPETOKEN ';' {
2107 Node *node = node_new (ENUMDEF_NODE,
2108 "etype:steal", $<id>6,
2109 "prefix:steal", $<id>2,
2110 "values:steal", enum_vals,
2113 nodes = g_list_append (nodes, node);
2115 | ENUM TOKEN '{' enumvals ',' '}' TYPETOKEN ';' {
2116 Node *node = node_new (ENUMDEF_NODE,
2117 "etype:steal", $<id>7,
2118 "prefix:steal", $<id>2,
2119 "values:steal", enum_vals,
2122 nodes = g_list_append (nodes, node);
2126 enumvals: enumvals ',' enumval {;}
2130 enumval: TOKEN '=' numtok {
2134 /* A float value, that's a bad enum */
2135 if (num[0] >= '0' &&
2137 strchr (num, '.') != NULL) {
2140 yyerror(_("parse error (enumerator value not integer constant)"));
2144 node = node_new (ENUMVALUE_NODE,
2145 "name:steal", $<id>1,
2148 enum_vals = g_list_append (enum_vals, node);
2153 node = node_new (ENUMVALUE_NODE,
2154 "name:steal", $<id>1,
2156 enum_vals = g_list_append (enum_vals, node);
2160 flagcode: FLAGS TOKEN '{' flagvals '}' TYPETOKEN ';' {
2161 Node *node = node_new (FLAGS_NODE,
2162 "ftype:steal", $<id>6,
2163 "prefix:steal", $<id>2,
2164 "values:steal", flag_vals,
2167 nodes = g_list_append (nodes, node);
2169 | FLAGS TOKEN '{' flagvals ',' '}' TYPETOKEN ';' {
2170 Node *node = node_new (FLAGS_NODE,
2171 "ftype:steal", $<id>7,
2172 "prefix:steal", $<id>2,
2173 "values:steal", flag_vals,
2176 nodes = g_list_append (nodes, node);
2180 flagvals: flagvals ',' TOKEN {
2181 flag_vals = g_list_append (flag_vals, $<id>3);
2184 flag_vals = g_list_append (flag_vals, $<id>1);
2188 errorcode: ERROR TOKEN '{' errorvals '}' TYPETOKEN ';' {
2189 Node *node = node_new (ERROR_NODE,
2190 "etype:steal", $<id>6,
2191 "prefix:steal", $<id>2,
2192 "values:steal", error_vals,
2195 nodes = g_list_append (nodes, node);
2197 | ERROR TOKEN '{' errorvals ',' '}' TYPETOKEN ';' {
2198 Node *node = node_new (ERROR_NODE,
2199 "etype:steal", $<id>7,
2200 "prefix:steal", $<id>2,
2201 "values:steal", error_vals,
2204 nodes = g_list_append (nodes, node);
2208 errorvals: errorvals ',' TOKEN {
2209 error_vals = g_list_append (error_vals, $<id>3);
2212 error_vals = g_list_append (error_vals, $<id>1);
2217 numtok: NUMBER { $<id>$ = $<id>1; }
2219 $<id>$ = g_strconcat("-",$<id>2,NULL);
2222 | SINGLE_CHAR { $<id>$ = $<id>1; }
2223 | TOKEN { $<id>$ = $<id>1; }