gboolean exit_on_warn = FALSE;
gboolean exit_on_error = TRUE;
gboolean got_error = FALSE;
-gint private_header = PRIVATE_HEADER_ALWAYS;
+gint private_header = PRIVATE_HEADER_ONDEMAND;
gboolean no_extern_c = FALSE;
gboolean no_write = FALSE;
gboolean no_lines = FALSE;
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) {
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);
}
}
}
static void
-print_signal_marsal_args(Method *m)
+print_signal_marsal_args_gtk1 (Method *m)
{
if(strcmp(m->gtktypes->next->data, "NONE")!=0) {
GList *li;
out_printf(out, ",\n\t\tfunc_data);\n}\n\n");
}
+static void
+add_marshal_gtk1 (Method *m, const char *mname)
+{
+ out_printf(out, "\nstatic void\n"
+ "___marshal_%s (GtkObject * object,\n"
+ "\tGtkSignalFunc func,\n"
+ "\tgpointer func_data,\n"
+ "\tGtkArg * args)\n"
+ "{\n", mname);
+
+ if(strcmp(m->gtktypes->data, "NONE")==0) {
+ out_printf(out, "\t___%s rfunc;\n\n"
+ "\trfunc = (___%s)func;\n\n"
+ "\t(*rfunc)((%s *)object", mname, mname, typebase);
+ } else {
+ const char *retcast = get_cast(m->gtktypes->data, FALSE);
+ gboolean is_none = (strcmp(m->gtktypes->next->data, "NONE")==0);
+ out_printf(out,
+ "\t___%s rfunc;\n\t"
+ "%s *retval;\n\n"
+ "\trfunc = (___%s)func;\n\n"
+ "\tretval = GTK_RETLOC_%s(args[%d]);\n\n"
+ "\t*retval = (*rfunc)((%s *)object",
+ mname, retcast, mname,
+ (char *)m->gtktypes->data,
+ g_list_length(m->gtktypes) - (is_none ? 2 : 1),
+ typebase);
+ }
+ print_signal_marsal_args_gtk1 (m);
+}
+
+static const char *
+gtk2_debool (const char *s)
+{
+ if (strcmp (s, "BOOL") == 0)
+ return "BOOLEAN";
+ else
+ return s;
+}
+
+static void
+print_signal_marsal_args_gtk2 (Method *m)
+{
+ if (strcmp (m->gtktypes->next->data, "NONE") != 0) {
+ GList *li;
+ int i;
+ for (i = 0, li = m->gtktypes->next;
+ li != NULL;
+ i++, li = li->next) {
+ char *get_func = g_strdup_printf
+ ("g_value_get_%s",
+ (char *)gtk2_debool (li->data));
+ g_strdown (get_func);
+ out_printf (out, ",\n\t\t(%s) "
+ "%s (param_values + %d)",
+ get_cast (li->data, FALSE),
+ get_func, i + 1);
+ g_free (get_func);
+ }
+ }
+ out_printf (out, ",\n\t\tdata2);\n");
+}
+
+static void
+add_marshal_gtk2 (Method *m, const char *mname)
+{
+ gboolean ret_none;
+ gboolean arglist_none;
+ const char *retcast;
+
+ ret_none = strcmp (m->gtktypes->data, "NONE") == 0;
+ arglist_none = strcmp (m->gtktypes->next->data, "NONE") == 0;
+
+ if (ret_none)
+ retcast = NULL;
+ else
+ retcast = get_cast (m->gtktypes->data, FALSE);
+
+ out_printf (out, "\nstatic void\n"
+ "___marshal_%s (GClosure *closure,\n"
+ "\tGValue *return_value,\n"
+ "\tguint n_param_values,\n"
+ "\tconst GValue *param_values,\n"
+ "\tgpointer invocation_hint,\n"
+ "\tgpointer marshal_data)\n"
+ "{\n", mname);
+
+ if ( ! ret_none)
+ out_printf (out, "\t%s v_return;\n", retcast);
+
+ out_printf (out, "\tregister ___%s callback;\n"
+ "\tregister GCClosure *cc = (GCClosure*) closure;\n"
+ "\tregister gpointer data1, data2;\n\n",
+ mname);
+
+ out_printf (out, "\tg_return_if_fail (n_param_values == %d);\n\n",
+ arglist_none ? 1 : g_list_length (m->gtktypes));
+
+ out_printf (out,
+ "\tif (G_CCLOSURE_SWAP_DATA (closure)) {\n"
+ "\t\tdata1 = closure->data;\n"
+ "\t\tdata2 = g_value_peek_pointer (param_values + 0);\n"
+ "\t} else {\n"
+ "\t\tdata1 = g_value_peek_pointer (param_values + 0);\n"
+ "\t\tdata2 = closure->data;\n"
+ "\t}\n\n");
+
+ out_printf (out, "\tcallback = (___%s) "
+ "(marshal_data != NULL ? marshal_data : cc->callback);"
+ "\n\n", mname);
+
+ if (ret_none) {
+ out_printf (out, "\tcallback ((%s *)data1", typebase);
+ } else {
+ out_printf (out, "\tv_return = callback ((%s *)data1",
+ typebase);
+ }
+
+ print_signal_marsal_args_gtk2 (m);
+
+ if ( ! ret_none) {
+ /* FIXME: This code is so fucking ugly it hurts */
+ gboolean take_ownership =
+ (strcmp ((char *)m->gtktypes->data, "STRING") == 0 ||
+ strcmp ((char *)m->gtktypes->data, "BOXED") == 0);
+ char *set_func = g_strdup_printf ("g_value_set_%s%s",
+ (char *)gtk2_debool (m->gtktypes->data),
+ take_ownership ?
+ "_take_ownership" : "");
+ g_strdown (set_func);
+
+ out_printf (out, "\n\t%s (return_value, v_return);\n",
+ set_func);
+
+ g_free (set_func);
+ }
+ out_printf (out, "}\n\n");
+}
+
+
static void
add_signal_prots(Method *m)
g_hash_table_insert(marsh, m, s);
eq_signal_methods = g_list_prepend(eq_signal_methods, m);
-
+
/* we know that we'll know all the gtktypes (so get_cast can't fail) */
out_printf(out, "\ntypedef %s (*___%s) (%s *, ",
get_cast(m->gtktypes->data, FALSE), s, typebase);
- if(strcmp(m->gtktypes->next->data, "NONE")!=0) {
- for(li=m->gtktypes->next; li; li=g_list_next(li))
+ if (strcmp (m->gtktypes->next->data, "NONE") != 0) {
+ for (li = m->gtktypes->next; li != NULL; li = li->next)
out_printf(out, "%s, ", get_cast(li->data, FALSE));
}
- out_printf(out, "gpointer);\n");
-
- out_printf(out, "\nstatic void\n"
- "___marshal_%s (GtkObject * object,\n"
- "\tGtkSignalFunc func,\n"
- "\tgpointer func_data,\n"
- "\tGtkArg * args)\n"
- "{\n", s);
+ out_printf (out, "gpointer);\n");
- if(strcmp(m->gtktypes->data, "NONE")==0) {
- out_printf(out, "\t___%s rfunc;\n\n"
- "\trfunc = (___%s)func;\n\n"
- "\t(*rfunc)((%s *)object", s, s, typebase);
- } else {
- const char *retcast = get_cast(m->gtktypes->data, FALSE);
- out_printf(out,
- "\t___%s rfunc;\n\t"
- "%s *retval;\n\n"
- "\trfunc = (___%s)func;\n\n"
- "\tretval = GTK_RETLOC_%s(args[%d]);\n\n"
- "\t*retval = (*rfunc)((%s *)object",
- s, retcast, s, (char *)m->gtktypes->data,
- g_list_length(m->gtktypes)-1, typebase);
- }
- print_signal_marsal_args(m);
+ out_printf (out, "\n#ifdef G_OBJECT_CLASS\n");
+ add_marshal_gtk2 (m, s);
+ out_printf (out, "#else /* ! G_OBJECT_CLASS */\n");
+ add_marshal_gtk1 (m, s);
+ out_printf (out, "#endif /* G_OBJECT_CLASS */\n\n");
}
static 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)
{
}
}
- out_printf(out, "\tgtk_object_class_add_signals (gtk_object_class,\n"
- "\t\tobject_signals, LAST_SIGNAL);\n\n");
+ out_printf (out, "#ifndef G_OBJECT_CLASS\n");
+ out_printf (out, "\tgtk_object_class_add_signals (gtk_object_class,\n"
+ "\t\tobject_signals, LAST_SIGNAL);\n");
+ out_printf (out, "#endif /* ! G_OBJECT_CLASS */\n\n");
}
static void
"#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)
{
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;
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,
out_printf(out, "#define SELF(x) %s(x)\n", macrobase);
out_printf(out, "#define SELF_CONST(x) %s_CONST(x)\n", macrobase);
out_printf(out, "#define IS_SELF(x) %s(x)\n", macrois);
+ out_printf(out, "#define TYPE_SELF %s\n", macrotype);
out_printf(out, "#define SELF_CLASS(x) %s_CLASS(x)\n\n",
macrobase);
out_printf(out, "#define SELF_GET_CLASS(x) %s_GET_CLASS(x)\n\n",
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;
" * 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) {
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) {