Handle template variables in the API snapshot (#56068)

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

Changelog: [Internal]

Adds support for templates in variable declaration to the c++ API snapshot generator

Reviewed By: cipolleschi

Differential Revision: D96279463

fbshipit-source-id: eb68f97f926e4a407d6c7fa2dda6edf7e43e23ba
This commit is contained in:
Dawid Małecki
2026-03-18 09:29:02 -07:00
committed by meta-codesync[bot]
parent 4b4ae62e95
commit 882dbe0118
5 changed files with 38 additions and 2 deletions
+5 -1
View File
@@ -249,7 +249,7 @@ def get_variable_member(
if initializer_type == InitializerType.BRACE:
is_brace_initializer = True
return VariableMember(
member = VariableMember(
variable_name,
variable_type,
visibility,
@@ -263,6 +263,10 @@ def get_variable_member(
is_brace_initializer,
)
member.add_template(get_template_params(member_def))
return member
def get_doxygen_params(
function_def: compound.MemberdefType,
+3
View File
@@ -162,6 +162,9 @@ class VariableMember(Member):
result = " " * indent
if self.template_list is not None:
result += self.template_list.to_string() + "\n" + " " * indent
if not hide_visibility:
result += self.visibility + " "
@@ -0,0 +1,7 @@
template <typename T>
const test::Strct<T> test::Strct<T>::VALUE;
template <typename T>
struct test::Strct {
public static const test::Strct<T> VALUE;
}
@@ -0,0 +1,20 @@
/*
* 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 {
template <typename T>
struct Strct {
static const Strct<T> VALUE;
};
template <typename T>
const Strct<T> Strct<T>::VALUE = {};
} // namespace test
@@ -1,5 +1,7 @@
constexpr T test::default_value;
constexpr test::MyType test::default_value<test::MyType>;
template <typename T>
constexpr T test::default_value;
template <typename T>
T* test::null_ptr;
test::MyType* test::null_ptr<test::MyType>;