Skip to content

Commit 5d2e2f4

Browse files
authored
Merge pull request #142 from mamoll/pr-more-robust-equivalence-check
Make type equivalence check for string and ostream more robust
2 parents 72d0a20 + bd4a882 commit 5d2e2f4

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

pygccxml/declarations/type_traits.py

+8-16
Original file line numberDiff line numberDiff line change
@@ -483,29 +483,21 @@ def is_fundamental(type_):
483483
string_equivalences = [
484484
(
485485
'::std::basic_string<char,std::char_traits<char>,'
486-
'std::allocator<char> >'),
487-
(
488-
'::std::basic_string<char, std::char_traits<char>, '
489-
'std::allocator<char> >'),
486+
'std::allocator<char>>'),
490487
'::std::basic_string<char>', '::std::string']
491488

492489
wstring_equivalences = [
493490
(
494491
'::std::basic_string<wchar_t,std::char_traits<wchar_t>,' +
495-
'std::allocator<wchar_t> >'),
496-
(
497-
'::std::basic_string<wchar_t, std::char_traits<wchar_t>, ' +
498-
'std::allocator<wchar_t> >'),
492+
'std::allocator<wchar_t>>'),
499493
'::std::basic_string<wchar_t>', '::std::wstring']
500494

501495
ostream_equivalences = [
502-
'::std::basic_ostream<char, std::char_traits<char> >',
503-
'::std::basic_ostream<char,std::char_traits<char> >',
496+
'::std::basic_ostream<char,std::char_traits<char>>',
504497
'::std::basic_ostream<char>', '::std::ostream']
505498

506499
wostream_equivalences = [
507-
'::std::basic_ostream<wchar_t, std::char_traits<wchar_t> >',
508-
'::std::basic_ostream<wchar_t,std::char_traits<wchar_t> >',
500+
'::std::basic_ostream<wchar_t,std::char_traits<wchar_t>>',
509501
'::std::basic_ostream<wchar_t>', '::std::wostream']
510502

511503

@@ -521,7 +513,7 @@ def is_std_string(type_):
521513
type_ = remove_alias(type_)
522514
type_ = remove_reference(type_)
523515
type_ = remove_cv(type_)
524-
return type_.decl_string in string_equivalences
516+
return type_.decl_string.replace(' ', '') in string_equivalences
525517

526518

527519
def is_std_wstring(type_):
@@ -536,7 +528,7 @@ def is_std_wstring(type_):
536528
type_ = remove_alias(type_)
537529
type_ = remove_reference(type_)
538530
type_ = remove_cv(type_)
539-
return type_.decl_string in wstring_equivalences
531+
return type_.decl_string.replace(' ', '') in wstring_equivalences
540532

541533

542534
def is_std_ostream(type_):
@@ -551,7 +543,7 @@ def is_std_ostream(type_):
551543
type_ = remove_alias(type_)
552544
type_ = remove_reference(type_)
553545
type_ = remove_cv(type_)
554-
return type_.decl_string in ostream_equivalences
546+
return type_.decl_string.replace(' ', '') in ostream_equivalences
555547

556548

557549
def is_std_wostream(type_):
@@ -566,4 +558,4 @@ def is_std_wostream(type_):
566558
type_ = remove_alias(type_)
567559
type_ = remove_reference(type_)
568560
type_ = remove_cv(type_)
569-
return type_.decl_string in wostream_equivalences
561+
return type_.decl_string.replace(' ', '') in wostream_equivalences

0 commit comments

Comments
 (0)