"\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\t(GtkClassInitFunc) NULL\n"
"\t\t};\n\n"
"\t\ttype = gtk_type_unique (%s_get_type(), &info);\n",
funcbase, typebase, typebase, typebase,
}
static void
-add_overrides(Class *c, char *oname, gboolean did_gtk_obj)
+add_overrides(Class *c, char *oname, gboolean did_base_obj)
{
GList *li;
GHashTable *done;
char *s;
done = g_hash_table_new(g_str_hash, g_str_equal);
- if(did_gtk_obj) {
+ if(did_base_obj) {
s = g_strdup("GtkObject"); /* This was already done */
g_hash_table_insert(done, s, s);
+ s = g_strdup("GObject"); /* This was probably already done as well (if using Gtk/Glib 1.3/2.0) */
+ g_hash_table_insert(done, s, s);
}
for(li=c->nodes; li; li=g_list_next(li)) {
Node *n = li->data;
out_printf(out, "\tobject_signals[%s_SIGNAL] =\n"
"\t\tgtk_signal_new (\"%s\",\n"
"\t\t\t(GtkSignalRunType)(%s),\n"
- "\t\t\tgtk_object_class->type,\n"
+ "\t\t\tGTK_CLASS_TYPE(gtk_object_class),\n"
"\t\t\tGTK_SIGNAL_OFFSET (%sClass, %s),\n"
"\t\t\t%s,\n"
"\t\t\tGTK_TYPE_%s, %d",
else if(need_finalize &&
finalize_handler &&
strcmp(m->id, "finalize") == 0)
- out_printf(out, "\tgtk_object_class->finalize "
- "= ___finalize;\n");
+ out_printf(out,
+ "#ifdef G_OBJECT_CLASS\n"
+ "\tg_object_class->finalize = ___finalize;\n"
+ "#else /* !G_OBJECT_CLASS */\n"
+ "\tgtk_object_class->finalize = ___finalize;\n"
+ "#endif /* G_OBJECT_CLASS */\n");
else if(m->cbuf)
out_printf(out,
"\t%s_class->%s = ___%x_%s_%s;\n",
out_printf(out, "\nstatic void\n"
"___destroy(GtkObject *obj_self)\n"
"{\n");
+ out_printf(out,
+ "#define __GOB_FUNCTION__ \"%s::destroy\"\n",
+ c->otype);
if(destructors > 0) {
out_printf(out, "\t%s *self G_GNUC_UNUSED = %s (obj_self);\n",
(guint)destroy_handler->unique_id, funcbase);
if(destroy_handler->line_no > 0)
out_addline_outfile(out);
+ } else {
+ out_printf(out,
+ "\tif(GTK_OBJECT_CLASS(parent_class)->destroy) \\\n"
+ "\t\t(* GTK_OBJECT_CLASS(parent_class)->destroy)(obj_self);\n");
}
if(destructors > 0) {
}
}
- out_printf(out, "}\n\n");
+ out_printf(out, "}\n"
+ "#undef __GOB_FUNCTION__\n\n");
}
static void
add_finalize(Class *c)
{
- out_printf(out, "\nstatic void\n"
+ /* Sort of a hack to make it work with gtk+ 1.3/2.0 */
+ out_printf(out,
+ "\n#ifdef G_OBJECT_CLASS\n"
+ "static void\n"
+ "___finalize(GObject *obj_self)\n"
+ "#else /* !G_OBJECT_CLASS */\n"
+ "static void\n"
"___finalize(GtkObject *obj_self)\n"
+ "#endif /* G_OBJECT_CLASS */\n"
"{\n");
+ out_printf(out,
+ "#define __GOB_FUNCTION__ \"%s::finalize\"\n",
+ c->otype);
if(privates > 0) {
out_printf(out, "\t%s *self = %s (obj_self);\n",
(guint)finalize_handler->unique_id, funcbase);
if(finalize_handler->line_no > 0)
out_addline_outfile(out);
+ } else {
+ /* Sort of a hack to make it work with gtk+ 1.3/2.0 */
+ out_printf(out,
+ "#ifdef G_OBJECT_CLASS\n"
+ "\tif(G_OBJECT_CLASS(parent_class)->finalize) \\\n"
+ "\t\t(* G_OBJECT_CLASS(parent_class)->finalize)(obj_self);\n"
+ "#else /* !G_OBJECT_CLASS */\n"
+ "\tif(GTK_OBJECT_CLASS(parent_class)->finalize) \\\n"
+ "\t\t(* GTK_OBJECT_CLASS(parent_class)->finalize)(obj_self);\n"
+ "#endif /* G_OBJECT_CLASS */\n");
}
if(privates > 0) {
"\tself->_priv = NULL;\n");
}
- out_printf(out, "}\n\n");
+ out_printf(out, "}\n"
+ "#undef __GOB_FUNCTION__\n\n");
}
static void
}
}
} else if(m->method == CLASS_INIT_METHOD) {
- gboolean did_gtk_obj = FALSE;
+ gboolean did_base_obj = FALSE;
if(m->line_no > 0)
out_addline_infile(out, m->line_no);
need_finalize) {
out_printf(out,
"\tGtkObjectClass *"
- "gtk_object_class = "
+ "gtk_object_class G_GNUC_UNUSED = "
"(GtkObjectClass*) %s;\n",
((FuncArg *)m->args->data)->name);
- did_gtk_obj = TRUE;
+ out_printf(out,
+ "#ifdef G_OBJECT_CLASS\n"
+ "\tGObjectClass *"
+ "g_object_class G_GNUC_UNUSED = "
+ "(GObjectClass*) %s;\n"
+ "#endif /* G_OBJECT_CLASS */\n",
+ ((FuncArg *)m->args->data)->name);
+ did_base_obj = TRUE;
}
if(overrides > 0)
add_overrides(c,
((FuncArg *)m->args->data)->name,
- did_gtk_obj);
+ did_base_obj);
if(initializers > 0) {
GList *li;
out_printf(out, "\tgtk_object_class->destroy "
"= ___destroy;\n");
if(need_finalize && !finalize_handler)
- out_printf(out, "\tgtk_object_class->finalize "
- "= ___finalize;\n");
+ out_printf(out,
+ "#ifdef G_OBJECT_CLASS\n"
+ "\tg_object_class->finalize = ___finalize;\n"
+ "#else /* !G_OBJECT_CLASS */\n"
+ "\tgtk_object_class->finalize = ___finalize;\n"
+ "#endif /* G_OBJECT_CLASS */\n");
if(arguments > 0)
make_arguments(c);
out_printf(out, "{\n"
"\t%sClass *klass;\n", typebase);
print_preconditions(m);
- out_printf(out, "\tklass = %s_CLASS(GTK_OBJECT(%s)->klass);\n\n"
+ out_printf(out, "\tklass = %s_GET_CLASS(%s);\n\n"
"\tif(klass->%s)\n",
macrobase, ((FuncArg *)m->args->data)->name,
get_real_id(m->id));
"(%s_get_type())\n",
macrotype, funcbase);
out_printf(outh, "#define %s(obj)\t"
- "GTK_CHECK_CAST((obj), %s_get_type(),%s)\n",
+ "GTK_CHECK_CAST((obj), %s_get_type(), %s)\n",
macrobase, funcbase, typebase);
+ out_printf(outh, "#define %s_CONST(obj)\t"
+ "GTK_CHECK_CAST((obj), %s_get_type(), %s const)\n",
+ macrobase, funcbase, typebase);
out_printf(outh, "#define %s_CLASS(klass)\t"
- "GTK_CHECK_CLASS_CAST((klass),%s_get_type(),%sClass)\n",
+ "GTK_CHECK_CLASS_CAST((klass), %s_get_type(), %sClass)\n",
macrobase, funcbase, typebase);
out_printf(outh, "#define %s(obj)\t"
- "GTK_CHECK_TYPE((obj),%s_get_type ())\n\n",
+ "GTK_CHECK_TYPE((obj), %s_get_type ())\n\n",
macrois, funcbase);
+ out_printf(outh, "#ifdef GTK_CHECK_GET_CLASS\n"
+ "#define %s_GET_CLASS(obj)\t"
+ "GTK_CHECK_GET_CLASS((obj), %s_get_type(), %sClass)\n",
+ macrobase, funcbase, typebase);
+ out_printf(outh, "#else /* !GTK_CHECK_GET_CLASS */\n"
+ "#define %s_GET_CLASS(obj)\t"
+ "((%sClass *)GTK_OBJECT(obj)->klass)\n"
+ "#endif /* GTK_CHECK_GET_CLASS */\n",
+ macrobase, typebase);
if( ! no_self_alias) {
out_printf(out, "/* self casting macros */\n");
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 SELF_CLASS(x) %s_CLASS(x)\n\n",
macrobase);
+ out_printf(out, "#define SELF_GET_CLASS(x) %s_GET_CLASS(x)\n\n",
+ macrobase);
out_printf(out, "/* self typedefs */\n");
out_printf(out, "typedef %s Self;\n", typebase);
out_printf(out, "typedef %sClass SelfClass;\n\n", typebase);
}
+ out_printf(out, "/* GTK_CLASS_TYPE for 1.2<->1.3/2.0 GTK+ compatibility */\n");
+ out_printf(out,
+ "#ifndef GTK_CLASS_TYPE\n"
+ "#define GTK_CLASS_TYPE(x) (GTK_OBJECT_CLASS(x)->type)\n"
+ "#endif /* GTK_CLASS_TYPE */\n\n");
+
if(privates > 0 || always_private_struct) {
out_printf(outh, "\n/* Private structure type */\n");
out_printf(outh, "typedef struct _%sPrivate %sPrivate;\n",
out_printf(outh,
"struct _%sClass {\n\t%sClass __parent__;\n",
typebase, ptypebase);
- for(l=c->nodes;l;l=g_list_next(l)) {
+ for(l = c->nodes; l != NULL; l = l->next) {
Node *n = l->data;
if(n->type == METHOD_NODE)
put_vs_method((Method *)n);
}
/* put class scope variables */
- for(l=c->nodes;l;l=g_list_next(l)) {
+ for(l = c->nodes; l != NULL; l = l->next) {
Node *n = l->data;
Variable *v = (Variable *)n;
if(n->type == VARIABLE_NODE &&
out_printf(outh, "};\n\n");
out_printf(out, "/* here are local prototypes */\n");
- if(arguments>0) {
+ if(arguments > 0) {
out_printf(out, "static void ___object_set_arg "
"(GtkObject *object, GtkArg *arg, "
"guint arg_id);\n"
" */\n");
out_printf(outh, "guint\t%s_get_type\t(void);\n", funcbase);
- for(l=c->nodes;l;l=g_list_next(l)) {
+ for(l = c->nodes; l != NULL; l = l->next) {
Node *n = l->data;
if(n->type == METHOD_NODE) {
put_pub_method((Method *)n);
/* argument wrapping macros */
- if(arguments>0 && !no_gnu) {
+ if(arguments > 0 && ! no_gnu) {
out_printf(outh, "\n/*\n"
" * Argument wrapping macros\n"
" */\n");
out_printf(outh, "#else /* __GNUC__ */\n");
put_argument_nongnu_wrappers(c);
out_printf(outh, "#endif /* __GNUC__ */\n\n");
- } else if(arguments>0 && no_gnu) {
+ } else if(arguments > 0 && no_gnu) {
out_printf(outh, "\n/*\n"
" * Argument wrapping macros\n"
" */\n");
put_argument_nongnu_wrappers(c);
}
- if(signals>0) {
- for(l=c->nodes;l;l=g_list_next(l)) {
+ if(signals > 0) {
+ for(l = c->nodes; l != NULL; l = l->next) {
Node *n = l->data;
if(n->type == METHOD_NODE)
add_signal_prots((Method *)n);
add_inits(c);
- if(arguments>0) {
+ if(arguments > 0) {
add_getset_arg(c, TRUE);
add_getset_arg(c, FALSE);
}
- for(l=c->nodes;l;l=g_list_next(l)) {
+ for(l = c->nodes; l != NULL; l = l->next) {
Node *n = l->data;
if(n->type == METHOD_NODE)
put_method((Method *)n);