Pelagicore / gdbus-codegen-glibmm

Code generator for C++ D-Bus stubs and proxies using Giomm/Glibmm
GNU Lesser General Public License v2.1
23 stars 25 forks source link

Namespace/class collision with interfaces where one is a prefix of another #57

Closed valpackett closed 5 years ago

valpackett commented 5 years ago

If I try to include interfaces named like A.B and A.B.C at the same time, the B is defined as both a class and a namespace :(

panel/320e00e@@n9-panel@exe/org.freedesktop.UPower.Device_proxy.h:9:11: error: redefinition of 'UPower' as different kind of symbol
namespace UPower {
          ^
panel/320e00e@@n9-panel@exe/org.freedesktop.UPower_proxy.h:10:7: note: previous definition is here
class UPower : public Glib::ObjectBase {
      ^

For now I'm using --cpp-namespace as a workaround, but I wonder if a better solution is possible…

martin-ejdestig commented 5 years ago

One solution to this could be to call the proxy classes *Proxy (UPowerProxy in this case).

I wonder if it also makes sense to append a Stub suffix to the stub class. Then there would be no name clashes between namespaces generated from interface names and it would be possible to include _proxy.h and _stub.h in the same compilation unit.

(Use case for including _proxy.h and _stub.h would be e.g. when a service exposes an interface that clients must implement and pass instances of for calling back. As in NetworkManager's SecretAgent and ConnMan's Agent interfaces.)

Breaks API of course, but the name clashes are annoying. :(