added a "release_check" to the OutArgument structure, which, if present,

2001-07-26  Michael Natterer  <mitch@convergence.de>

	* gobject/glib-genmarshal.c: added a "release_check" to the
	OutArgument structure, which, if present, gets integrated in the
	marshaller code and protects us from stuff like
	g_object_unref(NULL) on marshaller return values.
This commit is contained in:
Michael Natterer 2001-07-26 10:36:01 +00:00 committed by Michael Natterer
parent 8caf4a8c43
commit 9b25010f22
9 changed files with 90 additions and 21 deletions

View File

@ -1,3 +1,10 @@
2001-07-26 Michael Natterer <mitch@convergence.de>
* gobject/glib-genmarshal.c: added a "release_check" to the
OutArgument structure, which, if present, gets integrated in the
marshaller code and protects us from stuff like
g_object_unref(NULL) on marshaller return values.
2001-07-23 Padraig O'Briain <Padraig.Obriain@sun.com>
* gobject/gobjectnotifyqueue.c: fix unconditional check of

View File

@ -1,3 +1,10 @@
2001-07-26 Michael Natterer <mitch@convergence.de>
* gobject/glib-genmarshal.c: added a "release_check" to the
OutArgument structure, which, if present, gets integrated in the
marshaller code and protects us from stuff like
g_object_unref(NULL) on marshaller return values.
2001-07-23 Padraig O'Briain <Padraig.Obriain@sun.com>
* gobject/gobjectnotifyqueue.c: fix unconditional check of

View File

@ -1,3 +1,10 @@
2001-07-26 Michael Natterer <mitch@convergence.de>
* gobject/glib-genmarshal.c: added a "release_check" to the
OutArgument structure, which, if present, gets integrated in the
marshaller code and protects us from stuff like
g_object_unref(NULL) on marshaller return values.
2001-07-23 Padraig O'Briain <Padraig.Obriain@sun.com>
* gobject/gobjectnotifyqueue.c: fix unconditional check of

View File

@ -1,3 +1,10 @@
2001-07-26 Michael Natterer <mitch@convergence.de>
* gobject/glib-genmarshal.c: added a "release_check" to the
OutArgument structure, which, if present, gets integrated in the
marshaller code and protects us from stuff like
g_object_unref(NULL) on marshaller return values.
2001-07-23 Padraig O'Briain <Padraig.Obriain@sun.com>
* gobject/gobjectnotifyqueue.c: fix unconditional check of

View File

@ -1,3 +1,10 @@
2001-07-26 Michael Natterer <mitch@convergence.de>
* gobject/glib-genmarshal.c: added a "release_check" to the
OutArgument structure, which, if present, gets integrated in the
marshaller code and protects us from stuff like
g_object_unref(NULL) on marshaller return values.
2001-07-23 Padraig O'Briain <Padraig.Obriain@sun.com>
* gobject/gobjectnotifyqueue.c: fix unconditional check of

View File

@ -1,3 +1,10 @@
2001-07-26 Michael Natterer <mitch@convergence.de>
* gobject/glib-genmarshal.c: added a "release_check" to the
OutArgument structure, which, if present, gets integrated in the
marshaller code and protects us from stuff like
g_object_unref(NULL) on marshaller return values.
2001-07-23 Padraig O'Briain <Padraig.Obriain@sun.com>
* gobject/gobjectnotifyqueue.c: fix unconditional check of

View File

@ -1,3 +1,10 @@
2001-07-26 Michael Natterer <mitch@convergence.de>
* gobject/glib-genmarshal.c: added a "release_check" to the
OutArgument structure, which, if present, gets integrated in the
marshaller code and protects us from stuff like
g_object_unref(NULL) on marshaller return values.
2001-07-23 Padraig O'Briain <Padraig.Obriain@sun.com>
* gobject/gobjectnotifyqueue.c: fix unconditional check of

View File

@ -1,3 +1,10 @@
2001-07-26 Michael Natterer <mitch@convergence.de>
* gobject/glib-genmarshal.c: added a "release_check" to the
OutArgument structure, which, if present, gets integrated in the
marshaller code and protects us from stuff like
g_object_unref(NULL) on marshaller return values.
2001-07-23 Padraig O'Briain <Padraig.Obriain@sun.com>
* gobject/gobjectnotifyqueue.c: fix unconditional check of

View File

