diff options
Diffstat (limited to 'plugins/turtle_blocks_extras/turtle_blocks_extras.py')
-rw-r--r-- | plugins/turtle_blocks_extras/turtle_blocks_extras.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py index c75cbbd..04f83ff 100644 --- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py +++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py @@ -39,7 +39,7 @@ from TurtleArt.tautils import (round_int, debug_output, get_path, hat_on_top, listify, data_from_file) from TurtleArt.tajail import (myfunc, myfunc_import) from TurtleArt.taprimitive import (ArgSlot, ConstantArg, Primitive) -from TurtleArt.tatype import (TYPE_BOOL, TYPE_CHAR, TYPE_INT, TYPE_NUMBER, +from TurtleArt.tatype import (TYPE_BOOL, TYPE_BOX, TYPE_CHAR, TYPE_INT, TYPE_OBJECT, TYPE_STRING) @@ -475,7 +475,8 @@ program started')) help_string=_('pushes value onto FILO (first-in \ last-out heap)')) self.tw.lc.def_prim('push', 1, - lambda self, x: primitive_dictionary['push'](x)) + Primitive(self.tw.lc.heap.append, + arg_descs=[ArgSlot(TYPE_OBJECT)])) define_logo_function('tapush', 'to tapush :foo\nmake "taheap fput \ :foo :taheap\nend\nmake "taheap []\n') @@ -516,7 +517,7 @@ end\n') help_string=_('pops value off FILO (first-in \ last-out heap)')) self.tw.lc.def_prim('pop', 0, - lambda self: primitive_dictionary['pop']()) + Primitive(self.tw.lc.heap.pop, return_type=TYPE_BOX)) define_logo_function('tapop', 'to tapop\nif emptyp :taheap [stop]\n\ make "tmp first :taheap\nmake "taheap butfirst :taheap\noutput :tmp\nend\n') @@ -539,8 +540,11 @@ make "tmp first :taheap\nmake "taheap butfirst :taheap\noutput :tmp\nend\n') value_block=True, help_string=_('returns True if heap is empty')) self.tw.lc.def_prim('isheapempty2', 0, - lambda self: - primitive_dictionary['isheapempty2']()) + # Python automatically converts the heap to a boolean in contexts + # where a boolean is needed + Primitive(Primitive.not_, return_type=TYPE_BOOL, + arg_descs=[ConstantArg( + Primitive(self.tw.lc.get_heap, return_type=TYPE_BOOL))])) primitive_dictionary['print'] = self._prim_print palette.add_block('comment', |