Fix parsing of Objective-C block properties (#55776)

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

Doxygen splits block property types across `<type>` and `<argsstring>` elements. For example:

```objc
property (nonatomic, copy) void (^eventInterceptor)(NSString *eventName, NSDictionary *event, NSNumber *reactTag);
```

Produces XML like:
```xml
<type>void(^</type>
<name>eventInterceptor</name>
<argsstring>)(NSString *eventName, NSDictionary *event, NSNumber *reactTag)</argsstring>
```

This caused the parser to output incomplete types. The fix detects when the property type ends with `(^` and combines it with the property name and argsstring:
```
property (copy) void(^eventInterceptor)(NSString *eventName, NSDictionary *event, NSNumber *reactTag);
```

Changelog:
[Internal]

Reviewed By: cipolleschi

Differential Revision: D94366205

fbshipit-source-id: 2d741401f63916284d453f1112ae0f349234308e
This commit is contained in:
Dawid Małecki authored and meta-codesync[bot] committed 2026-03-05 07:21:42 -08:00
1 parent d473d9b598
commit 47ef0e173f
4 files changed
+35 -1

No files matched your search

+10
View File
@@ -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,
+5 -1
View File
@@ -404,7 +404,11 @@ class PropertyMember(Member):
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
@@ -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);
}
@@ -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