Use sdbus++ python library for name conversion
This code attempts to come up with sdbus++ property names by
doing its own string manipulation. That conversion is likely
wrong in the future. Instead, import the sdbus++ python code
directly and call the appropriate function from it.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I767ff842c37b183f925d7add87e96bb850092810
diff --git a/settings_manager.mako.hpp b/settings_manager.mako.hpp
index 6f8841f..c0dac66 100644
--- a/settings_manager.mako.hpp
+++ b/settings_manager.mako.hpp
@@ -4,6 +4,7 @@
<%
import re
from collections import defaultdict
+from sdbusplus.namedelement import NamedElement
objects = settingsDict.keys()
sdbusplus_namespaces = []
sdbusplus_includes = []
@@ -130,7 +131,7 @@
% for index, item in enumerate(settingsDict[object]):
% for propName, metaDict in item['Properties'].items():
-<% t = propName[:1].lower() + propName[1:] %>\
+<% t = NamedElement(name=propName).camelCase %>\
<% fname = "validate" + propName %>\
decltype(std::declval<Iface${index}>().${t}()) ${t}(decltype(std::declval<Iface${index}>().${t}()) value) override
{
@@ -173,7 +174,7 @@
fs::path path;
% for index, item in enumerate(settingsDict[object]):
% for propName, metaDict in item['Properties'].items():
-<% t = propName[:1].lower() + propName[1:] %>\
+<% t = NamedElement(name=propName).camelCase %>\
<% fname = "validate" + propName %>\
% if propName in validators:
@@ -223,7 +224,7 @@
<%
props = []
for index, item in enumerate(settingsDict[object]):
- intfProps = ["setting." + propName[:1].lower() + propName[1:] + "()" for \
+ intfProps = ["setting." + NamedElement(name=propName).camelCase + "()" for \
propName, metaDict in item['Properties'].items()]
props.extend(intfProps)
props = ', '.join(props)
@@ -240,7 +241,7 @@
% for index, item in enumerate(settingsDict[object]):
% for prop, metaDict in item['Properties'].items():
<%
- t = "setting." + prop[:1].lower() + prop[1:] + "()"
+ t = "setting." + NamedElement(name=prop).camelCase + "()"
props.append(prop)
%>\
decltype(${t}) ${prop}{};
@@ -252,7 +253,7 @@
% for index, item in enumerate(settingsDict[object]):
% for prop, metaDict in item['Properties'].items():
<%
- t = "setting." + prop[:1].lower() + prop[1:] + "(" + prop + ")"
+ t = "setting." + NamedElement(name=prop).camelCase + "(" + prop + ")"
%>\
${t};
% endfor
@@ -305,7 +306,7 @@
{
% for item in settingsDict[path]:
% for propName, metaDict in item['Properties'].items():
-<% p = propName[:1].lower() + propName[1:] %>\
+<% p = NamedElement(name=propName).camelCase %>\
<% defaultValue = metaDict['Default'] %>\
std::get<${index}>(settings)->
${get_setting_sdbusplus_type(item['Interface'])}::${p}(${defaultValue});