react-native-ble-nitro 1.6.0 → 1.7.1
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/README.md +28 -12
- package/android/src/main/java/com/margelo/nitro/co/zyke/ble/BleNitroBleManager.kt +8 -3
- package/android/src/main/java/com/margelo/nitro/co/zyke/ble/BleNitroBleManagerFactory.kt +21 -0
- package/ios/BleNitroBleManager.swift +36 -23
- package/ios/BleNitroBleManagerFactory.swift +19 -0
- package/lib/commonjs/index.d.ts +2 -5
- package/lib/commonjs/index.d.ts.map +1 -1
- package/lib/commonjs/index.js +7 -15
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/manager.d.ts +9 -0
- package/lib/commonjs/manager.d.ts.map +1 -1
- package/lib/commonjs/manager.js +44 -30
- package/lib/commonjs/manager.js.map +1 -1
- package/lib/commonjs/singleton.d.ts +10 -0
- package/lib/commonjs/singleton.d.ts.map +1 -0
- package/lib/commonjs/singleton.js +20 -0
- package/lib/commonjs/singleton.js.map +1 -0
- package/lib/commonjs/specs/NativeBleNitro.d.ts +1 -1
- package/lib/commonjs/specs/NativeBleNitro.d.ts.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.js +1 -0
- package/lib/commonjs/specs/NativeBleNitro.js.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts +2 -0
- package/lib/commonjs/specs/NativeBleNitro.nitro.d.ts.map +1 -1
- package/lib/commonjs/specs/NativeBleNitro.nitro.js.map +1 -1
- package/lib/commonjs/specs/NativeBleNitroFactory.d.ts +5 -0
- package/lib/commonjs/specs/NativeBleNitroFactory.d.ts.map +1 -0
- package/lib/commonjs/specs/NativeBleNitroFactory.js +23 -0
- package/lib/commonjs/specs/NativeBleNitroFactory.js.map +1 -0
- package/lib/commonjs/specs/NativeBleNitroFactory.nitro.d.ts +9 -0
- package/lib/commonjs/specs/NativeBleNitroFactory.nitro.d.ts.map +1 -0
- package/lib/commonjs/specs/NativeBleNitroFactory.nitro.js +3 -0
- package/lib/commonjs/specs/NativeBleNitroFactory.nitro.js.map +1 -0
- package/lib/index.d.ts +2 -5
- package/lib/index.js +2 -11
- package/lib/manager.d.ts +9 -0
- package/lib/manager.js +38 -25
- package/lib/singleton.d.ts +9 -0
- package/lib/singleton.js +15 -0
- package/lib/specs/NativeBleNitro.d.ts +1 -1
- package/lib/specs/NativeBleNitro.js +1 -0
- package/lib/specs/NativeBleNitro.nitro.d.ts +2 -0
- package/lib/specs/NativeBleNitroFactory.d.ts +4 -0
- package/lib/specs/NativeBleNitroFactory.js +6 -0
- package/lib/specs/NativeBleNitroFactory.nitro.d.ts +8 -0
- package/lib/specs/NativeBleNitroFactory.nitro.js +1 -0
- package/nitro.json +4 -0
- package/nitrogen/generated/android/BleNitro+autolinking.cmake +9 -4
- package/nitrogen/generated/android/BleNitroOnLoad.cpp +11 -2
- package/nitrogen/generated/android/c++/JBLEDevice.hpp +6 -2
- package/nitrogen/generated/android/c++/JFunc_void_std__vector_BLEDevice_.hpp +12 -12
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroFactorySpec.cpp +71 -0
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroFactorySpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.cpp +11 -3
- package/nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.hpp +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/BLEDevice.kt +4 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/Func_void_std__vector_BLEDevice_.kt +9 -9
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroFactorySpec.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroSpec.kt +5 -1
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.cpp +30 -13
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Bridge.hpp +134 -68
- package/nitrogen/generated/ios/BleNitro-Swift-Cxx-Umbrella.hpp +5 -0
- package/nitrogen/generated/ios/BleNitroAutolinking.mm +8 -0
- package/nitrogen/generated/ios/BleNitroAutolinking.swift +15 -0
- package/nitrogen/generated/ios/c++/HybridNativeBleNitroFactorySpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNativeBleNitroFactorySpecSwift.hpp +94 -0
- package/nitrogen/generated/ios/c++/HybridNativeBleNitroSpecSwift.hpp +10 -4
- package/nitrogen/generated/ios/swift/BLEDevice.swift +13 -2
- package/nitrogen/generated/ios/swift/Func_void_std__optional_BLEDevice__std__optional_std__string_.swift +3 -8
- package/nitrogen/generated/ios/swift/Func_void_std__vector_BLEDevice_.swift +5 -5
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroFactorySpec.swift +49 -0
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroFactorySpec_cxx.swift +151 -0
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridNativeBleNitroSpec_cxx.swift +25 -2
- package/nitrogen/generated/ios/swift/OperationResult.swift +2 -1
- package/nitrogen/generated/shared/c++/BLEDevice.hpp +14 -2
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroFactorySpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroFactorySpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.hpp +4 -3
- package/nitrogen/generated/shared/c++/ManufacturerData.hpp +8 -0
- package/nitrogen/generated/shared/c++/ManufacturerDataEntry.hpp +8 -0
- package/nitrogen/generated/shared/c++/OperationResult.hpp +8 -0
- package/nitrogen/generated/shared/c++/ScanFilter.hpp +8 -0
- package/package.json +19 -11
- package/src/__tests__/index.test.ts +36 -26
- package/src/index.ts +2 -13
- package/src/manager.ts +41 -25
- package/src/singleton.ts +17 -0
- package/src/specs/NativeBleNitro.nitro.ts +2 -0
- package/src/specs/NativeBleNitro.ts +2 -1
- package/src/specs/NativeBleNitroFactory.nitro.ts +6 -0
- package/src/specs/NativeBleNitroFactory.ts +9 -0
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
# include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/BleNitro+autolinking.cmake)
|
|
14
14
|
# ```
|
|
15
15
|
|
|
16
|
+
# Define a flag to check if we are building properly
|
|
17
|
+
add_definitions(-DBUILDING_BLENITRO_WITH_GENERATED_CMAKE_PROJECT)
|
|
18
|
+
|
|
19
|
+
# Enable Raw Props parsing in react-native (for Nitro Views)
|
|
20
|
+
add_definitions(-DRN_SERIALIZABLE_STATE)
|
|
21
|
+
|
|
16
22
|
# Add all headers that were generated by Nitrogen
|
|
17
23
|
include_directories(
|
|
18
24
|
"../nitrogen/generated/shared/c++"
|
|
@@ -28,16 +34,15 @@ target_sources(
|
|
|
28
34
|
../nitrogen/generated/android/BleNitroOnLoad.cpp
|
|
29
35
|
# Shared Nitrogen C++ sources
|
|
30
36
|
../nitrogen/generated/shared/c++/HybridNativeBleNitroSpec.cpp
|
|
37
|
+
../nitrogen/generated/shared/c++/HybridNativeBleNitroFactorySpec.cpp
|
|
31
38
|
# Android-specific Nitrogen C++ sources
|
|
32
39
|
../nitrogen/generated/android/c++/JHybridNativeBleNitroSpec.cpp
|
|
40
|
+
../nitrogen/generated/android/c++/JHybridNativeBleNitroFactorySpec.cpp
|
|
33
41
|
)
|
|
34
42
|
|
|
35
|
-
# Define a flag to check if we are building properly
|
|
36
|
-
add_definitions(-DBUILDING_BLENITRO_WITH_GENERATED_CMAKE_PROJECT)
|
|
37
|
-
|
|
38
43
|
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
39
44
|
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
40
|
-
|
|
45
|
+
target_compile_definitions(
|
|
41
46
|
BleNitro PRIVATE
|
|
42
47
|
-DFOLLY_NO_CONFIG=1
|
|
43
48
|
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
#include "JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string.hpp"
|
|
26
26
|
#include "JFunc_void_std__string_std__shared_ptr_ArrayBuffer_.hpp"
|
|
27
27
|
#include "JFunc_void_BLEState.hpp"
|
|
28
|
+
#include "JHybridNativeBleNitroFactorySpec.hpp"
|
|
28
29
|
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
29
30
|
|
|
30
31
|
namespace margelo::nitro::co::zyke::ble {
|
|
@@ -46,6 +47,7 @@ int initialize(JavaVM* vm) {
|
|
|
46
47
|
margelo::nitro::co::zyke::ble::JFunc_void_bool_std__shared_ptr_ArrayBuffer__std__string_cxx::registerNatives();
|
|
47
48
|
margelo::nitro::co::zyke::ble::JFunc_void_std__string_std__shared_ptr_ArrayBuffer__cxx::registerNatives();
|
|
48
49
|
margelo::nitro::co::zyke::ble::JFunc_void_BLEState_cxx::registerNatives();
|
|
50
|
+
margelo::nitro::co::zyke::ble::JHybridNativeBleNitroFactorySpec::registerNatives();
|
|
49
51
|
|
|
50
52
|
// Register Nitro Hybrid Objects
|
|
51
53
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
@@ -53,8 +55,15 @@ int initialize(JavaVM* vm) {
|
|
|
53
55
|
[]() -> std::shared_ptr<HybridObject> {
|
|
54
56
|
static DefaultConstructableObject<JHybridNativeBleNitroSpec::javaobject> object("com/margelo/nitro/co/zyke/ble/BleNitroBleManager");
|
|
55
57
|
auto instance = object.create();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
return instance->cthis()->shared();
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
62
|
+
"NativeBleNitroFactory",
|
|
63
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
64
|
+
static DefaultConstructableObject<JHybridNativeBleNitroFactorySpec::javaobject> object("com/margelo/nitro/co/zyke/ble/BleNitroBleManagerFactory");
|
|
65
|
+
auto instance = object.create();
|
|
66
|
+
return instance->cthis()->shared();
|
|
58
67
|
}
|
|
59
68
|
);
|
|
60
69
|
});
|
|
@@ -51,6 +51,8 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
51
51
|
jni::local_ref<jni::JArrayClass<jni::JString>> serviceUUIDs = this->getFieldValue(fieldServiceUUIDs);
|
|
52
52
|
static const auto fieldIsConnectable = clazz->getField<jboolean>("isConnectable");
|
|
53
53
|
jboolean isConnectable = this->getFieldValue(fieldIsConnectable);
|
|
54
|
+
static const auto fieldIsConnected = clazz->getField<jboolean>("isConnected");
|
|
55
|
+
jboolean isConnected = this->getFieldValue(fieldIsConnected);
|
|
54
56
|
return BLEDevice(
|
|
55
57
|
id->toStdString(),
|
|
56
58
|
name->toStdString(),
|
|
@@ -66,7 +68,8 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
66
68
|
}
|
|
67
69
|
return __vector;
|
|
68
70
|
}(),
|
|
69
|
-
static_cast<bool>(isConnectable)
|
|
71
|
+
static_cast<bool>(isConnectable),
|
|
72
|
+
static_cast<bool>(isConnected)
|
|
70
73
|
);
|
|
71
74
|
}
|
|
72
75
|
|
|
@@ -90,7 +93,8 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
90
93
|
}
|
|
91
94
|
return __array;
|
|
92
95
|
}(),
|
|
93
|
-
value.isConnectable
|
|
96
|
+
value.isConnectable,
|
|
97
|
+
value.isConnected
|
|
94
98
|
);
|
|
95
99
|
}
|
|
96
100
|
};
|
|
@@ -28,7 +28,7 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
28
28
|
using namespace facebook;
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
|
-
* Represents the Java/Kotlin callback `(
|
|
31
|
+
* Represents the Java/Kotlin callback `(peripherals: Array<BLEDevice>) -> Unit`.
|
|
32
32
|
* This can be passed around between C++ and Java/Kotlin.
|
|
33
33
|
*/
|
|
34
34
|
struct JFunc_void_std__vector_BLEDevice_: public jni::JavaClass<JFunc_void_std__vector_BLEDevice_> {
|
|
@@ -39,13 +39,13 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
39
39
|
/**
|
|
40
40
|
* Invokes the function this `JFunc_void_std__vector_BLEDevice_` instance holds through JNI.
|
|
41
41
|
*/
|
|
42
|
-
void invoke(const std::vector<BLEDevice>&
|
|
43
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JBLEDevice>> /*
|
|
42
|
+
void invoke(const std::vector<BLEDevice>& peripherals) const {
|
|
43
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<JBLEDevice>> /* peripherals */)>("invoke");
|
|
44
44
|
method(self(), [&]() {
|
|
45
|
-
size_t __size =
|
|
45
|
+
size_t __size = peripherals.size();
|
|
46
46
|
jni::local_ref<jni::JArrayClass<JBLEDevice>> __array = jni::JArrayClass<JBLEDevice>::newArray(__size);
|
|
47
47
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
48
|
-
const auto& __element =
|
|
48
|
+
const auto& __element = peripherals[__i];
|
|
49
49
|
__array->setElement(__i, *JBLEDevice::fromCpp(__element));
|
|
50
50
|
}
|
|
51
51
|
return __array;
|
|
@@ -58,7 +58,7 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
58
58
|
*/
|
|
59
59
|
struct JFunc_void_std__vector_BLEDevice__cxx final: public jni::HybridClass<JFunc_void_std__vector_BLEDevice__cxx, JFunc_void_std__vector_BLEDevice_> {
|
|
60
60
|
public:
|
|
61
|
-
static jni::local_ref<JFunc_void_std__vector_BLEDevice_::javaobject> fromCpp(const std::function<void(const std::vector<BLEDevice>& /*
|
|
61
|
+
static jni::local_ref<JFunc_void_std__vector_BLEDevice_::javaobject> fromCpp(const std::function<void(const std::vector<BLEDevice>& /* peripherals */)>& func) {
|
|
62
62
|
return JFunc_void_std__vector_BLEDevice__cxx::newObjectCxxArgs(func);
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -66,13 +66,13 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
66
66
|
/**
|
|
67
67
|
* Invokes the C++ `std::function<...>` this `JFunc_void_std__vector_BLEDevice__cxx` instance holds.
|
|
68
68
|
*/
|
|
69
|
-
void invoke_cxx(jni::alias_ref<jni::JArrayClass<JBLEDevice>>
|
|
69
|
+
void invoke_cxx(jni::alias_ref<jni::JArrayClass<JBLEDevice>> peripherals) {
|
|
70
70
|
_func([&]() {
|
|
71
|
-
size_t __size =
|
|
71
|
+
size_t __size = peripherals->size();
|
|
72
72
|
std::vector<BLEDevice> __vector;
|
|
73
73
|
__vector.reserve(__size);
|
|
74
74
|
for (size_t __i = 0; __i < __size; __i++) {
|
|
75
|
-
auto __element =
|
|
75
|
+
auto __element = peripherals->getElement(__i);
|
|
76
76
|
__vector.push_back(__element->toCpp());
|
|
77
77
|
}
|
|
78
78
|
return __vector;
|
|
@@ -81,7 +81,7 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
81
81
|
|
|
82
82
|
public:
|
|
83
83
|
[[nodiscard]]
|
|
84
|
-
inline const std::function<void(const std::vector<BLEDevice>& /*
|
|
84
|
+
inline const std::function<void(const std::vector<BLEDevice>& /* peripherals */)>& getFunction() const {
|
|
85
85
|
return _func;
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -92,11 +92,11 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
private:
|
|
95
|
-
explicit JFunc_void_std__vector_BLEDevice__cxx(const std::function<void(const std::vector<BLEDevice>& /*
|
|
95
|
+
explicit JFunc_void_std__vector_BLEDevice__cxx(const std::function<void(const std::vector<BLEDevice>& /* peripherals */)>& func): _func(func) { }
|
|
96
96
|
|
|
97
97
|
private:
|
|
98
98
|
friend HybridBase;
|
|
99
|
-
std::function<void(const std::vector<BLEDevice>& /*
|
|
99
|
+
std::function<void(const std::vector<BLEDevice>& /* peripherals */)> _func;
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
} // namespace margelo::nitro::co::zyke::ble
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridNativeBleNitroFactorySpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridNativeBleNitroFactorySpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `HybridNativeBleNitroSpec` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::co::zyke::ble { class HybridNativeBleNitroSpec; }
|
|
12
|
+
// Forward declaration of `BLEDevice` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::co::zyke::ble { struct BLEDevice; }
|
|
14
|
+
// Forward declaration of `ManufacturerData` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::co::zyke::ble { struct ManufacturerData; }
|
|
16
|
+
// Forward declaration of `ManufacturerDataEntry` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::co::zyke::ble { struct ManufacturerDataEntry; }
|
|
18
|
+
// Forward declaration of `ArrayBuffer` to properly resolve imports.
|
|
19
|
+
namespace NitroModules { class ArrayBuffer; }
|
|
20
|
+
|
|
21
|
+
#include <memory>
|
|
22
|
+
#include "HybridNativeBleNitroSpec.hpp"
|
|
23
|
+
#include "JHybridNativeBleNitroSpec.hpp"
|
|
24
|
+
#include <string>
|
|
25
|
+
#include <optional>
|
|
26
|
+
#include "BLEDevice.hpp"
|
|
27
|
+
#include <vector>
|
|
28
|
+
#include <functional>
|
|
29
|
+
#include "JFunc_void_std__vector_BLEDevice_.hpp"
|
|
30
|
+
#include "JBLEDevice.hpp"
|
|
31
|
+
#include "ManufacturerData.hpp"
|
|
32
|
+
#include "JManufacturerData.hpp"
|
|
33
|
+
#include "ManufacturerDataEntry.hpp"
|
|
34
|
+
#include "JManufacturerDataEntry.hpp"
|
|
35
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
36
|
+
#include <NitroModules/JArrayBuffer.hpp>
|
|
37
|
+
#include <NitroModules/JUnit.hpp>
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro::co::zyke::ble {
|
|
40
|
+
|
|
41
|
+
jni::local_ref<JHybridNativeBleNitroFactorySpec::jhybriddata> JHybridNativeBleNitroFactorySpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
42
|
+
return makeCxxInstance(jThis);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
void JHybridNativeBleNitroFactorySpec::registerNatives() {
|
|
46
|
+
registerHybrid({
|
|
47
|
+
makeNativeMethod("initHybrid", JHybridNativeBleNitroFactorySpec::initHybrid),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
size_t JHybridNativeBleNitroFactorySpec::getExternalMemorySize() noexcept {
|
|
52
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
53
|
+
return method(_javaPart);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
void JHybridNativeBleNitroFactorySpec::dispose() noexcept {
|
|
57
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
58
|
+
method(_javaPart);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Properties
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// Methods
|
|
65
|
+
std::shared_ptr<HybridNativeBleNitroSpec> JHybridNativeBleNitroFactorySpec::create(const std::optional<std::string>& nativeRestoreStateIdentifier, const std::optional<std::function<void(const std::vector<BLEDevice>& /* peripherals */)>>& restoreStateCallback) {
|
|
66
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JHybridNativeBleNitroSpec::javaobject>(jni::alias_ref<jni::JString> /* nativeRestoreStateIdentifier */, jni::alias_ref<JFunc_void_std__vector_BLEDevice_::javaobject> /* restoreStateCallback */)>("create_cxx");
|
|
67
|
+
auto __result = method(_javaPart, nativeRestoreStateIdentifier.has_value() ? jni::make_jstring(nativeRestoreStateIdentifier.value()) : nullptr, restoreStateCallback.has_value() ? JFunc_void_std__vector_BLEDevice__cxx::fromCpp(restoreStateCallback.value()) : nullptr);
|
|
68
|
+
return __result->cthis()->shared_cast<JHybridNativeBleNitroSpec>();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
} // namespace margelo::nitro::co::zyke::ble
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNativeBleNitroFactorySpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridNativeBleNitroFactorySpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::co::zyke::ble {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridNativeBleNitroFactorySpec: public jni::HybridClass<JHybridNativeBleNitroFactorySpec, JHybridObject>,
|
|
22
|
+
public virtual HybridNativeBleNitroFactorySpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/co/zyke/ble/HybridNativeBleNitroFactorySpec;";
|
|
25
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
26
|
+
static void registerNatives();
|
|
27
|
+
|
|
28
|
+
protected:
|
|
29
|
+
// C++ constructor (called from Java via `initHybrid()`)
|
|
30
|
+
explicit JHybridNativeBleNitroFactorySpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridNativeBleNitroFactorySpec::TAG),
|
|
32
|
+
HybridBase(jThis),
|
|
33
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
~JHybridNativeBleNitroFactorySpec() override {
|
|
37
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
size_t getExternalMemorySize() noexcept override;
|
|
43
|
+
void dispose() noexcept override;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
inline const jni::global_ref<JHybridNativeBleNitroFactorySpec::javaobject>& getJavaPart() const noexcept {
|
|
47
|
+
return _javaPart;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
// Properties
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
// Methods
|
|
56
|
+
std::shared_ptr<HybridNativeBleNitroSpec> create(const std::optional<std::string>& nativeRestoreStateIdentifier, const std::optional<std::function<void(const std::vector<BLEDevice>& /* peripherals */)>>& restoreStateCallback) override;
|
|
57
|
+
|
|
58
|
+
private:
|
|
59
|
+
friend HybridBase;
|
|
60
|
+
using HybridBase::HybridBase;
|
|
61
|
+
jni::global_ref<JHybridNativeBleNitroFactorySpec::javaobject> _javaPart;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace margelo::nitro::co::zyke::ble
|
|
@@ -24,10 +24,11 @@ namespace margelo::nitro::co::zyke::ble { struct ScanFilter; }
|
|
|
24
24
|
// Forward declaration of `AndroidScanMode` to properly resolve imports.
|
|
25
25
|
namespace margelo::nitro::co::zyke::ble { enum class AndroidScanMode; }
|
|
26
26
|
|
|
27
|
+
#include <string>
|
|
28
|
+
#include <optional>
|
|
27
29
|
#include "BLEDevice.hpp"
|
|
28
30
|
#include <vector>
|
|
29
31
|
#include "JBLEDevice.hpp"
|
|
30
|
-
#include <string>
|
|
31
32
|
#include "ManufacturerData.hpp"
|
|
32
33
|
#include "JManufacturerData.hpp"
|
|
33
34
|
#include "ManufacturerDataEntry.hpp"
|
|
@@ -39,7 +40,6 @@ namespace margelo::nitro::co::zyke::ble { enum class AndroidScanMode; }
|
|
|
39
40
|
#include "JBLEState.hpp"
|
|
40
41
|
#include "OperationResult.hpp"
|
|
41
42
|
#include "JOperationResult.hpp"
|
|
42
|
-
#include <optional>
|
|
43
43
|
#include <NitroModules/Promise.hpp>
|
|
44
44
|
#include <NitroModules/JPromise.hpp>
|
|
45
45
|
#include <functional>
|
|
@@ -80,7 +80,15 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
// Properties
|
|
83
|
-
|
|
83
|
+
std::optional<std::string> JHybridNativeBleNitroSpec::getRestoreStateIdentifier() {
|
|
84
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getRestoreStateIdentifier");
|
|
85
|
+
auto __result = method(_javaPart);
|
|
86
|
+
return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
|
|
87
|
+
}
|
|
88
|
+
void JHybridNativeBleNitroSpec::setRestoreStateIdentifier(const std::optional<std::string>& restoreStateIdentifier) {
|
|
89
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* restoreStateIdentifier */)>("setRestoreStateIdentifier");
|
|
90
|
+
method(_javaPart, restoreStateIdentifier.has_value() ? jni::make_jstring(restoreStateIdentifier.value()) : nullptr);
|
|
91
|
+
}
|
|
84
92
|
|
|
85
93
|
// Methods
|
|
86
94
|
void JHybridNativeBleNitroSpec::setRestoreStateCallback(const std::function<void(const std::vector<BLEDevice>& /* restoredPeripherals */)>& callback) {
|
|
@@ -49,7 +49,8 @@ namespace margelo::nitro::co::zyke::ble {
|
|
|
49
49
|
|
|
50
50
|
public:
|
|
51
51
|
// Properties
|
|
52
|
-
|
|
52
|
+
std::optional<std::string> getRestoreStateIdentifier() override;
|
|
53
|
+
void setRestoreStateIdentifier(const std::optional<std::string>& restoreStateIdentifier) override;
|
|
53
54
|
|
|
54
55
|
public:
|
|
55
56
|
// Methods
|
|
@@ -15,7 +15,7 @@ import dalvik.annotation.optimization.FastNative
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Represents the JavaScript callback `(
|
|
18
|
+
* Represents the JavaScript callback `(peripherals: array) => void`.
|
|
19
19
|
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
20
20
|
* or in Kotlin/Java (in which case it is a native callback).
|
|
21
21
|
*/
|
|
@@ -29,11 +29,11 @@ fun interface Func_void_std__vector_BLEDevice_: (Array<BLEDevice>) -> Unit {
|
|
|
29
29
|
*/
|
|
30
30
|
@DoNotStrip
|
|
31
31
|
@Keep
|
|
32
|
-
override fun invoke(
|
|
32
|
+
override fun invoke(peripherals: Array<BLEDevice>): Unit
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Represents the JavaScript callback `(
|
|
36
|
+
* Represents the JavaScript callback `(peripherals: array) => void`.
|
|
37
37
|
* This is implemented in C++, via a `std::function<...>`.
|
|
38
38
|
* The callback might be coming from JS.
|
|
39
39
|
*/
|
|
@@ -57,15 +57,15 @@ class Func_void_std__vector_BLEDevice__cxx: Func_void_std__vector_BLEDevice_ {
|
|
|
57
57
|
|
|
58
58
|
@DoNotStrip
|
|
59
59
|
@Keep
|
|
60
|
-
override fun invoke(
|
|
61
|
-
= invoke_cxx(
|
|
60
|
+
override fun invoke(peripherals: Array<BLEDevice>): Unit
|
|
61
|
+
= invoke_cxx(peripherals)
|
|
62
62
|
|
|
63
63
|
@FastNative
|
|
64
|
-
private external fun invoke_cxx(
|
|
64
|
+
private external fun invoke_cxx(peripherals: Array<BLEDevice>): Unit
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
|
-
* Represents the JavaScript callback `(
|
|
68
|
+
* Represents the JavaScript callback `(peripherals: array) => void`.
|
|
69
69
|
* This is implemented in Java/Kotlin, via a `(Array<BLEDevice>) -> Unit`.
|
|
70
70
|
* The callback is always coming from native.
|
|
71
71
|
*/
|
|
@@ -75,7 +75,7 @@ class Func_void_std__vector_BLEDevice__cxx: Func_void_std__vector_BLEDevice_ {
|
|
|
75
75
|
class Func_void_std__vector_BLEDevice__java(private val function: (Array<BLEDevice>) -> Unit): Func_void_std__vector_BLEDevice_ {
|
|
76
76
|
@DoNotStrip
|
|
77
77
|
@Keep
|
|
78
|
-
override fun invoke(
|
|
79
|
-
return this.function(
|
|
78
|
+
override fun invoke(peripherals: Array<BLEDevice>): Unit {
|
|
79
|
+
return this.function(peripherals)
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNativeBleNitroFactorySpec.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.co.zyke.ble
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.*
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A Kotlin class representing the NativeBleNitroFactory HybridObject.
|
|
17
|
+
* Implement this abstract class to create Kotlin-based instances of NativeBleNitroFactory.
|
|
18
|
+
*/
|
|
19
|
+
@DoNotStrip
|
|
20
|
+
@Keep
|
|
21
|
+
@Suppress(
|
|
22
|
+
"KotlinJniMissingFunction", "unused",
|
|
23
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
24
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
25
|
+
)
|
|
26
|
+
abstract class HybridNativeBleNitroFactorySpec: HybridObject() {
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
private var mHybridData: HybridData = initHybrid()
|
|
29
|
+
|
|
30
|
+
init {
|
|
31
|
+
super.updateNative(mHybridData)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun updateNative(hybridData: HybridData) {
|
|
35
|
+
mHybridData = hybridData
|
|
36
|
+
super.updateNative(hybridData)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Properties
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// Methods
|
|
43
|
+
abstract fun create(nativeRestoreStateIdentifier: String?, restoreStateCallback: ((peripherals: Array<BLEDevice>) -> Unit)?): HybridNativeBleNitroSpec
|
|
44
|
+
|
|
45
|
+
@DoNotStrip
|
|
46
|
+
@Keep
|
|
47
|
+
private fun create_cxx(nativeRestoreStateIdentifier: String?, restoreStateCallback: Func_void_std__vector_BLEDevice_?): HybridNativeBleNitroSpec {
|
|
48
|
+
val __result = create(nativeRestoreStateIdentifier, restoreStateCallback?.let { it })
|
|
49
|
+
return __result
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private external fun initHybrid(): HybridData
|
|
53
|
+
|
|
54
|
+
companion object {
|
|
55
|
+
private const val TAG = "HybridNativeBleNitroFactorySpec"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/co/zyke/ble/HybridNativeBleNitroSpec.kt
CHANGED
|
@@ -37,7 +37,11 @@ abstract class HybridNativeBleNitroSpec: HybridObject() {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// Properties
|
|
40
|
-
|
|
40
|
+
@get:DoNotStrip
|
|
41
|
+
@get:Keep
|
|
42
|
+
@set:DoNotStrip
|
|
43
|
+
@set:Keep
|
|
44
|
+
abstract var restoreStateIdentifier: String?
|
|
41
45
|
|
|
42
46
|
// Methods
|
|
43
47
|
abstract fun setRestoreStateCallback(callback: (restoredPeripherals: Array<BLEDevice>) -> Unit): Unit
|
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
|
|
10
10
|
// Include C++ implementation defined types
|
|
11
11
|
#include "BleNitro-Swift-Cxx-Umbrella.hpp"
|
|
12
|
+
#include "HybridNativeBleNitroFactorySpecSwift.hpp"
|
|
12
13
|
#include "HybridNativeBleNitroSpecSwift.hpp"
|
|
13
14
|
|
|
14
15
|
namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
15
16
|
|
|
16
17
|
// pragma MARK: std::function<void(const std::vector<BLEDevice>& /* restoredPeripherals */)>
|
|
17
|
-
Func_void_std__vector_BLEDevice_ create_Func_void_std__vector_BLEDevice_(void*
|
|
18
|
+
Func_void_std__vector_BLEDevice_ create_Func_void_std__vector_BLEDevice_(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
18
19
|
auto swiftClosure = BleNitro::Func_void_std__vector_BLEDevice_::fromUnsafe(swiftClosureWrapper);
|
|
19
20
|
return [swiftClosure = std::move(swiftClosure)](const std::vector<BLEDevice>& restoredPeripherals) mutable -> void {
|
|
20
21
|
swiftClosure.call(restoredPeripherals);
|
|
@@ -22,7 +23,7 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
// pragma MARK: std::function<void(const std::optional<BLEDevice>& /* device */, const std::optional<std::string>& /* error */)>
|
|
25
|
-
Func_void_std__optional_BLEDevice__std__optional_std__string_ create_Func_void_std__optional_BLEDevice__std__optional_std__string_(void*
|
|
26
|
+
Func_void_std__optional_BLEDevice__std__optional_std__string_ create_Func_void_std__optional_BLEDevice__std__optional_std__string_(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
26
27
|
auto swiftClosure = BleNitro::Func_void_std__optional_BLEDevice__std__optional_std__string_::fromUnsafe(swiftClosureWrapper);
|
|
27
28
|
return [swiftClosure = std::move(swiftClosure)](const std::optional<BLEDevice>& device, const std::optional<std::string>& error) mutable -> void {
|
|
28
29
|
swiftClosure.call(device, error);
|
|
@@ -30,7 +31,7 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
// pragma MARK: std::function<void(bool /* success */, const std::string& /* deviceId */, const std::string& /* error */)>
|
|
33
|
-
Func_void_bool_std__string_std__string create_Func_void_bool_std__string_std__string(void*
|
|
34
|
+
Func_void_bool_std__string_std__string create_Func_void_bool_std__string_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
34
35
|
auto swiftClosure = BleNitro::Func_void_bool_std__string_std__string::fromUnsafe(swiftClosureWrapper);
|
|
35
36
|
return [swiftClosure = std::move(swiftClosure)](bool success, const std::string& deviceId, const std::string& error) mutable -> void {
|
|
36
37
|
swiftClosure.call(success, deviceId, error);
|
|
@@ -38,7 +39,7 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
// pragma MARK: std::function<void(const std::string& /* deviceId */, bool /* interrupted */, const std::string& /* error */)>
|
|
41
|
-
Func_void_std__string_bool_std__string create_Func_void_std__string_bool_std__string(void*
|
|
42
|
+
Func_void_std__string_bool_std__string create_Func_void_std__string_bool_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
42
43
|
auto swiftClosure = BleNitro::Func_void_std__string_bool_std__string::fromUnsafe(swiftClosureWrapper);
|
|
43
44
|
return [swiftClosure = std::move(swiftClosure)](const std::string& deviceId, bool interrupted, const std::string& error) mutable -> void {
|
|
44
45
|
swiftClosure.call(deviceId, interrupted, error);
|
|
@@ -46,7 +47,7 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
// pragma MARK: std::function<void(bool /* success */, const std::string& /* error */)>
|
|
49
|
-
Func_void_bool_std__string create_Func_void_bool_std__string(void*
|
|
50
|
+
Func_void_bool_std__string create_Func_void_bool_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
50
51
|
auto swiftClosure = BleNitro::Func_void_bool_std__string::fromUnsafe(swiftClosureWrapper);
|
|
51
52
|
return [swiftClosure = std::move(swiftClosure)](bool success, const std::string& error) mutable -> void {
|
|
52
53
|
swiftClosure.call(success, error);
|
|
@@ -54,7 +55,7 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
// pragma MARK: std::function<void(bool /* success */, double /* rssi */, const std::string& /* error */)>
|
|
57
|
-
Func_void_bool_double_std__string create_Func_void_bool_double_std__string(void*
|
|
58
|
+
Func_void_bool_double_std__string create_Func_void_bool_double_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
58
59
|
auto swiftClosure = BleNitro::Func_void_bool_double_std__string::fromUnsafe(swiftClosureWrapper);
|
|
59
60
|
return [swiftClosure = std::move(swiftClosure)](bool success, double rssi, const std::string& error) mutable -> void {
|
|
60
61
|
swiftClosure.call(success, rssi, error);
|
|
@@ -62,7 +63,7 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
// pragma MARK: std::function<void(bool /* success */, const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* error */)>
|
|
65
|
-
Func_void_bool_std__shared_ptr_ArrayBuffer__std__string create_Func_void_bool_std__shared_ptr_ArrayBuffer__std__string(void*
|
|
66
|
+
Func_void_bool_std__shared_ptr_ArrayBuffer__std__string create_Func_void_bool_std__shared_ptr_ArrayBuffer__std__string(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
66
67
|
auto swiftClosure = BleNitro::Func_void_bool_std__shared_ptr_ArrayBuffer__std__string::fromUnsafe(swiftClosureWrapper);
|
|
67
68
|
return [swiftClosure = std::move(swiftClosure)](bool success, const std::shared_ptr<ArrayBuffer>& data, const std::string& error) mutable -> void {
|
|
68
69
|
swiftClosure.call(success, ArrayBufferHolder(data), error);
|
|
@@ -70,7 +71,7 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
// pragma MARK: std::function<void(const std::string& /* characteristicId */, const std::shared_ptr<ArrayBuffer>& /* data */)>
|
|
73
|
-
Func_void_std__string_std__shared_ptr_ArrayBuffer_ create_Func_void_std__string_std__shared_ptr_ArrayBuffer_(void*
|
|
74
|
+
Func_void_std__string_std__shared_ptr_ArrayBuffer_ create_Func_void_std__string_std__shared_ptr_ArrayBuffer_(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
74
75
|
auto swiftClosure = BleNitro::Func_void_std__string_std__shared_ptr_ArrayBuffer_::fromUnsafe(swiftClosureWrapper);
|
|
75
76
|
return [swiftClosure = std::move(swiftClosure)](const std::string& characteristicId, const std::shared_ptr<ArrayBuffer>& data) mutable -> void {
|
|
76
77
|
swiftClosure.call(characteristicId, ArrayBufferHolder(data));
|
|
@@ -78,7 +79,7 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
78
79
|
}
|
|
79
80
|
|
|
80
81
|
// pragma MARK: std::function<void(BLEState /* state */)>
|
|
81
|
-
Func_void_BLEState create_Func_void_BLEState(void*
|
|
82
|
+
Func_void_BLEState create_Func_void_BLEState(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
82
83
|
auto swiftClosure = BleNitro::Func_void_BLEState::fromUnsafe(swiftClosureWrapper);
|
|
83
84
|
return [swiftClosure = std::move(swiftClosure)](BLEState state) mutable -> void {
|
|
84
85
|
swiftClosure.call(static_cast<int>(state));
|
|
@@ -86,7 +87,7 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
// pragma MARK: std::function<void()>
|
|
89
|
-
Func_void create_Func_void(void*
|
|
90
|
+
Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
90
91
|
auto swiftClosure = BleNitro::Func_void::fromUnsafe(swiftClosureWrapper);
|
|
91
92
|
return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
|
|
92
93
|
swiftClosure.call();
|
|
@@ -94,7 +95,7 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
// pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
|
|
97
|
-
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void*
|
|
98
|
+
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
98
99
|
auto swiftClosure = BleNitro::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
|
|
99
100
|
return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
|
|
100
101
|
swiftClosure.call(error);
|
|
@@ -102,11 +103,11 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
// pragma MARK: std::shared_ptr<HybridNativeBleNitroSpec>
|
|
105
|
-
std::shared_ptr<HybridNativeBleNitroSpec> create_std__shared_ptr_HybridNativeBleNitroSpec_(void*
|
|
106
|
+
std::shared_ptr<HybridNativeBleNitroSpec> create_std__shared_ptr_HybridNativeBleNitroSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
106
107
|
BleNitro::HybridNativeBleNitroSpec_cxx swiftPart = BleNitro::HybridNativeBleNitroSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
107
108
|
return std::make_shared<margelo::nitro::co::zyke::ble::HybridNativeBleNitroSpecSwift>(swiftPart);
|
|
108
109
|
}
|
|
109
|
-
void*
|
|
110
|
+
void* NON_NULL get_std__shared_ptr_HybridNativeBleNitroSpec_(std__shared_ptr_HybridNativeBleNitroSpec_ cppType) {
|
|
110
111
|
std::shared_ptr<margelo::nitro::co::zyke::ble::HybridNativeBleNitroSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::co::zyke::ble::HybridNativeBleNitroSpecSwift>(cppType);
|
|
111
112
|
#ifdef NITRO_DEBUG
|
|
112
113
|
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
@@ -116,5 +117,21 @@ namespace margelo::nitro::co::zyke::ble::bridge::swift {
|
|
|
116
117
|
BleNitro::HybridNativeBleNitroSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
117
118
|
return swiftPart.toUnsafe();
|
|
118
119
|
}
|
|
120
|
+
|
|
121
|
+
// pragma MARK: std::shared_ptr<HybridNativeBleNitroFactorySpec>
|
|
122
|
+
std::shared_ptr<HybridNativeBleNitroFactorySpec> create_std__shared_ptr_HybridNativeBleNitroFactorySpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
123
|
+
BleNitro::HybridNativeBleNitroFactorySpec_cxx swiftPart = BleNitro::HybridNativeBleNitroFactorySpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
124
|
+
return std::make_shared<margelo::nitro::co::zyke::ble::HybridNativeBleNitroFactorySpecSwift>(swiftPart);
|
|
125
|
+
}
|
|
126
|
+
void* NON_NULL get_std__shared_ptr_HybridNativeBleNitroFactorySpec_(std__shared_ptr_HybridNativeBleNitroFactorySpec_ cppType) {
|
|
127
|
+
std::shared_ptr<margelo::nitro::co::zyke::ble::HybridNativeBleNitroFactorySpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::co::zyke::ble::HybridNativeBleNitroFactorySpecSwift>(cppType);
|
|
128
|
+
#ifdef NITRO_DEBUG
|
|
129
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
130
|
+
throw std::runtime_error("Class \"HybridNativeBleNitroFactorySpec\" is not implemented in Swift!");
|
|
131
|
+
}
|
|
132
|
+
#endif
|
|
133
|
+
BleNitro::HybridNativeBleNitroFactorySpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
134
|
+
return swiftPart.toUnsafe();
|
|
135
|
+
}
|
|
119
136
|
|
|
120
137
|
} // namespace margelo::nitro::co::zyke::ble::bridge::swift
|