@@ -480,40 +480,68 @@ 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>>' ,
510
+ '::std::basic_ostream<char, std::char_traits<char>>' ,
497
511
'::std::basic_ostream<char>' , '::std::ostream' ]
498
512
499
513
wostream_equivalences = [
500
- '::std::basic_ostream<wchar_t,std::char_traits<wchar_t>>' ,
514
+ '::std::basic_ostream<wchar_t, std::char_traits<wchar_t>>' ,
501
515
'::std::basic_ostream<wchar_t>' , '::std::wostream' ]
502
516
503
517
518
+ normalized_string_equivalences = _normalize_equivalences (
519
+ string_equivalences
520
+ )
521
+ normalized_wstring_equivalences = _normalize_equivalences (
522
+ wstring_equivalences
523
+ )
524
+ normalized_ostream_equivalences = _normalize_equivalences (
525
+ ostream_equivalences
526
+ )
527
+ normalized_wostream_equivalences = _normalize_equivalences (
528
+ wostream_equivalences
529
+ )
530
+
531
+
504
532
def is_std_string (type_ ):
505
533
"""
506
534
Returns True, if type represents C++ `std::string`, False otherwise.
507
535
508
536
"""
509
537
510
538
if isinstance (type_ , str ):
511
- return type_ in string_equivalences
539
+ return _normalize ( type_ ) in normalized_string_equivalences
512
540
513
541
type_ = remove_alias (type_ )
514
542
type_ = remove_reference (type_ )
515
543
type_ = remove_cv (type_ )
516
- return type_ .decl_string . replace ( ' ' , '' ) in string_equivalences
544
+ return _normalize ( type_ .decl_string ) in normalized_string_equivalences
517
545
518
546
519
547
def is_std_wstring (type_ ):
@@ -523,12 +551,12 @@ def is_std_wstring(type_):
523
551
"""
524
552
525
553
if isinstance (type_ , str ):
526
- return type_ in wstring_equivalences
554
+ return _normalize ( type_ ) in normalized_wstring_equivalences
527
555
528
556
type_ = remove_alias (type_ )
529
557
type_ = remove_reference (type_ )
530
558
type_ = remove_cv (type_ )
531
- return type_ .decl_string . replace ( ' ' , '' ) in wstring_equivalences
559
+ return _normalize ( type_ .decl_string ) in normalized_wstring_equivalences
532
560
533
561
534
562
def is_std_ostream (type_ ):
@@ -538,12 +566,12 @@ def is_std_ostream(type_):
538
566
"""
539
567
540
568
if isinstance (type_ , str ):
541
- return type_ in ostream_equivalences
569
+ return _normalize ( type_ ) in normalized_ostream_equivalences
542
570
543
571
type_ = remove_alias (type_ )
544
572
type_ = remove_reference (type_ )
545
573
type_ = remove_cv (type_ )
546
- return type_ .decl_string . replace ( ' ' , '' ) in ostream_equivalences
574
+ return _normalize ( type_ .decl_string ) in normalized_ostream_equivalences
547
575
548
576
549
577
def is_std_wostream (type_ ):
@@ -553,9 +581,9 @@ def is_std_wostream(type_):
553
581
"""
554
582
555
583
if isinstance (type_ , str ):
556
- return type_ in wostream_equivalences
584
+ return _normalize ( type_ ) in normalized_wostream_equivalences
557
585
558
586
type_ = remove_alias (type_ )
559
587
type_ = remove_reference (type_ )
560
588
type_ = remove_cv (type_ )
561
- return type_ .decl_string . replace ( ' ' , '' ) in wostream_equivalences
589
+ return _normalize ( type_ .decl_string ) in normalized_wostream_equivalences
0 commit comments