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 755613 - Use variadic templates in SignalProxy class
Use variadic templates in SignalProxy class
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2015-09-25 08:13 UTC by Marcin Kolny (IRC: loganek)
Modified: 2016-01-22 15:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
proposed solution (5.65 KB, patch)
2015-09-25 08:14 UTC, Marcin Kolny (IRC: loganek)
none Details | Review
proposed solution v2 (26.86 KB, patch)
2015-09-25 13:38 UTC, Marcin Kolny (IRC: loganek)
none Details | Review
proposed solution v3 (28.03 KB, patch)
2015-11-28 19:48 UTC, Marcin Kolny (IRC: loganek)
none Details | Review

Description Marcin Kolny (IRC: loganek) 2015-09-25 08:13:51 UTC
I'd add a variadic-template classes which replace SignalProxy* and SignalProxyDetailed*.
If we decide to break the API, generated code can be removed.
Comment 1 Marcin Kolny (IRC: loganek) 2015-09-25 08:14:12 UTC
Created attachment 312115 [details] [review]
proposed solution
Comment 2 Murray Cumming 2015-09-25 08:53:17 UTC
Could your patch please also remove the code that it replaces, or at least deprecate it?

As long as it's not an _ABI_ break, it should be fine.
Comment 3 Marcin Kolny (IRC: loganek) 2015-09-25 13:38:18 UTC
Created attachment 312144 [details] [review]
proposed solution v2

