Advertising a signal handler's argument as const char * instead of char *

In one of my GObjects I create a signal that passes a const gchar * as argument (i.e. the user must not free it). I have tried to add G_SIGNAL_TYPE_STATIC_SCOPE to it, but GtkDoc still documents the argument as char * (instead of const char *).

signals[SIGNAL_EMBLEM_SELECTED] = g_signal_new(
	I_("emblem-selected"),
	G_TYPE_FROM_CLASS(klass),
	G_SIGNAL_RUN_FIRST,
	0,
	NULL,
	NULL,
	_local_cclosure_marshal_VOID__STRING_ENUM_ENUM_POINTER,
	G_TYPE_NONE,
	4,
	/*  Maps `const gchar * emblem_name`  */
	G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE,
	/*  Maps `gint saved_state`  */
	G_TYPE_INT,
	/*  Maps `gint current_state`  */
	G_TYPE_INT,
	/*  Maps `const GList * inconsistent_group`  */
	G_TYPE_POINTER | G_SIGNAL_TYPE_STATIC_SCOPE
);

Is there a way to advertise (especially for the documentation) that a signal handler’s argument is a const char * and not a char *?

―madmurphy

No. The signal machinery has no idea what a “const” is. Arguments are stored and marshalled as GValue, and the value holds the data. The “static scope” just means that the value is not copied around during the signal emission; it does not mean it has to be handled as a constant value (as much as C even has constant values).

Hi Emmanuele,

but what about GtkDoc then? Is there a way to tell at least GtkDoc about it?

No, there’s no way to do that. Gtk-doc extracts the signal information by querying the type system, and the type system only knows that G_TYPE_CHAR is represented by gchararray, which is char*. Constness is not known at that level.

Okay, thank you.

―madmurphy

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.