Hello Andreas Sandberg,
I'd like you to do a code review. Please visit
https://gem5-review.googlesource.com/10601
to review the following change.
Change subject: python: Include hasattr helper for SimObjects
......................................................................
python: Include hasattr helper for SimObjects
With this patch it will be possibile to query a SimObject from
configuration file to check if it has a parameter.
Change-Id: Ie5eb6efe5595f9a8a44df49e6e149428c6c3464d
Signed-off-by: Giacomo Travaglini <giacomo.travagl...@arm.com>
Reviewed-by: Andreas Sandberg <andreas.sandb...@arm.com>
---
M src/python/m5/SimObject.py
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py
index 6e61961..0bcc900 100644
--- a/src/python/m5/SimObject.py
+++ b/src/python/m5/SimObject.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2017 ARM Limited
+# Copyright (c) 2017-2018 ARM Limited
# All rights reserved.
#
# The license below extends only to copyright in the software and shall
@@ -660,6 +660,16 @@
raise AttributeError, \
"object '%s' has no attribute '%s'" % (cls.__name__, attr)
+ # Check for attribute (called to see if foo has attribute attr when
+ # foo is an instance of class cls)
+ def hasattr(cls, attr):
+ try:
+ __getattr__(cls, attr)
+ except AttributeError:
+ return False
+ else:
+ return True
+
def __str__(cls):
return cls.__name__
--
To view, visit https://gem5-review.googlesource.com/10601
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ie5eb6efe5595f9a8a44df49e6e149428c6c3464d
Gerrit-Change-Number: 10601
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev