Skip to content

Commit c625015

Browse files
coadometa-codesync[bot]
authored andcommitted
Include packages/react-native/Libraries path in ReactApple snapshot (facebook#56060)
Summary: Pull Request resolved: facebook#56060 There are Objective-C files located in the `packages/react-native/Libraries` paths. This diff modifies the config to tell doxygen to parse them and fixes problem with parsing interfaces and protocols that share the same name. Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D96141632 fbshipit-source-id: 76c5873574108eb0f610637ce2bd2eeb54b8537c
1 parent 150377c commit c625015

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

scripts/cxx-api/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ ReactApple:
5454
- packages/react-native/ReactCommon
5555
- packages/react-native/React
5656
- packages/react-native/ReactApple
57+
- packages/react-native/Libraries
5758
exclude_patterns:
5859
- "*/test_utils/*"
5960
- "*/jni/*"
@@ -63,6 +64,8 @@ ReactApple:
6364
- "*/platform/android/*"
6465
- "*+Private.h"
6566
- "*+Internal.h"
67+
- "*/scripts/*"
68+
- "*/templates/*"
6669
definitions:
6770
__cplusplus: 1
6871
variants:

scripts/cxx-api/parser/snapshot.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,18 @@ def create_or_get_namespace(self, qualified_name: str) -> Scope[NamespaceScopeKi
9090
def create_protocol(self, qualified_name: str) -> Scope[ProtocolScopeKind]:
9191
"""
9292
Create a protocol in the snapshot.
93+
In Objective-C, a protocol and interface can share the same name,
94+
so protocols are stored with a '-p' suffix to differentiate them.
9395
"""
9496
path = parse_qualified_path(qualified_name)
9597
scope_path = path[0:-1]
9698
scope_name = path[-1]
99+
# Use '-p' suffix to allow protocols to coexist with interfaces of the same name
100+
scope_key = f"{scope_name}-p"
97101
current_scope = self.ensure_scope(scope_path)
98102

99-
if scope_name in current_scope.inner_scopes:
100-
scope = current_scope.inner_scopes[scope_name]
103+
if scope_key in current_scope.inner_scopes:
104+
scope = current_scope.inner_scopes[scope_key]
101105
if scope.kind.name == "temporary":
102106
scope.kind = ProtocolScopeKind()
103107
else:
@@ -108,7 +112,7 @@ def create_protocol(self, qualified_name: str) -> Scope[ProtocolScopeKind]:
108112
else:
109113
new_scope = Scope(ProtocolScopeKind(), scope_name)
110114
new_scope.parent_scope = current_scope
111-
current_scope.inner_scopes[scope_name] = new_scope
115+
current_scope.inner_scopes[scope_key] = new_scope
112116
return new_scope
113117

114118
def create_interface(self, qualified_name: str) -> Scope[InterfaceScopeKind]:

0 commit comments

Comments
 (0)