mirror of
https://github.com/react/react-native.git
synced 2026-09-28 13:23:09 +08:00
Deduplicate constructors when a class has multiple base classes (#56213)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56213 Changelog: [Internal] When a class has multiple base classes, all defining a constructor with the same signature, the inherited constructors were being duplicated in the snapshot (for each base class). This diff deduplicates them. Reviewed By: cipolleschi Differential Revision: D98102286 fbshipit-source-id: 2086645880afab8ec30d245b7cae5caa5e19679e
This commit is contained in:
committed by
meta-codesync[bot]
parent
33158cb18d
commit
e59957137a
@@ -193,22 +193,20 @@ def build_snapshots(
|
||||
failed_views = ", ".join(name for name, _ in errors)
|
||||
raise RuntimeError(f"Failed to generate snapshots: {failed_views}")
|
||||
else:
|
||||
with tempfile.TemporaryDirectory(prefix="cxx-api-test-") as work_dir:
|
||||
snapshot = build_snapshot_for_view(
|
||||
api_view="Test",
|
||||
react_native_dir=react_native_dir,
|
||||
include_directories=[],
|
||||
exclude_patterns=[],
|
||||
definitions={},
|
||||
output_dir=output_dir,
|
||||
codegen_platform=None,
|
||||
verbose=verbose,
|
||||
input_filter=input_filter,
|
||||
work_dir=work_dir,
|
||||
)
|
||||
snapshot = build_snapshot_for_view(
|
||||
api_view="Test",
|
||||
react_native_dir=react_native_dir,
|
||||
include_directories=[],
|
||||
exclude_patterns=[],
|
||||
definitions={},
|
||||
output_dir=output_dir,
|
||||
codegen_platform=None,
|
||||
verbose=verbose,
|
||||
input_filter=input_filter,
|
||||
)
|
||||
|
||||
if verbose:
|
||||
print(snapshot)
|
||||
if verbose:
|
||||
print(snapshot)
|
||||
|
||||
|
||||
def get_default_snapshot_dir() -> str:
|
||||
|
||||
@@ -34,7 +34,12 @@ class ScopeKind(ABC):
|
||||
stringified_members = [
|
||||
member.to_string(2) + member_suffix for member in scope.get_members()
|
||||
]
|
||||
|
||||
stringified_members = natsorted(stringified_members)
|
||||
# Deduplicate members that produce identical signatures (e.g.
|
||||
# constructors inherited from multiple bases).
|
||||
stringified_members = list(dict.fromkeys(stringified_members))
|
||||
|
||||
result = "{"
|
||||
if stringified_members:
|
||||
result += "\n" + "\n".join(stringified_members)
|
||||
|
||||
@@ -35,6 +35,8 @@ class NamespaceScopeKind(ScopeKind):
|
||||
result = []
|
||||
for kind in MemberKind:
|
||||
sorted_group = natsorted(groups[kind])
|
||||
# Deduplicate members with identical signatures.
|
||||
sorted_group = list(dict.fromkeys(sorted_group))
|
||||
result.extend(sorted_group)
|
||||
|
||||
return "\n".join(result)
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
class test::BaseTextShadowNode : public test::ShadowNode {
|
||||
public BaseTextShadowNode(const test::ShadowNode& source, const test::ShadowNode::Fragment& fragment);
|
||||
public BaseTextShadowNode(const test::ShadowNode::Fragment& fragment, const test::ShadowNode::Shared& family, test::ShadowNode::Traits traits);
|
||||
}
|
||||
|
||||
class test::ConcreteViewShadowNode : public test::ShadowNode {
|
||||
public ConcreteViewShadowNode(const test::ShadowNode& source, const test::ShadowNode::Fragment& fragment);
|
||||
public ConcreteViewShadowNode(const test::ShadowNode::Fragment& fragment, const test::ShadowNode::Shared& family, test::ShadowNode::Traits traits);
|
||||
}
|
||||
|
||||
class test::ParagraphShadowNode : public test::ConcreteViewShadowNode, public test::BaseTextShadowNode {
|
||||
public ParagraphShadowNode(const test::ShadowNode& source, const test::ShadowNode::Fragment& fragment);
|
||||
public ParagraphShadowNode(const test::ShadowNode::Fragment& fragment, const test::ShadowNode::Shared& family, test::ShadowNode::Traits traits);
|
||||
}
|
||||
|
||||
class test::ShadowNode {
|
||||
}
|
||||
|
||||
enum test::ShadowNode::Traits {
|
||||
None,
|
||||
}
|
||||
|
||||
struct test::ShadowNode::Fragment {
|
||||
}
|
||||
|
||||
struct test::ShadowNode::Shared {
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 {
|
||||
|
||||
class ShadowNode {
|
||||
public:
|
||||
struct Fragment {};
|
||||
struct Shared {};
|
||||
enum class Traits { None };
|
||||
};
|
||||
|
||||
class ConcreteViewShadowNode : public ShadowNode {
|
||||
public:
|
||||
ConcreteViewShadowNode(const ShadowNode &source, const Fragment &fragment);
|
||||
ConcreteViewShadowNode(const Fragment &fragment, const Shared &family, Traits traits);
|
||||
};
|
||||
|
||||
class BaseTextShadowNode : public ShadowNode {
|
||||
public:
|
||||
BaseTextShadowNode(const ShadowNode &source, const Fragment &fragment);
|
||||
BaseTextShadowNode(const Fragment &fragment, const Shared &family, Traits traits);
|
||||
};
|
||||
|
||||
class ParagraphShadowNode : public ConcreteViewShadowNode, public BaseTextShadowNode {
|
||||
public:
|
||||
using BaseTextShadowNode::BaseTextShadowNode;
|
||||
using ConcreteViewShadowNode::ConcreteViewShadowNode;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
Reference in New Issue
Block a user