[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 14/25: Revert "grc: fix callback evaluation
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 14/25: Revert "grc: fix callback evaluation" |
Date: |
Fri, 27 May 2016 19:14:58 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 33c5096a47d1c882fde2f89af677d91b969df095
Author: Sebastian Koslowski <address@hidden>
Date: Sat May 21 13:50:48 2016 +0200
Revert "grc: fix callback evaluation"
This reverts commit c85984f105106ff0a7e3b387d680e0f2f5884d55.
---
grc/core/generator/Generator.py | 25 ++++++++++++++-----------
grc/core/generator/flow_graph.tmpl | 6 +++---
grc/core/utils/expr_utils.py | 4 ++--
3 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/grc/core/generator/Generator.py b/grc/core/generator/Generator.py
index 2fdd850..4788711 100644
--- a/grc/core/generator/Generator.py
+++ b/grc/core/generator/Generator.py
@@ -141,7 +141,7 @@ class TopBlockGenerator(object):
pass
return code
- blocks_all = expr_utils.sort_objects(
+ blocks = expr_utils.sort_objects(
filter(lambda b: b.get_enabled() and not b.get_bypassed(),
fg.blocks),
lambda b: b.get_id(), _get_block_sort_text
)
@@ -150,7 +150,7 @@ class TopBlockGenerator(object):
Messages.send_warning("The block {!r} is deprecated.".format(key))
# List of regular blocks (all blocks minus the special ones)
- blocks = filter(lambda b: b not in (imports + parameters), blocks_all)
+ blocks = filter(lambda b: b not in (imports + parameters), blocks)
for block in blocks:
key = block.get_key()
@@ -216,15 +216,18 @@ class TopBlockGenerator(object):
msgs = filter(lambda c: c.is_msg(), fg.get_enabled_connections())
# List of variable names
var_ids = [var.get_id() for var in parameters + variables]
- replace_dict = dict((var_id, 'self.' + var_id) for var_id in var_ids)
- callbacks_all = []
- for block in blocks_all:
- callbacks_all.extend(expr_utils.expr_replace(cb, replace_dict) for
cb in block.get_callbacks())
+ # Prepend self.
+ replace_dict = dict([(var_id, 'self.%s' % var_id) for var_id in
var_ids])
+ # List of callbacks
+ callbacks = [
+ expr_utils.expr_replace(cb, replace_dict)
+ for cb in sum([block.get_callbacks() for block in
fg.get_enabled_blocks()], [])
+ ]
# Map var id to callbacks
- callbacks = {}
- for var_id in var_ids:
- callbacks[var_id] = [callback for callback in callbacks_all
- if
expr_utils.get_variable_dependencies(callback, ['self.' + var_id])]
+ var_id2cbs = dict([
+ (var_id, filter(lambda c: expr_utils.get_variable_dependencies(c,
[var_id]), callbacks))
+ for var_id in var_ids
+ ])
# Load the namespace
namespace = {
'title': title,
@@ -238,7 +241,7 @@ class TopBlockGenerator(object):
'connection_templates': connection_templates,
'msgs': msgs,
'generate_options': self._generate_options,
- 'callbacks': callbacks,
+ 'var_id2cbs': var_id2cbs,
}
# Build the template
t = Template(open(FLOW_GRAPH_TEMPLATE, 'r').read(), namespace)
diff --git a/grc/core/generator/flow_graph.tmpl
b/grc/core/generator/flow_graph.tmpl
index 07c4169..ecdb893 100644
--- a/grc/core/generator/flow_graph.tmpl
+++ b/grc/core/generator/flow_graph.tmpl
@@ -13,7 +13,7 @@
address@hidden connections the connections
address@hidden msgs the msg type connections
address@hidden generate_options the type of flow graph
address@hidden callbacks variable id map to callback strings
address@hidden var_id2cbs variable id map to callback strings
########################################################
#def indent($code)
#set $code = '\n '.join(str($code).splitlines())
@@ -301,12 +301,12 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)),
[$(', '.join($size_strs))])
#if $flow_graph.get_option('thread_safe_setters')
with self._lock:
self.$id = $id
- #for $callback in $callbacks[$id]
+ #for $callback in $var_id2cbs[$id]
$indent($callback)
#end for
#else
self.$id = $id
- #for $callback in $callbacks[$id]
+ #for $callback in $var_id2cbs[$id]
$indent($callback)
#end for
#end if
diff --git a/grc/core/utils/expr_utils.py b/grc/core/utils/expr_utils.py
index c506958..6691175 100644
--- a/grc/core/utils/expr_utils.py
+++ b/grc/core/utils/expr_utils.py
@@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA
"""
import string
-VAR_CHARS = string.letters + string.digits + '_.'
+VAR_CHARS = string.letters + string.digits + '_'
class graph(object):
@@ -118,7 +118,7 @@ def get_variable_dependencies(expr, vars):
a subset of vars used in the expression
"""
expr_toks = expr_split(expr)
- return set(var for var in vars if var in expr_toks)
+ return set(filter(lambda v: v in expr_toks, vars))
def get_graph(exprs):
- [Commit-gnuradio] [gnuradio] 01/25: grc: show comments next to rotated blocks (instead of underneath), (continued)
- [Commit-gnuradio] [gnuradio] 01/25: grc: show comments next to rotated blocks (instead of underneath), git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 22/25: Merge branch 'maint', git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 13/25: grc: Renamed reports window to console., git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 11/25: grc: Darker color for bypassed blocks., git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 04/25: grc: optionally hide all variable blocks, git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 21/25: grc: function probe block: relabel and move value param, git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 24/25: Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg', git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 07/25: grc: remove 'Showing: ...' messages, git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 12/25: grc: add warning for block flagged deprecated, git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 20/25: grc: faulty callback code if setter call contained a variable block id, git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 14/25: Revert "grc: fix callback evaluation",
git <=
- [Commit-gnuradio] [gnuradio] 18/25: modtool: Added version support for OOTs, git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 19/25: grc-refactor: minor clean-up of callback generator code, git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 15/25: grc: fix flow graph execution (amends ActionHandler refactoring), git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 10/25: grc: Variable editor tweaks., git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 25/25: Merge remote-tracking branch 'dkozel/uhd_lo_api', git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 16/25: Added controls for importing, exporting, and sharing LOs, git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 17/25: grc-refactor: fix custom canvas font sizes, git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 08/25: grc: Added the variable editor panel, git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 09/25: grc: Added context menu to variable editor, git, 2016/05/27
- [Commit-gnuradio] [gnuradio] 06/25: grc: remove some dead code in FlowGraph.what_is_selected(), git, 2016/05/27