[Mobies-commit] [commit] r3668 - in UDM/trunk: Projects/Win32/VC10/src/UdmCli src/UdmCliGen

ksmyth at redhat1.isis.vanderbilt.edu ksmyth at redhat1.isis.vanderbilt.edu
Wed Mar 23 15:13:59 CDT 2011


Author: ksmyth
Date: Wed Mar 23 15:13:59 2011
New Revision: 3668

Log:
Change namespace names

Deleted:
   UDM/trunk/src/UdmCliGen/Base.tmpl
Modified:
   UDM/trunk/Projects/Win32/VC10/src/UdmCli/UdmCliObject.cs
   UDM/trunk/src/UdmCliGen/Implementation.tmpl
   UDM/trunk/src/UdmCliGen/Interface.tmpl
   UDM/trunk/src/UdmCliGen/UdmCliGen.py
   UDM/trunk/src/UdmCliGen/common.py

Modified: UDM/trunk/Projects/Win32/VC10/src/UdmCli/UdmCliObject.cs
==============================================================================
--- UDM/trunk/Projects/Win32/VC10/src/UdmCli/UdmCliObject.cs	Wed Mar 23 12:34:31 2011	(r3667)
+++ UDM/trunk/Projects/Win32/VC10/src/UdmCli/UdmCliObject.cs	Wed Mar 23 15:13:59 2011	(r3668)
@@ -1,41 +1,59 @@
 using System;
 using System.Collections.Generic;
 using System.Text;
+using Udm.Native;
+using Udm.Native.Uml;
 
-namespace Udm.Cli
+namespace Udm.Native
 {
-    public class UdmCliObject : IUdmCliObject
+    public class UdmCliObject : IUdmObject
     {
-        public Udm.Native.UdmObject backing;
+        public UdmObject backing;
 
-        public UdmCliObject(Udm.Native.UdmObject o)
+        public UdmCliObject(UdmObject o)
         {
             backing = o;
         }
-        public UdmCliObject(Udm.Native.ObjectImpl o)
+        public UdmCliObject(ObjectImpl o)
         {
-            backing = new Udm.Native.UdmObject(o);
+            backing = new UdmObject(o);
         }
-        public static void CheckCast(Udm.Native.UdmObject a, Udm.Native.Uml.Class meta)
+        public static void CheckCast(UdmObject a, Uml.Class meta)
         {
-            if (!Udm.Native.Udm.IsDerivedFrom(a.type(), meta))
+            if (!Udm.IsDerivedFrom(a.type(), meta))
             {
-                throw new Udm.Native.UdmException("Invalid cast from type '" + a.type().name().Get() + "' to type '" + meta.name().Get() + "'");
+                throw new UdmException("Invalid cast from type '" + a.type().name().Get() + "' to type '" + meta.name().Get() + "'");
             }
         }
         public int id
         {
             get { return backing.uniqueId(); }
         }
+        public bool Equals(UdmCliObject that)
+        {
+            return this.id == that.id;
+        }
+        public override bool Equals(object that)
+        {
+            if (that as UdmCliObject != null)
+            {
+                return Equals((UdmCliObject)that);
+            }
+            return false;
+        }
+        public override int GetHashCode()
+        {
+            return id;
+        }
         public string type_name
         {
             get { return backing.type().name().Get(); }
         }
-        public Udm.Native.Uml.Class type
+        public Uml.Class type
         {
             get { return backing.type(); }
         }
-        public IUdmCliObject parent
+        public IUdmObject parent
         {
             get { return new UdmCliObject(backing.GetParent()); }
         }
@@ -47,45 +65,48 @@
         {
             get { return backing.isSubtype(); }
         }
-        public IUdmCliObject archetype
+        public IUdmObject archetype
         {
             get
             {
-                Udm.Native.UdmObject o = backing.archetype();
+                UdmObject o = backing.archetype();
                 if (o.uniqueId() == 0) return null;
                 return new UdmCliObject(o);
             }
         }
-        public System.Collections.Generic.IEnumerable<IUdmCliObject> instances
+        public System.Collections.Generic.IEnumerable<IUdmObject> instances
         {
             get
             {
                 return System.Linq.Enumerable.ToList(
-                    System.Linq.Enumerable.Select<Udm.Native.UdmObject, IUdmCliObject>
+                    System.Linq.Enumerable.Select<UdmObject, IUdmObject>
                     (backing.instances(), o => new UdmCliObject(o)));
             }
         }
-        public System.Collections.Generic.IEnumerable<IUdmCliObject> derived
+        public System.Collections.Generic.IEnumerable<IUdmObject> derived
         {
             get
             {
                 return System.Linq.Enumerable.ToList(
-                    System.Linq.Enumerable.Select<Udm.Native.UdmObject, IUdmCliObject>
+                    System.Linq.Enumerable.Select<UdmObject, IUdmObject>
                     (backing.derived(), o => new UdmCliObject(o)));
             }
         }
     }
-    public interface IUdmCliObject
+}
+namespace Udm
+{
+public interface IUdmObject
     {
         int id { get; }
-        // TODO: should be Class inherited from IUdmCliObject
+        // TODO: should be Class inherited from IUdmObject
         Udm.Native.Uml.Class type { get; }
-        IUdmCliObject parent { get; }
+        IUdmObject parent { get; }
 
         bool isInstance { get; }
         bool isSubtype { get; }
-        IUdmCliObject archetype { get; }
-        System.Collections.Generic.IEnumerable<IUdmCliObject> instances { get; }
-        System.Collections.Generic.IEnumerable<IUdmCliObject> derived { get; }
+        IUdmObject archetype { get; }
+        System.Collections.Generic.IEnumerable<IUdmObject> instances { get; }
+        System.Collections.Generic.IEnumerable<IUdmObject> derived { get; }
     }
 }

