3 # Copyright 2006 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING. If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
24 Generate code for uniform numeric vectors
27 import re, os, os.path
41 ('c32', 'std::complex<float>'),
42 ('c64', 'std::complex<double>')
48 * Copyright 2006 Free Software Foundation, Inc.
50 * This file is part of GNU Radio
52 * GNU Radio is free software; you can redistribute it and/or modify
53 * it under the terms of the GNU General Public License as published by
54 * the Free Software Foundation; either version 2, or (at your option)
57 * GNU Radio is distributed in the hope that it will be useful,
58 * but WITHOUT ANY WARRANTY; without even the implied warranty of
59 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
60 * GNU General Public License for more details.
62 * You should have received a copy of the GNU General Public License
63 * along with GNU Radio; see the file COPYING. If not, write to
64 * the Free Software Foundation, Inc., 51 Franklin Street,
65 * Boston, MA 02110-1301, USA.
84 #include <qa_pmt_unv.h>
85 #include <cppunit/TestAssert.h>
92 # set srcdir to the directory that contains Makefile.am
94 srcdir = os.environ['srcdir']
100 def open_src (name, mode):
102 return open(os.path.join (srcdir, name), mode)
105 def guard_name(filename):
106 return 'INCLUDED_' + re.sub('\.', '_', filename.upper())
108 def guard_head(filename):
109 guard = guard_name(filename)
116 def do_substitution (d, input, out_file):
117 def repl (match_obj):
118 key = match_obj.group (1)
122 out = re.sub (r"@([a-zA-Z0-9_]+)@", repl, input)
127 template = open_src('unv_template.h.t', 'r').read()
128 output_filename = 'pmt_unv_int.h'
129 output = open(output_filename, 'w')
131 output.write(guard_head(output_filename))
132 for tag, typ in unv_types:
133 d = { 'TAG' : tag, 'TYPE' : typ }
134 do_substitution(d, template, output)
135 output.write(guard_tail)
138 template = open_src('unv_template.cc.t', 'r').read()
139 output = open('pmt_unv.cc', 'w')
141 output.write(includes)
142 for tag, typ in unv_types:
143 d = { 'TAG' : tag, 'TYPE' : typ }
144 do_substitution(d, template, output)
148 output_filename = 'qa_pmt_unv.h'
149 output = open(output_filename, 'w')
151 output.write(guard_head(output_filename))
154 #include <cppunit/extensions/HelperMacros.h>
155 #include <cppunit/TestCase.h>
157 class qa_pmt_unv : public CppUnit::TestCase {
159 CPPUNIT_TEST_SUITE(qa_pmt_unv);
161 for tag, typ in unv_types:
162 output.write(' CPPUNIT_TEST(test_%svector);\n' % (tag,))
164 CPPUNIT_TEST_SUITE_END();
168 for tag, typ in unv_types:
169 output.write(' void test_%svector();\n' % (tag,))
171 output.write(guard_tail)
173 def generate_qa_cc():
174 template = open_src('unv_qa_template.cc.t', 'r').read()
175 output = open('qa_pmt_unv.cc', 'w')
177 output.write(qa_includes)
178 for tag, typ in unv_types:
179 d = { 'TAG' : tag, 'TYPE' : typ }
180 do_substitution(d, template, output)
189 if __name__ == '__main__':