From 33158cb18dc832b4bca0b63779546ea5185e17fe Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Thu, 26 Mar 2026 08:40:54 -0700 Subject: [PATCH] Handle member array types in the snapshot (#56206) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56206 Changelog: [Internal] Correctly handles array types in member definitions in the API snapshot. Reviewed By: cipolleschi Differential Revision: D97923375 fbshipit-source-id: b8b9ca07e819bfaa7cbaf7ad6506fd32a9719a9d --- scripts/cxx-api/parser/member/variable_member.py | 2 ++ .../should_handle_array_variable/snapshot.api | 1 + .../snapshots/should_handle_array_variable/test.h | 14 ++++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 scripts/cxx-api/tests/snapshots/should_handle_array_variable/snapshot.api create mode 100644 scripts/cxx-api/tests/snapshots/should_handle_array_variable/test.h diff --git a/scripts/cxx-api/parser/member/variable_member.py b/scripts/cxx-api/parser/member/variable_member.py index 8c456f6c1e1..403af09eae4 100644 --- a/scripts/cxx-api/parser/member/variable_member.py +++ b/scripts/cxx-api/parser/member/variable_member.py @@ -111,6 +111,8 @@ class VariableMember(Member): result += f"{qualified_type} (*{name})({formatted_args})" else: result += f"{format_parsed_type(self._parsed_type)} {name}" + if self.argstring: + result += self.argstring if STORE_INITIALIZERS_IN_SNAPSHOT and self.value is not None: if self.is_brace_initializer: diff --git a/scripts/cxx-api/tests/snapshots/should_handle_array_variable/snapshot.api b/scripts/cxx-api/tests/snapshots/should_handle_array_variable/snapshot.api new file mode 100644 index 00000000000..fd3f119e956 --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_handle_array_variable/snapshot.api @@ -0,0 +1 @@ +const char test::ViewComponentName[]; diff --git a/scripts/cxx-api/tests/snapshots/should_handle_array_variable/test.h b/scripts/cxx-api/tests/snapshots/should_handle_array_variable/test.h new file mode 100644 index 00000000000..cf1624f6b91 --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_handle_array_variable/test.h @@ -0,0 +1,14 @@ +/* + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#pragma once + +namespace test { + +const char ViewComponentName[] = "View"; + +} // namespace test