assertOpenCL
September 19, 2018
tools
opencl_parse_error_codes.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
# -*- coding: latin-1 -*-
3
4
"""
5
Parse the include file from OpenCL to extract list of error codes and names.
6
7
By default extract from the file:
8
/usr/include/CL/cl.h
9
10
:license: GPLv3 --- Copyright (C) 2018 Olivier Pirson
11
:author: Olivier Pirson --- http://www.opimedia.be/
12
:version: September 15, 2018
13
"""
14
15
from
__future__
import
print_function
16
17
import
re
18
import
sys
19
20
21
#
22
# Main
23
######
24
def
main
():
25
"""
26
Main
27
"""
28
filename = (sys.argv[1]
if
len(sys.argv) > 1
29
else
'/usr/include/CL/cl.h'
)
30
31
active =
False
32
33
with open(filename)
as
fin:
34
for
line
in
fin:
35
line = line.strip()
36
37
if
re.match(
r'/\*\s*error codes\s*\*/'
, line.lower()):
38
active =
True
39
elif
re.match(
r'/\*'
, line):
40
active =
False
41
42
if
active:
43
match = re.match(
r'#define\s+(\S+)\s+(\S+)'
, line)
44
if
match:
45
print(
'{{{}, "{}"}},'
46
.format(match.group(2), match.group(1)))
47
48
49
if
__name__ ==
'__main__'
:
50
main
()
opencl_parse_error_codes.main
def main()
Definition:
opencl_parse_error_codes.py:24
Generated by
1.8.13