Use strict C function prototypes
This fixes warnings when compiling with `-Wstrict-prototypes`. Functions with empty parameter lists behave differently in C and C++: - void func() in C is same as void func(...) in C++. - void func() in C++ is same as void func(void) in C.
This commit is contained in:
parent
ce891b57e1
commit
8410b1383f
|
@ -449,10 +449,11 @@ def get_function_impls(content, ident, has_impl=True):
|
||||||
|
|
||||||
# parse the arguments
|
# parse the arguments
|
||||||
args = []
|
args = []
|
||||||
for v in argval.split(','):
|
if argval != 'void':
|
||||||
v = v.strip()
|
for v in argval.split(','):
|
||||||
if len(v) > 0:
|
v = v.strip()
|
||||||
args.append(v)
|
if len(v) > 0:
|
||||||
|
args.append(v)
|
||||||
|
|
||||||
result.append({
|
result.append({
|
||||||
'retval': retval.strip(),
|
'retval': retval.strip(),
|
||||||
|
@ -1208,7 +1209,7 @@ class obj_function:
|
||||||
for cls in self.arguments:
|
for cls in self.arguments:
|
||||||
cls.get_types(list)
|
cls.get_types(list)
|
||||||
|
|
||||||
def get_capi_parts(self, defined_structs=[], prefix=None):
|
def get_capi_parts(self, defined_structs=[], isimpl=False, prefix=None):
|
||||||
""" Return the parts of the C API function definition. """
|
""" Return the parts of the C API function definition. """
|
||||||
retval = ''
|
retval = ''
|
||||||
dict = self.retval.get_type().get_capi(defined_structs)
|
dict = self.retval.get_type().get_capi(defined_structs)
|
||||||
|
@ -1225,6 +1226,8 @@ class obj_function:
|
||||||
# const virtual functions get const self pointers
|
# const virtual functions get const self pointers
|
||||||
str = 'const ' + str
|
str = 'const ' + str
|
||||||
args.append(str)
|
args.append(str)
|
||||||
|
elif not isimpl and len(self.arguments) == 0:
|
||||||
|
args.append('void')
|
||||||
|
|
||||||
if len(self.arguments) > 0:
|
if len(self.arguments) > 0:
|
||||||
for cls in self.arguments:
|
for cls in self.arguments:
|
||||||
|
@ -1245,9 +1248,9 @@ class obj_function:
|
||||||
|
|
||||||
return {'retval': retval, 'name': name, 'args': args}
|
return {'retval': retval, 'name': name, 'args': args}
|
||||||
|
|
||||||
def get_capi_proto(self, defined_structs=[], prefix=None):
|
def get_capi_proto(self, defined_structs=[], isimpl=False, prefix=None):
|
||||||
""" Return the prototype of the C API function. """
|
""" Return the prototype of the C API function. """
|
||||||
parts = self.get_capi_parts(defined_structs, prefix)
|
parts = self.get_capi_parts(defined_structs, isimpl, prefix)
|
||||||
result = parts['retval']+' '+parts['name']+ \
|
result = parts['retval']+' '+parts['name']+ \
|
||||||
'('+', '.join(parts['args'])+')'
|
'('+', '.join(parts['args'])+')'
|
||||||
return result
|
return result
|
||||||
|
@ -2098,7 +2101,7 @@ if __name__ == "__main__":
|
||||||
funcs = header.get_funcs()
|
funcs = header.get_funcs()
|
||||||
if len(funcs) > 0:
|
if len(funcs) > 0:
|
||||||
for func in funcs:
|
for func in funcs:
|
||||||
result += func.get_capi_proto(defined_names) + ';\n'
|
result += func.get_capi_proto(defined_names, True) + ';\n'
|
||||||
result += '\n'
|
result += '\n'
|
||||||
|
|
||||||
classes = header.get_classes()
|
classes = header.get_classes()
|
||||||
|
@ -2108,7 +2111,7 @@ if __name__ == "__main__":
|
||||||
funcs = cls.get_virtual_funcs()
|
funcs = cls.get_virtual_funcs()
|
||||||
if len(funcs) > 0:
|
if len(funcs) > 0:
|
||||||
for func in funcs:
|
for func in funcs:
|
||||||
result += '\t' + func.get_capi_proto(defined_names) + ';\n'
|
result += '\t' + func.get_capi_proto(defined_names, True) + ';\n'
|
||||||
result += '}\n\n'
|
result += '}\n\n'
|
||||||
|
|
||||||
defined_names.append(cls.get_capi_name())
|
defined_names.append(cls.get_capi_name())
|
||||||
|
@ -2117,6 +2120,6 @@ if __name__ == "__main__":
|
||||||
funcs = cls.get_static_funcs()
|
funcs = cls.get_static_funcs()
|
||||||
if len(funcs) > 0:
|
if len(funcs) > 0:
|
||||||
for func in funcs:
|
for func in funcs:
|
||||||
result += func.get_capi_proto(defined_names) + ';\n'
|
result += func.get_capi_proto(defined_names, True) + ';\n'
|
||||||
result += '\n'
|
result += '\n'
|
||||||
sys.stdout.write(result)
|
sys.stdout.write(result)
|
||||||
|
|
|
@ -20,7 +20,7 @@ def make_cpptoc_function_impl_existing(cls, name, func, impl, defined_names):
|
||||||
notify(name + ' has manual edits')
|
notify(name + ' has manual edits')
|
||||||
|
|
||||||
# retrieve the C API prototype parts
|
# retrieve the C API prototype parts
|
||||||
parts = func.get_capi_parts(defined_names)
|
parts = func.get_capi_parts(defined_names, True)
|
||||||
|
|
||||||
changes = format_translation_changes(impl, parts)
|
changes = format_translation_changes(impl, parts)
|
||||||
if len(changes) > 0:
|
if len(changes) > 0:
|
||||||
|
@ -36,7 +36,7 @@ def make_cpptoc_function_impl_new(cls, name, func, defined_names, base_scoped):
|
||||||
func.parent, obj_header)
|
func.parent, obj_header)
|
||||||
|
|
||||||
# retrieve the C API prototype parts
|
# retrieve the C API prototype parts
|
||||||
parts = func.get_capi_parts(defined_names)
|
parts = func.get_capi_parts(defined_names, True)
|
||||||
result = make_cpptoc_impl_proto(name, func, parts) + ' {'
|
result = make_cpptoc_impl_proto(name, func, parts) + ' {'
|
||||||
|
|
||||||
if isinstance(func.parent, obj_class) and \
|
if isinstance(func.parent, obj_class) and \
|
||||||
|
|
|
@ -52,7 +52,7 @@ def make_libcef_dll_dylib_impl_parts(name, retval, args):
|
||||||
|
|
||||||
def make_libcef_dll_dylib_impl_func(func):
|
def make_libcef_dll_dylib_impl_func(func):
|
||||||
name = func.get_capi_name()
|
name = func.get_capi_name()
|
||||||
parts = func.get_capi_parts([])
|
parts = func.get_capi_parts([], True)
|
||||||
retval = parts['retval']
|
retval = parts['retval']
|
||||||
args = parts['args']
|
args = parts['args']
|
||||||
return make_libcef_dll_dylib_impl_parts(name, retval, args)
|
return make_libcef_dll_dylib_impl_parts(name, retval, args)
|
||||||
|
|
Loading…
Reference in New Issue