33import os
44from builtins import range
55from functools import reduce
6+ from typing import Any , Dict , List # Needed for python 3.8 compatibility.
67import functools
78import json
89
@@ -1869,8 +1870,10 @@ def produce_docs():
18691870 f .write (doc_str )
18701871
18711872
1872- def get_dialect_versions (data , std_dialects , use_implemented_status ):
1873- """Impementation for feature_test_macros.get_(std_|)dialect_versions()."""
1873+ def get_ftms (
1874+ data , std_dialects : List [str ], use_implemented_status : bool
1875+ ) -> Dict [str , Dict [str , Any ]]:
1876+ """Impementation for FeatureTestMacros.(standard|implemented)_ftms()."""
18741877 result = dict ()
18751878 for feature in data :
18761879 last = None
@@ -2000,20 +2003,20 @@ class FeatureTestMacros:
20002003 # The JSON data structure.
20012004 __data = None
20022005
2003- def __init__ (self , filename ):
2006+ def __init__ (self , filename : str ):
20042007 """Initializes the class with the JSON data in the file 'filename'."""
20052008 self .__data = json .load (open (filename ))
20062009
20072010 @functools .cached_property
2008- def std_dialects (self ):
2011+ def std_dialects (self ) -> List [ str ] :
20092012 """Returns the C++ dialects avaiable.
20102013
20112014 The available dialects are based on the 'c++xy' keys found the 'values'
20122015 entries in '__data'. So when WG21 starts to feature-test macros for a
20132016 future C++ Standard this dialect will automatically be available.
20142017
20152018 The return value is a sorted list with the C++ dialects used. Since FTM
2016- were added in C++14 the list will not contain C++98 or C++11.
2019+ were added in C++14 the list will not contain C++03 or C++11.
20172020 """
20182021 dialects = set ()
20192022 for feature in self .__data :
@@ -2024,7 +2027,7 @@ def std_dialects(self):
20242027 return sorted (list (dialects ))
20252028
20262029 @functools .cached_property
2027- def standard_ftms (self ):
2030+ def standard_ftms (self ) -> Dict [ str , Dict [ str , Any ]] :
20282031 """Returns the FTM versions per dialect in the Standard.
20292032
20302033 This function does not use the 'implemented' flag. The output contains
@@ -2038,10 +2041,10 @@ def standard_ftms(self):
20382041 * key: The version of the C++ dialect.
20392042 * value: The value of the feature-test macro.
20402043 """
2041- return get_dialect_versions (self .__data , self .std_dialects , False )
2044+ return get_ftms (self .__data , self .std_dialects , False )
20422045
20432046 @functools .cached_property
2044- def implemented_ftms (self ):
2047+ def implemented_ftms (self ) -> Dict [ str , Dict [ str , Any ]] :
20452048 """Returns the FTM versions per dialect implemented in libc++.
20462049
20472050 Unlike `get_std_dialect_versions` this function uses the 'implemented'
@@ -2055,7 +2058,7 @@ def implemented_ftms(self):
20552058 macro is not implemented its value is None.
20562059 """
20572060
2058- return get_dialect_versions (self .__data , self .std_dialects , True )
2061+ return get_ftms (self .__data , self .std_dialects , True )
20592062
20602063
20612064def main ():
0 commit comments