334334 'while' , 'xor' , 'xor_eq'
335335]
336336
337+
338+ _simple_type_sepcifiers_re = re .compile (r"""(?x)
339+ \b(
340+ auto|void|bool
341+ # Integer
342+ # -------
343+ |((signed|unsigned)\s+)?(char|__int128|(
344+ ((long\s+long|long|short)\s+)?int
345+ ))
346+ |wchar_t|char(8|16|32)_t
347+ # extensions
348+ |((signed|unsigned)\s+)?__int(64|128)
349+ # Floating-point
350+ # --------------
351+ |(float|double|long\s+double)(\s+(_Complex|_Imaginary))?
352+ |(_Complex|_Imaginary)\s+(float|double|long\s+double)
353+ # extensions
354+ |__float80|_Float64x|__float128|_Float128
355+ # Integer types that could be prefixes of the previous ones
356+ # ---------------------------------------------------------
357+ |((signed|unsigned)\s+)?(long\s+long|long|short)
358+ |signed|unsigned
359+ )\b
360+ """ )
361+
337362_max_id = 4
338363_id_prefix = [None , '' , '_CPPv2' , '_CPPv3' , '_CPPv4' ]
339364# Ids are used in lookup keys which are used across pickled files,
449474 'long long int' : 'x' ,
450475 'signed long long' : 'x' ,
451476 'signed long long int' : 'x' ,
477+ '__int64' : 'x' ,
452478 'unsigned long long' : 'y' ,
453479 'unsigned long long int' : 'y' ,
480+ '__int128' : 'n' ,
481+ 'signed __int128' : 'n' ,
482+ 'unsigned __int128' : 'o' ,
454483 'float' : 'f' ,
455484 'double' : 'd' ,
456485 'long double' : 'e' ,
486+ '__float80' : 'e' , '_Float64x' : 'e' ,
487+ '__float128' : 'g' , '_Float128' : 'g' ,
488+ 'float _Complex' : 'Cf' , '_Complex float' : 'Cf' ,
489+ 'double _Complex' : 'Cd' , '_Complex double' : 'Cd' ,
490+ 'long double _Complex' : 'Ce' , '_Complex long double' : 'Ce' ,
491+ 'float _Imaginary' : 'f' , '_Imaginary float' : 'f' ,
492+ 'double _Imaginary' : 'd' , '_Imaginary double' : 'd' ,
493+ 'long double _Imaginary' : 'e' , '_Imaginary long double' : 'e' ,
457494 'auto' : 'Da' ,
458495 'decltype(auto)' : 'Dc' ,
459496 'std::nullptr_t' : 'Dn'
@@ -1817,31 +1854,38 @@ def describe_signature(self, signode: TextElement, mode: str,
18171854
18181855class ASTTrailingTypeSpecFundamental (ASTTrailingTypeSpec ):
18191856 def __init__ (self , name : str ) -> None :
1820- self .name = name
1857+ self .names = name . split ()
18211858
18221859 def _stringify (self , transform : StringifyTransform ) -> str :
1823- return self .name
1860+ return ' ' . join ( self .names )
18241861
18251862 def get_id (self , version : int ) -> str :
18261863 if version == 1 :
18271864 res = []
1828- for a in self .name . split ( ' ' ) :
1865+ for a in self .names :
18291866 if a in _id_fundamental_v1 :
18301867 res .append (_id_fundamental_v1 [a ])
18311868 else :
18321869 res .append (a )
18331870 return '-' .join (res )
18341871
1835- if self .name not in _id_fundamental_v2 :
1872+ txt = str (self )
1873+ if txt not in _id_fundamental_v2 :
18361874 raise Exception (
18371875 'Semi-internal error: Fundamental type "%s" can not be mapped '
1838- 'to an id . Is it a true fundamental type? If not so, the '
1839- 'parser should have rejected it.' % self . name )
1840- return _id_fundamental_v2 [self . name ]
1876+ 'to an ID . Is it a true fundamental type? If not so, the '
1877+ 'parser should have rejected it.' % txt )
1878+ return _id_fundamental_v2 [txt ]
18411879
18421880 def describe_signature (self , signode : TextElement , mode : str ,
18431881 env : "BuildEnvironment" , symbol : "Symbol" ) -> None :
1844- signode += addnodes .desc_sig_keyword_type (self .name , self .name )
1882+ first = True
1883+ for n in self .names :
1884+ if not first :
1885+ signode += addnodes .desc_sig_space ()
1886+ else :
1887+ first = False
1888+ signode += addnodes .desc_sig_keyword_type (n , n )
18451889
18461890
18471891class ASTTrailingTypeSpecDecltypeAuto (ASTTrailingTypeSpec ):
@@ -4996,15 +5040,6 @@ def dump(self, indent: int) -> str:
49965040
49975041
49985042class DefinitionParser (BaseParser ):
4999- # those without signedness and size modifiers
5000- # see https://en.cppreference.com/w/cpp/language/types
5001- _simple_fundemental_types = (
5002- 'void' , 'bool' , 'char' , 'wchar_t' , 'char8_t' , 'char16_t' , 'char32_t' ,
5003- 'int' , 'float' , 'double' , 'auto'
5004- )
5005-
5006- _prefix_keys = ('class' , 'struct' , 'enum' , 'union' , 'typename' )
5007-
50085043 @property
50095044 def language (self ) -> str :
50105045 return 'C++'
@@ -5821,33 +5856,11 @@ def _parse_nested_name(self, memberPointer: bool = False) -> ASTNestedName:
58215856 # ==========================================================================
58225857
58235858 def _parse_trailing_type_spec (self ) -> ASTTrailingTypeSpec :
5824- # fundemental types
5859+ # fundamental types, https://en.cppreference.com/w/cpp/language/type
5860+ # and extensions
58255861 self .skip_ws ()
5826- for t in self ._simple_fundemental_types :
5827- if self .skip_word (t ):
5828- return ASTTrailingTypeSpecFundamental (t )
5829-
5830- # TODO: this could/should be more strict
5831- elements = []
5832- if self .skip_word_and_ws ('signed' ):
5833- elements .append ('signed' )
5834- elif self .skip_word_and_ws ('unsigned' ):
5835- elements .append ('unsigned' )
5836- while 1 :
5837- if self .skip_word_and_ws ('short' ):
5838- elements .append ('short' )
5839- elif self .skip_word_and_ws ('long' ):
5840- elements .append ('long' )
5841- else :
5842- break
5843- if self .skip_word_and_ws ('char' ):
5844- elements .append ('char' )
5845- elif self .skip_word_and_ws ('int' ):
5846- elements .append ('int' )
5847- elif self .skip_word_and_ws ('double' ):
5848- elements .append ('double' )
5849- if len (elements ) > 0 :
5850- return ASTTrailingTypeSpecFundamental (' ' .join (elements ))
5862+ if self .match (_simple_type_sepcifiers_re ):
5863+ return ASTTrailingTypeSpecFundamental (self .matched_text )
58515864
58525865 # decltype
58535866 self .skip_ws ()
@@ -5867,7 +5880,7 @@ def _parse_trailing_type_spec(self) -> ASTTrailingTypeSpec:
58675880 # prefixed
58685881 prefix = None
58695882 self .skip_ws ()
5870- for k in self . _prefix_keys :
5883+ for k in ( 'class' , 'struct' , 'enum' , 'union' , 'typename' ) :
58715884 if self .skip_word_and_ws (k ):
58725885 prefix = k
58735886 break
0 commit comments