summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2019-04-12 18:05:45 +0000
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2019-04-12 19:57:36 +0000
commit3864659ed532ade6b06fa3e833a2bebb177e5d5f (patch)
tree0e8d5571457e97f8105e3a05fde9ba2330c9d8b7
parente6b21c74581c30ea635aabbbc08d0a56f8e27063 (diff)
downloadphosphor-inventory-manager-3864659ed532ade6b06fa3e833a2bebb177e5d5f.tar.gz
phosphor-inventory-manager-3864659ed532ade6b06fa3e833a2bebb177e5d5f.zip
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>
-rw-r--r--example/extra_interfaces.d/xyz/openbmc_project/Example/Iface2.interface.yaml4
-rw-r--r--gen_serialization.mako.hpp10
-rwxr-xr-xpimgen.py5
3 files changed, 10 insertions, 9 deletions
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 @@ properties:
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 @@ void save(Archive& a,
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 @@ void load(Archive& a,
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 @@ class InterfaceComposite(object):
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
OpenPOWER on IntegriCloud