react-native 0.88.0-rc.1 → 0.88.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/React/Base/RCTVersion.m +1 -1
- package/React/FBReactNativeSpec/FBReactNativeSpec/FBReactNativeSpec.h +3 -4
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
- package/ReactCommon/react/nativemodule/core/iostests/RCTTurboModuleTests.mm +18 -65
- package/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.h +1 -2
- package/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm +1 -2
- package/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h +2 -9
- package/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm +33 -71
- package/ReactCommon/react/nativemodule/samples/platform/ios/ReactCommon/RCTSampleTurboModule.mm +8 -19
- package/gradle/libs.versions.toml +1 -1
- package/package.json +14 -11
- package/scripts/spm/generate-spm-autolinking.js +20 -9
- package/scripts/spm/generate-spm-xcodeproj.js +3 -1
- package/sdks/hermes-engine/version.properties +1 -1
- package/src/react-private-interface.js +4 -0
- package/src/react-private-interface.js.flow +1 -0
- package/types_generated/src/private/featureflags/ReactNativeFeatureFlags.d.ts +646 -0
- package/types_generated/src/private/featureflags/ReactNativeFeatureFlagsBase.d.ts +24 -0
- package/types_generated/src/private/featureflags/specs/NativeReactNativeFeatureFlags.d.ts +117 -0
- package/types_generated/src/react-private-interface.d.ts +2 -1
- package/React/Base/RCTArrayBuffer.h +0 -64
- package/React/Base/RCTArrayBuffer.mm +0 -127
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @generated SignedSource<<3f726257f68b8a5e94033b55e216f5f1>>
|
|
8
|
+
*
|
|
9
|
+
* This file was translated from Flow by scripts/js-api/build-types/index.js.
|
|
10
|
+
* Original file: packages/react-native/src/private/featureflags/ReactNativeFeatureFlagsBase.js
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { ReactNativeFeatureFlagsJsOnly, ReactNativeFeatureFlagsJsOnlyOverrides } from "./ReactNativeFeatureFlags";
|
|
14
|
+
import NativeReactNativeFeatureFlags from "./specs/NativeReactNativeFeatureFlags";
|
|
15
|
+
export type Getter<T> = () => T;
|
|
16
|
+
export type OverridesFor<T extends {
|
|
17
|
+
readonly [$$Key$$: string]: () => unknown;
|
|
18
|
+
}> = Partial<{ [key in keyof T]: Getter<null | undefined | ReturnType<T[key]>> }>;
|
|
19
|
+
export declare function createJavaScriptFlagGetter<K extends keyof ReactNativeFeatureFlagsJsOnly>(configName: K, defaultValue: ReturnType<ReactNativeFeatureFlagsJsOnly[K]>): Getter<ReturnType<ReactNativeFeatureFlagsJsOnly[K]>>;
|
|
20
|
+
type NativeFeatureFlags = NonNullable<typeof NativeReactNativeFeatureFlags>;
|
|
21
|
+
export declare function createNativeFlagGetter<K extends keyof NativeFeatureFlags>(configName: K, defaultValue: ReturnType<NonNullable<NativeFeatureFlags[K]>>, skipUnavailableNativeModuleError?: boolean): Getter<ReturnType<NonNullable<NativeFeatureFlags[K]>>>;
|
|
22
|
+
export declare function getOverrides(): null | undefined | ReactNativeFeatureFlagsJsOnlyOverrides;
|
|
23
|
+
export declare function setOverrides(newOverrides: ReactNativeFeatureFlagsJsOnlyOverrides): void;
|
|
24
|
+
export declare function dangerouslyResetForTesting(): void;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @generated SignedSource<<77332752cda558f1020473f04f9bcbb5>>
|
|
8
|
+
*
|
|
9
|
+
* This file was translated from Flow by scripts/js-api/build-types/index.js.
|
|
10
|
+
* Original file: packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* IMPORTANT: Do NOT modify this file directly.
|
|
15
|
+
*
|
|
16
|
+
* To change the definition of the flags, edit
|
|
17
|
+
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
|
|
18
|
+
*
|
|
19
|
+
* To regenerate this code, run the following script from the repo root:
|
|
20
|
+
* yarn featureflags --update
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import type { TurboModule } from "../../../../Libraries/TurboModule/RCTExport";
|
|
24
|
+
export interface Spec extends TurboModule {
|
|
25
|
+
readonly commonTestFlag?: (() => boolean) | undefined;
|
|
26
|
+
readonly commonTestFlagWithoutNativeImplementation?: (() => boolean) | undefined;
|
|
27
|
+
readonly cdpInteractionMetricsEnabled?: (() => boolean) | undefined;
|
|
28
|
+
readonly cxxNativeAnimatedEnabled?: (() => boolean) | undefined;
|
|
29
|
+
readonly defaultTextToOverflowHidden?: (() => boolean) | undefined;
|
|
30
|
+
readonly disableEarlyViewCommandExecution?: (() => boolean) | undefined;
|
|
31
|
+
readonly disableImageViewPreallocationAndroid?: (() => boolean) | undefined;
|
|
32
|
+
readonly disableMountItemReorderingAndroid?: (() => boolean) | undefined;
|
|
33
|
+
readonly disableSubviewClippingAndroid?: (() => boolean) | undefined;
|
|
34
|
+
readonly disableTextLayoutManagerCacheAndroid?: (() => boolean) | undefined;
|
|
35
|
+
readonly disableViewPreallocationAndroid?: (() => boolean) | undefined;
|
|
36
|
+
readonly enableAccessibilityOrder?: (() => boolean) | undefined;
|
|
37
|
+
readonly enableAccumulatedUpdatesInRawPropsAndroid?: (() => boolean) | undefined;
|
|
38
|
+
readonly enableAndroidTextMeasurementOptimizations?: (() => boolean) | undefined;
|
|
39
|
+
readonly enableBridgelessArchitecture?: (() => boolean) | undefined;
|
|
40
|
+
readonly enableBufferedCallInvoker?: (() => boolean) | undefined;
|
|
41
|
+
readonly enableCppPropsIteratorSetter?: (() => boolean) | undefined;
|
|
42
|
+
readonly enableCustomFocusSearchOnClippedElementsAndroid?: (() => boolean) | undefined;
|
|
43
|
+
readonly enableDestroyShadowTreeRevisionAsync?: (() => boolean) | undefined;
|
|
44
|
+
readonly enableDoubleMeasurementFixAndroid?: (() => boolean) | undefined;
|
|
45
|
+
readonly enableEagerRootViewAttachment?: (() => boolean) | undefined;
|
|
46
|
+
readonly enableExclusivePropsUpdateAndroid?: (() => boolean) | undefined;
|
|
47
|
+
readonly enableFabricCommitBranching?: (() => boolean) | undefined;
|
|
48
|
+
readonly enableFabricLogs?: (() => boolean) | undefined;
|
|
49
|
+
readonly enableFlexboxAutoMinSizeInStrictMode?: (() => boolean) | undefined;
|
|
50
|
+
readonly enableFontScaleChangesUpdatingLayout?: (() => boolean) | undefined;
|
|
51
|
+
readonly enableIOSCompressedTextFrameAdjustment?: (() => boolean) | undefined;
|
|
52
|
+
readonly enableIOSTextBaselineOffsetPerLine?: (() => boolean) | undefined;
|
|
53
|
+
readonly enableIOSViewClipToPaddingBox?: (() => boolean) | undefined;
|
|
54
|
+
readonly enableImagePrefetchingAndroid?: (() => boolean) | undefined;
|
|
55
|
+
readonly enableImageTransparentTintColor?: (() => boolean) | undefined;
|
|
56
|
+
readonly enableImmediateUpdateModeForContentOffsetChanges?: (() => boolean) | undefined;
|
|
57
|
+
readonly enableImperativeEvents?: (() => boolean) | undefined;
|
|
58
|
+
readonly enableImperativeFocus?: (() => boolean) | undefined;
|
|
59
|
+
readonly enableInteropViewManagerClassLookUpOptimizationIOS?: (() => boolean) | undefined;
|
|
60
|
+
readonly enableIntersectionObserverByDefault?: (() => boolean) | undefined;
|
|
61
|
+
readonly enableKeyEvents?: (() => boolean) | undefined;
|
|
62
|
+
readonly enableLayoutAnimationsOnAndroid?: (() => boolean) | undefined;
|
|
63
|
+
readonly enableLayoutAnimationsOnIOS?: (() => boolean) | undefined;
|
|
64
|
+
readonly enableModuleArgumentNSNullConversionIOS?: (() => boolean) | undefined;
|
|
65
|
+
readonly enableMountingCoordinatorPullModelAndroid?: (() => boolean) | undefined;
|
|
66
|
+
readonly enableMutationObserverByDefault?: (() => boolean) | undefined;
|
|
67
|
+
readonly enableNativeCSSParsing?: (() => boolean) | undefined;
|
|
68
|
+
readonly enablePreparedTextLayout?: (() => boolean) | undefined;
|
|
69
|
+
readonly enablePropsUpdateReconciliationAndroid?: (() => boolean) | undefined;
|
|
70
|
+
readonly enableResizeObserverByDefault?: (() => boolean) | undefined;
|
|
71
|
+
readonly enableSwiftUIBasedFilters?: (() => boolean) | undefined;
|
|
72
|
+
readonly enableViewCulling?: (() => boolean) | undefined;
|
|
73
|
+
readonly enableViewRecycling?: (() => boolean) | undefined;
|
|
74
|
+
readonly enableViewRecyclingForImage?: (() => boolean) | undefined;
|
|
75
|
+
readonly enableViewRecyclingForScrollView?: (() => boolean) | undefined;
|
|
76
|
+
readonly enableViewRecyclingForText?: (() => boolean) | undefined;
|
|
77
|
+
readonly enableViewRecyclingForView?: (() => boolean) | undefined;
|
|
78
|
+
readonly enableVirtualViewContainerStateExperimental?: (() => boolean) | undefined;
|
|
79
|
+
readonly fixDifferentiatorParentTagForUnflattenCase?: (() => boolean) | undefined;
|
|
80
|
+
readonly fixMappingOfEventPrioritiesBetweenFabricAndReact?: (() => boolean) | undefined;
|
|
81
|
+
readonly fixYogaFlexBasisFitContentInMainAxis?: (() => boolean) | undefined;
|
|
82
|
+
readonly fuseboxAssertSingleHostState?: (() => boolean) | undefined;
|
|
83
|
+
readonly fuseboxEnabledRelease?: (() => boolean) | undefined;
|
|
84
|
+
readonly fuseboxFrameRecordingEnabled?: (() => boolean) | undefined;
|
|
85
|
+
readonly fuseboxScreenshotCaptureEnabled?: (() => boolean) | undefined;
|
|
86
|
+
readonly fuseboxWebSocketEventsEnabled?: (() => boolean) | undefined;
|
|
87
|
+
readonly optimizedAnimatedPropUpdates?: (() => boolean) | undefined;
|
|
88
|
+
readonly overrideBySynchronousMountPropsAtMountingAndroid?: (() => boolean) | undefined;
|
|
89
|
+
readonly perfIssuesEnabled?: (() => boolean) | undefined;
|
|
90
|
+
readonly perfMonitorV2Enabled?: (() => boolean) | undefined;
|
|
91
|
+
readonly preparedTextCacheSize?: (() => number) | undefined;
|
|
92
|
+
readonly preventShadowTreeCommitExhaustion?: (() => boolean) | undefined;
|
|
93
|
+
readonly redBoxV2Android?: (() => boolean) | undefined;
|
|
94
|
+
readonly redBoxV2IOS?: (() => boolean) | undefined;
|
|
95
|
+
readonly shouldPressibilityUseW3CPointerEventsForHover?: (() => boolean) | undefined;
|
|
96
|
+
readonly shouldTriggerResponderTransferOnScrollAndroid?: (() => boolean) | undefined;
|
|
97
|
+
readonly skipActivityIdentityAssertionOnHostPause?: (() => boolean) | undefined;
|
|
98
|
+
readonly syncAndroidClipBoundsWithOverflow?: (() => boolean) | undefined;
|
|
99
|
+
readonly traceTurboModulePromiseRejectionsOnAndroid?: (() => boolean) | undefined;
|
|
100
|
+
readonly updateRuntimeShadowNodeReferencesOnCommit?: (() => boolean) | undefined;
|
|
101
|
+
readonly updateRuntimeShadowNodeReferencesOnCommitThread?: (() => boolean) | undefined;
|
|
102
|
+
readonly useAlwaysAvailableJSErrorHandling?: (() => boolean) | undefined;
|
|
103
|
+
readonly useFabricInterop?: (() => boolean) | undefined;
|
|
104
|
+
readonly useNativeViewConfigsInBridgelessMode?: (() => boolean) | undefined;
|
|
105
|
+
readonly useNestedScrollViewAndroid?: (() => boolean) | undefined;
|
|
106
|
+
readonly useSharedAnimatedBackend?: (() => boolean) | undefined;
|
|
107
|
+
readonly useTraitHiddenOnAndroid?: (() => boolean) | undefined;
|
|
108
|
+
readonly useTurboModuleInterop?: (() => boolean) | undefined;
|
|
109
|
+
readonly viewCullingOutsetRatio?: (() => number) | undefined;
|
|
110
|
+
readonly viewTransitionEnabled?: (() => boolean) | undefined;
|
|
111
|
+
readonly viewTransitionUseHardwareBitmapAndroid?: (() => boolean) | undefined;
|
|
112
|
+
readonly virtualViewPrerenderRatio?: (() => number) | undefined;
|
|
113
|
+
}
|
|
114
|
+
declare const NativeReactNativeFeatureFlags: null | undefined | Spec;
|
|
115
|
+
declare const $$NativeReactNativeFeatureFlags: typeof NativeReactNativeFeatureFlags;
|
|
116
|
+
declare type $$NativeReactNativeFeatureFlags = typeof $$NativeReactNativeFeatureFlags;
|
|
117
|
+
export default $$NativeReactNativeFeatureFlags;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @generated SignedSource<<
|
|
7
|
+
* @generated SignedSource<<da47aab453fb7e939bb4d522892273eb>>
|
|
8
8
|
*
|
|
9
9
|
* This file was translated from Flow by scripts/js-api/build-types/index.js.
|
|
10
10
|
* Original file: packages/react-native/src/react-private-interface.js.flow
|
|
@@ -19,6 +19,7 @@ export { default as BatchedBridge } from "../Libraries/BatchedBridge/BatchedBrid
|
|
|
19
19
|
export { default as ExceptionsManager } from "../Libraries/Core/ExceptionsManager";
|
|
20
20
|
export { default as Platform } from "../Libraries/Utilities/Platform";
|
|
21
21
|
export { default as RCTEventEmitter } from "../Libraries/EventEmitter/RCTEventEmitter";
|
|
22
|
+
export * as ReactNativeFeatureFlags from "./private/featureflags/ReactNativeFeatureFlags";
|
|
22
23
|
export * as ReactNativeViewConfigRegistry from "../Libraries/Renderer/shims/ReactNativeViewConfigRegistry";
|
|
23
24
|
export { default as TextInputState } from "../Libraries/Components/TextInput/TextInputState";
|
|
24
25
|
export { default as UIManager } from "../Libraries/ReactNative/UIManager";
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
#import <Foundation/Foundation.h>
|
|
9
|
-
|
|
10
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* A fixed-length byte buffer shared between JS `ArrayBuffer`s and ObjC TurboModules. Fixed
|
|
14
|
-
* length lets the backing store alias JS memory; `NSMutableData` cannot do that.
|
|
15
|
-
*
|
|
16
|
-
* `isOwningBytes`:
|
|
17
|
-
* - `YES` — safe to retain and use from any thread (synchronize if aliasing JS
|
|
18
|
-
* memory).
|
|
19
|
-
* - `NO` — valid only during the synchronous call on the calling thread; copy with
|
|
20
|
-
* `arrayBufferWithCopiedBytes:length:` to keep the bytes.
|
|
21
|
-
*/
|
|
22
|
-
@interface RCTArrayBuffer : NSObject
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* NULL when `length` is 0, non-NULL otherwise, matching `NSData.bytes`.
|
|
26
|
-
*/
|
|
27
|
-
@property (nonatomic, readonly, nullable) void *mutableBytes NS_RETURNS_INNER_POINTER;
|
|
28
|
-
|
|
29
|
-
@property (nonatomic, readonly) NSUInteger length;
|
|
30
|
-
|
|
31
|
-
/** Whether the buffer owns its bytes. See the class comment. */
|
|
32
|
-
@property (nonatomic, readonly, getter=isOwningBytes) BOOL owningBytes;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* A new zero-filled owning buffer.
|
|
36
|
-
*/
|
|
37
|
-
+ (instancetype)arrayBufferWithLength:(NSUInteger)length;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* A new owning buffer holding a copy of `bytes`. Passing NULL zero-fills.
|
|
41
|
-
*/
|
|
42
|
-
+ (instancetype)arrayBufferWithCopiedBytes:(const void *_Nullable)bytes length:(NSUInteger)length;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* An owning buffer aliasing `bytes` without copying. If `cleanup` is non-nil, it runs on dealloc,
|
|
46
|
-
* like `-[NSData dataWithBytesNoCopy:length:freeWhenDone:YES]`; if nil, the caller must keep
|
|
47
|
-
* `bytes` valid until dealloc. NULL `bytes` with non-zero `length` raises NSInvalidArgumentException.
|
|
48
|
-
*/
|
|
49
|
-
+ (instancetype)arrayBufferWithOwnedBytes:(nullable void *)bytes
|
|
50
|
-
length:(NSUInteger)length
|
|
51
|
-
cleanup:(nullable void (^)(void))cleanup;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* A non-owning, zero-copy alias of `bytes`. See the class comment for lifetime rules. NULL `bytes`
|
|
55
|
-
* with non-zero `length` raises NSInvalidArgumentException.
|
|
56
|
-
*/
|
|
57
|
-
+ (instancetype)arrayBufferWithUnownedBytes:(nullable void *)bytes length:(NSUInteger)length;
|
|
58
|
-
|
|
59
|
-
- (instancetype)init NS_UNAVAILABLE;
|
|
60
|
-
+ (instancetype)new NS_UNAVAILABLE;
|
|
61
|
-
|
|
62
|
-
@end
|
|
63
|
-
|
|
64
|
-
NS_ASSUME_NONNULL_END
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
#import "RCTArrayBuffer.h"
|
|
9
|
-
|
|
10
|
-
#include <cstdint>
|
|
11
|
-
#include <cstring>
|
|
12
|
-
#include <utility>
|
|
13
|
-
#include <vector>
|
|
14
|
-
|
|
15
|
-
@interface RCTArrayBuffer ()
|
|
16
|
-
|
|
17
|
-
- (instancetype)initWithBytesNoCopy:(nullable void *)bytes
|
|
18
|
-
length:(NSUInteger)length
|
|
19
|
-
owningBytes:(BOOL)owningBytes
|
|
20
|
-
cleanup:(nullable void (^)(void))cleanup NS_DESIGNATED_INITIALIZER;
|
|
21
|
-
- (instancetype)initWithCopiedBytes:(const void *_Nullable)bytes length:(NSUInteger)length;
|
|
22
|
-
|
|
23
|
-
@end
|
|
24
|
-
|
|
25
|
-
@implementation RCTArrayBuffer {
|
|
26
|
-
void *_bytes;
|
|
27
|
-
NSUInteger _length;
|
|
28
|
-
BOOL _owningBytes;
|
|
29
|
-
void (^_cleanup)(void);
|
|
30
|
-
std::vector<uint8_t> _copiedBytes;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
#pragma mark - Initializers
|
|
34
|
-
|
|
35
|
-
- (instancetype)initWithBytesNoCopy:(void *)bytes
|
|
36
|
-
length:(NSUInteger)length
|
|
37
|
-
owningBytes:(BOOL)owningBytes
|
|
38
|
-
cleanup:(void (^)(void))cleanup
|
|
39
|
-
{
|
|
40
|
-
if (bytes == NULL && length != 0) {
|
|
41
|
-
[NSException raise:NSInvalidArgumentException
|
|
42
|
-
format:@"RCTArrayBuffer: NULL bytes with length %lu", (unsigned long)length];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (self = [super init]) {
|
|
46
|
-
_bytes = bytes;
|
|
47
|
-
_length = length;
|
|
48
|
-
_owningBytes = owningBytes;
|
|
49
|
-
_cleanup = [cleanup copy];
|
|
50
|
-
}
|
|
51
|
-
return self;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
- (instancetype)initWithCopiedBytes:(const void *)bytes length:(NSUInteger)length
|
|
55
|
-
{
|
|
56
|
-
if (length == 0) {
|
|
57
|
-
return [self initWithBytesNoCopy:NULL length:0 owningBytes:YES cleanup:nil];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
std::vector<uint8_t> copy(length);
|
|
61
|
-
if (bytes != NULL) {
|
|
62
|
-
std::memcpy(copy.data(), bytes, length);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Moving a vector hands over its heap buffer, so `data()` stays valid in `_copiedBytes`.
|
|
66
|
-
if (self = [self initWithBytesNoCopy:copy.data() length:length owningBytes:YES cleanup:nil]) {
|
|
67
|
-
_copiedBytes = std::move(copy);
|
|
68
|
-
}
|
|
69
|
-
return self;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
+ (instancetype)arrayBufferWithLength:(NSUInteger)length
|
|
73
|
-
{
|
|
74
|
-
return [[self alloc] initWithCopiedBytes:NULL length:length];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
+ (instancetype)arrayBufferWithCopiedBytes:(const void *)bytes length:(NSUInteger)length
|
|
78
|
-
{
|
|
79
|
-
return [[self alloc] initWithCopiedBytes:bytes length:length];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
+ (instancetype)arrayBufferWithOwnedBytes:(void *)bytes
|
|
83
|
-
length:(NSUInteger)length
|
|
84
|
-
cleanup:(nullable void (^)(void))cleanup
|
|
85
|
-
{
|
|
86
|
-
return [[self alloc] initWithBytesNoCopy:bytes length:length owningBytes:YES cleanup:cleanup];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
+ (instancetype)arrayBufferWithUnownedBytes:(void *)bytes length:(NSUInteger)length
|
|
90
|
-
{
|
|
91
|
-
return [[self alloc] initWithBytesNoCopy:bytes length:length owningBytes:NO cleanup:nil];
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
#pragma mark - Accessors
|
|
95
|
-
|
|
96
|
-
- (void *)mutableBytes
|
|
97
|
-
{
|
|
98
|
-
return _bytes;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
- (NSUInteger)length
|
|
102
|
-
{
|
|
103
|
-
return _length;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
- (BOOL)isOwningBytes
|
|
107
|
-
{
|
|
108
|
-
return _owningBytes;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
- (NSString *)description
|
|
112
|
-
{
|
|
113
|
-
return [NSString stringWithFormat:@"<%@: %p; length = %lu; owningBytes = %@>",
|
|
114
|
-
NSStringFromClass([self class]),
|
|
115
|
-
self,
|
|
116
|
-
(unsigned long)_length,
|
|
117
|
-
_owningBytes ? @"YES" : @"NO"];
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
- (void)dealloc
|
|
121
|
-
{
|
|
122
|
-
if (_cleanup != nil) {
|
|
123
|
-
_cleanup();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
@end
|