params: Fix floating point parameters
[gem5.git] / src / python / m5 / SimObject.py
index 22c488f5d834ed448b8d03ed9af935931fdf637f..41ed3df9e9e190a83a13f9c958caf7f2f527c55c 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:
@@ -721,43 +723,44 @@ 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:
             return self._ccParams
 
-        cc_params_struct = eval('m5.objects.params.%sParams' % self.type)
+        cc_params_struct = getattr(m5.objects.params, '%sParams' % self.type)
         cc_params = cc_params_struct()
         cc_params.object = self
         cc_params.name = str(self)
@@ -792,12 +795,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