OK, I've removed SignalProxy* classes.
I don't know, if the change breaks the ABI, but I think, it's not. Some classes contain members of type SignalProxy, but SignalProxy class doesn't contain any member, so I think it's not ABI breaking change.
Can someone confirm it?
Comment 4 Kjell Ahlstedt 2015-11-13 16:06:08 UTC
I've tested version 2 (from comment 3).
The nm command does not show any trace of SignalProxy# or SignalProxyDetailed#
in the .so files in either glibmm or gtkmm. (# = 0..6)

Test sequence:
1. 'make check' in gtkmm and gtkmm-documentation.
   Passed
2. Apply the patch in glibmm. 'make && make install && make check' in glibmm.
   Passed
3. Without recompiling anything in gtkmm and gtkmm-documentation, run some
   programs in gtkmm and gtkmm-documentation.
   Passed
4. Build gtkmm.
   Failed because Glib::SignalProxy# does not exist.
5. Force rebuild of generated code in gtkmm. (Remove src/.stamps directories.)
   Failed because atkmm uses Glib::SignalProxy#.
6. Force rebuild of generated code in atkmm. (Remove src/.stamps directory.)
   Passed
7. Build gtkmm.
   Failed because Glib::SignalProxy# is used in hand-coded code.
8. Replace SignalProxy# by SignalProxy, 'make && make install' in gtkmm.
   Passed
9. Without 'make check' in gtkmm and gtkmm-documentation, run some programs in
   gtkmm and gtkmm-documentation.
   Passed
10. 'make check' in gtkmm and gtkmm-documentation, then run some programs in
    gtkmm and gtkmm-documentation.
   Passed

Conclusion
----------
It's no ABI break, but of course it's an API break. The API break affects several
mm modules, but probably very few, if any, application programs. I think very
few apps use SignalProxy# directly in their own code.


I also tested with a bunch of alias templates in signalproxy.h. Then no API is
removed. The effect on other packages is insignificant.

template <typename R>
using SignalProxy0 = SignalProxy<R>;
template <typename R, typename T1>
using SignalProxy1 = SignalProxy<R, T1>;
template <typename R, typename T1, typename T2>
using SignalProxy2 = SignalProxy<R, T1, T2>;
template <typename R, typename T1, typename T2, typename T3>
using SignalProxy3 = SignalProxy<R, T1, T2, T3>;
template <typename R, typename T1, typename T2, typename T3, typename T4>
using SignalProxy4 = SignalProxy<R, T1, T2, T3, T4>;
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5>
using SignalProxy5 = SignalProxy<R, T1, T2, T3, T4, T5>;
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
using SignalProxy6 = SignalProxy<R, T1, T2, T3, T4, T5, T6>;

template <typename R>
using SignalProxyDetailed0 = SignalProxyDetailedAnyType<R>;
template <typename R, typename T1>
using SignalProxyDetailed1 = SignalProxyDetailedAnyType<R, T1>;
template <typename R, typename T1, typename T2>
using SignalProxyDetailed2 = SignalProxyDetailedAnyType<R, T1, T2>;
template <typename R, typename T1, typename T2, typename T3>
using SignalProxyDetailed3 = SignalProxyDetailedAnyType<R, T1, T2, T3>;
template <typename R, typename T1, typename T2, typename T3, typename T4>
using SignalProxyDetailed4 = SignalProxyDetailedAnyType<R, T1, T2, T3, T4>;
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5>
using SignalProxyDetailed5 = SignalProxyDetailedAnyType<R, T1, T2, T3, T4, T5>;
template <typename R, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
using SignalProxyDetailed6 = SignalProxyDetailedAnyType<R, T1, T2, T3, T4, T5, T6>;

A few details ought to be changed:

- When signalproxy.h is not generated, it must be included in
  glibmm_files_extra_h in glib/glibmm/filelist.am. Otherwise it won't be
  distributed.

- The first line in signalproxy.h says
  /* This is a generated file, do not edit.  Generated from signalproxy.h.m4 */
  That's not true any more. It should be replaced by the usual copyright and
  license notice.
Comment 5 Marcin Kolny (IRC: loganek) 2015-11-28 19:48:58 UTC
Created attachment 316451 [details] [review]
proposed solution v3

Thanks Kjell for the review. I've mended a patch. If everything is ok, I'll push it.
Comment 6 Kjell Ahlstedt 2015-12-02 10:06:04 UTC
First two trivial comments that can be fixed in a separate commit, if you prefer
not to make a 4th version.

- One comment in glib/glibmm/signalproxy.h and one comment in tools/m4/signal.m4
  mention SignalProxy0<void>. Should now be SignalProxy<void>.
- We've now changed all(?) null pointers in glibmm from 0 to nullptr.
  That should be done also in signalproxy.h:
    // Return 0 if the connection is blocked.
    return (!pConnectionNode->slot_.blocked()) ? &pConnectionNode->slot_ : 0;

Then a more important question that I leave to Murray:

Shall the 2*7 alias templates (see comment 4) be included in signalproxy.h?
Then handwritten code with SignalProxy# in other mm modules need not be changed
immediately. If they are included now, they can be deprecated or removed later.
Comment 7 Murray Cumming 2015-12-02 10:55:49 UTC
(In reply to Kjell Ahlstedt from comment #6)
> Then a more important question that I leave to Murray:
> 
> Shall the 2*7 alias templates (see comment 4) be included in signalproxy.h?
> Then handwritten code with SignalProxy# in other mm modules need not be
> changed
> immediately. If they are included now, they can be deprecated or removed
> later.

So they'd still be available at runtime for apps that were built against older libsigc++, though newly-built apps wouldn't use them? And there would be no conflict or ambiguity in our API? Sounds good.
Comment 8 Kjell Ahlstedt 2015-12-02 14:41:36 UTC
This bug concerns Glib::SignalProxy# and Glib::SignalProxyDetailed# (# = 0..6).
As far as I can see, they are not part of the ABI, neither in glibmm nor in
gtkmm, probably because they are templates. (It does not go without saying that
names of templates are not part of any ABI. See e.g. libsigc++ bug 753612.)

If SignalProxy#<> and SignalProxyDetailed#<> are replaced by the variadic
templates SignalProxy<> and SignalProxyDetailedAnyType<>, API would be broken.
With the alias templates near the end of comment 4, this API break is avoided.
The old class names would still be available at compile-time.

Btw the name SignalProxyDetailedAnyType is not perfect. Unfortunately there is
a non-template base class named SignalProxyDetailed. Its name can't be changed
without breaking ABI.
Comment 9 Murray Cumming 2015-12-05 09:09:21 UTC
Sounds great. Please go for it.
Comment 10 Kjell Ahlstedt 2016-01-21 10:14:54 UTC
Why has this bug come to a halt? Are Marcin and me waiting for each other to
continue? My expectation was (and is) that Marcin will push solution v3 or
something very similar, probably with the alias templates in comment 4 added.
Comment 11 Marcin Kolny (IRC: loganek) 2016-01-21 11:07:50 UTC
That's my fault, I was quite busy last time and completely forgot about this bug. I'll look at this at the evening.
Comment 12 Marcin Kolny (IRC: loganek) 2016-01-21 18:11:56 UTC
Pushed.
Comment 13 Kjell Ahlstedt 2016-01-22 15:08:06 UTC
Looks great. Closing this bug.