3 # Copyright 2004 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.
27 f.write ('''/* -*- c++ -*- */
29 * Copyright 2004 Free Software Foundation, Inc.
31 * This file is part of GNU Radio
33 * GNU Radio is free software; you can redistribute it and/or modify
34 * it under the terms of the GNU General Public License as published by
35 * the Free Software Foundation; either version 2, or (at your option)
38 * GNU Radio is distributed in the hope that it will be useful,
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 * GNU General Public License for more details.
43 * You should have received a copy of the GNU General Public License
44 * along with GNU Radio; see the file COPYING. If not, write to
45 * the Free Software Foundation, Inc., 51 Franklin Street,
46 * Boston, MA 02110-1301, USA.
49 #ifndef INCLUDED_GNURADIO_SWIG_BUG_WORKAROUND_H
50 #define INCLUDED_GNURADIO_SWIG_BUG_WORKAROUND_H
53 * This include files works around a bug in SWIG 1.3.21 and 22
54 * where it fails to emit these declarations when doing
55 * %import "gnuradio.i"
60 def write_trailer (f):
62 #endif /* INCLUDED_GNURADIO_SWIG_BUG_WORKAROUND_H */
65 def doit (input, output):
66 re_RULES_BEGIN = re.compile ('RULES \(BEGIN\)')
67 re_RULES_END = re.compile ('RULES \(END\)')
68 re_RETURN = re.compile ('^\s*return')
69 re_NOT_ID = re.compile ('[^a-zA-Z0-9_]')
74 if re_RULES_BEGIN.search (line):
78 if re_RULES_END.search (line):
80 if not re_RETURN.match (line):
82 line = re_NOT_ID.sub (' ', line)
83 line = re.sub (' +', ' ', line)
84 for w in line.split (' '):
87 for w in ('', 'return', 'void', 'x'):
93 output.write ('class ' + w + ';\n')
95 write_trailer (output)
99 if len (sys.argv) != 3:
100 sys.stderr.write ("usage: %s gnuradio_swig_python.cc gnuradio_swig_bug_workaround.h\n"
103 input_filename = sys.argv[1]
104 output_filename = sys.argv[2]
105 input = open (input_filename, "r")
106 output = open (output_filename, "w")
109 if __name__ == '__main__':