Skip to content

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
mordante committed Jul 4, 2024
1 parent 4eaacab commit c8dd9ad
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# ===----------------------------------------------------------------------===##

# RUN: %{python} %s %{libcxx-dir}/utils %{libcxx-dir}/utils/data/feature_test_macros/test_data.json
# RUN: %{python} %s %{libcxx-dir}/utils %{libcxx-dir}/test/libcxx/feature_test_macro/test_data.json

import sys

Expand Down
2 changes: 1 addition & 1 deletion libcxx/test/libcxx/feature_test_macro/standard_ftms.sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# ===----------------------------------------------------------------------===##

# RUN: %{python} %s %{libcxx-dir}/utils %{libcxx-dir}/utils/data/feature_test_macros/test_data.json
# RUN: %{python} %s %{libcxx-dir}/utils %{libcxx-dir}/test/libcxx/feature_test_macro/test_data.json

import sys

Expand Down
2 changes: 1 addition & 1 deletion libcxx/test/libcxx/feature_test_macro/std_dialects.sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# ===----------------------------------------------------------------------===##

# RUN: %{python} %s %{libcxx-dir}/utils %{libcxx-dir}/utils/data/feature_test_macros/test_data.json
# RUN: %{python} %s %{libcxx-dir}/utils %{libcxx-dir}/test/libcxx/feature_test_macro/test_data.json

import sys

Expand Down
20 changes: 11 additions & 9 deletions libcxx/utils/generate_feature_test_macro_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -1869,8 +1869,10 @@ def produce_docs():
f.write(doc_str)


def get_dialect_versions(data, std_dialects, use_implemented_status):
"""Impementation for feature_test_macros.get_(std_|)dialect_versions()."""
def get_ftms(
data, std_dialects: list[str], use_implemented_status: bool
) -> dict[str, dict[str, any]]:
"""Impementation for FeatureTestMacros.(standard|implemented)_ftms()."""
result = dict()
for feature in data:
last = None
Expand Down Expand Up @@ -2000,20 +2002,20 @@ class FeatureTestMacros:
# The JSON data structure.
__data = None

def __init__(self, filename):
def __init__(self, filename: str):
"""Initializes the class with the JSON data in the file 'filename'."""
self.__data = json.load(open(filename))

@functools.cached_property
def std_dialects(self):
def std_dialects(self) -> list[str]:
"""Returns the C++ dialects avaiable.
The available dialects are based on the 'c++xy' keys found the 'values'
entries in '__data'. So when WG21 starts to feature-test macros for a
future C++ Standard this dialect will automatically be available.
The return value is a sorted list with the C++ dialects used. Since FTM
were added in C++14 the list will not contain C++98 or C++11.
were added in C++14 the list will not contain C++03 or C++11.
"""
dialects = set()
for feature in self.__data:
Expand All @@ -2024,7 +2026,7 @@ def std_dialects(self):
return sorted(list(dialects))

@functools.cached_property
def standard_ftms(self):
def standard_ftms(self) -> dict[str, dict[str, any]]:
"""Returns the FTM versions per dialect in the Standard.
This function does not use the 'implemented' flag. The output contains
Expand All @@ -2038,10 +2040,10 @@ def standard_ftms(self):
* key: The version of the C++ dialect.
* value: The value of the feature-test macro.
"""
return get_dialect_versions(self.__data, self.std_dialects, False)
return get_ftms(self.__data, self.std_dialects, False)

@functools.cached_property
def implemented_ftms(self):
def implemented_ftms(self) -> dict[str, dict[str, any]]:
"""Returns the FTM versions per dialect implemented in libc++.
Unlike `get_std_dialect_versions` this function uses the 'implemented'
Expand All @@ -2055,7 +2057,7 @@ def implemented_ftms(self):
macro is not implemented its value is None.
"""

return get_dialect_versions(self.__data, self.std_dialects, True)
return get_ftms(self.__data, self.std_dialects, True)


def main():
Expand Down

0 comments on commit c8dd9ad

Please sign in to comment.