summaryrefslogtreecommitdiff
path: root/gr-utils/src/python
diff options
context:
space:
mode:
authorJosh Blum2013-06-11 15:04:51 -0700
committerJosh Blum2013-06-11 15:04:51 -0700
commit62402b122cd3f4f3fb80325771d6117f75798b11 (patch)
treec3560564ed73adbd212c18a2e96d4ef72ebaba09 /gr-utils/src/python
parentf4fc952e58ce318298258926f7382ed28b92bfae (diff)
parent2b7292593d898d7ce9a851c7ae7f168f200ea1c1 (diff)
downloadgnuradio-62402b122cd3f4f3fb80325771d6117f75798b11.tar.gz
gnuradio-62402b122cd3f4f3fb80325771d6117f75798b11.tar.bz2
gnuradio-62402b122cd3f4f3fb80325771d6117f75798b11.zip
Merge branch 'v3.6.4_branch' into v3.6.4git_gras_support
Diffstat (limited to 'gr-utils/src/python')
-rw-r--r--gr-utils/src/python/modtool/code_generator.py2
-rw-r--r--gr-utils/src/python/modtool/modtool_newmod.py2
-rw-r--r--gr-utils/src/python/modtool/templates.py40
-rw-r--r--gr-utils/src/python/modtool/util_functions.py6
4 files changed, 32 insertions, 18 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/modtool_newmod.py b/gr-utils/src/python/modtool/modtool_newmod.py
index 0613d5fbe..e3b0e8e79 100644
--- a/gr-utils/src/python/modtool/modtool_newmod.py
+++ b/gr-utils/src/python/modtool/modtool_newmod.py
@@ -37,7 +37,7 @@ class ModToolNewModule(ModTool):
def setup_parser(self):
" Initialise the option parser for 'gr_modtool newmod' "
parser = ModTool.setup_parser(self)
- parser.usage = '%prog rm [options]. \n Call %prog without any options to run it interactively.'
+ parser.usage = '%prog nm [options]. \n Call %prog without any options to run it interactively.'
ogroup = OptionGroup(parser, "New out-of-tree module options")
ogroup.add_option("--srcdir", type="string",
help="Source directory for the module template.")
diff --git a/gr-utils/src/python/modtool/templates.py b/gr-utils/src/python/modtool/templates.py
index 58617336e..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_IN+>, <+MAX_IN+>, 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+>
@@ -230,9 +231,10 @@ namespace gr {
*/
class ${modname.upper()}_API $blockname
{
+ public:
${blockname}(${arglist});
~${blockname}();
- private:
+ private:
};
#else
/*!
@@ -293,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'
@@ -454,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
@@ -496,12 +498,16 @@ gr_modtool help <command> -- Shows the help for a given command. '''
# SWIG string
Templates['swig_block_magic'] = """#if $version == '36'
+#if $blocktype != 'noblock'
GR_SWIG_BLOCK_MAGIC($modname, $blockname);
+#end if
%include "${modname}_${blockname}.h"
#else
%include "${modname}/${blockname}.h"
+#if $blocktype != 'noblock'
GR_SWIG_BLOCK_MAGIC2($modname, $blockname);
#end if
+#end if
"""
## Old stuff
@@ -542,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
/*
@@ -591,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
@@ -610,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'}