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

Make type equivalence check for string and ostream more robust #142

Merged
merged 1 commit into from
Aug 1, 2023
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
24 changes: 8 additions & 16 deletions pygccxml/declarations/type_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,29 +483,21 @@ def is_fundamental(type_):
string_equivalences = [
(
'::std::basic_string<char,std::char_traits<char>,'
'std::allocator<char> >'),
(
'::std::basic_string<char, std::char_traits<char>, '
'std::allocator<char> >'),
'std::allocator<char>>'),
'::std::basic_string<char>', '::std::string']

wstring_equivalences = [
(
'::std::basic_string<wchar_t,std::char_traits<wchar_t>,' +
'std::allocator<wchar_t> >'),
(
'::std::basic_string<wchar_t, std::char_traits<wchar_t>, ' +
'std::allocator<wchar_t> >'),
'std::allocator<wchar_t>>'),
'::std::basic_string<wchar_t>', '::std::wstring']

ostream_equivalences = [
'::std::basic_ostream<char, std::char_traits<char> >',
'::std::basic_ostream<char,std::char_traits<char> >',
'::std::basic_ostream<char,std::char_traits<char>>',
'::std::basic_ostream<char>', '::std::ostream']

wostream_equivalences = [
'::std::basic_ostream<wchar_t, std::char_traits<wchar_t> >',
'::std::basic_ostream<wchar_t,std::char_traits<wchar_t> >',
'::std::basic_ostream<wchar_t,std::char_traits<wchar_t>>',
'::std::basic_ostream<wchar_t>', '::std::wostream']


Expand All @@ -521,7 +513,7 @@ def is_std_string(type_):
type_ = remove_alias(type_)
type_ = remove_reference(type_)
type_ = remove_cv(type_)
return type_.decl_string in string_equivalences
return type_.decl_string.replace(' ', '') in string_equivalences


def is_std_wstring(type_):
Expand All @@ -536,7 +528,7 @@ def is_std_wstring(type_):
type_ = remove_alias(type_)
type_ = remove_reference(type_)
type_ = remove_cv(type_)
return type_.decl_string in wstring_equivalences
return type_.decl_string.replace(' ', '') in wstring_equivalences


def is_std_ostream(type_):
Expand All @@ -551,7 +543,7 @@ def is_std_ostream(type_):
type_ = remove_alias(type_)
type_ = remove_reference(type_)
type_ = remove_cv(type_)
return type_.decl_string in ostream_equivalences
return type_.decl_string.replace(' ', '') in ostream_equivalences


def is_std_wostream(type_):
Expand All @@ -566,4 +558,4 @@ def is_std_wostream(type_):
type_ = remove_alias(type_)
type_ = remove_reference(type_)
type_ = remove_cv(type_)
return type_.decl_string in wostream_equivalences
return type_.decl_string.replace(' ', '') in wostream_equivalences
Loading