ocl: workaround for OpenCL C++ bindings usage: CL/cl.hpp
This commit is contained in:
@@ -182,6 +182,29 @@ def generateTemplates(sz, lprefix, switch_name, calling_convention=''):
|
||||
print '};'
|
||||
print ''
|
||||
|
||||
@outputToString
|
||||
def generateInlineWrappers(fns):
|
||||
print '// generated by %s' % os.path.basename(sys.argv[0])
|
||||
for fn in fns:
|
||||
print '#undef %s' % (fn['name'])
|
||||
print '#define %s %s_fn' % (fn['name'], fn['name'])
|
||||
params = []
|
||||
call_params = []
|
||||
for i in range(0, len(fn['params'])):
|
||||
t = fn['params'][i]
|
||||
if t.find('*)') >= 0:
|
||||
p = re.sub(r'\*\)', (' *p%d)' % i), t, 1)
|
||||
params.append(p)
|
||||
else:
|
||||
params.append('%s p%d' % (t, i))
|
||||
call_params.append('p%d' % (i))
|
||||
|
||||
if len(fn['ret']) == 1 and fn['ret'][0] == 'void':
|
||||
print 'inline void %s(%s) { %s_pfn(%s); }' \
|
||||
% (fn['name'], ', '.join(params), fn['name'], ', '.join(call_params))
|
||||
else:
|
||||
print 'inline %s %s(%s) { return %s_pfn(%s); }' \
|
||||
% (' '.join(fn['ret']), fn['name'], ', '.join(params), fn['name'], ', '.join(call_params))
|
||||
|
||||
def ProcessTemplate(inputFile, ctx, noteLine='//\n// AUTOGENERATED, DO NOT EDIT\n//'):
|
||||
f = open(inputFile, "r")
|
||||
|
@@ -10,6 +10,7 @@ try:
|
||||
if len(sys.argv) > 1:
|
||||
outfile = open('../../../include/opencv2/ocl/cl_runtime/' + sys.argv[1] + '.hpp', "w")
|
||||
outfile_impl = open('../' + sys.argv[1] + '_impl.hpp', "w")
|
||||
outfile_wrappers = open('../../../include/opencv2/ocl/cl_runtime/' + sys.argv[1] + '_wrappers.hpp', "w")
|
||||
if len(sys.argv) > 2:
|
||||
f = open(sys.argv[2], "r")
|
||||
else:
|
||||
@@ -102,6 +103,11 @@ ctx['CL_FN_DECLARATIONS'] = generateFnDeclaration(fns)
|
||||
sys.stdout = outfile
|
||||
ProcessTemplate('template/cl_runtime_opencl.hpp.in', ctx)
|
||||
|
||||
ctx['CL_FN_INLINE_WRAPPERS'] = generateInlineWrappers(fns)
|
||||
|
||||
sys.stdout = outfile_wrappers
|
||||
ProcessTemplate('template/cl_runtime_opencl_wrappers.hpp.in', ctx)
|
||||
|
||||
ctx['CL_FN_ENUMS'] = generateEnums(fns)
|
||||
ctx['CL_FN_NAMES'] = generateNames(fns)
|
||||
ctx['CL_FN_DEFINITIONS'] = generateFnDefinition(fns)
|
||||
|
@@ -0,0 +1,6 @@
|
||||
#ifndef __OPENCV_OCL_CL_RUNTIME_OPENCL_WRAPPERS_HPP__
|
||||
#define __OPENCV_OCL_CL_RUNTIME_OPENCL_WRAPPERS_HPP__
|
||||
|
||||
@CL_FN_INLINE_WRAPPERS@
|
||||
|
||||
#endif // __OPENCV_OCL_CL_RUNTIME_OPENCL_WRAPPERS_HPP__
|
Reference in New Issue
Block a user