Skip to content

Commit db11646

Browse files
christophpurrermeta-codesync[bot]
authored andcommitted
Drop RCT_EXPORT_METHOD from RCTImageEditingManager (#57773)
Summary: Pull Request resolved: #57773 RCTImageEditingManager is a TurboModule conforming to `NativeImageEditorSpec`. For TurboModules, JS->ObjC dispatch is driven by codegen via the generated `NativeImageEditorSpecJSI`, not by `RCT_EXPORT_METHOD`'s `__rct_export__` metadata, so the macro is dead weight. Protocol conformance gives compiler-enforced signature parity. This diff is part of the `CodemodConfigDevmateDropRctExportMethod` pipeline that removes the legacy macro from first-party ObjC TurboModules. Change: - Converts `RCT_EXPORT_METHOD(cropImage: ...)` to plain ObjC method `- (void)cropImage:(NSString *)...` Type-mismatch reconciliation (cAST mod flagged `FLAG type-mismatch`): - Generated spec requires `(NSString *)uri`, but the legacy impl declared `(NSURLRequest *)imageRequest`. - The macro was silently coercing the arg via `RCTConvert`. - Preserve coercion manually: signature now takes `NSString *imageRequestString`, body restores `NSURLRequest *imageRequest = [RCTConvert NSURLRequest:imageRequestString];` at top. Existing `loadImageWithURLRequest:` usage unchanged. Generated spec (from `FBReactNativeSpec.h`): ``` protocol NativeImageEditorSpec <RCTBridgeModule, RCTTurboModule> - (void)cropImage:(NSString *)uri cropData:(JS::NativeImageEditor::Options &)cropData successCallback:(RCTResponseSenderBlock)successCallback errorCallback:(RCTResponseSenderBlock)errorCallback; end ``` `RCT_EXPORT_MODULE()` and `getTurboModule:` are left untouched. Changelog: [Internal] Reviewed By: shwanton Differential Revision: D114288222 fbshipit-source-id: 09724f31d11929209d52b77795ebd1a28a7f81ce
1 parent ed3229a commit db11646

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

packages/react-native/Libraries/Image/RCTImageEditingManager.mm

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,22 @@ @implementation RCTImageEditingManager
3838
* be scaled down to `displaySize` rather than `size`.
3939
* All units are in px (not points).
4040
*/
41-
RCT_EXPORT_METHOD(
42-
cropImage : (NSURLRequest *)imageRequest cropData : (JS::NativeImageEditor::Options &)cropData successCallback : (
43-
RCTResponseSenderBlock)successCallback errorCallback : (RCTResponseSenderBlock)errorCallback)
41+
- (void)cropImage:(NSString *)imageRequestString
42+
cropData:(JS::NativeImageEditor::Options &)cropData
43+
successCallback:(RCTResponseSenderBlock)successCallback
44+
errorCallback:(RCTResponseSenderBlock)errorCallback
4445
{
46+
NSURLRequest *imageRequest = [RCTConvert NSURLRequest:imageRequestString];
47+
4548
CGRect rect = {
46-
[RCTConvert CGPoint:@{
47-
@"x" : @(cropData.offset().x()),
48-
@"y" : @(cropData.offset().y()),
49-
}],
50-
[RCTConvert CGSize:@{
51-
@"width" : @(cropData.size().width()),
52-
@"height" : @(cropData.size().height()),
53-
}]
54-
};
49+
[RCTConvert CGPoint:@{
50+
@"x" : @(cropData.offset().x()),
51+
@"y" : @(cropData.offset().y()),
52+
}],
53+
[RCTConvert CGSize:@{
54+
@"width" : @(cropData.size().width()),
55+
@"height" : @(cropData.size().height()),
56+
}]};
5557

5658
// We must keep a copy of cropData so that we can access data from it at a later time
5759
JS::NativeImageEditor::Options cropDataCopy = cropData;

0 commit comments

Comments
 (0)