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

Add Proxy suffix to proxies and Stub suffix to stubs #74

Closed martin-ejdestig closed 5 years ago

martin-ejdestig commented 5 years ago

Avoids name clashes between namespace names and class names when an interface is a put "below" another one. E.g. the interfaces a.B and a.B.C would add a class named B for a.B and a namespace called B for a.B.C.

Since the proxy and stub classes are named differently now it is also OK to include _proxy.h and _stub.h in the same compilation unit. The use case for this would be e.g. a service with name a.B requiring a client to implement an interface with the name a.B.C .

Fixes #57 .

There are conflicts with #68 and #73 . Please hold with merging this until those have gone in.

martin-ejdestig commented 5 years ago

Maybe this should be configurable with command line switches, but that can be handled in a separate pr if you think this approach is good.

Also, I tried to remove/rework cpp_class_name since it is a bit of a misnomer now but I could not understand what https://github.com/Pelagicore/gdbus-codegen-glibmm/blob/12e30b66288e13791b4f46baae9c67432a820adc/codegen_glibmm/dbustypes.py#L245 does. It seems like the inner block there that actually uses class_name is never reached.

Here are the locations where (cpp_)class_name is still used:

$ grep -rI class_name codegen_glibmm/ | grep -v "cpp_class_name_proxy\|cpp_class_name_stub\|class_name_with_namespace"
codegen_glibmm/dbustypes.py:    def cppvalue_send(self, name, param, cpp_class_name):
codegen_glibmm/dbustypes.py:    def cppvalue_get(self, outvar, idx, cpp_class_name):
codegen_glibmm/dbustypes.py:    def cppvalue_send(self, name, param, cpp_class_name):
codegen_glibmm/dbustypes.py:            return Type.cppvalue_send(self, name, param, cpp_class_name)
codegen_glibmm/dbustypes.py:    def cppvalue_get(self, outvar, idx, cpp_class_name):
codegen_glibmm/dbustypes.py:                value = self.class_name + value
codegen_glibmm/dbustypes.py:    def post_process(self, class_name, arg_number):
codegen_glibmm/dbustypes.py:        self.class_name = class_name
codegen_glibmm/dbustypes.py:    def post_process(self, class_name, cns, cns_upper, cns_lower):
codegen_glibmm/dbustypes.py:            a.post_process(class_name, arg_count)
codegen_glibmm/dbustypes.py:            a.post_process(class_name, arg_count)
codegen_glibmm/dbustypes.py:    def post_process(self, class_name, cns, cns_upper, cns_lower, containing_iface):
codegen_glibmm/dbustypes.py:            a.post_process(class_name, arg_count)
codegen_glibmm/dbustypes.py:    def post_process(self, class_name, cns, cns_upper, cns_lower):
codegen_glibmm/dbustypes.py:        self.arg.post_process(class_name, 0)
codegen_glibmm/dbustypes.py:        namespace_and_class_name = self.name_without_prefix.replace(".", "::")
codegen_glibmm/dbustypes.py:        (self.cpp_namespace_name, self.cpp_class_name) = namespace_and_class_name.rsplit('::', 1)
codegen_glibmm/dbustypes.py:            m.post_process(self.cpp_class_name, cns, cns_upper, cns_lower)
codegen_glibmm/dbustypes.py:            s.post_process(self.cpp_class_name, cns, cns_upper, cns_lower, self)
codegen_glibmm/dbustypes.py:            p.post_process(self.cpp_class_name, cns, cns_upper, cns_lower)
codegen_glibmm/templates/stub.h.templ:        {{ type.cppvalue_send('var' + index, 'p' + index, interface.cpp_class_name) | indent(2) }}
codegen_glibmm/templates/proxy.h.templ:        {{ arg.cppvalue_send(arg.name + "_param", arg.name, interface.cpp_class_name) }}
codegen_glibmm/templates/common.h.templ:class {{ interface.cpp_class_name }}TypeWrap {
codegen_glibmm/templates/common.h.templ:        {{ arg.cppvalue_send(arg.name + "_param", "arg_" + arg.name, interface.cpp_class_name) | indent(2) }}
codegen_glibmm/templates/common.h.templ:        {{ arg.cppvalue_send("params", "arg_" + arg.name, interface.cpp_class_name) | indent(2) }}
codegen_glibmm/templates/proxy.cpp.templ:    base = {{ interface.cpp_class_name }}TypeWrap::{{ method.camel_name }}_pack(
codegen_glibmm/templates/proxy.cpp.templ:    {{ arg.cppvalue_get("out_" + arg.name, loop.index0|string, interface.cpp_class_name) | indent(1) }}
martin-ejdestig commented 5 years ago

But, perhaps the cleanup of remaining use of class_name can wait?

martin-ejdestig commented 5 years ago

Rebased on latest master and updated README.md.

Noticed that additions to README.md in #73 got lost in a rebase... or something... so put a separate commit for that on top.