]> git.draconx.ca Git - gob-dx.git/blobdiff - src/main.c
Release 1.0.9
[gob-dx.git] / src / main.c
index a3682d1acd411fabda5ae01d3d50240f79a77f49..f60175774e8d66e853d41731c390c96d75f506c9 100644 (file)
@@ -559,7 +559,8 @@ make_inits(Class *cl)
                                  NULL, NULL, NULL, g_strdup("class_init"),
                                  make_func_arg(cl->otype, TRUE, g_strdup("c")),
                                  NULL, NULL, NULL, 0, 0, FALSE,
-                                 method_unique_id++);
+                                 method_unique_id++,
+                                 FALSE /*bonobo_x_func*/);
                cl->nodes = g_list_prepend(cl->nodes, node);
        }
        if(!got_init) {
@@ -569,7 +570,8 @@ make_inits(Class *cl)
                                  NULL, NULL, NULL, g_strdup("init"),
                                  make_func_arg(cl->otype, FALSE, g_strdup("o")),
                                  NULL, NULL, NULL, 0, 0, FALSE,
-                                 method_unique_id++);
+                                 method_unique_id++,
+                                 FALSE /*bonobo_x_func*/);
                cl->nodes = g_list_prepend(cl->nodes, node);
        }
 }
@@ -850,6 +852,49 @@ add_get_type(void)
                   "}\n\n");
 }
 
+static void
+add_bonobo_x_get_type (void)
+{
+       char *chunk_size = ((Class*)class)->chunk_size;
+       
+       out_printf(out,
+                  "GtkType\n"
+                  "%s_get_type (void)\n"
+                  "{\n"
+                  "\tstatic GtkType type = 0;\n\n"
+                  "\tif (type == 0) {\n"
+                  "\t\tstatic const GtkTypeInfo info = {\n"
+                  "\t\t\t\"%s\",\n"
+                  "\t\t\tsizeof (%s),\n"
+                  "\t\t\tsizeof (%sClass),\n"
+                  "\t\t\t(GtkClassInitFunc) %s_class_init,\n"
+                  "\t\t\t(GtkObjectInitFunc) %s_init,\n"
+                  "\t\t\t/* reserved_1 */ NULL,\n"
+                  "\t\t\t/* reserved_2 */ NULL,\n"
+                  "\t\t\t(GtkClassInitFunc) NULL\n"
+                  "\t\t};\n\n"
+                  "\t\ttype = bonobo_x_type_unique\n"
+                  "\t\t\t(%s_get_type (),\n"
+                  "\t\t\tPOA_%s__init, NULL,\n"
+                  "\t\t\tGTK_STRUCT_OFFSET (%sClass, _epv),\n"
+                  "\t\t\t&info);\n",
+                  funcbase, typebase, typebase, typebase,
+                  funcbase, funcbase, pfuncbase,
+                  ((Class*)class)->bonobo_x_class,
+                  typebase);
+       if(chunk_size)  {
+               out_printf(out,
+                          "#if %s > 0\n"
+                          "\t\tgtk_type_set_chunk_alloc(type, %s);\n"
+                          "#endif\n", 
+                          chunk_size, chunk_size);
+       }
+       out_printf(out,
+                  "\t}\n\n"
+                  "\treturn type;\n"
+                  "}\n\n");
+}
+
 static void
 add_overrides(Class *c, const char *oname, gboolean did_base_obj)
 {
@@ -1356,6 +1401,36 @@ add_finalize(Class *c)
                   "#undef __GOB_FUNCTION__\n\n");
 }
 
+static void
+make_bonobo_x_epv (Class *c, const char *classname)
+{
+       GList *li;
+       gboolean added_line = FALSE;
+
+       for (li = c->nodes; li != NULL; li = li->next) {
+               Node *n = li->data;
+               Method *m = (Method *)n;
+               if(n->type != METHOD_NODE ||
+                  m->method == OVERRIDE_METHOD)
+                       continue;
+
+               if (m->bonobo_x_func) {
+                       if(m->line_no > 0) {
+                               out_addline_infile(out, m->line_no);
+                               added_line = TRUE;
+                       } else if (m->line_no == 0 &&
+                                  added_line) {
+                               out_addline_outfile(out);
+                               added_line = FALSE;
+                       }
+                       out_printf (out, "\t%s->_epv.%s = %s;\n",
+                                   classname, m->id, m->id);
+               }
+       }
+       if (added_line)
+               out_addline_outfile(out);
+}
+
 static void
 add_inits(Class *c)
 {
@@ -1479,6 +1554,9 @@ add_inits(Class *c)
                        if(get_arguments > 0 || set_arguments > 0)
                                make_arguments(c);
 
+                       if (c->bonobo_x_class != NULL) {
+                               make_bonobo_x_epv (c, ((FuncArg *)m->args->data)->name);
+                       }
                } else
                        continue;
 
@@ -1677,6 +1755,8 @@ print_preconditions(Method *m)
 static void
 print_method_body(Method *m, int pre)
 {
+       if (m->line_no > 0)
+               out_addline_outfile(out);
        out_printf(out, "{\n"
                   "#define __GOB_FUNCTION__ \"%s::%s\"\n",
                   ((Class *)class)->otype,
@@ -2278,6 +2358,13 @@ print_class_block(Class *c)
                if(n->type == METHOD_NODE)
                        put_vs_method((Method *)n);
        }
+       /* If BonoboX type class put down the epv */
+       if (c->bonobo_x_class != NULL) {
+               out_printf (outh,
+                           "\t/* Bonobo object epv */\n"
+                           "\tPOA_%s__epv _epv;\n",
+                           c->bonobo_x_class);
+       }
        /* put class scope variables */
        for(l = c->nodes; l != NULL; l = l->next) {
                Node *n = l->data;
@@ -2304,11 +2391,13 @@ print_class_block(Class *c)
                   " * Public methods\n"
                   " */\n");
 
-       out_printf(outh, "GtkType\t%s_get_type\t(void)", funcbase);
-       if ( ! no_gnu) {
-               out_printf(outh, " G_GNUC_CONST;\n");
-       } else {
-               out_printf(outh, ";\n");
+       if ( ! overrode_get_type) {
+               out_printf(outh, "GtkType\t%s_get_type\t(void)", funcbase);
+               if ( ! no_gnu) {
+                       out_printf(outh, " G_GNUC_CONST;\n");
+               } else {
+                       out_printf(outh, ";\n");
+               }
        }
 
        for(l = c->nodes; l != NULL; l = l->next) {
@@ -2362,8 +2451,12 @@ print_class_block(Class *c)
 
        add_enums(c);
 
-       if ( ! overrode_get_type)
-               add_get_type();
+       if ( ! overrode_get_type) {
+               if (c->bonobo_x_class != NULL)
+                       add_bonobo_x_get_type ();
+               else
+                       add_get_type ();
+       }
 
        if(any_method_to_alias(c)) {
                if( ! no_gnu) {