Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix test_element_type test #224

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 32 additions & 31 deletions src/pygccxml/declarations/traits_impl_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,40 @@ def find_value_type(global_ns, value_type_str):
name=value_type_str,
function=lambda decl: not isinstance(decl, calldef.calldef_t),
allow_empty=True)
if not found:
no_global_ns_value_type_str = value_type_str[2:]
if no_global_ns_value_type_str in cpptypes.FUNDAMENTAL_TYPES:
return cpptypes.FUNDAMENTAL_TYPES[no_global_ns_value_type_str]
elif type_traits.is_std_string(value_type_str):
string_ = global_ns.typedef('::std::string')
return type_traits.remove_declarated(string_)
elif type_traits.is_std_wstring(value_type_str):
string_ = global_ns.typedef('::std::wstring')
return type_traits.remove_declarated(string_)

if len(found) == 1:
return found[0]

no_global_ns_value_type_str = value_type_str[2:]
if no_global_ns_value_type_str in cpptypes.FUNDAMENTAL_TYPES:
return cpptypes.FUNDAMENTAL_TYPES[no_global_ns_value_type_str]
elif type_traits.is_std_string(value_type_str):
string_ = global_ns.typedef('::std::string')
return type_traits.remove_declarated(string_)
elif type_traits.is_std_wstring(value_type_str):
string_ = global_ns.typedef('::std::wstring')
return type_traits.remove_declarated(string_)
else:
value_type_str = no_global_ns_value_type_str
has_const = value_type_str.startswith('const ')
if has_const:
value_type_str = value_type_str[len('const '):]
has_pointer = value_type_str.endswith('*')
if has_pointer:
value_type_str = value_type_str[:-1]
found = None
if has_const or has_pointer:
found = impl_details.find_value_type(
global_ns,
value_type_str)
if not found:
return None
else:
value_type_str = no_global_ns_value_type_str
has_const = value_type_str.startswith('const ')
if isinstance(found, class_declaration.class_types):
return cpptypes.declarated_t(found)
if has_const:
value_type_str = value_type_str[len('const '):]
has_pointer = value_type_str.endswith('*')
return cpptypes.const_t(found)
if has_pointer:
value_type_str = value_type_str[:-1]
found = None
if has_const or has_pointer:
found = impl_details.find_value_type(
global_ns,
value_type_str)
if not found:
return None
else:
if isinstance(found, class_declaration.class_types):
return cpptypes.declarated_t(found)
if has_const:
return cpptypes.const_t(found)
if has_pointer:
return cpptypes.pointer_t(found)
if len(found) == 1:
return found[0]
return cpptypes.pointer_t(found)

return None