sdbusplus updates (client-bindings and namespace)

Patrick Williams patrick at stwcx.xyz
Mon May 8 06:37:59 AEST 2023


On Fri, May 05, 2023 at 05:09:53PM +0800, Lei Yu wrote:
> On Thu, May 4, 2023 at 6:23 AM Patrick Williams <patrick at stwcx.xyz> wrote:

> >     Interface: xyz.openbmc_project.Object.Enable
> >     Old Class: sdbusplus::xyz::openbmc_project::Object::server::Enable
> >     New Class: sdbusplus::server::xyz::openbmc_project::object::Enable
> >     Client Class: sdbusplus::client::xyz::openbmc_project::object::Enable
> 
> The previous class was using `Object` but now with the new namespace
> it becomes `object`, is it intended about the upper-case `O` becoming
> the lower-case `o`?
> If yes, why the `Enable` still kept the upper-case `E`?
> Do we have a rule that all the strings other than the last part should
> be lower-case?

Yes, this was intentional.

The older namespace code did not apply an explicit style to the
namespace or server but just used the portions of the interface name.
We happen to name interfaces in UpperCamelCase.  With the `server` near
the end, there was no name-identifier collision between:

    * ...Foo -> ...::server::Foo
    * ...Foo.Create -> ...::Foo::server::Create

By putting the `server` near the beginning you end up with:

    * ...Foo -> server::...::Foo
    * ...Foo.Create -> server::...::Foo::Create

This causes a collision because `server::...::Foo` is both a namespace
and a classname.

The project C++ style guide states[1]:

    * Structs, classes, enums, and typed template parameters should all be in
      UpperCamelCase.
    * Namespaces should be lower_snake_case.

In order to satisfy both the namespace/classname collision problem when
dealing with nested interface names and to closer align with the C++
style guide we have documented, I explicitly use the lower_snake_case
on the namespace portions and UpperCameCase on the classname portion.

[1]: https://github.com/openbmc/docs/blob/master/cpp-style-and-conventions.md

-- 
Patrick Williams
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/openbmc/attachments/20230507/808c21e7/attachment-0001.sig>


More information about the openbmc mailing list