Modified: UDM/trunk/src/UdmCliGen/Implementation.tmpl
==============================================================================
--- UDM/trunk/src/UdmCliGen/Implementation.tmpl	Wed Mar 23 12:34:31 2011	(r3667)
+++ UDM/trunk/src/UdmCliGen/Implementation.tmpl	Wed Mar 23 15:13:59 2011	(r3668)
@@ -7,7 +7,7 @@
 #if $c.baseTypes
         $fq_name($c.baseTypes[0])
 #else
-        global::${impl_namespace}${diagram_name}.UdmCliObject
+        global::Udm.Native.UdmCliObject
 #end if
         , ${fq_iname($c)}
     {
@@ -17,16 +17,16 @@
 
 ## TODO: should be refactored into a factory class
         public static ${c.name} Cast(global::Udm.Native.UdmObject o) {
-            global::${impl_namespace}${diagram_name}.UdmCliObject.CheckCast(o, meta);
+            global::Udm.Native.UdmCliObject.CheckCast(o, meta);
             return new ${c.name}(o);
         }
 
-        public static ${c.name} Cast(global::${impl_namespace}${diagram_name}.UdmCliObject o) {
+        public static ${c.name} Cast(global::Udm.Native.UdmCliObject o) {
             return Cast(o.backing);
         }
 
-        public static ${c.name} Cast(global::${diagram_name}.IUdmCliObject o) {
-            return Cast(((global::${impl_namespace}${diagram_name}.UdmCliObject)o).backing);
+        public static ${c.name} Cast(global::Udm.IUdmObject o) {
+            return Cast(((global::Udm.Native.UdmCliObject)o).backing);
         }
 
         public global::System.Collections.Generic.IEnumerable<${fq_iname($c)}> instances
@@ -76,6 +76,7 @@
 #set meta_name = $fq_name($c) + "." + role_metaname(attr)
         public $type $attr.name
         {
+## FIXME: need to handle arrays, access modifiers
 #if $type == "string"
             get { return backing.getStringAttr($meta_name); }
             set { backing.setStringAttr($meta_name, value); }

Modified: UDM/trunk/src/UdmCliGen/Interface.tmpl
==============================================================================
--- UDM/trunk/src/UdmCliGen/Interface.tmpl	Wed Mar 23 12:34:31 2011	(r3667)
+++ UDM/trunk/src/UdmCliGen/Interface.tmpl	Wed Mar 23 15:13:59 2011	(r3668)
@@ -6,7 +6,7 @@
 #if $c.baseTypes
         : ${", ".join([fq_iname(b) for b in $c.baseTypes])}
 #else
-        : global::${diagram_name}.IUdmCliObject
+        : global::Udm.IUdmObject
 #end if
     {
 

Modified: UDM/trunk/src/UdmCliGen/UdmCliGen.py
==============================================================================
--- UDM/trunk/src/UdmCliGen/UdmCliGen.py	Wed Mar 23 12:34:31 2011	(r3667)
+++ UDM/trunk/src/UdmCliGen/UdmCliGen.py	Wed Mar 23 15:13:59 2011	(r3668)
@@ -13,6 +13,7 @@
     parser = OptionParser(usage="usage: %prog [options] input-uml.xml")
     parser.add_option("-o", "--output", dest="output")
     parser.add_option("--impl_namespace", dest="impl_namespace")
+    parser.add_option("--interface_namespace", dest="interface_namespace")
     (options, args) = parser.parse_args()
     if len(args) != 1:
         print parser.print_help()
@@ -25,6 +26,8 @@
     output.write("#pragma warning disable 0108\n");
     if options.impl_namespace:
         common.impl_namespace = options.impl_namespace + "."
+    if options.interface_namespace:
+        common.interface_namespace = options.interface_namespace + "."
     
     uml = udm.map_uml_names(udm.uml_diagram())
     dn = udm.SmartDataNetwork(udm.uml_diagram())
@@ -41,7 +44,7 @@
         classes.extend(namespace.children(child_type=uml.Class))
     
     for child in classes:
-        searchList = {'c': child, 'namespace': common.get_path(child.parent), 'uml': uml, 'diagram_name': dn.root.name}
+        searchList = {'c': child, 'namespace': common.interface_namespace + common.get_path(child.parent), 'uml': uml, 'diagram_name': dn.root.name}
         t = Template(file="Interface.tmpl", searchList=[searchList])
         output.write(str(t))
 
@@ -52,6 +55,3 @@
     searchList = {'root': dn.root}
     t = Template(file="Initialize.tmpl", searchList=[searchList])
     output.write(str(t))
-
-    t = Template(file="Base.tmpl", searchList=[{ 'diagram_name': dn.root.name }])
-    output.write(str(t))

Modified: UDM/trunk/src/UdmCliGen/common.py
==============================================================================
--- UDM/trunk/src/UdmCliGen/common.py	Wed Mar 23 12:34:31 2011	(r3667)
+++ UDM/trunk/src/UdmCliGen/common.py	Wed Mar 23 15:13:59 2011	(r3668)
@@ -1,5 +1,6 @@
 
-impl_namespace = "UdmImpl."
+impl_namespace = "Udm.Impl."
+interface_namespace = ""
 
 attr_typemap = { 'String': 'string',
     'Boolean': 'bool',
@@ -12,7 +13,7 @@
     while parent.id != 0:
         ret = parent.name + "." + ret
         parent = parent.parent
-    return "global::" + ret
+    return "global::" + interface_namespace + ret
 
 def iter_parents(o, include_self=True):
     if include_self:


More information about the Mobies-commit mailing list