Giacomo Travaglini has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/39898 )
Change subject: sim: Define PARAMS macro utility
......................................................................
sim: Define PARAMS macro utility
To reduce code duplication and to ensure that the result of [1] will not
deteriorate, define a macro to be used in every descendant of SimObject
that needs its own params().
[1] 91d83cc8a12883f2d7493b37f50487cd7f03a9e6
Change-Id: I1a1a0dedf91ae228ea27b8ed324577ee3439ea68
Signed-off-by: Alexander Klimov <[email protected]>
---
M src/sim/sim_object.hh
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/sim/sim_object.hh b/src/sim/sim_object.hh
index a75f8dd..1e1d553 100644
--- a/src/sim/sim_object.hh
+++ b/src/sim/sim_object.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 ARM Limited
+ * Copyright (c) 2015, 2021 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -314,6 +314,21 @@
static SimObject *find(const char *name);
};
+/* Add PARAMS(ClassName) to every descendant of SimObject that needs
+ * params.
+ *
+ * Strictly speaking, we need static_cast here, because the types are
+ * related by inheritance, but since the target type may be
+ * incomplete, the compiler does not know the relation.
+ */
+#define PARAMS(type) \
+ using Params = type ## Params; \
+ const Params & \
+ params() const \
+ { \
+ return reinterpret_cast<const Params&>(_params); \
+ }
+
/**
* Base class to wrap object resolving functionality.
*
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/39898
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I1a1a0dedf91ae228ea27b8ed324577ee3439ea68
Gerrit-Change-Number: 39898
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s