serialization: use the same inflection as sdbus++
When generating code sdbus++ uses python inflection to normalize names.
Use the sdbus++ module that does this when we generate the code that
calls methods in code generated by sdbus++. This avoids build failures
like:
gen_serialization.hpp:22:68: error: ‘const class
sdbusplus::xyz::openbmc_project::Example::server::Iface2’ has no member
named ‘example_Property4’; did you mean ‘exampleProperty4’?
Change-Id: I4b6dbb1f977465ea176f27d021ed2633ae40c37b
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface2.interface.yaml b/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface2.interface.yaml
index cb81630..eecbd41 100644
--- a/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface2.interface.yaml
+++ b/example/extra_interfaces.d/xyz/openbmc_project/Example/Iface2.interface.yaml
@@ -9,6 +9,10 @@
type: int64
description: >
An example int64 property.
+ - name: Example_Property4
+ type: int64
+ description: >
+ An example int64 property with an underscore in the name.
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
diff --git a/gen_serialization.mako.hpp b/gen_serialization.mako.hpp
index 5cf3c13..4245fd9 100644
--- a/gen_serialization.mako.hpp
+++ b/gen_serialization.mako.hpp
@@ -25,7 +25,7 @@
const std::uint32_t version)
{
<%
- props = ["object." + p[:1].lower() + p[1:] + "()" for p in properties]
+ props = ["object." + p.camelCase + "()" for p in properties]
props = ', '.join(props)
%>\
a(${props});
@@ -38,15 +38,15 @@
const std::uint32_t version)
{
% for p in properties:
-<% t = "object." + p[:1].lower() + p[1:] + "()" %>\
- decltype(${t}) ${p}{};
+<% t = "object." + p.camelCase + "()" %>\
+ decltype(${t}) ${p.CamelCase}{};
% endfor
<%
- props = ', '.join(properties)
+ props = ', '.join([p.CamelCase for p in properties])
%>\
a(${props});
% for p in properties:
-<% t = "object." + p[:1].lower() + p[1:] + "(" + p + ")" %>\
+<% t = "object." + p.camelCase + "(" + p.CamelCase + ")" %>\
${t};
% endfor
}
diff --git a/pimgen.py b/pimgen.py
index 7c9ee53..c7ed933 100755
--- a/pimgen.py
+++ b/pimgen.py
@@ -41,16 +41,13 @@
def __init__(self, dict):
self.dict = dict
- def properties(self, interface):
- return self.dict[interface]
-
def interfaces(self):
return self.dict.keys()
def names(self, interface):
names = []
if self.dict[interface]:
- names = [x["name"] for x in self.dict[interface]]
+ names = [NamedElement(name=x["name"]) for x in self.dict[interface]]
return names