sdbus++: refactor enum handling for container-types

Previously an attempt was made to support container types holding
an enumeration, like 'struct[int, enum[self.Foo]]', but this code
was not fully functional.  There are some generated functions that
occur outside of the class that defines the enum, so the fully
qualified namespace is required.  Previously, only the enum name
was given, resulting in compile errors.

Refactor the enumeration type handling by inserting C++-like
placeholders into the early-parsed type name and then replace those
placeholders, as appropriate, when it is determined if we need
a fully-qualified or locally-qualified type.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Iddfcf99299a1ad4770f614431474d388cb6d9088
diff --git a/tools/sdbusplus/property.py b/tools/sdbusplus/property.py
index b13356a..6dceca1 100644
--- a/tools/sdbusplus/property.py
+++ b/tools/sdbusplus/property.py
@@ -4,6 +4,10 @@
 
 
 class Property(NamedElement, Renderer):
+
+    LOCAL_ENUM_MAGIC = "<LOCAL_ENUM>"
+    NONLOCAL_ENUM_MAGIC = "<NONLOCAL_ENUM>"
+
     def __init__(self, **kwargs):
         self.enum = False
         self.typeName = kwargs.pop('type', None)
@@ -31,15 +35,23 @@
         Currently only 'enum' requires conversion.
     """
     def cppTypeParam(self, interface, full=False, server=True):
+
+        ns_type = "server" if server else "client"
+
+        iface = interface.split(".")
+        iface.insert(-1, ns_type)
+        iface = "::".join(iface)
+
         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")
-                r = "::".join(r)
+        # Fix up local enum placeholders.
+        if full:
+            r = r.replace(self.LOCAL_ENUM_MAGIC, iface)
+        else:
+            r = r.replace(self.LOCAL_ENUM_MAGIC + "::", "")
+
+        # Fix up non-local enum placeholders.
+        r = r.replace(self.NONLOCAL_ENUM_MAGIC, ns_type)
 
         return r
 
@@ -154,7 +166,12 @@
 
             # self. means local type.
             if result.startswith("self."):
-                return result[5:]   # "self." is 5 characters
+                return result.replace("self.", self.LOCAL_ENUM_MAGIC + "::")
+
+            # Insert place-holder for header-type namespace (ex. "server")
+            result = result.split('.')
+            result.insert(-2, self.NONLOCAL_ENUM_MAGIC)
+            result = "::".join(result)
             return result
 
         # Parse each parameter entry, if appropriate, and create C++ template