mirror of
https://github.com/opencv/opencv.git
synced 2024-11-25 03:30:34 +08:00
ocl: eliminate build warning
Templates are replaced by macro
This commit is contained in:
parent
39467d84bf
commit
a0add98b30
@ -136,16 +136,30 @@ def generateFilterNames(fns):
|
||||
print '%s%s' % ('' if fn.has_key('enabled') else '//', fn['name'])
|
||||
print '#total %d' % len(fns)
|
||||
|
||||
callback_check = re.compile(r'([^\(]*\(.*)(\* *)(\).*\(.*\))')
|
||||
|
||||
def getTypeWithParam(t, p):
|
||||
if callback_check.match(t):
|
||||
return callback_check.sub(r'\1 *' + p + r'\3', t)
|
||||
return t + ' ' + p
|
||||
|
||||
@outputToString
|
||||
def generateStructDefinitions(fns, lprefix='opencl_fn', enumprefix='OPENCL_FN'):
|
||||
print '// generated by %s' % os.path.basename(sys.argv[0])
|
||||
first = True
|
||||
for fn in fns:
|
||||
commentStr = '' if fn.has_key('enabled') else '//'
|
||||
print commentStr + ('%s%s (%s *%s)(%s) =\n%s %s%d<%s_%s, %s%s>::switch_fn;' % \
|
||||
decl_args = []
|
||||
for (i, t) in enumerate(fn['params']):
|
||||
decl_args.append(getTypeWithParam(t, 'p%d' % (i+1)))
|
||||
decl_args_str = '(' + (', '.join(decl_args)) + ')'
|
||||
print '%s%s%d(%s_%s, %s, %s)' % \
|
||||
(commentStr, lprefix, len(fn['params']), enumprefix, fn['name'], \
|
||||
' '.join(fn['ret']), decl_args_str)
|
||||
print commentStr + ('%s%s (%s *%s)(%s) =\n%s %s_%s_switch_fn;' % \
|
||||
((' '.join(fn['modifiers'] + ' ') if len(fn['modifiers']) > 0 else ''),
|
||||
' '.join(fn['ret']), ' '.join(fn['calling']), fn['name'], ', '.join(fn['params']), \
|
||||
commentStr, lprefix, len(fn['params']), enumprefix, fn['name'], ' '.join(fn['ret']), ('' if len(fn['params']) == 0 else ', ' + ', '.join(fn['params']))))
|
||||
commentStr, enumprefix, fn['name']))
|
||||
print commentStr + ('static const struct DynamicFnEntry %s_definition = { "%s", (void**)&%s};' % (fn['name'], fn['name'], fn['name']))
|
||||
print
|
||||
first = False
|
||||
@ -200,22 +214,12 @@ def generateFnDeclaration(fns):
|
||||
def generateTemplates(sz, lprefix, switch_name, calling_convention=''):
|
||||
print '// generated by %s' % os.path.basename(sys.argv[0])
|
||||
for sz in range(sz):
|
||||
template_params = ['int ID', 'typename _R']
|
||||
types = []
|
||||
types_with_params = []
|
||||
params = []
|
||||
for i in range(1, sz + 1):
|
||||
template_params.append('typename _T%d' % i)
|
||||
types.append('_T%d' % i)
|
||||
types_with_params.append('_T%d p%d' % (i, i))
|
||||
params.append('p%d' % i)
|
||||
print 'template <%s>' % ', '.join(template_params)
|
||||
print 'struct %s%d' % (lprefix, sz)
|
||||
print '{'
|
||||
print ' typedef _R (%s *FN)(%s);' % (calling_convention, ', '.join(types))
|
||||
print ' static _R %s switch_fn(%s)' % (calling_convention, ', '.join(types_with_params))
|
||||
print ' { return ((FN)%s(ID))(%s); }' % (switch_name, ', '.join(params))
|
||||
print '};'
|
||||
template_params = ['ID', '_R', 'decl_args']
|
||||
params = ['p%d' % (i + 1) for i in range(0, sz)]
|
||||
print '#define %s%d(%s) \\' % (lprefix, sz, ', '.join(template_params))
|
||||
print ' typedef _R (%s *ID##FN)decl_args; \\' % (calling_convention)
|
||||
print ' static _R %s ID##_switch_fn decl_args \\' % (calling_convention)
|
||||
print ' { return ((ID##FN)%s(ID))(%s); } \\' % (switch_name, ', '.join(params))
|
||||
print ''
|
||||
|
||||
@outputToString
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __OPENCV_CORE_OCL_RUNTIME_CLAMDBLAS_HPP__
|
||||
#ifndef OPENCV_CORE_OCL_RUNTIME_CLAMDBLAS_HPP
|
||||
#error "Invalid usage"
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __OPENCV_CORE_OCL_RUNTIME_CLAMDFFT_HPP__
|
||||
#ifndef OPENCV_CORE_OCL_RUNTIME_CLAMDFFT_HPP
|
||||
#error "Invalid usage"
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __OPENCV_CORE_OCL_RUNTIME_OPENCL_CORE_HPP__
|
||||
#ifndef OPENCV_CORE_OCL_RUNTIME_OPENCL_CORE_HPP
|
||||
#error "Invalid usage"
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __OPENCV_CORE_OCL_RUNTIME_OPENCL_WRAPPERS_HPP__
|
||||
#ifndef OPENCV_CORE_OCL_RUNTIME_OPENCL_WRAPPERS_HPP
|
||||
#error "Invalid usage"
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_HPP__
|
||||
#ifndef OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_HPP
|
||||
#error "Invalid usage"
|
||||
#endif
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#ifndef __OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_WRAPPERS_HPP__
|
||||
#ifndef OPENCV_CORE_OCL_RUNTIME_OPENCL_GL_WRAPPERS_HPP
|
||||
#error "Invalid usage"
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user