X-Git-Url: https://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/a352a00ec1bf767c9d2655a9ecd966b03cfff24f..4f09fcd75bb0057d90c7431f7db57ca2c5a6c028:/src/parse.y diff --git a/src/parse.y b/src/parse.y index ba4615b..47fdcf2 100644 --- a/src/parse.y +++ b/src/parse.y @@ -36,13 +36,15 @@ GList *nodes = NULL; static GList *class_nodes = NULL; Node *class = NULL; -char *chunk_size = NULL; +static char *chunk_size = NULL; +static char *bonobo_x_class = NULL; static GList *typestack = NULL; static GList *funcargs = NULL; static GList *checks = NULL; static int has_self = FALSE; static int vararg = FALSE; +static Method *last_added_method = NULL; /* destructor and initializer for variables */ static char *destructor = NULL; @@ -168,7 +170,10 @@ push_function(int scope, int method, char *oid, char *id, node = new_method(scope, method, type, oid, gtktypes, flags, id, funcargs, onerror, defreturn, c_cbuf, line_no, - ccode_line, vararg, method_unique_id++); + ccode_line, vararg, method_unique_id++, + FALSE); + + last_added_method = (Method *)node; if(cbuf) g_string_free(cbuf, @@ -368,24 +373,32 @@ class: classdec '{' classcode '}' { } ; -classdec: CLASS TYPETOKEN FROM TYPETOKEN chunk { - class = new_class($2,$4,chunk_size,NULL); +classdec: CLASS TYPETOKEN FROM TYPETOKEN classflags { + class = new_class ($2, $4, + bonobo_x_class, chunk_size, NULL); } ; -chunk: - | '(' TOKEN TOKEN ')' { +classflags: + | '(' TOKEN TOKEN ')' classflags { if(strcmp($2,"chunks") == 0) { - chunk_size = g_strdup($4); + g_free (chunk_size); + chunk_size = g_strdup($3); + } else if(strcmp($2,"BonoboX") == 0) { + g_free (bonobo_x_class); + bonobo_x_class = g_strdup($3); } else { yyerror(_("parse error")); YYERROR; } } - | '(' TOKEN NUMBER ')' { + | '(' TOKEN NUMBER ')' classflags { if(strcmp($2,"chunks") == 0) { - if(atoi($4) != 0) - chunk_size = g_strdup($4); + g_free (chunk_size); + if(atoi($3) != 0) + chunk_size = g_strdup($3); + else + chunk_size = NULL; } else { yyerror(_("parse error")); YYERROR; @@ -398,6 +411,14 @@ classcode: classcode thing { ; } ; thing: method { ; } + | TOKEN method { + if (strcmp ($1, "BonoboX") != 0) { + g_free($1); + yyerror(_("parse error")); + YYERROR; + } + last_added_method->bonobo_x_func = TRUE; + } | variable { ; } | argument { ; } | ';' { ; } @@ -573,13 +594,11 @@ argument: ARGUMENT flags argtype TOKEN TOKEN '{' CCODE TOKEN '{' CCODE ';' { root, $4); } else if(strcmp($5, "objectlink")==0) { set = g_strdup_printf( - "if(%s->%s) " - "gtk_object_unref(GTK_OBJECT(%s->%s)); " - "%s->%s = ARG; " - "if(%s->%s) " - "gtk_object_ref(GTK_OBJECT(%s->%s));", - root, $4, - root, $4, + "if (ARG != NULL) " + "gtk_object_ref (GTK_OBJECT (ARG)); " + "if (%s->%s != NULL) " + "gtk_object_unref (GTK_OBJECT (%s->%s)); " + "%s->%s = ARG;", root, $4, root, $4, root, $4);