python: added __nonzero__ function to SimObject Bool params
authorBrad Beckmann <Brad.Beckmann@amd.com>
Fri, 6 Apr 2012 20:47:07 +0000 (13:47 -0700)
committerBrad Beckmann <Brad.Beckmann@amd.com>
Fri, 6 Apr 2012 20:47:07 +0000 (13:47 -0700)
src/python/m5/params.py

index 84af269f091182b6cb10a03c1414e6e4f6e2eff4..f5af3a14b7c7da0260f4a79c1b42576ed63a0b30 100644 (file)
@@ -639,6 +639,11 @@ class Bool(ParamValue):
     def __str__(self):
         return str(self.value)
 
+    # implement truth value testing for Bool parameters so that these params
+    # evaluate correctly during the python configuration phase
+    def __nonzero__(self):
+        return bool(self.value)
+
     def ini_str(self):
         if self.value:
             return 'true'