diff options
author | Tom Rondeau | 2013-05-24 17:20:46 -0400 |
---|---|---|
committer | Johnathan Corgan | 2013-05-25 14:09:23 -0700 |
commit | 2ebafea749da3101f4fb43d77444cedbc719ee08 (patch) | |
tree | 8643c52d5145a312cc8f4b09c38a77cc83474467 | |
parent | d1f48160a87388369c54c7c6eeef404c1a31fe3e (diff) | |
download | gnuradio-2ebafea749da3101f4fb43d77444cedbc719ee08.tar.gz gnuradio-2ebafea749da3101f4fb43d77444cedbc719ee08.tar.bz2 gnuradio-2ebafea749da3101f4fb43d77444cedbc719ee08.zip |
modtool: Fixes for intial templates of a block.
1. adds '$' to args in the GRC xml <make> tag.
2. sets <+ITYPE+> and <+OTYPE+> for all I/O data types in io_signature and in work functions to be more clear what needs modification.
Conflicts:
gr-utils/src/python/modtool/templates.py
-rw-r--r-- | gr-utils/src/python/modtool/code_generator.py | 2 | ||||
-rw-r--r-- | gr-utils/src/python/modtool/templates.py | 33 | ||||
-rw-r--r-- | gr-utils/src/python/modtool/util_functions.py | 6 |
3 files changed, 25 insertions, 16 deletions
diff --git a/gr-utils/src/python/modtool/code_generator.py b/gr-utils/src/python/modtool/code_generator.py index 525b3d1e9..f6bfcd984 100644 --- a/gr-utils/src/python/modtool/code_generator.py +++ b/gr-utils/src/python/modtool/code_generator.py @@ -26,6 +26,7 @@ from util_functions import str_to_fancyc_comment from util_functions import str_to_python_comment from util_functions import strip_default_values from util_functions import strip_arg_types +from util_functions import strip_arg_types_grc class GRMTemplate(Cheetah.Template.Template): """ An extended template class """ @@ -43,6 +44,7 @@ class GRMTemplate(Cheetah.Template.Template): searchList['str_to_python_comment'] = str_to_python_comment searchList['strip_default_values'] = strip_default_values searchList['strip_arg_types'] = strip_arg_types + searchList['strip_arg_types_grc'] = strip_arg_types_grc Cheetah.Template.Template.__init__(self, src, searchList=searchList) self.grblocktype = self.grtypelist[searchList['blocktype']] diff --git a/gr-utils/src/python/modtool/templates.py b/gr-utils/src/python/modtool/templates.py index 878baaadf..362912c06 100644 --- a/gr-utils/src/python/modtool/templates.py +++ b/gr-utils/src/python/modtool/templates.py @@ -118,7 +118,8 @@ namespace gr { ${blockname}::sptr ${blockname}::make(${strip_default_values($arglist)}) { - return gnuradio::get_initial_sptr (new ${blockname}_impl(${strip_arg_types($arglist)})); + return gnuradio::get_initial_sptr + (new ${blockname}_impl(${strip_arg_types($arglist)})); } #if $blocktype == 'decimator' @@ -131,12 +132,12 @@ namespace gr { #if $blocktype == 'source' #set $inputsig = '0, 0, 0' #else -#set $inputsig = '<+MIN_IN+>, <+MAX_IN+>, sizeof (<+float+>)' +#set $inputsig = '<+MIN_IN+>, <+MAX_IN+>, sizeof(<+ITYPE+>)' #end if #if $blocktype == 'sink' #set $outputsig = '0, 0, 0' #else -#set $outputsig = '<+MIN_OUT+>, <+MAX_OUT+>, sizeof (<+float+>)' +#set $outputsig = '<+MIN_OUT+>, <+MAX_OUT+>, sizeof(<+OTYPE+>)' #end if /* * The private constructor @@ -175,8 +176,8 @@ namespace gr { gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; + const <+ITYPE*> *in = (const <+ITYPE*> *) input_items[0]; + <+OTYPE*> *out = (<+OTYPE*> *) output_items[0]; // Do <+signal processing+> // Tell runtime system how many input items we consumed on @@ -194,8 +195,8 @@ namespace gr { gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; + const <+ITYPE+> *in = (const <+ITYPE+> *) input_items[0]; + <+OTYPE+> *out = (<+OTYPE+> *) output_items[0]; // Do <+signal processing+> @@ -294,12 +295,12 @@ import numpy #if $blocktype == 'source' #set $inputsig = '0, 0, 0' #else -#set $inputsig = '<+MIN_IN+>, <+MAX_IN+>, gr.sizeof_<+float+>' +#set $inputsig = '<+MIN_IN+>, <+MAX_IN+>, gr.sizeof_<+ITYPE+>' #end if #if $blocktype == 'sink' #set $outputsig = '0, 0, 0' #else -#set $outputsig = '<+MIN_OUT+>, <+MAX_OUT+>, gr.sizeof_<+float+>' +#set $outputsig = '<+MIN_OUT+>, <+MAX_OUT+>, gr.sizeof_<+OTYPE+>' #end if #end if #if $blocktype == 'interpolator' @@ -455,7 +456,7 @@ Templates['grc_xml'] = '''<?xml version="1.0"?> <key>${modname}_$blockname</key> <category>$modname</category> <import>import $modname</import> - <make>${modname}.${blockname}(${strip_arg_types($arglist)})</make> + <make>${modname}.${blockname}(${strip_arg_types_grc($arglist)})</make> <!-- Make one 'param' node for every Parameter you want settable from the GUI. Sub-nodes: * name @@ -547,12 +548,12 @@ ${modname}_make_${blockname} (${strip_default_values($arglist)}) #if $blocktype == 'sink' #set $inputsig = '0, 0, 0' #else -#set $inputsig = '<+MIN_IN+>, <+MAX_IN+>, sizeof (<+float+>)' +#set $inputsig = '<+MIN_IN+>, <+MAX_IN+>, sizeof(<+ITYPE+>)' #end if #if $blocktype == 'source' #set $outputsig = '0, 0, 0' #else -#set $outputsig = '<+MIN_OUT+>, <+MAX_OUT+>, sizeof (<+float+>)' +#set $outputsig = '<+MIN_OUT+>, <+MAX_OUT+>, sizeof(<+OTYPE+>)' #end if /* @@ -596,8 +597,8 @@ ${modname}_${blockname}::general_work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; + const <+ITYPE+> *in = (const <+ITYPE+> *) input_items[0]; + <+OTYPE+> *out = (<+OTYPE+> *) output_items[0]; // Do <+signal processing+> // Tell runtime system how many input items we consumed on @@ -615,8 +616,8 @@ ${modname}_${blockname}::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const float *in = (const float *) input_items[0]; - float *out = (float *) output_items[0]; + const <+ITYPE+> *in = (const <+ITYPE+> *) input_items[0]; + <+OTYPE+> *out = (<+OTYPE+> *) output_items[0]; // Do <+signal processing+> diff --git a/gr-utils/src/python/modtool/util_functions.py b/gr-utils/src/python/modtool/util_functions.py index c40dbd73b..9551056f0 100644 --- a/gr-utils/src/python/modtool/util_functions.py +++ b/gr-utils/src/python/modtool/util_functions.py @@ -81,6 +81,12 @@ def strip_arg_types(string): string = strip_default_values(string) return ", ".join([part.strip().split(' ')[-1] for part in string.split(',')]) +def strip_arg_types_grc(string): + """" Strip the argument types from a list of arguments for GRC make tag. + Example: "int arg1, double arg2" -> "$arg1, $arg2" """ + string = strip_default_values(string) + return ", ".join(['$' + part.strip().split(' ')[-1] for part in string.split(',')]) + def get_modname(): """ Grep the current module's name from gnuradio.project or CMakeLists.txt """ modname_trans = {'howto-write-a-block': 'howto'} |