sdbus++: use native enums for message operations

Support was added in earlier commits for handing enums as native
types in message::read and message::append operations.  Fix up all
the generated templates to use this support.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I9f002d6f9fd681abfd0a22a757d5e99fa775c715
diff --git a/tools/sdbusplus/property.py b/tools/sdbusplus/property.py
index 4349186..34a71c1 100644
--- a/tools/sdbusplus/property.py
+++ b/tools/sdbusplus/property.py
@@ -30,10 +30,12 @@
     """ Return a conversion of the cppTypeName valid as a function parameter.
         Currently only 'enum' requires conversion.
     """
-    def cppTypeParam(self, interface, server=True):
+    def cppTypeParam(self, interface, full=False, server=True):
         r = self.cppTypeName
 
         if self.is_enum():
+            if "." not in r and full:
+                r = interface + "." + r
             if "." in r:
                 r = r.split('.')
                 r.insert(-2, "server" if server else "client")
@@ -41,14 +43,6 @@
 
         return r
 
-    """ Return a conversion of the cppTypeName valid as it is read out of a
-        message.  Currently only 'enum' requires conversion.
-    """
-    def cppTypeMessage(self, interface):
-        if self.is_enum():
-            return "std::string"
-        return self.cppTypeName
-
     def enum_namespace(self, interface):
         if not self.is_enum():
             return ""
diff --git a/tools/sdbusplus/templates/method.mako.prototype.hpp.in b/tools/sdbusplus/templates/method.mako.prototype.hpp.in
index fa88e30..c9065d3 100644
--- a/tools/sdbusplus/templates/method.mako.prototype.hpp.in
+++ b/tools/sdbusplus/templates/method.mako.prototype.hpp.in
@@ -13,27 +13,25 @@
         return ",\n            ".\
             join([ parameter(p, defaultValue) for p in method.parameters ])
 
-    def parameters_as_local(as_param=True):
-        return "{};\n    ".join([ parameter(p,as_param=as_param)
-                for p in method.parameters ])
+    def parameters_as_local():
+        return "{};\n    ".join([ parameter(p) for p in method.parameters ])
 
     def parameters_as_list(transform=lambda p: p.camelCase):
         return ", ".join([ transform(p) for p in method.parameters ])
 
     def parameters_types_as_list():
