Make time format in 'started' line same as 'compiled'.
[gem5.git] / src / python / m5 / SimObject.py
index 14978dd750bf307641fe05f84c346417767d757c..4cf0f7a3d563a4621a2528fec2d6c73552460c2e 100644 (file)
@@ -32,7 +32,6 @@ import sys, types
 import proxy
 import m5
 from util import *
-from multidict import multidict
 
 # These utility functions have to come first because they're
 # referenced in params.py... otherwise they won't be defined when we
@@ -217,7 +216,10 @@ class MetaSimObject(type):
                 # just declaring a pointer.
                 decl = 'class %s;' % _cxx_class
                 if namespace:
-                    decl = 'namespace %s { %s }' % (namespace, decl)
+                    namespaces = namespace.split('::')
+                    namespaces.reverse()
+                    for namespace in namespaces:
+                        decl = 'namespace %s { %s }' % (namespace, decl)
                 cls._value_dict['cxx_predecls'] = [decl]
 
             if 'swig_predecls' not in cls._value_dict:
@@ -394,13 +396,21 @@ class MetaSimObject(type):
                 code += '#include "enums/%s.hh"\n' % ptype.__name__
                 code += "\n\n"
 
+        code += cls.cxx_struct(base, params)
+
+        # close #ifndef __PARAMS__* guard
+        code += "\n#endif\n"
+        return code
+
+    def cxx_struct(cls, base, params):
+        if cls == SimObject:
+            return '#include "sim/sim_object_params.hh"\n'
+
         # now generate the actual param struct
-        code += "struct %sParams" % cls
+        code = "struct %sParams" % cls
         if base:
             code += " : public %sParams" % base
         code += "\n{\n"
-        if cls == SimObject:
-            code += "    virtual ~%sParams() {}\n" % cls
         if not hasattr(cls, 'abstract') or not cls.abstract:
             if 'type' in cls.__dict__:
                 code += "    %s create();\n" % cls.cxx_type
@@ -409,8 +419,6 @@ class MetaSimObject(type):
         code += "".join(["    %s\n" % d for d in decls])
         code += "};\n"
 
-        # close #ifndef __PARAMS__* guard
-        code += "\n#endif\n"
         return code
 
     def cxx_type_decl(cls):
@@ -481,7 +489,6 @@ class SimObject(object):
     type = 'SimObject'
     abstract = True
 
-    name = Param.String("Object name")
     swig_objdecls = [ '%include "python/swig/sim_object.i"' ]
 
     # Initialize new instance.  For objects with SimObject-valued
@@ -721,37 +728,38 @@ class SimObject(object):
         for child in child_names:
             self._children[child].unproxy_all()
 
-    def print_ini(self):
-        print '[' + self.path() + ']'  # .ini section header
+    def print_ini(self, ini_file):
+        print >>ini_file, '[' + self.path() + ']'      # .ini section header
 
         instanceDict[self.path()] = self
 
         if hasattr(self, 'type'):
-            print 'type=%s' % self.type
+            print >>ini_file, 'type=%s' % self.type
 
         child_names = self._children.keys()
         child_names.sort()
         if len(child_names):
-            print 'children=%s' % ' '.join(child_names)
+            print >>ini_file, 'children=%s' % ' '.join(child_names)
 
         param_names = self._params.keys()
         param_names.sort()
         for param in param_names:
             value = self._values.get(param)
             if value != None:
-                print '%s=%s' % (param, self._values[param].ini_str())
+                print >>ini_file, '%s=%s' % (param,
+                                             self._values[param].ini_str())
 
         port_names = self._ports.keys()
         port_names.sort()
         for port_name in port_names:
             port = self._port_refs.get(port_name, None)
             if port != None:
-                print '%s=%s' % (port_name, port.ini_str())
+                print >>ini_file, '%s=%s' % (port_name, port.ini_str())
 
-        print  # blank line between objects
+        print >>ini_file       # blank line between objects
 
         for child in child_names:
-            self._children[child].print_ini()
+            self._children[child].print_ini(ini_file)
 
     def getCCParams(self):
         if self._ccParams:
@@ -759,7 +767,7 @@ class SimObject(object):
 
         cc_params_struct = getattr(m5.objects.params, '%sParams' % self.type)
         cc_params = cc_params_struct()
-        cc_params.object = self
+        cc_params.pyobj = self
         cc_params.name = str(self)
 
         param_names = self._params.keys()
@@ -792,12 +800,14 @@ class SimObject(object):
     # necessary to construct it.  Does *not* recursively create
     # children.
     def getCCObject(self):
-        params = self.getCCParams()
         if not self._ccObject:
-            self._ccObject = -1 # flag to catch cycles in recursion
+            # Cycles in the configuration heirarchy are not supported. This
+            # will catch the resulting recursion and stop.
+            self._ccObject = -1
+            params = self.getCCParams()
             self._ccObject = params.create()
         elif self._ccObject == -1:
-            raise RuntimeError, "%s: recursive call to getCCObject()" \
+            raise RuntimeError, "%s: Cycle found in configuration heirarchy." \
                   % self.path()
         return self._ccObject