Commit 40691ae6 authored by Christian Hergert's avatar Christian Hergert

signature: improve signatures of ctors with var args

parent 7670098a
......@@ -1177,6 +1177,7 @@ girst_parser_object_get_signature (GirstParserObject *self)
g_autofree gchar *formatted = NULL;
GirstParserObject *return_value;
GirstParserObject *params;
gboolean found_a_param = FALSE;
guint space = 0;
guint begin;
......@@ -1272,11 +1273,7 @@ girst_parser_object_get_signature (GirstParserObject *self)
if (GIRST_IS_GLIB_SIGNAL (self))
{
g_string_append_printf (param_str, "%s *self, ", container_c_type);
}
else if (params == NULL)
{
g_string_append (str, "void");
goto cleanup;
found_a_param = TRUE;
}
if (params != NULL)
......@@ -1292,36 +1289,37 @@ girst_parser_object_get_signature (GirstParserObject *self)
g_autofree gchar *name = NULL;
if (!GIRST_IS_PARAMETER (child) &&
!GIRST_IS_INSTANCE_PARAMETER (child) &&
!GIRST_IS_VARARGS (child))
!GIRST_IS_INSTANCE_PARAMETER (child))
continue;
g_string_append_c (param_str, ' ');
found_a_param = TRUE;
if (GIRST_IS_VARARGS (child))
{
g_string_append (param_str, "...");
break;
}
g_string_append_c (param_str, ' ');
g_object_get (child, "name", &name, NULL);
c_type = girst_parser_object_get_lhs_ctype (child);
g_string_append_printf (param_str, "%s %s, ", c_type, name);
if (g_str_equal (name, "..."))
g_string_append (param_str, "..., ");
else
g_string_append_printf (param_str, "%s %s, ", c_type, name);
}
}
if (GIRST_IS_GLIB_SIGNAL (self))
g_string_append (param_str, "gpointer user_data, ");
if (param_str->len > 2)
g_string_truncate (param_str, param_str->len - 2);
formatted = reformat_parameters (param_str->str, space);
g_string_append (str, formatted);
cleanup:
g_string_append (str, ");");
if (found_a_param && param_str->len > 2)
{
g_string_truncate (param_str, param_str->len - 2);
formatted = reformat_parameters (param_str->str, space);
g_string_append (str, formatted);
g_string_append (str, ");");
}
else
{
g_string_append (str, "void);");
}
return g_string_free (g_steal_pointer (&str), FALSE);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment