misc: Adopt the gem5 namespace
Apply the gem5 namespace to the codebase. Some anonymous namespaces could theoretically be removed, but since this change's main goal was to keep conflicts at a minimum, it was decided not to modify much the general shape of the files. A few missing comments of the form "// namespace X" that occurred before the newly added "} // namespace gem5" have been added for consistency. std out should not be included in the gem5 namespace, so they weren't. ProtoMessage has not been included in the gem5 namespace, since I'm not familiar with how proto works. Regarding the SystemC files, although they belong to gem5, they actually perform integration between gem5 and SystemC; therefore, it deserved its own separate namespace. Files that are automatically generated have been included in the gem5 namespace. The .isa files currently are limited to a single namespace. This limitation should be later removed to make it easier to accomodate a better API. Regarding the files in util, gem5:: was prepended where suitable. Notice that this patch was tested as much as possible given that most of these were already not previously compiling. Change-Id: Ia53d404ec79c46edaa98f654e23bc3b0e179fe2d Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/46323 Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu> Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu> Reviewed-by: Matthew Poremba <matthew.poremba@amd.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Daniel Carvalho
parent
d4904b3b89
commit
974a47dfb9
@@ -135,6 +135,9 @@ def createCxxConfigDirectoryEntryFile(code, name, simobj, is_header):
|
||||
end_of_decl = ';'
|
||||
code('#include "sim/cxx_config.hh"')
|
||||
code()
|
||||
code('namespace gem5')
|
||||
code('{')
|
||||
code()
|
||||
code('class ${param_class} : public CxxConfigParams,'
|
||||
' public ${name}Params')
|
||||
code('{')
|
||||
@@ -161,6 +164,8 @@ def createCxxConfigDirectoryEntryFile(code, name, simobj, is_header):
|
||||
code('#include "base/str.hh"')
|
||||
code('#include "cxx_config/${name}.hh"')
|
||||
|
||||
code('namespace gem5')
|
||||
code('{')
|
||||
code()
|
||||
code('${member_prefix}DirectoryEntry::DirectoryEntry()');
|
||||
code('{')
|
||||
@@ -384,6 +389,8 @@ def createCxxConfigDirectoryEntryFile(code, name, simobj, is_header):
|
||||
code.dedent()
|
||||
code('};')
|
||||
|
||||
code('} // namespace gem5')
|
||||
|
||||
# The metaclass for SimObject. This class controls how new classes
|
||||
# that derive from SimObject are instantiated, and provides inherited
|
||||
# class behavior (just like a class controls how instances of that
|
||||
@@ -745,6 +752,9 @@ class MetaSimObject(type):
|
||||
|
||||
code('''namespace py = pybind11;
|
||||
|
||||
namespace gem5
|
||||
{
|
||||
|
||||
static void
|
||||
module_init(py::module_ &m_internal)
|
||||
{
|
||||
@@ -813,10 +823,15 @@ module_init(py::module_ &m_internal)
|
||||
code('static EmbeddedPyBind '
|
||||
'embed_obj("${0}", module_init, "${1}");',
|
||||
cls, cls._base.type if cls._base else "")
|
||||
code()
|
||||
code('} // namespace gem5')
|
||||
|
||||
# include the create() methods whether or not python is enabled.
|
||||
if not hasattr(cls, 'abstract') or not cls.abstract:
|
||||
if 'type' in cls.__dict__:
|
||||
code()
|
||||
code('namespace gem5')
|
||||
code('{')
|
||||
code()
|
||||
code('namespace')
|
||||
code('{')
|
||||
@@ -881,6 +896,8 @@ module_init(py::module_ &m_internal)
|
||||
code(' return Dummy${cls}Shunt<${{cls.cxx_class}}>::')
|
||||
code(' create(*this);')
|
||||
code('}')
|
||||
code()
|
||||
code('} // namespace gem5')
|
||||
|
||||
_warned_about_nested_templates = False
|
||||
|
||||
@@ -1009,6 +1026,10 @@ module_init(py::module_ &m_internal)
|
||||
code('#include "enums/${{ptype.__name__}}.hh"')
|
||||
code()
|
||||
|
||||
code('namespace gem5')
|
||||
code('{')
|
||||
code('')
|
||||
|
||||
# now generate the actual param struct
|
||||
code("struct ${cls}Params")
|
||||
if cls._base:
|
||||
@@ -1034,6 +1055,8 @@ module_init(py::module_ &m_internal)
|
||||
|
||||
code.dedent()
|
||||
code('};')
|
||||
code()
|
||||
code('} // namespace gem5')
|
||||
|
||||
code()
|
||||
code('#endif // __PARAMS__${cls}__')
|
||||
@@ -1192,6 +1215,7 @@ class SimObject(object, metaclass=MetaSimObject):
|
||||
abstract = True
|
||||
|
||||
cxx_header = "sim/sim_object.hh"
|
||||
cxx_class = 'gem5::SimObject'
|
||||
cxx_extra_bases = [ "Drainable", "Serializable", "statistics::Group" ]
|
||||
eventq_index = Param.UInt32(Parent.eventq_index, "Event Queue Index")
|
||||
|
||||
|
||||
@@ -1325,6 +1325,8 @@ class MetaEnum(MetaParamValue):
|
||||
#ifndef $idem_macro
|
||||
#define $idem_macro
|
||||
|
||||
namespace gem5
|
||||
{
|
||||
''')
|
||||
if cls.is_class:
|
||||
code('''\
|
||||
@@ -1356,7 +1358,10 @@ extern const char *${name}Strings[static_cast<int>(${name}::Num_${name})];
|
||||
|
||||
if not cls.is_class:
|
||||
code.dedent(1)
|
||||
code('};')
|
||||
code('}; // $wrapper_name')
|
||||
|
||||
code()
|
||||
code('} // namespace gem5')
|
||||
|
||||
code()
|
||||
code('#endif // $idem_macro')
|
||||
@@ -1368,6 +1373,12 @@ extern const char *${name}Strings[static_cast<int>(${name}::Num_${name})];
|
||||
|
||||
code('#include "base/compiler.hh"')
|
||||
code('#include "enums/$file_name.hh"')
|
||||
|
||||
code()
|
||||
code('namespace gem5')
|
||||
code('{')
|
||||
code()
|
||||
|
||||
if cls.wrapper_is_struct:
|
||||
code('const char *${wrapper_name}::${name}Strings'
|
||||
'[Num_${name}] =')
|
||||
@@ -1392,7 +1403,9 @@ namespace enums
|
||||
|
||||
if not cls.wrapper_is_struct and not cls.is_class:
|
||||
code.dedent(1)
|
||||
code('} // namespace $wrapper_name')
|
||||
code('} // namespace enums')
|
||||
|
||||
code('} // namespace gem5')
|
||||
|
||||
|
||||
def pybind_def(cls, code):
|
||||
@@ -1407,6 +1420,9 @@ namespace enums
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
namespace gem5
|
||||
{
|
||||
|
||||
static void
|
||||
module_init(py::module_ &m_internal)
|
||||
{
|
||||
@@ -1432,6 +1448,8 @@ module_init(py::module_ &m_internal)
|
||||
code.dedent()
|
||||
code()
|
||||
code('static EmbeddedPyBind embed_enum("enum_${name}", module_init);')
|
||||
code()
|
||||
code('} // namespace gem5')
|
||||
|
||||
|
||||
# Base class for enum types.
|
||||
|
||||
Reference in New Issue
Block a user