]> git.draconx.ca Git - gob-dx.git/blobdiff - src/parse.y
Release 1.0.9
[gob-dx.git] / src / parse.y
index ba4615b50c16a3f04f5c22a23c307be3d8799ceb..47fdcf2aa98c0af79f4e6305fa682988539aa30d 100644 (file)
@@ -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($<id>2,$<id>4,chunk_size,NULL);
+classdec:      CLASS TYPETOKEN FROM TYPETOKEN  classflags {
+                       class = new_class ($<id>2, $<id>4,
+                                          bonobo_x_class, chunk_size, NULL);
                                                }
        ;
 
-chunk:
-       | '(' TOKEN TOKEN ')' {
+classflags:
+       | '(' TOKEN TOKEN ')' classflags {
                        if(strcmp($<id>2,"chunks") == 0) {
-                                       chunk_size = g_strdup($<id>4);
+                               g_free (chunk_size);
+                               chunk_size = g_strdup($<id>3);
+                       } else if(strcmp($<id>2,"BonoboX") == 0) {
+                               g_free (bonobo_x_class);
+                               bonobo_x_class = g_strdup($<id>3);
                        } else {
                                yyerror(_("parse error"));
                                YYERROR;
                        }
                }
-       | '(' TOKEN NUMBER ')' {
+       | '(' TOKEN NUMBER ')' classflags {
                        if(strcmp($<id>2,"chunks") == 0) {
-                               if(atoi($<id>4) != 0)
-                                       chunk_size = g_strdup($<id>4);
+                               g_free (chunk_size);
+                               if(atoi($<id>3) != 0)
+                                       chunk_size = g_strdup($<id>3);
+                               else
+                                       chunk_size = NULL;
                        } else {
                                yyerror(_("parse error"));
                                YYERROR;
@@ -398,6 +411,14 @@ classcode: classcode thing                 { ; }
        ;
 
 thing:                 method                          { ; }
+       |       TOKEN method                    {
+                       if (strcmp ($<id>1, "BonoboX") != 0) {
+                               g_free($<id>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, $<id>4);
                        } else if(strcmp($<id>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, $<id>4,
-                                 root, $<id>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, $<id>4,
                                  root, $<id>4,
                                  root, $<id>4);