feat: Add SharedArray.getSize() (#2406)

* feat: Add `SharedArray.getSize()`

* Rename `count` to `size` on iOS

* `->` instead of `.`
This commit is contained in:
Marc Rousavy
2024-01-17 18:30:26 +01:00
committed by GitHub
parent 03ee0a2099
commit 2f21609e39
5 changed files with 20 additions and 6 deletions

View File

@@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
#endif
@property(nonatomic, readonly, nonnull) uint8_t* data;
@property(nonatomic, readonly) NSInteger count;
@property(nonatomic, readonly) NSInteger size;
@end

View File

@@ -15,7 +15,7 @@ using namespace facebook;
@implementation SharedArray {
uint8_t* _data;
NSInteger _count;
NSInteger _size;
std::shared_ptr<vision::TypedArrayBase> _array;
}
@@ -29,7 +29,7 @@ vision::TypedArrayKind getTypedArrayKind(int unsafeEnumValue) {
vision::TypedArrayKind kind = getTypedArrayKind((int)type);
_array = std::make_shared<vision::TypedArrayBase>(vision::TypedArrayBase(runtime, size, kind));
_data = _array->getBuffer(runtime).data(runtime);
_count = size;
_size = size;
}
return self;
}
@@ -38,7 +38,7 @@ vision::TypedArrayKind getTypedArrayKind(int unsafeEnumValue) {
if (self = [super init]) {
_array = typedArray;
_data = _array->getBuffer(runtime).data(runtime);
_count = _array->getBuffer(runtime).size(runtime);
_size = _array->getBuffer(runtime).size(runtime);
}
return self;
}
@@ -51,8 +51,8 @@ vision::TypedArrayKind getTypedArrayKind(int unsafeEnumValue) {
return _data;
}
- (NSInteger)count {
return _count;
- (NSInteger)size {
return _size;
}
@end