-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ffigen] Release all ObjC references on the main thread (#1603)
- Loading branch information
1 parent
963155d
commit f9a3888
Showing
18 changed files
with
197 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
#import <Foundation/NSObject.h> | ||
|
||
void objc_autoreleasePoolPop(void *pool); | ||
void *objc_autoreleasePoolPush(); | ||
|
||
@interface ArcTestObject : NSObject { | ||
int32_t* counter; | ||
} | ||
|
||
+ (instancetype)allocTheThing; | ||
+ (instancetype)newWithCounter:(int32_t*) _counter; | ||
- (instancetype)initWithCounter:(int32_t*) _counter; | ||
+ (ArcTestObject*)makeAndAutorelease:(int32_t*) _counter; | ||
- (void)setCounter:(int32_t*) _counter; | ||
- (void)dealloc; | ||
- (ArcTestObject*)copyMe; | ||
- (ArcTestObject*)mutableCopyMe; | ||
- (id)copyWithZone:(NSZone*) zone; | ||
- (ArcTestObject*)returnsRetained NS_RETURNS_RETAINED; | ||
- (ArcTestObject*)copyMeNoRetain __attribute__((ns_returns_not_retained)); | ||
- (ArcTestObject*)copyMeAutorelease __attribute__((ns_returns_autoreleased)); | ||
- (ArcTestObject*)copyMeConsumeSelf __attribute__((ns_consumes_self)); | ||
+ (void)consumeArg:(ArcTestObject*) __attribute((ns_consumed)) arg; | ||
|
||
@property (assign) ArcTestObject* assignedProperty; | ||
@property (retain) ArcTestObject* retainedProperty; | ||
@property (copy) ArcTestObject* copiedProperty; | ||
|
||
@end | ||
|
||
@interface ArcDtorTestObject : NSObject { | ||
int32_t* dtorCounter; | ||
int32_t* dtorOnMainThreadCounter; | ||
} | ||
- (instancetype)initWithCounters:(int32_t*) _dtorCounter | ||
onMainThread: (int32_t*) _dtorOnMainThreadCounter; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
pkgs/objective_c/lib/src/objective_c_bindings_generated.dart.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <stdint.h> | ||
#import "../../src/foundation.h" | ||
#import "../../src/proxy.h" | ||
|
||
#if !__has_feature(objc_arc) | ||
#error "This file must be compiled with ARC enabled" | ||
#endif | ||
|
||
id objc_retain(id); | ||
id objc_retainBlock(id); | ||
|
||
typedef void (^_ListenerTrampoline)(void * arg0, id arg1); | ||
_ListenerTrampoline _wrapListenerBlock_3f15836a(_ListenerTrampoline block) NS_RETURNS_RETAINED { | ||
return ^void(void * arg0, id arg1) { | ||
objc_retainBlock(block); | ||
block(arg0, objc_retain(arg1)); | ||
}; | ||
} | ||
|
||
typedef void (^_ListenerTrampoline1)(void * arg0); | ||
_ListenerTrampoline1 _wrapListenerBlock_162449db(_ListenerTrampoline1 block) NS_RETURNS_RETAINED { | ||
return ^void(void * arg0) { | ||
objc_retainBlock(block); | ||
block(arg0); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
#import <Foundation/NSThread.h> | ||
#import <dispatch/dispatch.h> | ||
|
||
void runOnMainThread(void (*fn)(void*), void* arg) { | ||
#ifdef NO_MAIN_THREAD_DISPATCH | ||
fn(arg); | ||
#else | ||
if ([NSThread isMainThread]) { | ||
fn(arg); | ||
} else { | ||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
fn(arg); | ||
}); | ||
} | ||
#endif | ||
} |
Oops, something went wrong.