feat: SharedArray:wrapData:withSize init for iOS (#2410)
* feat: `ArrayBuffer:wrapData:withSize` init for iOS * Format * fix build error * Update ExampleFrameProcessorPlugin.m * docs: Add class docs for SharedArray
This commit is contained in:
@@ -12,25 +12,51 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#import "../../cpp/MutableRawBuffer.h"
|
||||
#import <jsi/jsi.h>
|
||||
using namespace facebook;
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* An ArrayBuffer of type uint8 that can be shared between native and JS without copying.
|
||||
*/
|
||||
@interface SharedArray : NSObject
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
- (instancetype)initWithProxy:(VisionCameraProxyHolder*)proxy size:(NSInteger)size;
|
||||
|
||||
/**
|
||||
* Allocates a new SharedArray with the given size.
|
||||
* Use `data` to write to the SharedArray.
|
||||
*/
|
||||
- (instancetype)initWithProxy:(VisionCameraProxyHolder*)proxy allocateWithSize:(NSInteger)size;
|
||||
|
||||
/**
|
||||
* Wraps the given data in a SharedArray without copying.
|
||||
* Use `data` to write to the SharedArray.
|
||||
*/
|
||||
- (instancetype)initWithProxy:(VisionCameraProxyHolder*)proxy
|
||||
wrapData:(uint8_t*)data
|
||||
withSize:(NSInteger)size
|
||||
freeOnDealloc:(BOOL)freeOnDealloc;
|
||||
|
||||
#ifdef __cplusplus
|
||||
- (instancetype)initWithRuntime:(jsi::Runtime&)runtime arrayBuffer:(std::shared_ptr<jsi::ArrayBuffer>)arrayBuffer;
|
||||
/**
|
||||
* Wraps the given JSI ArrayBuffer in a SharedArray for native access.
|
||||
* Use `data` to write to the SharedArray.
|
||||
*/
|
||||
- (instancetype)initWithRuntime:(jsi::Runtime&)runtime wrapArrayBuffer:(std::shared_ptr<jsi::ArrayBuffer>)arrayBuffer;
|
||||
|
||||
- (std::shared_ptr<jsi::ArrayBuffer>)arrayBuffer;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The underlying contents of the ArrayBuffer which can be used for reading and writing.
|
||||
*/
|
||||
@property(nonatomic, readonly, nonnull) uint8_t* data;
|
||||
/**
|
||||
* The size of the ArrayBuffer.
|
||||
*/
|
||||
@property(nonatomic, readonly) NSInteger size;
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user