Files
react-native/packages/react-native/React/Base/RCTManagedPointer.h
T
Christoph PurrerandFacebook GitHub Bot 65f5cd7995 Use C++17 namespace format everywhere (#36987)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36987

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D45130727

fbshipit-source-id: 66f9fbd2a3a5f4d637b59bee77d085a35117d69d
2023-04-20 14:19:50 -07:00

39 lines
816 B
Objective-C

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#ifdef __cplusplus
#include <memory>
#import <Foundation/Foundation.h>
/**
* Type erased wrapper over any cxx value that can be passed as an argument
* to native method.
*/
@interface RCTManagedPointer : NSObject
@property (nonatomic, readonly) void *voidPointer;
- (instancetype)initWithPointer:(std::shared_ptr<void>)pointer;
@end
namespace facebook::react {
template <typename T, typename P>
RCTManagedPointer *managedPointer(P initializer)
{
auto ptr = std::shared_ptr<void>(new T(initializer));
return [[RCTManagedPointer alloc] initWithPointer:std::move(ptr)];
}
} // namespace facebook::react
#endif