Update to 2.0.0 tree from current Fremantle build
[opencv] / utils / extract_constants.py
1 #! /usr/bin/env python
2 """
3 This script extracts #defines from those OpenCV headers that can't be
4 directly parsed by current SWIG versions and must be pre-filtered by
5 the C preprocessor (that erases all #defines).
6 """
7
8 import sys, re
9
10 for fn in sys.argv[1:]:
11     f = open( fn, "r" )
12     in_define = 0
13     for l in f.xreadlines():
14         if re.match( r"^#define\s+(CV_|IPL_|cv)\w+\s+", l ):
15             in_define = 1
16         if re.match (r"^#define\s+CV_MAKETYPE", l):
17             in_define = 1
18         if re.match (r"^#define\s+CV_CN", l):
19             in_define = 1
20         if re.match (r"^#define\s+CV_MAT_TYPE", l):
21             in_define = 1
22         if re.match (r"^#define\s+CV_MAT_DEPTH", l):
23             in_define = 1
24         if in_define:
25             print l[:l.find ('/*')]
26             if not l.endswith( "\\\n" ):
27                 in_define = 0
28                 print
29     f.close()
30