Skip to content

Commit

Permalink
Merge pull request #142 from mamoll/pr-more-robust-equivalence-check
Browse files Browse the repository at this point in the history
Make type equivalence check for string and ostream more robust
  • Loading branch information
iMichka committed Aug 1, 2023
2 parents 72d0a20 + bd4a882 commit 5d2e2f4
Showing 1 changed file with 8 additions and 16 deletions.
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

0 comments on commit 5d2e2f4

Please sign in to comment.