blob: 60fd68813e9855b2f85dec89be87a9c9429c256a [file] [log] [blame]
Phil Howard95c6d562016-02-29 12:07:24 +00001HEADERS = []
Phil Howardaee4f5d2016-02-28 09:54:53 +00002
Phil Howard95c6d562016-02-29 12:07:24 +00003src = open("wiringpi.i").read().split('\n')
Phil Howardaee4f5d2016-02-28 09:54:53 +00004
Phil Howard95c6d562016-02-29 12:07:24 +00005for line in src:
6 line = line.strip()
7 if line.startswith('#include') and line.endswith('.h"'):
8 HEADERS.append(line.replace('#include','').replace('"','').strip())
9
10#print(HEADERS)
11
Phil Howardaee4f5d2016-02-28 09:54:53 +000012def is_c_decl(line):
Phil Howard8e29d402016-02-28 10:50:21 +000013 for fn in ['wiringPiISR','wiringPiSetupPiFace','wiringPiSetupPiFaceForGpioProg']:
14 if fn in line:
15 return False
Phil Howardaee4f5d2016-02-28 09:54:53 +000016 for prefix in ['extern','void','int','uint8_t']:
17 if line.startswith(prefix):
18 return True
19
Phil Howard8e29d402016-02-28 10:50:21 +000020print("// Generated by generate-bindings.py - do not edit manually!")
21
Phil Howardaee4f5d2016-02-28 09:54:53 +000022for file in HEADERS:
23 print("\n// Header file {}".format(file))
24 h = open(file).read().split('\n')
25 extern = False
26 cont = False
27 if 'extern "C" {' not in h:
28 extern = True
29 for line in h:
30 line = line.strip()
31 if cont:
32 print("\t{}".format(line))
33 cont = ";" not in line
34 continue
35 if line.startswith('extern "C"'):
36 extern = True
37 continue
38 if is_c_decl(line) and extern:
39 print(line)
40 cont = ";" not in line