def __fix_invalid_integral(self, func, arg): try: int(arg.default_value) return arg.default_value except: pass try: int(arg.default_value, 16) if 64 == utils.get_architecture(): # on 64 bit architecture, gccxml reports 0fffff, which is # valid number the problem is that in this case it is so # buggy so pygccxml can not fix it users will have to fix the # default value manually return arg.default_value default_value = arg.default_value.lower() found_hex = [ch for ch in default_value if ch in 'abcdef'] if found_hex and not default_value.startswith('0x'): int('0x' + default_value, 16) return '0x' + default_value except: pass # may be we deal with enum parent = func.parent while parent: found = self.__find_enum(parent, arg.default_value) if found: if declarations.is_fundamental(arg.type) and ' ' in \ arg.type.decl_string: template = '(%s)(%s)' else: template = '%s(%s)' return template % (arg.type.decl_string, self.__join_names(found.parent.decl_string, arg.default_value)) else: parent = parent.parent # check if we have an unqualified integral constant # only do patching in cases where we have a bare variable name c_var = re.compile("[a-z_][a-z0-9_]*", re.IGNORECASE) m = c_var.match(arg.default_value) if m: parent = func.parent while parent: try: found = parent.variable(arg.default_value, recursive=False) except declarations.matcher.declaration_not_found_t: # ignore exceptions if a match is not found found = None if found: if declarations.is_fundamental(arg.type): return "%s" % self.__join_names( found.parent.decl_string, arg.default_value) parent = parent.parent return arg.default_value
def __fix_invalid_integral(self, func, arg): try: int(arg.default_value) return arg.default_value except: pass try: int(arg.default_value, 16) if 64 == utils.get_architecture(): # on 64 bit architecture, gccxml reports 0fffff, which is # valid number the problem is that in this case it is so # buggy so pygccxml can not fix it users will have to fix the # default value manually return arg.default_value default_value = arg.default_value.lower() found_hex = [ch for ch in default_value if ch in 'abcdef'] if found_hex and not default_value.startswith('0x'): int('0x' + default_value, 16) return '0x' + default_value except: pass # may be we deal with enum parent = func.parent while parent: found = self.__find_enum(parent, arg.default_value) if found: if declarations.is_fundamental(arg.type) and ' ' in \ arg.type.decl_string: template = '(%s)(%s)' else: template = '%s(%s)' return template % (arg.type.decl_string, self.__join_names( found.parent.decl_string, arg.default_value)) else: parent = parent.parent return arg.default_value
def __fix_invalid_integral(self, func, arg): try: int(arg.default_value) return arg.default_value except: pass try: int(arg.default_value, 16) if 64 == utils.get_architecture(): # on 64 bit architecture, gccxml reports 0fffff, which is # valid number the problem is that in this case it is so # buggy so pygccxml can not fix it users will have to fix the # default value manually return arg.default_value default_value = arg.default_value.lower() found_hex = [ch for ch in default_value if ch in 'abcdef'] if found_hex and not default_value.startswith('0x'): int('0x' + default_value, 16) return '0x' + default_value except: pass # may be we deal with enum parent = func.parent while parent: found = self.__find_enum(parent, arg.default_value) if found: if declarations.is_fundamental(arg.type) and ' ' in \ arg.type.decl_string: template = '(%s)(%s)' else: template = '%s(%s)' return template % (arg.type.decl_string, self.__join_names(found.parent.decl_string, arg.default_value)) else: parent = parent.parent return arg.default_value
def __fix_invalid_integral(self, func, arg): try: int(arg.default_value) return arg.default_value except: pass try: int(arg.default_value, 16) if 64 == utils.get_architecture(): # on 64 bit architecture, gccxml reports 0fffff, which is # valid number the problem is that in this case it is so # buggy so pygccxml can not fix it users will have to fix the # default value manually return arg.default_value default_value = arg.default_value.lower() found_hex = [ch for ch in default_value if ch in 'abcdef'] if found_hex and not default_value.startswith('0x'): int('0x' + default_value, 16) return '0x' + default_value except: pass # may be we deal with enum # CastXML qualifies the enum value with enum type, so split the # argument and use only the enum value enum_value = arg.default_value.split('::')[-1] parent = func.parent while parent: found = self.__find_enum(parent, enum_value) if found: if declarations.is_fundamental(arg.type) and ' ' in \ arg.type.decl_string: template = '(%s)(%s)' else: template = '%s(%s)' if self.__cxx_std.is_cxx11_or_greater: qualifier_decl_string = found.decl_string else: qualifier_decl_string = found.parent.decl_string return template % (arg.type.decl_string, self.__join_names(qualifier_decl_string, enum_value)) else: parent = parent.parent # check if we have an unqualified integral constant # only do patching in cases where we have a bare variable name c_var = re.compile("[a-z_][a-z0-9_]*", re.IGNORECASE) m = c_var.match(arg.default_value) if m: parent = func.parent while parent: try: found = parent.variable(arg.default_value, recursive=False) except declarations.matcher.declaration_not_found_t: # ignore exceptions if a match is not found found = None if found: if declarations.is_fundamental(arg.type): return "%s" % self.__join_names( found.parent.decl_string, arg.default_value) parent = parent.parent return arg.default_value