@ -62,6 +62,7 @@ typedef struct
const gchar *ctype; /* C type name [gchar*] */
const gchar *setter; /* value setter function [g_value_set_string] */
const gchar *release; /* value release function [g_free] */
const gchar *release_check; /* checks if release function is safe to call */
} OutArgument;
typedef struct
{
@ -177,27 +178,27 @@ static gboolean
complete_out_arg (OutArgument *oarg)
{
static const OutArgument args[] = {
/* keyword sig_name ctype setter release */
{ "VOID", "VOID", "void", NULL, NULL, },
{ "BOOLEAN", "BOOLEAN", "gboolean", "g_value_set_boolean", NULL, },
{ "CHAR", "CHAR", "gchar", "g_value_set_char", NULL, },
{ "UCHAR", "UCHAR", "guchar", "g_value_set_uchar", NULL, },
{ "INT", "INT", "gint", "g_value_set_int", NULL, },
{ "UINT", "UINT", "guint", "g_value_set_uint", NULL, },
{ "LONG", "LONG", "glong", "g_value_set_long", NULL, },
{ "ULONG", "ULONG", "gulong", "g_value_set_ulong", NULL, },
{ "ENUM", "ENUM", "gint", "g_value_set_enum", NULL, },
{ "FLAGS", "FLAGS", "guint", "g_value_set_flags", NULL, },
{ "FLOAT", "FLOAT", "gfloat", "g_value_set_float", NULL, },
{ "DOUBLE", "DOUBLE", "gdouble", "g_value_set_double", NULL, },
{ "STRING", "STRING", "gchar*", "g_value_set_string_take_ownership", NULL, },
{ "PARAM", "PARAM", "GParamSpec*", "g_value_set_param", "g_param_spec_unref", },
{ "BOXED", "BOXED", "gpointer", "g_value_set_boxed_take_ownership", NULL, },
{ "POINTER", "POINTER", "gpointer", "g_value_set_pointer", NULL, },
{ "OBJECT", "OBJECT", "GObject*", "g_value_set_object", "g_object_unref", },
/* keyword sig_name ctype setter release release_check */
{ "VOID", "VOID", "void", NULL, NULL, NULL },
{ "BOOLEAN", "BOOLEAN", "gboolean", "g_value_set_boolean", NULL, NULL },
{ "CHAR", "CHAR", "gchar", "g_value_set_char", NULL, NULL },
{ "UCHAR", "UCHAR", "guchar", "g_value_set_uchar", NULL, NULL },
{ "INT", "INT", "gint", "g_value_set_int", NULL, NULL },
{ "UINT", "UINT", "guint", "g_value_set_uint", NULL, NULL },
{ "LONG", "LONG", "glong", "g_value_set_long", NULL, NULL },
{ "ULONG", "ULONG", "gulong", "g_value_set_ulong", NULL, NULL },
{ "ENUM", "ENUM", "gint", "g_value_set_enum", NULL, NULL },
{ "FLAGS", "FLAGS", "guint", "g_value_set_flags", NULL, NULL },
{ "FLOAT", "FLOAT", "gfloat", "g_value_set_float", NULL, NULL },
{ "DOUBLE", "DOUBLE", "gdouble", "g_value_set_double", NULL, NULL },
{ "STRING", "STRING", "gchar*", "g_value_set_string_take_ownership", NULL, NULL },
{ "PARAM", "PARAM", "GParamSpec*", "g_value_set_param", "g_param_spec_unref", NULL },
{ "BOXED", "BOXED", "gpointer", "g_value_set_boxed_take_ownership", NULL, NULL },
{ "POINTER", "POINTER", "gpointer", "g_value_set_pointer", NULL, NULL },
{ "OBJECT", "OBJECT", "GObject*", "g_value_set_object", "g_object_unref", "NULL !=" },
/* deprecated: */
{ "NONE", "VOID", "void", NULL, NULL, },
{ "BOOL", "BOOLEAN", "gboolean", "g_value_set_boolean", NULL, },
{ "NONE", "VOID", "void", NULL, NULL, NULL },
{ "BOOL", "BOOLEAN", "gboolean", "g_value_set_boolean", NULL, NULL }
};
const guint n_args = sizeof (args) / sizeof (args[0]);
guint i;
@ -211,6 +212,7 @@ complete_out_arg (OutArgument *oarg)
oarg->ctype = args[i].ctype;
oarg->setter = args[i].setter;
oarg->release = args[i].release;
oarg->release_check = args[i].release_check;
return TRUE;
}
@ -398,7 +400,18 @@ generate_marshal (const gchar *signame,
fprintf (fout, "\n");
fprintf (fout, " %s (return_value, v_return);\n", sig->rarg->setter);
if (sig->rarg->release)
{
if (sig->rarg->release_check)
{
fprintf (fout, " if (%s (v_return))\n", sig->rarg->release_check);
fprintf (fout, " %s (v_return);\n", sig->rarg->release);
}
else
{
fprintf (fout, " %s (v_return);\n", sig->rarg->release);
}
}
}
/* cfile marshal footer */