@@ -480,25 +480,57 @@ def is_fundamental(type_):
480
480
(cpptypes .volatile_t , cpptypes .const_t ))
481
481
482
482
483
+ def _normalize (string ):
484
+ return string .replace (' ' , '' ).replace ("::std" , "std" )
485
+
486
+
487
+ def _normalize_equivalences (equivalences ):
488
+ return [_normalize (eq ) for eq in equivalences ]
489
+
490
+
483
491
string_equivalences = [
484
492
(
485
- '::std::basic_string<char,std::char_traits<char>,'
486
- 'std::allocator<char>>' ),
487
- '::std::basic_string<char>' , '::std::string' ]
493
+ 'std::basic_string<char, std::char_traits<char>, '
494
+ 'std::allocator<char>>'
495
+ ),
496
+ 'std::basic_string<char>' ,
497
+ 'std::string'
498
+ ]
488
499
489
500
wstring_equivalences = [
490
501
(
491
- '::std::basic_string<wchar_t,std::char_traits<wchar_t>,' +
492
- 'std::allocator<wchar_t>>' ),
493
- '::std::basic_string<wchar_t>' , '::std::wstring' ]
502
+ 'std::basic_string<wchar_t, std::char_traits<wchar_t>, '
503
+ 'std::allocator<wchar_t>>'
504
+ ),
505
+ 'std::basic_string<wchar_t>' ,
506
+ 'std::wstring'
507
+ ]
494
508
495
509
ostream_equivalences = [
496
- '::std::basic_ostream<char,std::char_traits<char>>' ,
497
- '::std::basic_ostream<char>' , '::std::ostream' ]
510
+ 'std::basic_ostream<char, std::char_traits<char>>' ,
511
+ 'std::basic_ostream<char>' ,
512
+ 'std::ostream'
513
+ ]
498
514
499
515
wostream_equivalences = [
500
- '::std::basic_ostream<wchar_t,std::char_traits<wchar_t>>' ,
501
- '::std::basic_ostream<wchar_t>' , '::std::wostream' ]
516
+ 'std::basic_ostream<wchar_t, std::char_traits<wchar_t>>' ,
517
+ 'std::basic_ostream<wchar_t>' ,
518
+ 'std::wostream'
519
+ ]
520
+
521
+
522
+ normalized_string_equivalences = _normalize_equivalences (
523
+ string_equivalences
524
+ )
525
+ normalized_wstring_equivalences = _normalize_equivalences (
526
+ wstring_equivalences
527
+ )
528
+ normalized_ostream_equivalences = _normalize_equivalences (
529
+ ostream_equivalences
530
+ )
531
+ normalized_wostream_equivalences = _normalize_equivalences (
532
+ wostream_equivalences
533
+ )
502
534
503
535
504
536
def is_std_string (type_ ):
@@ -508,12 +540,12 @@ def is_std_string(type_):
508
540
"""
509
541
510
542
if isinstance (type_ , str ):
511
- return type_ in string_equivalences
543
+ return _normalize ( type_ ) in normalized_string_equivalences
512
544
513
545
type_ = remove_alias (type_ )
514
546
type_ = remove_reference (type_ )
515
547
type_ = remove_cv (type_ )
516
- return type_ .decl_string . replace ( ' ' , '' ) in string_equivalences
548
+ return _normalize ( type_ .decl_string ) in normalized_string_equivalences
517
549
518
550
519
551
def is_std_wstring (type_ ):
@@ -523,12 +555,12 @@ def is_std_wstring(type_):
523
555
"""
524
556
525
557
if isinstance (type_ , str ):
526
- return type_ in wstring_equivalences
558
+ return _normalize ( type_ ) in normalized_wstring_equivalences
527
559
528
560
type_ = remove_alias (type_ )
529
561
type_ = remove_reference (type_ )
530
562
type_ = remove_cv (type_ )
531
- return type_ .decl_string . replace ( ' ' , '' ) in wstring_equivalences
563
+ return _normalize ( type_ .decl_string ) in normalized_wstring_equivalences
532
564
533
565
534
566
def is_std_ostream (type_ ):
@@ -538,12 +570,12 @@ def is_std_ostream(type_):
538
570
"""
539
571
540
572
if isinstance (type_ , str ):
541
- return type_ in ostream_equivalences
573
+ return _normalize ( type_ ) in normalized_ostream_equivalences
542
574
543
575
type_ = remove_alias (type_ )
544
576
type_ = remove_reference (type_ )
545
577
type_ = remove_cv (type_ )
546
- return type_ .decl_string . replace ( ' ' , '' ) in ostream_equivalences
578
+ return _normalize ( type_ .decl_string ) in normalized_ostream_equivalences
547
579
548
580
549
581
def is_std_wostream (type_ ):
@@ -553,9 +585,9 @@ def is_std_wostream(type_):
553
585
"""
554
586
555
587
if isinstance (type_ , str ):
556
- return type_ in wostream_equivalences
588
+ return _normalize ( type_ ) in normalized_wostream_equivalences
557
589
558
590
type_ = remove_alias (type_ )
559
591
type_ = remove_reference (type_ )
560
592
type_ = remove_cv (type_ )
561
- return type_ .decl_string . replace ( ' ' , '' ) in wostream_equivalences
593
+ return _normalize ( type_ .decl_string ) in normalized_wostream_equivalences
0 commit comments