Fix compilation warnings in the Python wrapper.

This commit is contained in:
Ghislain MARY 2014-07-16 18:09:15 +02:00
parent 4b3a1fb016
commit fa38f30896

View file

@ -266,8 +266,8 @@ class MethodDefinition:
if self.self_arg is not None and return_type_class['class_refcountable']:
ref_function = return_type_class['class_c_function_prefix'] + "ref"
self.body += \
""" {func}(cresult);
""".format(func=ref_function)
""" {func}(({cast_type})cresult);
""".format(func=ref_function, cast_type=self.__remove_const_from_complete_type(self.return_complete_type))
self.body += \
""" pyret = Py_BuildValue("{fmt}", pyresult);
""".format(fmt=self.build_value_format)
@ -343,6 +343,12 @@ class MethodDefinition:
self.body += \
""" self->ob_type->tp_free(self);"""
def __remove_const_from_complete_type(self, complete_type):
splitted_type = complete_type.split(' ')
while 'const' in splitted_type:
splitted_type.remove('const')
return ' '.join(splitted_type)
def __ctype_to_str_format(self, name, basic_type, complete_type):
splitted_type = complete_type.split(' ')
if basic_type == 'char':