static gboolean special_array[SPECIAL_LAST] = {0};
static gboolean any_special = FALSE;
-static gboolean need_shutdown = FALSE;
-static Method * shutdown_handler = NULL;
+static gboolean need_dispose = FALSE;
+static Method * dispose_handler = NULL;
static gboolean need_finalize = FALSE;
static Method * finalize_handler = NULL;
}
static void
-add_bad_hack_to_avoid_unused_warnings(Class *c)
+add_bad_hack_to_avoid_unused_warnings(const Class *c)
{
GList *li;
}
static void
-put_variable(Variable *v, FILE *fp)
+put_variable(const Variable *v, FILE *fp)
{
out_printf(fp, "\t");
print_type(fp, v->vtype, FALSE);
}
static void
-put_priv_method_prot(Method *m)
+put_priv_method_prot(const Method *m)
{
if(m->method == SIGNAL_LAST_METHOD ||
m->method == SIGNAL_FIRST_METHOD ||
}
static void
-find_shutdown(Class *cl)
+find_dispose(const Class *cl)
{
GList *li;
- shutdown_handler = NULL;
+ dispose_handler = NULL;
for(li=cl->nodes;li;li=g_list_next(li)) {
Node *n = li->data;
if(n->type == METHOD_NODE) {
Method *m = (Method *)n;
if(m->method == OVERRIDE_METHOD &&
- strcmp(m->id, "shutdown")==0) {
+ strcmp(m->id, "dispose")==0) {
if(strcmp(m->otype, "G:Object") != 0) {
error_print(GOB_ERROR, m->line_no,
- "shutdown method override "
+ "dispose method override "
"of class other then "
"G:Object");
}
if(g_list_length(m->args) != 1) {
error_print(GOB_ERROR, m->line_no,
- "shutdown method override "
+ "dispose method override "
"with more then one "
"parameter");
}
- shutdown_handler = m;
+ dispose_handler = m;
break;
}
}
}
static void
-find_finalize(Class *cl)
+find_finalize(const Class *cl)
{
GList *li;
/* compare a list of strings */
static gboolean
-is_list_equal(GList *a, GList *b)
+is_list_equal(const GList *a, const GList *b)
{
for(;a && b; a=a->next, b=b->next) {
if(strcmp(a->data, b->data)!=0) {
}
static Method *
-find_same_type_signal(Method *m)
+find_same_type_signal(const Method *m)
{
GList *li;
for(li=eq_signal_methods;li;li=li->next) {
}
static void
-print_signal_marsal_args (Method *m)
+print_signal_marsal_args (const Method *m)
{
if (strcmp (m->gtktypes->next->data, "NONE") != 0) {
GList *li;
for (i = 0, li = m->gtktypes->next;
li != NULL;
i++, li = li->next) {
- char *get_func = g_strdup_printf
- ("g_value_get_%s", (char *)li->data);
+ char *get_func;
+
+ if (strcmp (li->data, "UNICHAR") == 0)
+ /* hack because glib is braindamaged */
+ get_func = g_strdup ("g_value_get_uint");
+ else
+ get_func = g_strdup_printf
+ ("g_value_get_%s", (char *)li->data);
+
g_strdown (get_func);
out_printf (out, ",\n\t\t(%s) "
"%s (param_values + %d)",
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 *)m->gtktypes->data,
- take_ownership ?
+ char *set_func;
+
+
+ if (strcmp (m->gtktypes->data, "UNICHAR") == 0)
+ /* hack because glib is braindamaged */
+ set_func = g_strdup ("g_value_set_uint");
+ else
+ set_func = g_strdup_printf ("g_value_set_%s%s",
+ (char *)m->gtktypes->data,
+ take_ownership ?
"_take_ownership" : "");
g_strdown (set_func);
if(strcmp(m->gtktypes->data, "NONE") != 0 ||
! is_none) {
GList *gl, *al;
- char *sep = "";
+ const char *sep = "";
out_printf(out, "\tif(");
if(strcmp(m->gtktypes->data, "NONE") != 0) {
out_printf(out, "%s sizeof(", sep);
s = replace_sep (m->otype, '_');
g_strdown (s);
- if (need_shutdown &&
- shutdown_handler != NULL &&
- strcmp (m->id, "shutdown") == 0)
- out_printf (out, "\tg_object_class->shutdown "
- "= ___shutdown;\n");
+ if (need_dispose &&
+ dispose_handler != NULL &&
+ strcmp (m->id, "dispose") == 0)
+ out_printf (out, "\tg_object_class->dispose "
+ "= ___dispose;\n");
else if (need_finalize &&
finalize_handler &&
strcmp(m->id, "finalize") == 0)
static void
print_destructor (Variable *v)
{
- char *root;
+ const char *root;
if(v->destructor == NULL)
return;
}
static void
-add_shutdown (Class *c)
+add_dispose (Class *c)
{
out_printf(out, "\nstatic void\n"
- "___shutdown (GObject *obj_self)\n"
+ "___dispose (GObject *obj_self)\n"
"{\n");
out_printf(out,
- "#define __GOB_FUNCTION__ \"%s::shutdown\"\n",
+ "#define __GOB_FUNCTION__ \"%s::dispose\"\n",
c->otype);
if (unreftors > 0) {
typebase, macrobase);
}
- if (shutdown_handler != NULL) {
+ if (dispose_handler != NULL) {
/* so we get possible bad argument warning */
- if (shutdown_handler->line_no > 0)
- out_addline_infile (out, shutdown_handler->line_no);
- out_printf (out, "\t___%x_%s_shutdown(obj_self);\n",
- (guint)shutdown_handler->unique_id, funcbase);
- if (shutdown_handler->line_no > 0)
+ if (dispose_handler->line_no > 0)
+ out_addline_infile (out, dispose_handler->line_no);
+ out_printf (out, "\t___%x_%s_dispose(obj_self);\n",
+ (guint)dispose_handler->unique_id, funcbase);
+ if (dispose_handler->line_no > 0)
out_addline_outfile (out);
} else {
out_printf (out,
- "\tif (G_OBJECT_CLASS (parent_class)->shutdown) \\\n"
- "\t\t(* G_OBJECT_CLASS (parent_class)->shutdown) (obj_self);\n");
+ "\tif (G_OBJECT_CLASS (parent_class)->dispose) \\\n"
+ "\t\t(* G_OBJECT_CLASS (parent_class)->dispose) (obj_self);\n");
}
if (unreftors > 0) {
if (set_properties > 0 ||
get_properties > 0 ||
signals > 0 ||
- need_shutdown ||
+ need_dispose ||
need_finalize) {
out_printf(out,
"\tGObjectClass *"
/* if there are no handlers for these things, we
* need to set them up here */
- if(need_shutdown && !shutdown_handler)
- out_printf(out, "\tg_object_class->shutdown "
- "= ___shutdown;\n");
+ if(need_dispose && !dispose_handler)
+ out_printf(out, "\tg_object_class->dispose "
+ "= ___dispose;\n");
if(need_finalize && !finalize_handler)
out_printf(out, "\tg_object_class->finalize = "
"___finalize;\n");
the_type_lower = g_strdup (a->gtktype);
g_strdown (the_type_lower);
+ /* HACK because there is no g_value_set/get for unichar */
+ if (strcmp (the_type_lower, "unichar") == 0) {
+ g_free (the_type_lower);
+ the_type_lower = g_strdup ("uint");
+ }
+
if (is_set) {
char *cast;
"\tg_value_init (&___param_values[%d], G_TYPE_%s);\n",
i, i, (char *)ali->data);
- set_func = g_strdup_printf ("g_value_set%s_%s",
- do_static ? "_static" : "",
- (char *)ali->data);
+ if (strcmp (ali->data, "UNICHAR") == 0)
+ /* hack because glib is braindamaged */
+ set_func = g_strdup ("g_value_set_uint");
+ else
+ set_func = g_strdup_printf ("g_value_set%s_%s",
+ do_static ? "_static" : "",
+ (char *)ali->data);
g_strdown (set_func);
out_printf (out, "\t%s (&___param_values[%d], (%s) %s);\n\n",
}
static char *
-get_arg_names_for_macro(Method *m)
+get_arg_names_for_macro (Method *m)
{
- char *p;
+ const char *sep;
GList *li;
GString *gs = g_string_new(NULL);
- p = "";
+ sep = "";
for(li=m->args;li;li=g_list_next(li)) {
FuncArg *arg = li->data;
- g_string_sprintfa(gs, "%s___%s", p, arg->name);
- p = ",";
+ g_string_sprintfa (gs, "%s___%s", sep, arg->name);
+ sep = ",";
}
- p = gs->str;
- g_string_free(gs, FALSE);
- return p;
+ return g_string_free (gs, FALSE);
}
static void
if (cast == NULL)
cast = get_type (m->mtype, TRUE);
- set_func = g_strdup_printf ("g_value_set%s_%s",
- do_static ? "_static" : "",
- (char *)m->gtktypes->data);
+ if (strcmp (m->gtktypes->data, "UNICHAR") == 0)
+ /* hack because glib is braindamaged */
+ set_func = g_strdup ("g_value_set_uint");
+ else
+ set_func = g_strdup_printf ("g_value_set%s_%s",
+ do_static ? "_static" : "",
+ (char *)m->gtktypes->data);
g_strdown (set_func);
out_printf (out, "\t%s (&___return_val, (%s) (%s));\n",
if (strcmp (m->gtktypes->data, "NONE") != 0) {
char *cast = g_strdup (get_cast (m->gtktypes->data, FALSE));
- char *getfunc = g_strdup_printf ("g_value_get_%s",
- (char *)m->gtktypes->data);
+ char *getfunc;
+
+ if (strcmp (m->gtktypes->data, "UNICHAR") == 0)
+ /* hack because glib is braindamaged */
+ getfunc = g_strdup ("g_value_get_uint");
+ else
+ getfunc = g_strdup_printf ("g_value_get_%s",
+ (char *)m->gtktypes->data);
g_strdown (getfunc);
if (cast == NULL)
" */\n");
if ( ! overrode_get_type) {
- out_printf (outh, "GType\t%s_get_type\t(void)", funcbase);
- if ( ! no_gnu) {
- out_printf (outh, " G_GNUC_CONST;\n");
- } else {
- out_printf (outh, ";\n");
- }
+ out_printf (outh, "GType\t%s_get_type\t(void);", funcbase);
}
for(li = c->nodes; li != NULL; li = li->next) {
no_gnu ? "" : " G_GNUC_UNUSED",
typebase, typebase, typebase, funcbase);
- if (need_shutdown)
- add_shutdown (c);
+ if (need_dispose)
+ add_dispose (c);
if (need_finalize)
add_finalize (c);
make_bases ();
make_inits ((Class *)class);
if(unreftors > 0) {
- need_shutdown = TRUE;
- find_shutdown ((Class *)class);
+ need_dispose = TRUE;
+ find_dispose ((Class *)class);
}
if (destructors > 0 ||
privates > 0) {