Fix indexed access in function arguments (#55645)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55645

Changelog: [Internal]

Updates the C++ api snapshot generator to correctly handle arrays of fixed size.

Reviewed By: cipolleschi

Differential Revision: D93407605

fbshipit-source-id: b64d30db04696ea54109258d7d4c4fbf43a4cc69
This commit is contained in:
Jakub Piasecki authored and meta-codesync[bot] committed 2026-02-25 11:16:36 -08:00
1 parent bf4978ef58
commit 269a2ee0cb
3 files changed
+53

No files matched your search

+24
View File
@@ -230,6 +230,30 @@ def get_doxygen_params(
resolve_ref_text_name(param.defval).strip() if param.defval else None
)
# Doxygen splits array dimensions into a separate <array> element.
# For complex declarators like "PropNameID (&&propertyNames)[N]",
# doxygen gives type="PropNameID(&&)", name="propertyNames",
# array="[N]". We must reconstruct the full declarator with the
# name embedded inside the grouping parentheses:
# PropNameID(&&propertyNames)[N]
param_array = param.array
if param_array:
# Match type ending with a pointer/reference declarator group:
# e.g. "PropNameID(&&)", "int(&)", "void(*)"
m = re.search(r"\([*&]+\)\s*$", param_type)
if m and param_name:
# Insert name before the closing ')' and append array
insert_pos = m.end() - 1 # position of trailing ')'
param_type = (
param_type[:insert_pos]
+ param_name
+ param_type[insert_pos:]
+ param_array
)
param_name = None
else:
param_type += param_array
qualifiers, core_type = extract_qualifiers(param_type)
arguments.append((qualifiers, core_type, param_name, param_default))
@@ -0,0 +1,8 @@
struct test::Node {
public void setArray(int(&arr)[10]);
template <size_t N>
public static std::vector< test::PropNameID > names(PropNameID(&&propertyNames)[N]);
}
struct test::PropNameID {
}
@@ -0,0 +1,21 @@
/*
* 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 {
struct PropNameID {};
struct Node {
template <size_t N>
static std::vector<PropNameID> names(PropNameID (&&propertyNames)[N]);
void setArray(int (&arr)[10]);
};
} // namespace test