Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/react-native/.doxygen.config.template
Original file line number Diff line number Diff line change
Expand Up @@ -2443,7 +2443,21 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

PREDEFINED = FOLLY_PACK_PUSH="" FOLLY_PACK_POP="" FOLLY_PACK_ATTR="" __attribute__(x)="" ${PREDEFINED}
PREDEFINED = FOLLY_PACK_PUSH="" \
FOLLY_PACK_POP="" \
FOLLY_PACK_ATTR="" \
__attribute__(x)="" \
__deprecated_msg(x)="" \
NS_REQUIRES_SUPER="" \
NS_UNAVAILABLE="" \
CF_RETURNS_NOT_RETAINED="" \
NS_DESIGNATED_INITIALIZER="" \
NS_DESIGNATED_INITIALIZER="" \
RCT_EXTERN="" \
RCT_DEPRECATED="" \
RCT_EXTERN_MODULE="" \
API_AVAILABLE(x)="" \
${PREDEFINED}

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
Expand Down
15 changes: 14 additions & 1 deletion scripts/cxx-api/manual_test/.doxygen.config.template
Original file line number Diff line number Diff line change
Expand Up @@ -2442,7 +2442,20 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

PREDEFINED = FOLLY_PACK_PUSH="" FOLLY_PACK_POP="" FOLLY_PACK_ATTR="" __attribute__(x)="" ${PREDEFINED}
PREDEFINED = FOLLY_PACK_PUSH="" \
FOLLY_PACK_POP="" \
FOLLY_PACK_ATTR="" \
__attribute__(x)="" \
__deprecated_msg(x)="" \
NS_REQUIRES_SUPER="" \
NS_UNAVAILABLE="" \
CF_RETURNS_NOT_RETAINED="" \
NS_DESIGNATED_INITIALIZER="" \
RCT_EXTERN="" \
RCT_DEPRECATED="" \
RCT_EXTERN_MODULE="" \
API_AVAILABLE(x)="" \
${PREDEFINED}

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
Expand Down
29 changes: 28 additions & 1 deletion scripts/cxx-api/parser/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,16 @@ def get_property_member(
is_readable = getattr(member_def, "readable", "no") == "yes"
is_writable = getattr(member_def, "writable", "no") == "yes"

# Handle block properties: Doxygen splits the block type across <type> and <argsstring>
# <type> = "void(^"
# <argsstring> = ")(NSString *eventName, NSDictionary *event, NSNumber *reactTag)"
# We need to combine them: "void(^eventInterceptor)(NSString *, NSDictionary *, NSNumber *)"
if property_type.endswith("(^"):
argsstring = member_def.get_argsstring()
if argsstring:
property_type = f"{property_type}{property_name}{argsstring}"
property_name = ""

return PropertyMember(
property_name,
property_type,
Expand Down Expand Up @@ -465,7 +475,24 @@ def create_interface_scope(

interface_scope = snapshot.create_interface(interface_name)
base_classes = get_base_classes(scope_def, base_class=InterfaceScopeKind.Base)
interface_scope.kind.add_base(base_classes)

# Doxygen incorrectly splits "Foo <Protocol1, Protocol2>" into separate base classes:
# "Foo", "<Protocol1>", "<Protocol2>". Combine them back into "Foo <Protocol1, Protocol2>".
combined_bases = []
for base in base_classes:
if base.name.startswith("<") and base.name.endswith(">") and combined_bases:
prev_name = combined_bases[-1].name
protocol = base.name[1:-1] # Strip < and >
if "<" in prev_name and prev_name.endswith(">"):
# Previous base already has protocols, merge inside the brackets
combined_bases[-1].name = f"{prev_name[:-1]}, {protocol}>"
else:
# First protocol for this base class
combined_bases[-1].name = f"{prev_name} <{protocol}>"
else:
combined_bases.append(base)

interface_scope.kind.add_base(combined_bases)
interface_scope.location = scope_def.location.file

_process_objc_sections(
Expand Down
6 changes: 5 additions & 1 deletion scripts/cxx-api/parser/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,11 @@ def to_string(
if self.is_static:
result += "static "

result += f"@property {attrs_str}{self.type} {name};"
# For block properties, name is embedded in the type (e.g., "void(^eventInterceptor)(args)")
if name:
result += f"@property {attrs_str}{self.type} {name};"
else:
result += f"@property {attrs_str}{self.type};"

return result

Expand Down
14 changes: 13 additions & 1 deletion scripts/cxx-api/tests/snapshots/.doxygen.config.template
Original file line number Diff line number Diff line change
Expand Up @@ -2442,7 +2442,19 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.

PREDEFINED = FOLLY_PACK_PUSH="" FOLLY_PACK_POP="" FOLLY_PACK_ATTR="" __attribute__(x)=""
PREDEFINED = FOLLY_PACK_PUSH="" \
FOLLY_PACK_POP="" \
FOLLY_PACK_ATTR="" \
__attribute__(x)="" \
__deprecated_msg(x)="" \
NS_REQUIRES_SUPER="" \
NS_UNAVAILABLE="" \
CF_RETURNS_NOT_RETAINED="" \
NS_DESIGNATED_INITIALIZER="" \
RCT_EXTERN="" \
RCT_DEPRECATED="" \
RCT_EXTERN_MODULE="" \
API_AVAILABLE(x)=""

# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface RCTAppearance : public RCTEventEmitter <RCTBridgeModule> {
public virtual instancetype init();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 {

@interface RCTAppearance : RCTEventEmitter <RCTBridgeModule>
- (instancetype)init;
@end

} // namespace test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
interface RCTAlertManager : public NSObject <RCTBridgeModule, RCTInvalidating> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 {

@interface RCTAlertManager : NSObject <RCTBridgeModule, RCTInvalidating>

@end

} // namespace test
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
interface RCTDeprecatedInterface {
public virtual void customBubblingEventTypes();
public virtual void legacyTitle();
public virtual void normalMethod();
public virtual void oldMethod();
}

interface RCTTestInterface {
public virtual NSArray * deprecatedMethod:(id param);
public virtual void normalMethod:(NSString * name);
}

protocol RCTDeprecatedProtocol {
public virtual void deprecatedProtocolMethod();
public virtual void normalProtocolMethod();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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.
*/

@interface RCTTestInterface

- (void)normalMethod:(NSString *)name;

- (NSArray *)deprecatedMethod:(id)param __deprecated_msg("Use newMethod instead.");

@end

@interface RCTDeprecatedInterface

- (void)normalMethod;

- (void)oldMethod __deprecated_msg("Use newMethod instead.");

- (void)customBubblingEventTypes __deprecated_msg("Use RCTBubblingEventBlock props instead.");

- (void)legacyTitle __deprecated_msg("This API will be removed along with the legacy architecture.");

@end

@protocol RCTDeprecatedProtocol

- (void)normalProtocolMethod;

- (void)deprecatedProtocolMethod __deprecated_msg("Protocol method is deprecated.");

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
interface RCTInterfaceWithBlockProperty : public NSObject {
public @property (copy) NSString *(^blockWithReturn)(int value);
public @property (copy) void(^eventInterceptor)(NSString *eventName, NSDictionary *event, NSNumber *reactTag);
public @property (copy) void(^simpleBlock)(void);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 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.
*/

@interface RCTInterfaceWithBlockProperty : NSObject

@property (nonatomic, copy, nullable) void (^eventInterceptor)
(NSString *eventName, NSDictionary *event, NSNumber *reactTag);
@property (nonatomic, copy) void (^simpleBlock)(void);
@property (nonatomic, copy) NSString * (^blockWithReturn)(int value);

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
interface RCTTestMacros {
public @property (strong, readonly) dispatch_queue_t methodQueue;
public @property (weak, readonly) id bridge;
public virtual instancetype initWithDelegate:options:(id delegate, NSDictionary * options);
public virtual instancetype initWithName:(NSString * name);
public virtual static UIUserInterfaceStyle userInterfaceStyle();
public virtual void deprecatedMethod();
}

protocol RCTTestProtocol {
public @property (assign, readonly) NSString * name;
public virtual void normalMethod();
public virtual void requiredMethod();
}
36 changes: 36 additions & 0 deletions scripts/cxx-api/tests/snapshots/should_strip_objc_macros/test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.
*/

@interface RCTTestMacros

- (instancetype)initWithName:(NSString *)name NS_DESIGNATED_INITIALIZER;

- (instancetype)initWithDelegate:(id)delegate options:(NSDictionary *)options NS_DESIGNATED_INITIALIZER;

@property (nonatomic, strong, readonly) dispatch_queue_t methodQueue RCT_DEPRECATED;

@property (nonatomic, weak, readonly) id bridge RCT_DEPRECATED;

- (void)deprecatedMethod RCT_DEPRECATED;

+ (UIUserInterfaceStyle)userInterfaceStyle API_AVAILABLE(ios(12));

@end

RCT_EXTERN void RCTExternFunction(const char *input, NSString **output);

RCT_EXTERN NSString *RCTParseType(const char **input);

@protocol RCTTestProtocol

- (void)normalMethod;

- (void)requiredMethod NS_DESIGNATED_INITIALIZER;

@property (nonatomic, readonly) NSString *name RCT_DEPRECATED;

@end
Loading