Gabe Black has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/48375 )

Change subject: scons: Build the source filter factories dict in SourceFilter.
......................................................................

scons: Build the source filter factories dict in SourceFilter.

This is a little cleaner since it avoids an additional global variable.

Change-Id: I19d9a0afd12fdfeeda0b524bd71943d155ed5d7d
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48375
Tested-by: kokoro <[email protected]>
Reviewed-by: Hoa Nguyen <[email protected]>
Maintainer: Bobby R. Bruce <[email protected]>
---
M src/SConscript
1 file changed, 5 insertions(+), 9 deletions(-)

Approvals:
  Hoa Nguyen: Looks good to me, approved
  Bobby R. Bruce: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/SConscript b/src/SConscript
index 5afbb36..9dadd99 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -149,6 +149,7 @@
     return tags

 class SourceFilter(object):
+    factories = {}
     def __init__(self, predicate):
         self.predicate = predicate

@@ -160,10 +161,6 @@
         return SourceFilter(lambda env, tags: self.predicate(env, tags) and
                                               other.predicate(env, tags))

-def with_tags_that(predicate):
-    '''Return a list of sources with tags that satisfy a predicate.'''
-    return SourceFilter(predicate)
-
 def with_any_tags(*tags):
     '''Return a list of sources with any of the supplied tags.'''
     return SourceFilter(lambda env, stags: \
@@ -186,16 +183,15 @@
     '''Return a list of sources without the supplied tag.'''
     return without_tags(*[tag])

-source_filter_factories = {
-    'with_tags_that': with_tags_that,
+SourceFilter.factories.update({
     'with_any_tags': with_any_tags,
     'with_all_tags': with_all_tags,
     'with_tag': with_tag,
     'without_tags': without_tags,
     'without_tag': without_tag,
-}
+})

-Export(source_filter_factories)
+Export(SourceFilter.factories)

 class SourceList(list):
     def apply_filter(self, env, f):
@@ -204,7 +200,7 @@
         return SourceList(filter(match, self))

     def __getattr__(self, name):
-        func = source_filter_factories.get(name, None)
+        func = SourceFilter.factories.get(name, None)
         if not func:
             raise AttributeError


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/48375
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: I19d9a0afd12fdfeeda0b524bd71943d155ed5d7d
Gerrit-Change-Number: 48375
Gerrit-PatchSet: 11
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Bobby R. Bruce <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Hoa Nguyen <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to