blob: e6afb8fb116868080b1eb85a7cac1d1a1a09b5f2 [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:
Yang Deokgyuc9a97352019-08-27 18:48:12 +090015 if 'wiringPiISRCancel' in line:
16 return True
17 else:
18 return False
Phil Howardaee4f5d2016-02-28 09:54:53 +000019 for prefix in ['extern','void','int','uint8_t']:
20 if line.startswith(prefix):
21 return True
22
Phil Howard8e29d402016-02-28 10:50:21 +000023print("// Generated by generate-bindings.py - do not edit manually!")
24
Phil Howardaee4f5d2016-02-28 09:54:53 +000025for file in HEADERS:
26 print("\n// Header file {}".format(file))
27 h = open(file).read().split('\n')
28 extern = False
29 cont = False
30 if 'extern "C" {' not in h:
31 extern = True
32 for line in h:
33 line = line.strip()
34 if cont:
35 print("\t{}".format(line))
36 cont = ";" not in line
37 continue
38 if line.startswith('extern "C"'):
39 extern = True
40 continue
41 if is_c_decl(line) and extern:
42 print(line)
43 cont = ";" not in line