mirror of
https://github.com/react/react-native.git
synced 2026-09-28 13:23:09 +08:00
Filter category members from interface scope (#55899)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55899 Doxygen incorrectly merges category members into the base interface XML output. This causes duplicate members to appear in both the category scope and the interface scope. The fix detects category members by checking if their definition contains the pattern `ClassName(CategoryName)::` (e.g., `RCTBridgeProxy(Cxx)::cxxOnlyProperty`) and filters them out when processing interface sections. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D95191148 fbshipit-source-id: 69d2f35d5aabd8e7567d254dc9b4686b4da2eb89
This commit is contained in:
committed by
meta-codesync[bot]
parent
97430c8165
commit
725b056dc7
@@ -389,15 +389,40 @@ def create_enum_scope(snapshot: Snapshot, enum_def: compound.EnumdefType) -> Non
|
||||
)
|
||||
|
||||
|
||||
def _is_category_member(member_def: compound.MemberdefType) -> bool:
|
||||
"""
|
||||
Check if a member comes from a category based on its definition.
|
||||
|
||||
Doxygen merges category members into the base interface XML output, but the
|
||||
member's definition field contains the category name in parentheses, e.g.:
|
||||
"int RCTBridgeProxy(Cxx)::cxxOnlyProperty"
|
||||
|
||||
We use this to filter out category members from the interface scope.
|
||||
"""
|
||||
definition = member_def.definition
|
||||
if not definition:
|
||||
return False
|
||||
|
||||
# Look for pattern: ClassName(CategoryName)::memberName
|
||||
# The definition contains the qualified name with category info
|
||||
return bool(re.search(r"\w+\([^)]+\)::", definition))
|
||||
|
||||
|
||||
def _process_objc_sections(
|
||||
snapshot: Snapshot,
|
||||
scope,
|
||||
section_defs: list,
|
||||
location_file: str,
|
||||
scope_type: str,
|
||||
filter_category_members: bool = False,
|
||||
) -> None:
|
||||
"""
|
||||
Common section processing for protocols and interfaces.
|
||||
|
||||
Args:
|
||||
filter_category_members: If True, skip members that come from categories.
|
||||
This is used for interfaces since Doxygen incorrectly merges category
|
||||
members into the base interface XML output.
|
||||
"""
|
||||
for section_def in section_defs:
|
||||
kind = section_def.kind
|
||||
@@ -412,11 +437,15 @@ def _process_objc_sections(
|
||||
if member_type == "attrib":
|
||||
for member_def in section_def.memberdef:
|
||||
if member_def.kind == "variable":
|
||||
if filter_category_members and _is_category_member(member_def):
|
||||
continue
|
||||
scope.add_member(
|
||||
get_variable_member(member_def, visibility, is_static)
|
||||
)
|
||||
elif member_type == "func":
|
||||
for function_def in section_def.memberdef:
|
||||
if filter_category_members and _is_category_member(function_def):
|
||||
continue
|
||||
scope.add_member(
|
||||
get_function_member(function_def, visibility, is_static)
|
||||
)
|
||||
@@ -425,6 +454,8 @@ def _process_objc_sections(
|
||||
if member_def.kind == "enum":
|
||||
create_enum_scope(snapshot, member_def)
|
||||
elif member_def.kind == "typedef":
|
||||
if filter_category_members and _is_category_member(member_def):
|
||||
continue
|
||||
scope.add_member(get_typedef_member(member_def, visibility))
|
||||
else:
|
||||
print(
|
||||
@@ -435,6 +466,8 @@ def _process_objc_sections(
|
||||
elif visibility == "property":
|
||||
for member_def in section_def.memberdef:
|
||||
if member_def.kind == "property":
|
||||
if filter_category_members and _is_category_member(member_def):
|
||||
continue
|
||||
scope.add_member(
|
||||
get_property_member(member_def, "public", is_static)
|
||||
)
|
||||
@@ -504,6 +537,7 @@ def create_interface_scope(
|
||||
scope_def.sectiondef,
|
||||
scope_def.location.file,
|
||||
"interface",
|
||||
filter_category_members=True,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -3,5 +3,4 @@ category RCTConvert(UIActivityIndicatorView) {
|
||||
}
|
||||
|
||||
interface RCTConvert : public NSObject {
|
||||
public virtual static UIActivityIndicatorViewStyle UIActivityIndicatorViewStyle:(id json);
|
||||
}
|
||||
|
||||
-2
@@ -4,6 +4,4 @@ category RCTConvert(Transform) {
|
||||
}
|
||||
|
||||
interface RCTConvert : public NSObject {
|
||||
public virtual static CATransform3D CATransform3D:(id json);
|
||||
public virtual static RCTTransformOrigin RCTTransformOrigin:(id json);
|
||||
}
|
||||
|
||||
@@ -3,5 +3,4 @@ category RCTBridgeProxy(Cxx) {
|
||||
}
|
||||
|
||||
interface RCTBridgeProxy : public NSObject {
|
||||
public @property (assign) int cxxOnlyProperty;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,4 @@ category RCTConvert(CategoryTwo) {
|
||||
}
|
||||
|
||||
interface RCTConvert : public NSObject {
|
||||
public virtual static NSString* methodOne:(id json);
|
||||
public virtual static NSString* methodTwo:(id json);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user