diff options
author | Martin Braun <martin.braun@ettus.com> | 2014-10-22 23:12:53 +0200 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2015-12-28 13:15:38 -0800 |
commit | 2dbbe486a51b8decc21566ceb0a5cb1c414eb499 (patch) | |
tree | feeedf7ec01549c4cac7b635d4fbb88703741501 /gr-utils/python/modtool/templates.py | |
parent | 9bfa5e35d27da1f2ee3935542e98f73c183bcb0d (diff) |
modtool: Switched over to mako template engine
Diffstat (limited to 'gr-utils/python/modtool/templates.py')
-rw-r--r-- | gr-utils/python/modtool/templates.py | 546 |
1 files changed, 267 insertions, 279 deletions
diff --git a/gr-utils/python/modtool/templates.py b/gr-utils/python/modtool/templates.py index dc840df392..2e222e2172 100644 --- a/gr-utils/python/modtool/templates.py +++ b/gr-utils/python/modtool/templates.py @@ -1,5 +1,5 @@ # -# Copyright 2013 Free Software Foundation, Inc. +# Copyright 2013-2014 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -26,7 +26,7 @@ Templates = {} # Default licence Templates['defaultlicense'] = ''' -Copyright %d <+YOU OR YOUR COMPANY+>. +Copyright {0} <+YOU OR YOUR COMPANY+>. This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -42,10 +42,10 @@ You should have received a copy of the GNU General Public License along with this software; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301, USA. -''' % datetime.now().year +'''.format(datetime.now().year) Templates['grlicense'] = ''' -Copyright %d Free Software Foundation, Inc. +Copyright {0} Free Software Foundation, Inc. This file is part of GNU Radio @@ -63,15 +63,15 @@ You should have received a copy of the GNU General Public License along with GNU Radio; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301, USA. -''' % datetime.now().year +'''.format(datetime.now().year) # Header file of a sync/decimator/interpolator block Templates['block_impl_h'] = '''/* -*- c++ -*- */ -${str_to_fancyc_comment($license)} -\#ifndef INCLUDED_${modname.upper()}_${blockname.upper()}_IMPL_H -\#define INCLUDED_${modname.upper()}_${blockname.upper()}_IMPL_H +${str_to_fancyc_comment(license)} +#ifndef INCLUDED_${modname.upper()}_${blockname.upper()}_IMPL_H +#define INCLUDED_${modname.upper()}_${blockname.upper()}_IMPL_H -\#include <${include_dir_prefix}/${blockname}.h> +#include <${include_dir_prefix}/${blockname}.h> namespace gr { namespace ${modname} { @@ -81,112 +81,118 @@ namespace gr { private: // Nothing to declare in this block. -#if $blocktype == 'tagged_stream' +% if blocktype == 'tagged_stream': protected: int calculate_output_stream_length(const gr_vector_int &ninput_items); -#end if +% endif public: - ${blockname}_impl(${strip_default_values($arglist)}); + ${blockname}_impl(${strip_default_values(arglist)}); ~${blockname}_impl(); // Where all the action really happens -#if $blocktype == 'general' +% if blocktype == 'general': void forecast (int noutput_items, gr_vector_int &ninput_items_required); int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); -#else if $blocktype == 'tagged_stream' - int work(int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -#else if $blocktype == 'hier' -#silent pass -#else - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -#end if + +% elif blocktype == 'tagged_stream': + int work( + int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ); +% elif blocktype == 'hier': +% else: + int work( + int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items + ); +% endif }; } // namespace ${modname} } // namespace gr -\#endif /* INCLUDED_${modname.upper()}_${blockname.upper()}_IMPL_H */ +#endif /* INCLUDED_${modname.upper()}_${blockname.upper()}_IMPL_H */ ''' # C++ file of a GR block Templates['block_impl_cpp'] = '''/* -*- c++ -*- */ -${str_to_fancyc_comment($license)} -\#ifdef HAVE_CONFIG_H -\#include "config.h" -\#endif - -\#include <gnuradio/io_signature.h> -#if $blocktype == 'noblock' -\#include <${include_dir_prefix}/${blockname}.h> -#else -\#include "${blockname}_impl.h" -#end if +${str_to_fancyc_comment(license)} +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gnuradio/io_signature.h> +% if blocktype == 'noblock': +#include <${include_dir_prefix}/${blockname}.h> +% else: +#include "${blockname}_impl.h" +% endif namespace gr { namespace ${modname} { -#if $blocktype == 'noblock' - $blockname::${blockname}(${strip_default_values($arglist)}) +% if blocktype == 'noblock': + ${blockname}::${blockname}(${strip_default_values(arglist)}) { } - $blockname::~${blockname}() + ${blockname}::~${blockname}() { } -#else +% else: ${blockname}::sptr - ${blockname}::make(${strip_default_values($arglist)}) + ${blockname}::make(${strip_default_values(arglist)}) { return gnuradio::get_initial_sptr - (new ${blockname}_impl(${strip_arg_types($arglist)})); + (new ${blockname}_impl(${strip_arg_types(arglist)})); } -#if $blocktype == 'decimator' -#set $decimation = ', <+decimation+>' -#else if $blocktype == 'interpolator' -#set $decimation = ', <+interpolation+>' -#else if $blocktype == 'tagged_stream' -#set $decimation = ', <+len_tag_key+>' -#else -#set $decimation = '' -#end if -#if $blocktype == 'source' -#set $inputsig = '0, 0, 0' -#else -#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(<+OTYPE+>)' -#end if +<% + if blocktype == 'decimator': + decimation = ', <+decimation+>' + elif blocktype == 'interpolator': + decimation = ', <+interpolation+>' + elif blocktype == 'tagged_stream': + decimation = ', <+len_tag_key+>' + else: + decimation = '' + endif + if blocktype == 'source': + inputsig = '0, 0, 0' + else: + inputsig = '<+MIN_IN+>, <+MAX_IN+>, sizeof(<+ITYPE+>)' + endif + if blocktype == 'sink': + outputsig = '0, 0, 0' + else: + outputsig = '<+MIN_OUT+>, <+MAX_OUT+>, sizeof(<+OTYPE+>)' + endif +%> /* * The private constructor */ - ${blockname}_impl::${blockname}_impl(${strip_default_values($arglist)}) + ${blockname}_impl::${blockname}_impl(${strip_default_values(arglist)}) : gr::${grblocktype}("${blockname}", - gr::io_signature::make($inputsig), - gr::io_signature::make($outputsig)$decimation) -#if $blocktype == 'hier' + gr::io_signature::make(${inputsig}), + gr::io_signature::make(${outputsig})${decimation}) + % if blocktype == 'hier': { connect(self(), 0, d_firstblock, 0); // connect other blocks connect(d_lastblock, 0, self(), 0); } -#else + % else: {} -#end if + % endif /* * Our virtual destructor. @@ -195,7 +201,7 @@ namespace gr { { } -#if $blocktype == 'general' + % if blocktype == 'general': void ${blockname}_impl::forecast (int noutput_items, gr_vector_int &ninput_items_required) { @@ -219,7 +225,7 @@ namespace gr { // Tell runtime system how many output items we produced. return noutput_items; } -#else if $blocktype == 'tagged_stream' + % elif blocktype == 'tagged_stream': int ${blockname}_impl::calculate_output_stream_length(const gr_vector_int &ninput_items) { @@ -241,32 +247,27 @@ namespace gr { // Tell runtime system how many output items we produced. return noutput_items; } -#else if $blocktype == 'hier' -#silent pass -#else + % elif blocktype == 'hier': + % else: int ${blockname}_impl::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { -#if $blocktype == 'source' -#silent pass -#else + % if blocktype != 'source': const <+ITYPE+> *in = (const <+ITYPE+> *) input_items[0]; -#end if -#if $blocktype == 'sink' -#silent pass -#else + % endif + % if blocktype != 'sink': <+OTYPE+> *out = (<+OTYPE+> *) output_items[0]; -#end if + % endif // Do <+signal processing+> // Tell runtime system how many output items we produced. return noutput_items; } -#end if -#end if + % endif +% endif } /* namespace ${modname} */ } /* namespace gr */ @@ -275,38 +276,38 @@ namespace gr { # Block definition header file (for include/) Templates['block_def_h'] = '''/* -*- c++ -*- */ -${str_to_fancyc_comment($license)} +${str_to_fancyc_comment(license)} -\#ifndef INCLUDED_${modname.upper()}_${blockname.upper()}_H -\#define INCLUDED_${modname.upper()}_${blockname.upper()}_H +#ifndef INCLUDED_${modname.upper()}_${blockname.upper()}_H +#define INCLUDED_${modname.upper()}_${blockname.upper()}_H -\#include <${include_dir_prefix}/api.h> -#if $blocktype != 'noblock' -\#include <gnuradio/${grblocktype}.h> -#end if +#include <${include_dir_prefix}/api.h> +% if blocktype != 'noblock': +#include <gnuradio/${grblocktype}.h> +% endif namespace gr { namespace ${modname} { -#if $blocktype == 'noblock' +% if blocktype == 'noblock': /*! * \\brief <+description+> * */ - class ${modname.upper()}_API $blockname + class ${modname.upper()}_API ${blockname} { public: ${blockname}(${arglist}); ~${blockname}(); private: }; -#else +% else: /*! * \\brief <+description of block+> * \ingroup ${modname} * */ - class ${modname.upper()}_API ${blockname} : virtual public gr::$grblocktype + class ${modname.upper()}_API ${blockname} : virtual public gr::${grblocktype} { public: typedef boost::shared_ptr<${blockname}> sptr; @@ -319,85 +320,94 @@ namespace gr { * class. ${modname}::${blockname}::make is the public interface for * creating new instances. */ - static sptr make($arglist); + static sptr make(${arglist}); }; -#end if +% endif } // namespace ${modname} } // namespace gr -\#endif /* INCLUDED_${modname.upper()}_${blockname.upper()}_H */ +#endif /* INCLUDED_${modname.upper()}_${blockname.upper()}_H */ ''' # Python block -Templates['block_python'] = '''\#!/usr/bin/env python +Templates['block_python'] = '''#!/usr/bin/env python # -*- coding: utf-8 -*- -${str_to_python_comment($license)} -# -#if $blocktype == 'noblock' -#stop -#end if - -#if $blocktype in ('sync', 'sink', 'source') -#set $parenttype = 'gr.sync_block' -#else -#set $parenttype = {'hier': 'gr.hier_block2', 'interpolator': 'gr.interp_block', 'decimator': 'gr.decim_block', 'general': 'gr.basic_block'}[$blocktype] -#end if -#if $blocktype != 'hier' -import numpy -#if $blocktype == 'source' -#set $inputsig = 'None' -#else -#set $inputsig = '[<+numpy.float+>]' -#end if -#if $blocktype == 'sink' -#set $outputsig = 'None' -#else -#set $outputsig = '[<+numpy.float+>]' -#end if -#else -#if $blocktype == 'source' -#set $inputsig = '0, 0, 0' -#else -#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_<+OTYPE+>' -#end if -#end if -#if $blocktype == 'interpolator' -#set $deciminterp = ', <+interpolation+>' -#else if $blocktype == 'decimator' -#set $deciminterp = ', <+decimation+>' -#else -#set $deciminterp = '' -#end if -from gnuradio import gr +${str_to_python_comment(license)} +#\ +<% + if blocktype == 'noblock': + return + if blocktype in ('sync', 'sink', 'source'): + parenttype = 'gr.sync_block' + else: + parenttype = { + 'hier': 'gr.hier_block2', + 'interpolator': 'gr.interp_block', + 'decimator': 'gr.decim_block', + 'general': 'gr.basic_block' + }[blocktype] +%> +% if blocktype != 'hier': + +import numpy\ +<% + if blocktype == 'source': + inputsig = 'None' + else: + inputsig = '[<+numpy.float32+>]' + if blocktype == 'sink': + outputsig = 'None' + else: + outputsig = '[<+numpy.float32+>]' +%> +% else: +<% + if blocktype == 'source': + inputsig = '0, 0, 0' + else: + inputsig = '<+MIN_IN+>, <+MAX_IN+>, gr.sizeof_<+ITYPE+>' + if blocktype == 'sink': + outputsig = '0, 0, 0' + else: + outputsig = '<+MIN_OUT+>, <+MAX_OUT+>, gr.sizeof_<+OTYPE+>' +%> +% endif +<% + if blocktype == 'interpolator': + deciminterp = ', <+interpolation+>' + elif blocktype == 'decimator': + deciminterp = ', <+decimation+>' + else: + deciminterp = '' + if arglist == '': + arglistsep = '' + else: + arglistsep = ', ' +%>from gnuradio import gr class ${blockname}(${parenttype}): """ docstring for block ${blockname} """ - def __init__(self#if $arglist == '' then '' else ', '#$arglist): + def __init__(self${arglistsep}${arglist}): ${parenttype}.__init__(self, -#if $blocktype == 'hier' - "$blockname", +% if blocktype == 'hier': + "${blockname}", gr.io_signature(${inputsig}), # Input signature gr.io_signature(${outputsig})) # Output signature # Define blocks and connect them self.connect() -#stop -#else +<% return %> +% else: name="${blockname}", in_sig=${inputsig}, out_sig=${outputsig}${deciminterp}) -#end if +% endif -#if $blocktype == 'general' +% if blocktype == 'general': def forecast(self, noutput_items, ninput_items_required): #setup size of input_items[i] for work call for i in range(len(ninput_items_required)): @@ -408,37 +418,37 @@ class ${blockname}(${parenttype}): consume(0, len(input_items[0])) \#self.consume_each(len(input_items[0])) return len(output_items[0]) -#stop -#end if +<% return %> +% endif def work(self, input_items, output_items): -#if $blocktype != 'source' +% if blocktype != 'source': in0 = input_items[0] -#end if -#if $blocktype != 'sink' +% endif +% if blocktype != 'sink': out = output_items[0] -#end if +% endif # <+signal processing here+> -#if $blocktype in ('sync', 'decimator', 'interpolator') +% if blocktype in ('sync', 'decimator', 'interpolator'): out[:] = in0 return len(output_items[0]) -#else if $blocktype == 'sink' +% elif blocktype == 'sink': return len(input_items[0]) -#else if $blocktype == 'source' +% elif blocktype == 'source': out[:] = whatever return len(output_items[0]) -#end if +% endif ''' # C++ file for QA Templates['qa_cpp'] = '''/* -*- c++ -*- */ -${str_to_fancyc_comment($license)} +${str_to_fancyc_comment(license)} -\#include <gnuradio/attributes.h> -\#include <cppunit/TestAssert.h> -\#include "qa_${blockname}.h" -\#include <${include_dir_prefix}/${blockname}.h> +#include <gnuradio/attributes.h> +#include <cppunit/TestAssert.h> +#include "qa_${blockname}.h" +#include <${include_dir_prefix}/${blockname}.h> namespace gr { namespace ${modname} { @@ -456,13 +466,13 @@ namespace gr { # Header file for QA Templates['qa_h'] = '''/* -*- c++ -*- */ -${str_to_fancyc_comment($license)} +${str_to_fancyc_comment(license)} -\#ifndef _QA_${blockname.upper()}_H_ -\#define _QA_${blockname.upper()}_H_ +#ifndef _QA_${blockname.upper()}_H_ +#define _QA_${blockname.upper()}_H_ -\#include <cppunit/extensions/HelperMacros.h> -\#include <cppunit/TestCase.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/TestCase.h> namespace gr { namespace ${modname} { @@ -481,25 +491,25 @@ namespace gr { } /* namespace ${modname} */ } /* namespace gr */ -\#endif /* _QA_${blockname.upper()}_H_ */ +#endif /* _QA_${blockname.upper()}_H_ */ ''' # Python QA code -Templates['qa_python'] = '''\#!/usr/bin/env python +Templates['qa_python'] = '''#!/usr/bin/env python # -*- coding: utf-8 -*- -${str_to_python_comment($license)} +${str_to_python_comment(license)} # from gnuradio import gr, gr_unittest from gnuradio import blocks -#if $lang == 'cpp' +% if lang == 'cpp': import ${modname}_swig as ${modname} -#else +% else: from ${blockname} import ${blockname} -#end if +% endif -class qa_$blockname (gr_unittest.TestCase): +class qa_${blockname} (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -519,11 +529,11 @@ if __name__ == '__main__': Templates['grc_xml'] = '''<?xml version="1.0"?> <block> - <name>$blockname</name> - <key>${modname}_$blockname</key> - <category>$modname</category> - <import>import $modname</import> - <make>${modname}.${blockname}(${strip_arg_types_grc($arglist)})</make> + <name>${blockname}</name> + <key>${modname}_${blockname}</key> + <category>${modname}</category> + <import>import ${modname}</import> + <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 @@ -564,80 +574,85 @@ gr_modtool help -- Show a list of commands. 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 "${include_dir_prefix}/${blockname}.h" -#if $blocktype != 'noblock' -GR_SWIG_BLOCK_MAGIC2($modname, $blockname); -#end if -#end if +Templates['swig_block_magic'] = """% if version == '36': +% if blocktype != 'noblock': +GR_SWIG_BLOCK_MAGIC(${modname}, ${blockname}); +% endif +%%include "${modname}_${blockname}.h" +% else: +%%include "${include_dir_prefix}/${blockname}.h" + % if blocktype != 'noblock': +GR_SWIG_BLOCK_MAGIC2(${modname}, ${blockname}); + % endif +% endif """ ## Old stuff # C++ file of a GR block Templates['block_cpp36'] = '''/* -*- c++ -*- */ -${str_to_fancyc_comment($license)} -\#ifdef HAVE_CONFIG_H -\#include "config.h" -\#endif - -#if $blocktype != 'noblock' -\#include <gr_io_signature.h> -#end if -\#include "${modname}_${blockname}.h" - -#if $blocktype == 'noblock' -${modname}_${blockname}::${modname}_${blockname}(${strip_default_values($arglist)}) +${str_to_fancyc_comment(license)} +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +% if blocktype != 'noblock': +#include <gr_io_signature.h> +% endif +#include "${modname}_${blockname}.h" + +% if blocktype == 'noblock': +${modname}_${blockname}::${modname}_${blockname}(${strip_default_values(arglist)}) { } ${modname}_${blockname}::~${modname}_${blockname}() { } -#else +% else: ${modname}_${blockname}_sptr -${modname}_make_${blockname} (${strip_default_values($arglist)}) +${modname}_make_${blockname} (${strip_default_values(arglist)}) { - return gnuradio::get_initial_sptr (new ${modname}_${blockname}(${strip_arg_types($arglist)})); + return gnuradio::get_initial_sptr (new ${modname}_${blockname}(${strip_arg_types(arglist)})); } -#if $blocktype == 'decimator' -#set $decimation = ', <+decimation+>' -#else if $blocktype == 'interpolator' -#set $decimation = ', <+interpolation+>' -#else -#set $decimation = '' -#end if -#if $blocktype == 'sink' -#set $inputsig = '0, 0, 0' -#else -#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(<+OTYPE+>)' -#end if +<% + if blocktype == 'interpolator': + deciminterp = ', <+interpolation+>' + elif blocktype == 'decimator': + deciminterp = ', <+decimation+>' + else: + deciminterp = '' + if arglist == '': + arglistsep = '' + else: + arglistsep = ', ' + if blocktype == 'source': + inputsig = '0, 0, 0' + else: + inputsig = '<+MIN_IN+>, <+MAX_IN+>, sizeof(<+ITYPE+>)' + endif + if blocktype == 'sink': + outputsig = '0, 0, 0' + else: + outputsig = '<+MIN_OUT+>, <+MAX_OUT+>, sizeof(<+OTYPE+>)' + endif +%> /* * The private constructor */ -${modname}_${blockname}::${modname}_${blockname} (${strip_default_values($arglist)}) +${modname}_${blockname}::${modname}_${blockname} (${strip_default_values(arglist)}) : gr_${grblocktype} ("${blockname}", - gr_make_io_signature($inputsig), - gr_make_io_signature($outputsig)$decimation) + gr_make_io_signature(${inputsig}), + gr_make_io_signature(${outputsig})${deciminterp}) { -#if $blocktype == 'hier' +% if blocktype == 'hier' connect(self(), 0, d_firstblock, 0); // <+connect other blocks+> connect(d_lastblock, 0, self(), 0); -#else +% else: // Put in <+constructor stuff+> here -#end if +% endif } @@ -648,10 +663,10 @@ ${modname}_${blockname}::~${modname}_${blockname}() { // Put in <+destructor stuff+> here } -#end if +% endif -#if $blocktype == 'general' +% if blocktype == 'general' void ${modname}_${blockname}::forecast (int noutput_items, gr_vector_int &ninput_items_required) { @@ -675,9 +690,8 @@ ${modname}_${blockname}::general_work (int noutput_items, // Tell runtime system how many output items we produced. return noutput_items; } -#else if $blocktype == 'hier' or $blocktype == 'noblock' -#pass -#else +% elif blocktype == 'hier' or $blocktype == 'noblock': +% else: int ${modname}_${blockname}::work(int noutput_items, gr_vector_const_void_star &input_items, @@ -691,51 +705,51 @@ ${modname}_${blockname}::work(int noutput_items, // Tell runtime system how many output items we produced. return noutput_items; } -#end if +% endif ''' # Block definition header file (for include/) Templates['block_h36'] = '''/* -*- c++ -*- */ -${str_to_fancyc_comment($license)} +${str_to_fancyc_comment(license)} -\#ifndef INCLUDED_${modname.upper()}_${blockname.upper()}_H -\#define INCLUDED_${modname.upper()}_${blockname.upper()}_H +#ifndef INCLUDED_${modname.upper()}_${blockname.upper()}_H +#define INCLUDED_${modname.upper()}_${blockname.upper()}_H -\#include <${modname}_api.h> -#if $blocktype == 'noblock' -class ${modname.upper()}_API $blockname +#include <${modname}_api.h> +% if blocktype == 'noblock' +class ${modname.upper()}_API ${blockname} { ${blockname}(${arglist}); ~${blockname}(); private: }; -#else -\#include <gr_${grblocktype}.h> +% else: +#include <gr_${grblocktype}.h> class ${modname}_${blockname}; typedef boost::shared_ptr<${modname}_${blockname}> ${modname}_${blockname}_sptr; -${modname.upper()}_API ${modname}_${blockname}_sptr ${modname}_make_${blockname} ($arglist); +${modname.upper()}_API ${modname}_${blockname}_sptr ${modname}_make_${blockname} (${arglist}); /*! * \\brief <+description+> * \ingroup ${modname} * */ -class ${modname.upper()}_API ${modname}_${blockname} : public gr_$grblocktype +class ${modname.upper()}_API ${modname}_${blockname} : public gr_${grblocktype} { private: - friend ${modname.upper()}_API ${modname}_${blockname}_sptr ${modname}_make_${blockname} (${strip_default_values($arglist)}); + friend ${modname.upper()}_API ${modname}_${blockname}_sptr ${modname}_make_${blockname} (${strip_default_values(arglist)}); - ${modname}_${blockname}(${strip_default_values($arglist)}); + ${modname}_${blockname}(${strip_default_values(arglist)}); public: ~${modname}_${blockname}(); -#if $blocktype == 'general' + % if blocktype == 'general': void forecast (int noutput_items, gr_vector_int &ninput_items_required); // Where all the action really happens @@ -743,43 +757,17 @@ class ${modname.upper()}_API ${modname}_${blockname} : public gr_$grblocktype gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); -#else if $blocktype == 'hier' -#pass -#else + % elif blocktype == 'hier': + % else: // Where all the action really happens int work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); -#end if + % endif }; -#end if +% endif -\#endif /* INCLUDED_${modname.upper()}_${blockname.upper()}_H */ +#endif /* INCLUDED_${modname.upper()}_${blockname.upper()}_H */ ''' -# C++ file for QA -Templates['qa_cpp36'] = '''/* -*- c++ -*- */ -${str_to_fancyc_comment($license)} - -\#include <boost/test/unit_test.hpp> - -BOOST_AUTO_TEST_CASE(qa_${modname}_${blockname}_t1){ - BOOST_CHECK_EQUAL(2 + 2, 4); - // TODO BOOST_* test macros here -} - -BOOST_AUTO_TEST_CASE(qa_${modname}_${blockname}_t2){ - BOOST_CHECK_EQUAL(2 + 2, 4); - // TODO BOOST_* test macros here -} - -''' - -# Header file for QA -Templates['qa_cmakeentry36'] = """ -add_executable($basename $filename) -target_link_libraries($basename gnuradio-$modname \${Boost_LIBRARIES}) -GR_ADD_TEST($basename $basename) -""" - |