Gabe Black has uploaded this change for review. ( 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
---
M src/SConscript
A src/proto/hello.proto
2 files changed, 18 insertions(+), 9 deletions(-)



diff --git a/src/SConscript b/src/SConscript
index e914bbd..6da1bf0 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -148,6 +148,7 @@
     return tags

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

@@ -159,10 +160,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: \
@@ -185,16 +182,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):
@@ -203,7 +199,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

diff --git a/src/proto/hello.proto b/src/proto/hello.proto
new file mode 100644
index 0000000..f2490f3
--- /dev/null
+++ b/src/proto/hello.proto
@@ -0,0 +1,13 @@
+syntax = "proto3";
+
+service HelloService {
+  rpc SayHello (HelloRequest) returns (HelloResponse);
+}
+
+message HelloRequest {
+  string greeting = 1;
+}
+
+message HelloResponse {
+  string reply = 1;
+}

--
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: 1
Gerrit-Owner: Gabe Black <[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

Reply via email to