Fixing up filters a bit to pass QA tests for all versions.
[debian/gnuradio] / gnuradio-core / src / lib / filter / generate_gri_fir_filter_with_buffer_XXX.py
1 #!/usr/bin/env python
2 # -*- python -*-
3 #
4 # Copyright 2010 Free Software Foundation, Inc.
5
6 # This file is part of GNU Radio
7
8 # GNU Radio is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3, or (at your option)
11 # any later version.
12
13 # GNU Radio is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17
18 # You should have received a copy of the GNU General Public License
19 # along with GNU Radio; see the file COPYING.  If not, write to
20 # the Free Software Foundation, Inc., 51 Franklin Street,
21 # Boston, MA 02110-1301, USA.
22
23
24 import re
25 from generate_utils import *
26
27 roots = ['gri_fir_filter_with_buffer_XXX',]
28
29 def code3_to_acc_code (code3):
30     if i_code (code3) == 'c' or o_code (code3) == 'c' or tap_code (code3) == 'c':
31         return 'c'
32     if i_code (code3) == 'f' or o_code (code3) == 'f' or tap_code (code3) == 'f':
33         return 'f'
34     if i_code (code3) == 'i' or o_code (code3) == 'i' or tap_code (code3) == 'i':
35         return 'i'
36     return 'i'                          # even short short short needs int accumulator
37
38 def code3_to_input_cast (code3):
39     if i_code (code3) == 's' and o_code (code3) == 'c':
40         return '(float)'
41     return ''
42
43 def expand_h_cc (root, code3):
44     d = init_dict (root, code3)
45     expand_template (d, root + '.h.t')
46     expand_template (d, root + '.cc.t')
47
48 def init_dict (root, code3):
49     name = re.sub ('X+', code3, root)
50     d = standard_dict (name, code3)
51     d['INPUT_CAST'] = code3_to_input_cast (code3)
52     acc_code = code3_to_acc_code (code3)
53     d['ACC_TYPE'] = char_to_type[acc_code]
54     return d
55     
56
57 def generate ():
58     for r in roots:
59         for s in fir_signatures:
60             expand_h_cc (r, s)
61
62
63 if __name__ == '__main__':
64     generate ()