After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 93108 - Document - and _ equivalence for signals / properties.
Document - and _ equivalence for signals / properties.
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: docs
2.0.x
Other other
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 100119 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2002-09-12 12:42 UTC by Thomas Vander Stichele
Modified: 2011-02-18 15:55 UTC
See Also:
GNOME target: ---
GNOME version: 2.0



Description Thomas Vander Stichele 2002-09-12 12:42:51 UTC
Hi,

g_signal_new seems to be undocumented.  Maybe some sample code would help,
or an explanation on how to make sure your callback is the right prototype.
 This is an often-used function.

What would also be very useful in the docs is some statement that - and _
are treated equally as signal names, and some explanation on why this is. 
I learned that the hard way.
Comment 1 Owen Taylor 2002-09-12 14:04:09 UTC
"blah () isn't documnted", isn't that useful, since very little
of GObject is documented, and we know that.

But keeping open and retitling since you mention some details that 
definitely should be documented and could be overlooked.
Comment 2 Matthias Clasen 2002-12-01 01:40:07 UTC
I have added a note to g_signal_new() docs now - don't know the exact
reason though. I also notice in the implementation that it is not a
simple s/-/_/, but rather s/[_-|> <.:^]/_/. Should anything be said
about the other chars ? Final note: g_signal_lookup doesn't transform
the name in any way. Doesn't that lead to confusing behaviour where
you first register a signal with g_signal_new("my-signal",...) and
then g_signal_lookup("my-signal") comes up empty ?
Comment 3 Owen Taylor 2002-12-02 19:10:45 UTC
As you've noted in bug 100119, registering my-signal will
result in entries being added for both my_signal and my-signal
to the table that g_signal_lookup() uses. 

I believe the intended behavior could be described as:

 A signal name consists of segments consisting of 
 ascii letters and digits, separated by either the
 '-' or '_' character. When registering a signal and
 lookup  a signal, either separator can be used, but 
 they cannot be mixed. (That is, 'foo-bar-baz' and
 'foo_bar_baz' refer to the same signal, but
 'foo-bar_baz' is illegal.)

Of course, the actual rules for registration are
looser than this:

 - The segments can consist of any sequence of bytes
   except for -_|> <.:^\0

 - Any byte other than \0 is treated as a segment
   separator.

But I think we can simply leave this under the 
rubric of "undefined behavior". The only questions
in my mind are:

 - What are the exact set of segment characters we
   should consider valid? The printing ASCII 
   characters currently allowed other than A-Za-z0-9 
   are ~`!@#$%&*()+=\]}[{'";,/?.  My instinct
   would be to simply disallow all of these, since they
   could cause a problem in one language or another.
   (And signal names are used as symbols in quite
   a few language bindings.) Use of non-ASCII characters
   should definitely not be allowed (unless we want
   to require valid UTF-8, but...)

 - Do we want to impose additional rules (In particular,   
   require that the first character of the signal name is 
   a segment separatoror [A-Za-z], so that signal names
   always have a valid representation as a C or C++ signal.)

 - Should we actually do validation of signal names to
   our documented rules in g_signal_new(), or just document
   the rules? I'd tend to not do so, at least until Glib-3.0.

 - What about property names?
Comment 4 Matthias Clasen 2002-12-02 19:54:13 UTC
I think allowing only a-zA-Z0-9 in segments and details is a good idea,
even if we don't enforce this yet. The docs should warn about
undefined behaviour if other characters are used. Demanding that
signal names start with a-zA-Z also seems good.

I think property names should follow the same rules. 

Ok to add a paragraph explaining this to the GSignal docs ?
Comment 5 Owen Taylor 2002-12-02 20:43:10 UTC
Probably best to mail gtk-devel-list (maybe Cc timj@gtk.org)
first; if you don't get any response, then go ahead and
make the docs change. 

(One thing to be noted is that when using property names,
the '-' form is going to be considerably more efficient,
and in fact, for property names as details, you _have_
to use the '-' form.)
Comment 6 Owen Taylor 2002-12-04 02:08:10 UTC
*** Bug 100119 has been marked as a duplicate of this bug. ***
Comment 7 Matthias Clasen 2002-12-05 22:49:03 UTC
Committed the signal name explanation now, keeping the bug open as a
reminder to add the same for parameter names.
Comment 8 Matthias Clasen 2002-12-15 02:40:13 UTC
Also added a note on property names now.