-        return ", ".join([ p.cppTypeMessage(interface.name)
+        return ", ".join([ p.cppTypeParam(interface.name, full=True)
                 for p in method.parameters ])
 
-    def parameter(p, defaultValue=False, as_param=True):
-        r = "%s %s" % (p.cppTypeParam(interface.name) if as_param else \
-                p.cppTypeMessage(interface.name), p.camelCase)
+    def parameter(p, defaultValue=False):
+        r = "%s %s" % (p.cppTypeParam(interface.name), p.camelCase)
         if defaultValue:
             r += default_value(p)
         return r
 
-    def returns_as_list(as_param=True):
-        return ", ".join([ (r.cppTypeParam(interface.name) if as_param else
-                r.cppTypeMessage(interface.name)) for r in method.returns ])
+    def returns_as_list(full=False):
+        return ", ".join([ r.cppTypeParam(interface.name, full=full)
+                for r in method.returns ])
 
     def returns_as_tuple_index(tuple, pre="", post=""):
         return ", ".join([ "%sstd::move(std::get<%d>(%s))%s" %\
@@ -63,16 +61,6 @@
         l = error_namespace(e).split('::')
         l.pop() # Remove "Error"
         return '/'.join(l) + '/error.hpp';
-
-    def enum_convert(p):
-        if not p.is_enum():
-            return p.camelCase
-        else:
-            return "%sconvert%sFromString(%s)" % \
-                (p.enum_namespace(interface.name),
-                 p.enum_name(interface.name),
-                 p.camelCase)
-
 %>
 ###
 ### Emit 'header'
@@ -121,8 +109,6 @@
 int ${interface_name()}::_callback_${ method.CamelCase }(
         sd_bus_message* msg, void* context, sd_bus_error* error)
 {
-    using sdbusplus::server::binding::details::convertForMessage;
-
     try
     {
         ### Need to add a ref to msg since we attached it to an
@@ -138,7 +124,7 @@
 #endif
 
     % if len(method.parameters) != 0:
-        ${parameters_as_local(as_param=False)}{};
+        ${parameters_as_local()}{};
 
         m.read(${parameters_as_list()});
     % endif
@@ -147,16 +133,16 @@
     % if len(method.returns) != 0:
         auto r = \
     %endif
-        o->${ method.camelCase }(${parameters_as_list(transform=enum_convert)});
+        o->${ method.camelCase }(${parameters_as_list()});
 
         auto reply = m.new_method_return();
     % if len(method.returns) == 0:
         // No data to append on reply.
     % elif len(method.returns) == 1:
-        reply.append(convertForMessage(std::move(r)));
+        reply.append(std::move(r));
     % else:
         reply.append(\
-${returns_as_tuple_index("r",pre="convertForMessage(",post=")")});
+${returns_as_tuple_index("r")});
     % endif
 
         reply.method_return();
@@ -191,7 +177,7 @@
         utility::tuple_to_array(std::make_tuple('\0'));
     % else:
         utility::tuple_to_array(message::types::type_id<
-                ${ returns_as_list(as_param=False) }>());
+                ${ returns_as_list(full=True) }>());
     % endif
 }
 }
diff --git a/tools/sdbusplus/templates/property.mako.prototype.hpp.in b/tools/sdbusplus/templates/property.mako.prototype.hpp.in
index 4d9a56e..238d6af 100644
--- a/tools/sdbusplus/templates/property.mako.prototype.hpp.in
+++ b/tools/sdbusplus/templates/property.mako.prototype.hpp.in
@@ -32,8 +32,6 @@
         const char* property, sd_bus_message* reply, void* context,
         sd_bus_error* error)
 {
-    using sdbusplus::server::binding::details::convertForMessage;
-
     // TODO(venture): Can this except? I wouldn't think so.
     auto o = static_cast<${classname}*>(context);
 
@@ -50,7 +48,7 @@
         }
 #endif
 
-        m.append(convertForMessage(o->${property.camelCase}()));
+        m.append(o->${property.camelCase}());
     }
     catch(sdbusplus::internal_exception_t& e)
     {
@@ -107,14 +105,9 @@
         }
 #endif
 
-        ${property.cppTypeMessage(interface.name)} v{};
+        ${property.cppTypeParam(interface.name)} v{};
         m.read(v);
-    % if property.is_enum():
-        o->${property.camelCase}(${property.enum_namespace(interface.name)}\
-convert${property.enum_name(interface.name)}FromString(v));
-    % else:
         o->${property.camelCase}(v);
-    % endif
     }
     catch(sdbusplus::internal_exception_t& e)
     {
@@ -136,7 +129,7 @@
 {
 static const auto _property_${property.name} =
     utility::tuple_to_array(message::types::type_id<
-            ${property.cppTypeMessage(interface.name)}>());
+            ${property.cppTypeParam(interface.name, full=True)}>());
 }
 }
 % elif ptype == 'callback-cpp-includes':
diff --git a/tools/sdbusplus/templates/signal.mako.prototype.hpp b/tools/sdbusplus/templates/signal.mako.prototype.hpp
index 048eedb..113785e 100644
--- a/tools/sdbusplus/templates/signal.mako.prototype.hpp
+++ b/tools/sdbusplus/templates/signal.mako.prototype.hpp
@@ -14,7 +14,7 @@
                 for p in signal.properties ])
 
     def parameters_types_as_list():
-        return ", ".join([ p.cppTypeMessage(interface.name)
+        return ", ".join([ p.cppTypeParam(interface.name, full=True)
                 for p in signal.properties ])
 
     def default_value(p):
@@ -56,12 +56,10 @@
 void ${interface_name()}::${ signal.camelCase }(
             ${ parameters() })
 {
-    using sdbusplus::server::binding::details::convertForMessage;
-
     auto& i = _${"_".join(interface.name.split('.'))}_interface;
     auto m = i.new_signal("${ signal.name }");
 
-    m.append(${ parameters_as_list(pre="convertForMessage(", post=")") });
+    m.append(${ parameters_as_list() });
     m.signal_send();
 }