]> git.draconx.ca Git - gob-dx.git/blobdiff - src/main.c
Release 0.90.5
[gob-dx.git] / src / main.c
index 35ebda6cf1f63a7a7ddd71465c1b302b159c7ddc..e55600609017600f1a98430a99c2a89638611fc3 100644 (file)
@@ -49,6 +49,7 @@ static char *funcbase;
 static char *pfuncbase;
 static char *macrobase;
 static char *macrois;
+static char *macrotype;
 static char *typebase;
 static char *ptypebase;
 
@@ -132,17 +133,19 @@ separns_replace_sep(char *base, char **ns, char **name, char r)
                *name = s;
 }
 
+/* make a macro with some prefix before the name but after
+   namespace */
 static char *
-make_is_macro(char *base)
+make_pre_macro(char *base, char *pre)
 {
        char *s1,*s2;
        char *s;
 
        separns_replace_sep(base,&s1,&s2,'_');
        if(s1)
-               s = g_strconcat(s1,"_IS_",s2,NULL);
+               s = g_strconcat(s1,"_",pre,"_",s2,NULL);
        else
-               s = g_strconcat("IS_",s2,NULL);
+               s = g_strconcat(pre,"_",s2,NULL);
 
        g_strup(s);
        
@@ -167,7 +170,8 @@ make_bases(void)
        macrobase = replace_sep(((Class *)class)->otype,'_');
        g_strup(macrobase);
        
-       macrois = make_is_macro(((Class *)class)->otype);
+       macrois = make_pre_macro(((Class *)class)->otype,"IS");
+       macrotype = make_pre_macro(((Class *)class)->otype,"TYPE");
 
        typebase = remove_sep(((Class *)class)->otype);
 
@@ -900,7 +904,7 @@ print_checks(Method *m, FuncArg *fa)
                        out_printf(out,"%s != NULL",fa->name);
                        break;
                case TYPE_CHECK:
-                       s = make_is_macro(fa->atype->name);
+                       s = make_pre_macro(fa->atype->name,"IS");
                        out_printf(out,"%s (%s)",s,fa->name);
                        g_free(s);
                        break;
@@ -1075,7 +1079,15 @@ put_method(Method *m)
        case OVERRIDE_METHOD:
                out_addline_infile(out,m->line_no);
                print_method(out,"static ","\n"," ","\n",m,FALSE);
+               s = replace_sep(m->otype,'_');
+               g_strup(s);
+               out_printf(out,"#define PARENT_HANDLER(args...) \\\n"
+                          "\t{ if(%s_CLASS(parent_class)->%s) \\\n"
+                          "\t\t(* %s_CLASS(parent_class)->%s)(##args); }\n",
+                          s,m->id,s,m->id);
+               g_free(s);
                print_method_body(m,TRUE);
+               out_printf(out,"#undef PARENT_HANDLER\n");
                break;
        default:
                break;
@@ -1103,7 +1115,8 @@ check_duplicate(Class *c,Node *node,char *id, int line_no)
                        continue;
                if(n==node ||
                   line_no>=nline_no ||
-                  strcmp(nid,id)!=0)
+                  strcmp(nid,id)!=0 ||
+                  n->type != node->type)
                        continue;
                s = g_strdup_printf("symbol '%s' redefined, "
                                    "first defined on line %d",
@@ -1352,8 +1365,11 @@ generate_outfiles(void)
                        signals = count_signals(c);
                        arguments = count_arguments(c);
                        overrides = count_overrides(c);
-                       
-                       out_printf(outh,"\n#define %s(obj)\t"
+
+                       out_printf(outh,"\n#define %s\t"
+                               "(%s_get_type())\n",
+                               macrotype,funcbase);
+                       out_printf(outh,"#define %s(obj)\t"
                                "GTK_CHECK_CAST((obj),%s_get_type(),%s)\n",
                                macrobase,funcbase,typebase);
                        out_printf(outh,"#define %s_CLASS(klass)\t"