From cc9d06bef7c5c3ccd0e73b3001890f6cb6a46cab Mon Sep 17 00:00:00 2001 From: Jakub Piasecki Date: Thu, 26 Mar 2026 08:40:54 -0700 Subject: [PATCH] Fix array brackets appearing in the wrong place in the snapshot (#56214) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56214 Changelog: [Internal] Snapshot generator was putting `[]` in wrong place when generating array type - it was adding it to the type name instead of the variable name. This diff addresses that. Reviewed By: cipolleschi Differential Revision: D98102328 fbshipit-source-id: c5b1f290da3c94ad4834a9756d849ae879733033 --- scripts/cxx-api/parser/builders.py | 2 ++ .../snapshot.api | 3 +++ .../should_handle_array_syntax_correctly/test.h | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 scripts/cxx-api/tests/snapshots/should_handle_array_syntax_correctly/snapshot.api create mode 100644 scripts/cxx-api/tests/snapshots/should_handle_array_syntax_correctly/test.h diff --git a/scripts/cxx-api/parser/builders.py b/scripts/cxx-api/parser/builders.py index c595183d86c..beb9be1c51c 100644 --- a/scripts/cxx-api/parser/builders.py +++ b/scripts/cxx-api/parser/builders.py @@ -333,6 +333,8 @@ def get_doxygen_params( + param_array ) param_name = None + elif param_name: + param_name += param_array else: param_type += param_array diff --git a/scripts/cxx-api/tests/snapshots/should_handle_array_syntax_correctly/snapshot.api b/scripts/cxx-api/tests/snapshots/should_handle_array_syntax_correctly/snapshot.api new file mode 100644 index 00000000000..d0f9dd2bf87 --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_handle_array_syntax_correctly/snapshot.api @@ -0,0 +1,3 @@ +void test::arrayParam(const char name[]); +void test::arrayParamSized(int values[10]); +void test::arrayParamUnnamed(const char[]); diff --git a/scripts/cxx-api/tests/snapshots/should_handle_array_syntax_correctly/test.h b/scripts/cxx-api/tests/snapshots/should_handle_array_syntax_correctly/test.h new file mode 100644 index 00000000000..43240dd86f0 --- /dev/null +++ b/scripts/cxx-api/tests/snapshots/should_handle_array_syntax_correctly/test.h @@ -0,0 +1,16 @@ +/* + * 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 { + +void arrayParam(const char name[]); +void arrayParamSized(int values[10]); +void arrayParamUnnamed(const char[]); + +} // namespace test