blob: 143442177d8d55549d0ee85e6247eb19b4f054bf [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()
Yang Deokgyu6e3ed1f2019-08-29 18:45:48 +090034 if 'UNU' in line[-5:]:
35 line = line[:-5] + ';'
Phil Howardaee4f5d2016-02-28 09:54:53 +000036 if cont:
37 print("\t{}".format(line))
38 cont = ";" not in line
39 continue
40 if line.startswith('extern "C"'):
41 extern = True
42 continue
43 if is_c_decl(line) and extern:
44 print(line)
45 cont = ";" not in line