commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r9037 - in grc/trunk: notes src/grc_gnuradio


From: jblum
Subject: [Commit-gnuradio] r9037 - in grc/trunk: notes src/grc_gnuradio
Date: Tue, 29 Jul 2008 00:33:47 -0600 (MDT)

Author: jblum
Date: 2008-07-29 00:33:47 -0600 (Tue, 29 Jul 2008)
New Revision: 9037

Modified:
   grc/trunk/notes/todo.txt
   grc/trunk/src/grc_gnuradio/Block.py
   grc/trunk/src/grc_gnuradio/Generator.py
   grc/trunk/src/grc_gnuradio/Param.py
Log:
callbacks (self.) moved to generator, param special property flags have init 
flag

Modified: grc/trunk/notes/todo.txt
===================================================================
--- grc/trunk/notes/todo.txt    2008-07-29 02:06:09 UTC (rev 9036)
+++ grc/trunk/notes/todo.txt    2008-07-29 06:33:47 UTC (rev 9037)
@@ -20,7 +20,6 @@
 -auto generate hier library
 -auto clean hier library
 -add hier blocks to tree without restart?
--multi select, enable, disable, repeat, undo = error?
 
 ############ Suggestions: ####################
 -simple usrp

Modified: grc/trunk/src/grc_gnuradio/Block.py
===================================================================
--- grc/trunk/src/grc_gnuradio/Block.py 2008-07-29 02:06:09 UTC (rev 9036)
+++ grc/trunk/src/grc_gnuradio/Block.py 2008-07-29 06:33:47 UTC (rev 9037)
@@ -38,7 +38,6 @@
                @param n the nested odict
                @return block a new block
                """
-               self.self_flag = False
                #grab the data
                doc = Utils.exists_or_else(n, 'doc', '')
                imports = map(lambda i: i.strip(), Utils.listify(n, 'import'))
@@ -127,11 +126,6 @@
        def get_callbacks(self):
                """!
                Get a list of function callbacks for this block.
-               Set the self flag so that variables references are rewritten 
with self.
-               Unset the self flag before returning the callbacks.
                @return a list of strings
                """
-               self.self_flag = True
-               callbacks = map(lambda c: self.get_id() + '.' + 
self.resolve_dependencies(c), self._callbacks)
-               self.self_flag = False
-               return callbacks
+               return map(lambda c: self.get_id() + '.' + 
self.resolve_dependencies(c), self._callbacks)

Modified: grc/trunk/src/grc_gnuradio/Generator.py
===================================================================
--- grc/trunk/src/grc_gnuradio/Generator.py     2008-07-29 02:06:09 UTC (rev 
9036)
+++ grc/trunk/src/grc_gnuradio/Generator.py     2008-07-29 06:33:47 UTC (rev 
9037)
@@ -82,10 +82,13 @@
                blocks = filter(lambda b: b not in (imports + parameters + 
variables), blocks)
                #list of connections where each endpoint is enabled
                connections = self._flow_graph.get_enabled_connections()
-               #list of callbacks
-               callbacks = sum([block.get_callbacks() for block in 
self._flow_graph.get_blocks()], [])
                #list of variable names
                var_ids = [var.get_id() for var in parameters + variables]
+               #list of callbacks (prepend self.)
+               callbacks = [
+                       expr_utils.expr_prepend(cb, var_ids, 'self.')
+                       for cb in sum([block.get_callbacks() for block in 
self._flow_graph.get_blocks()], [])
+               ]
                #map var id to the expression (prepend self.)
                var_id2expr = dict(
                        [(var.get_id(), 
expr_utils.expr_prepend(var.get_make().split('\n')[0], var_ids, 'self.'))

Modified: grc/trunk/src/grc_gnuradio/Param.py
===================================================================
--- grc/trunk/src/grc_gnuradio/Param.py 2008-07-29 02:06:09 UTC (rev 9036)
+++ grc/trunk/src/grc_gnuradio/Param.py 2008-07-29 06:33:47 UTC (rev 9037)
@@ -26,6 +26,9 @@
 
 class Param(_Param):
 
+       _init = False
+       _hostage_cells = list()
+
        ##possible param types
        TYPES = _Param.TYPES + [
                'complex', 'real', 'int',
@@ -43,7 +46,7 @@
                """
                self._lisitify_flag = False
                self._stringify_flag = False
-
+               self._hostage_cells = list()
                def eval_string(v):
                        try:
                                e = self.get_parent().get_parent().evaluate(v)
@@ -153,7 +156,6 @@
                # Grid Position Type
                #########################
                elif t == 'grid_pos':
-                       self._hostage_cells = list()
                        if not v: return '' #allow for empty grid pos
                        e = self.get_parent().get_parent().evaluate(v)
                        try:
@@ -180,7 +182,6 @@
                        #avoid collisions
                        params = filter(lambda p: p is not self, 
self.get_all_params('grid_pos'))
                        for param in params:
-                               if not hasattr(param, '_hostage_cells'): 
continue
                                for cell in param._hostage_cells:
                                        if cell in self._hostage_cells:
                                                
self._add_error_message('Another graphical element is using cell 
"%s".'%str(cell))
@@ -205,23 +206,12 @@
        def to_code(self):
                """!
                Convert the value to code.
-               Call the internal to code method.
-               If the block's self flag was set, 
-               append self. to variable references.
                @return a string representing the code
                """
-               code = self._to_code()
-               #add self. to variables
-               if self.get_parent().self_flag:
-                       var_ids = [var.get_id() for var in 
self.get_parent().get_parent().get_variables()]
-                       code = expr_utils.expr_prepend(code, var_ids, 'self.')
-               return code
-
-       def _to_code(self):
-               """!
-               Convert the value to code.
-               @return a string representing the code
-               """
+               #run init tasks in evaluate
+               if not self._init:
+                       self.evaluate()
+                       self._init = True
                v = self.get_value()
                t = self.get_type()
                if t in ('string', 'file_open', 'file_save'): #string types





reply via email to

[Prev in Thread] Current Thread [Next in Thread]