munim-wifi 0.1.0
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/LICENSE +21 -0
- package/MunimWifi.podspec +31 -0
- package/README.md +591 -0
- package/android/CMakeLists.txt +32 -0
- package/android/build.gradle +148 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +6 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/munimwifi/HybridMunimWifi.kt +283 -0
- package/android/src/main/java/com/munimwifi/MunimWifiPackage.kt +20 -0
- package/ios/Bridge.h +8 -0
- package/ios/HybridMunimWifi.swift +222 -0
- package/lib/commonjs/index.js +216 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/munim-wifi.nitro.js +6 -0
- package/lib/commonjs/specs/munim-wifi.nitro.js.map +1 -0
- package/lib/module/index.js +198 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/specs/munim-wifi.nitro.js +4 -0
- package/lib/module/specs/munim-wifi.nitro.js.map +1 -0
- package/lib/typescript/src/index.d.ts +120 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/specs/munim-wifi.nitro.d.ts +118 -0
- package/lib/typescript/src/specs/munim-wifi.nitro.d.ts.map +1 -0
- package/nitro.json +24 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/MunimWifi+autolinking.cmake +85 -0
- package/nitrogen/generated/android/MunimWifi+autolinking.gradle +27 -0
- package/nitrogen/generated/android/MunimWifiOnLoad.cpp +44 -0
- package/nitrogen/generated/android/MunimWifiOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JChannelInfo.hpp +61 -0
- package/nitrogen/generated/android/c++/JHybridMunimWifiSpec.cpp +262 -0
- package/nitrogen/generated/android/c++/JHybridMunimWifiSpec.hpp +78 -0
- package/nitrogen/generated/android/c++/JLocation.hpp +61 -0
- package/nitrogen/generated/android/c++/JScanOptions.hpp +61 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_ChannelInfo.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_ChannelInfo.hpp +71 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_Double.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_Double.hpp +69 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_String.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_String.hpp +70 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_WifiNetwork.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_WifiNetwork.hpp +73 -0
- package/nitrogen/generated/android/c++/JWifiFingerprint.hpp +89 -0
- package/nitrogen/generated/android/c++/JWifiNetwork.hpp +86 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/ChannelInfo.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/HybridMunimWifiSpec.kt +107 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Location.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/MunimWifiOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/ScanOptions.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_ChannelInfo.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_Double.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_String.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/Variant_NullType_WifiNetwork.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/WifiFingerprint.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimwifi/WifiNetwork.kt +59 -0
- package/nitrogen/generated/ios/MunimWifi+autolinking.rb +60 -0
- package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Bridge.cpp +105 -0
- package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Bridge.hpp +653 -0
- package/nitrogen/generated/ios/MunimWifi-Swift-Cxx-Umbrella.hpp +64 -0
- package/nitrogen/generated/ios/MunimWifiAutolinking.mm +33 -0
- package/nitrogen/generated/ios/MunimWifiAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridMunimWifiSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridMunimWifiSpecSwift.hpp +189 -0
- package/nitrogen/generated/ios/swift/ChannelInfo.swift +35 -0
- package/nitrogen/generated/ios/swift/Func_void_WifiFingerprint.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__ChannelInfo_.swift +59 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__WifiNetwork_.swift +59 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__double_.swift +59 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__std__string_.swift +59 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_WifiNetwork_.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridMunimWifiSpec.swift +68 -0
- package/nitrogen/generated/ios/swift/HybridMunimWifiSpec_cxx.swift +382 -0
- package/nitrogen/generated/ios/swift/Location.swift +47 -0
- package/nitrogen/generated/ios/swift/ScanOptions.swift +47 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_ChannelInfo.swift +18 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_Double.swift +18 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_String.swift +18 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_WifiNetwork.swift +18 -0
- package/nitrogen/generated/ios/swift/WifiFingerprint.swift +52 -0
- package/nitrogen/generated/ios/swift/WifiNetwork.swift +103 -0
- package/nitrogen/generated/shared/c++/ChannelInfo.hpp +87 -0
- package/nitrogen/generated/shared/c++/HybridMunimWifiSpec.cpp +33 -0
- package/nitrogen/generated/shared/c++/HybridMunimWifiSpec.hpp +90 -0
- package/nitrogen/generated/shared/c++/Location.hpp +87 -0
- package/nitrogen/generated/shared/c++/ScanOptions.hpp +87 -0
- package/nitrogen/generated/shared/c++/WifiFingerprint.hpp +97 -0
- package/nitrogen/generated/shared/c++/WifiNetwork.hpp +112 -0
- package/package.json +122 -0
- package/src/index.ts +221 -0
- package/src/specs/munim-wifi.nitro.ts +140 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridMunimWifiSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridMunimWifiSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `WifiNetwork` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::munimwifi { struct WifiNetwork; }
|
|
12
|
+
// Forward declaration of `WifiFingerprint` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::munimwifi { struct WifiFingerprint; }
|
|
14
|
+
// Forward declaration of `Location` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::munimwifi { struct Location; }
|
|
16
|
+
// Forward declaration of `ChannelInfo` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::munimwifi { struct ChannelInfo; }
|
|
18
|
+
// Forward declaration of `ScanOptions` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::munimwifi { struct ScanOptions; }
|
|
20
|
+
|
|
21
|
+
#include <NitroModules/Promise.hpp>
|
|
22
|
+
#include <NitroModules/JPromise.hpp>
|
|
23
|
+
#include "WifiNetwork.hpp"
|
|
24
|
+
#include <vector>
|
|
25
|
+
#include "JWifiNetwork.hpp"
|
|
26
|
+
#include <string>
|
|
27
|
+
#include <optional>
|
|
28
|
+
#include "WifiFingerprint.hpp"
|
|
29
|
+
#include "JWifiFingerprint.hpp"
|
|
30
|
+
#include "Location.hpp"
|
|
31
|
+
#include "JLocation.hpp"
|
|
32
|
+
#include <NitroModules/Null.hpp>
|
|
33
|
+
#include <variant>
|
|
34
|
+
#include "JVariant_NullType_Double.hpp"
|
|
35
|
+
#include <NitroModules/JNull.hpp>
|
|
36
|
+
#include "JVariant_NullType_String.hpp"
|
|
37
|
+
#include "ChannelInfo.hpp"
|
|
38
|
+
#include "JVariant_NullType_ChannelInfo.hpp"
|
|
39
|
+
#include "JChannelInfo.hpp"
|
|
40
|
+
#include "JVariant_NullType_WifiNetwork.hpp"
|
|
41
|
+
#include "ScanOptions.hpp"
|
|
42
|
+
#include "JScanOptions.hpp"
|
|
43
|
+
|
|
44
|
+
namespace margelo::nitro::munimwifi {
|
|
45
|
+
|
|
46
|
+
jni::local_ref<JHybridMunimWifiSpec::jhybriddata> JHybridMunimWifiSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
47
|
+
return makeCxxInstance(jThis);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
void JHybridMunimWifiSpec::registerNatives() {
|
|
51
|
+
registerHybrid({
|
|
52
|
+
makeNativeMethod("initHybrid", JHybridMunimWifiSpec::initHybrid),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
size_t JHybridMunimWifiSpec::getExternalMemorySize() noexcept {
|
|
57
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
58
|
+
return method(_javaPart);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
bool JHybridMunimWifiSpec::equals(const std::shared_ptr<HybridObject>& other) {
|
|
62
|
+
if (auto otherCast = std::dynamic_pointer_cast<JHybridMunimWifiSpec>(other)) {
|
|
63
|
+
return _javaPart == otherCast->_javaPart;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void JHybridMunimWifiSpec::dispose() noexcept {
|
|
69
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
70
|
+
method(_javaPart);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
std::string JHybridMunimWifiSpec::toString() {
|
|
74
|
+
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
|
|
75
|
+
auto javaString = method(_javaPart);
|
|
76
|
+
return javaString->toStdString();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Properties
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
// Methods
|
|
83
|
+
std::shared_ptr<Promise<bool>> JHybridMunimWifiSpec::isWifiEnabled() {
|
|
84
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("isWifiEnabled");
|
|
85
|
+
auto __result = method(_javaPart);
|
|
86
|
+
return [&]() {
|
|
87
|
+
auto __promise = Promise<bool>::create();
|
|
88
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
89
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
90
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
91
|
+
});
|
|
92
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
93
|
+
jni::JniException __jniError(__throwable);
|
|
94
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
95
|
+
});
|
|
96
|
+
return __promise;
|
|
97
|
+
}();
|
|
98
|
+
}
|
|
99
|
+
std::shared_ptr<Promise<bool>> JHybridMunimWifiSpec::requestWifiPermission() {
|
|
100
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("requestWifiPermission");
|
|
101
|
+
auto __result = method(_javaPart);
|
|
102
|
+
return [&]() {
|
|
103
|
+
auto __promise = Promise<bool>::create();
|
|
104
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
105
|
+
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
|
|
106
|
+
__promise->resolve(static_cast<bool>(__result->value()));
|
|
107
|
+
});
|
|
108
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
109
|
+
jni::JniException __jniError(__throwable);
|
|
110
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
111
|
+
});
|
|
112
|
+
return __promise;
|
|
113
|
+
}();
|
|
114
|
+
}
|
|
115
|
+
std::shared_ptr<Promise<std::vector<WifiNetwork>>> JHybridMunimWifiSpec::scanNetworks(const std::optional<ScanOptions>& options) {
|
|
116
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JScanOptions> /* options */)>("scanNetworks");
|
|
117
|
+
auto __result = method(_javaPart, options.has_value() ? JScanOptions::fromCpp(options.value()) : nullptr);
|
|
118
|
+
return [&]() {
|
|
119
|
+
auto __promise = Promise<std::vector<WifiNetwork>>::create();
|
|
120
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
121
|
+
auto __result = jni::static_ref_cast<jni::JArrayClass<JWifiNetwork>>(__boxedResult);
|
|
122
|
+
__promise->resolve([&]() {
|
|
123
|
+
size_t __size = __result->size();
|
|
124
|
+
std::vector<WifiNetwork> __vector;
|
|
125
|
+
__vector.reserve(__size);
|
|
126
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
127
|
+
auto __element = __result->getElement(__i);
|
|
128
|
+
__vector.push_back(__element->toCpp());
|
|
129
|
+
}
|
|
130
|
+
return __vector;
|
|
131
|
+
}());
|
|
132
|
+
});
|
|
133
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
134
|
+
jni::JniException __jniError(__throwable);
|
|
135
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
136
|
+
});
|
|
137
|
+
return __promise;
|
|
138
|
+
}();
|
|
139
|
+
}
|
|
140
|
+
void JHybridMunimWifiSpec::startScan(const std::optional<ScanOptions>& options) {
|
|
141
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JScanOptions> /* options */)>("startScan");
|
|
142
|
+
method(_javaPart, options.has_value() ? JScanOptions::fromCpp(options.value()) : nullptr);
|
|
143
|
+
}
|
|
144
|
+
void JHybridMunimWifiSpec::stopScan() {
|
|
145
|
+
static const auto method = javaClassStatic()->getMethod<void()>("stopScan");
|
|
146
|
+
method(_javaPart);
|
|
147
|
+
}
|
|
148
|
+
std::shared_ptr<Promise<std::vector<std::string>>> JHybridMunimWifiSpec::getSSIDs() {
|
|
149
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getSSIDs");
|
|
150
|
+
auto __result = method(_javaPart);
|
|
151
|
+
return [&]() {
|
|
152
|
+
auto __promise = Promise<std::vector<std::string>>::create();
|
|
153
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
154
|
+
auto __result = jni::static_ref_cast<jni::JArrayClass<jni::JString>>(__boxedResult);
|
|
155
|
+
__promise->resolve([&]() {
|
|
156
|
+
size_t __size = __result->size();
|
|
157
|
+
std::vector<std::string> __vector;
|
|
158
|
+
__vector.reserve(__size);
|
|
159
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
160
|
+
auto __element = __result->getElement(__i);
|
|
161
|
+
__vector.push_back(__element->toStdString());
|
|
162
|
+
}
|
|
163
|
+
return __vector;
|
|
164
|
+
}());
|
|
165
|
+
});
|
|
166
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
167
|
+
jni::JniException __jniError(__throwable);
|
|
168
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
169
|
+
});
|
|
170
|
+
return __promise;
|
|
171
|
+
}();
|
|
172
|
+
}
|
|
173
|
+
std::shared_ptr<Promise<WifiFingerprint>> JHybridMunimWifiSpec::getWifiFingerprint() {
|
|
174
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("getWifiFingerprint");
|
|
175
|
+
auto __result = method(_javaPart);
|
|
176
|
+
return [&]() {
|
|
177
|
+
auto __promise = Promise<WifiFingerprint>::create();
|
|
178
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
179
|
+
auto __result = jni::static_ref_cast<JWifiFingerprint>(__boxedResult);
|
|
180
|
+
__promise->resolve(__result->toCpp());
|
|
181
|
+
});
|
|
182
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
183
|
+
jni::JniException __jniError(__throwable);
|
|
184
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
185
|
+
});
|
|
186
|
+
return __promise;
|
|
187
|
+
}();
|
|
188
|
+
}
|
|
189
|
+
std::shared_ptr<Promise<std::variant<nitro::NullType, double>>> JHybridMunimWifiSpec::getRSSI(const std::string& ssid) {
|
|
190
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* ssid */)>("getRSSI");
|
|
191
|
+
auto __result = method(_javaPart, jni::make_jstring(ssid));
|
|
192
|
+
return [&]() {
|
|
193
|
+
auto __promise = Promise<std::variant<nitro::NullType, double>>::create();
|
|
194
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
195
|
+
auto __result = jni::static_ref_cast<JVariant_NullType_Double>(__boxedResult);
|
|
196
|
+
__promise->resolve(__result->toCpp());
|
|
197
|
+
});
|
|
198
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
199
|
+
jni::JniException __jniError(__throwable);
|
|
200
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
201
|
+
});
|
|
202
|
+
return __promise;
|
|
203
|
+
}();
|
|
204
|
+
}
|
|
205
|
+
std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>> JHybridMunimWifiSpec::getBSSID(const std::string& ssid) {
|
|
206
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* ssid */)>("getBSSID");
|
|
207
|
+
auto __result = method(_javaPart, jni::make_jstring(ssid));
|
|
208
|
+
return [&]() {
|
|
209
|
+
auto __promise = Promise<std::variant<nitro::NullType, std::string>>::create();
|
|
210
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
211
|
+
auto __result = jni::static_ref_cast<JVariant_NullType_String>(__boxedResult);
|
|
212
|
+
__promise->resolve(__result->toCpp());
|
|
213
|
+
});
|
|
214
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
215
|
+
jni::JniException __jniError(__throwable);
|
|
216
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
217
|
+
});
|
|
218
|
+
return __promise;
|
|
219
|
+
}();
|
|
220
|
+
}
|
|
221
|
+
std::shared_ptr<Promise<std::variant<nitro::NullType, ChannelInfo>>> JHybridMunimWifiSpec::getChannelInfo(const std::string& ssid) {
|
|
222
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* ssid */)>("getChannelInfo");
|
|
223
|
+
auto __result = method(_javaPart, jni::make_jstring(ssid));
|
|
224
|
+
return [&]() {
|
|
225
|
+
auto __promise = Promise<std::variant<nitro::NullType, ChannelInfo>>::create();
|
|
226
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
227
|
+
auto __result = jni::static_ref_cast<JVariant_NullType_ChannelInfo>(__boxedResult);
|
|
228
|
+
__promise->resolve(__result->toCpp());
|
|
229
|
+
});
|
|
230
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
231
|
+
jni::JniException __jniError(__throwable);
|
|
232
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
233
|
+
});
|
|
234
|
+
return __promise;
|
|
235
|
+
}();
|
|
236
|
+
}
|
|
237
|
+
std::shared_ptr<Promise<std::variant<nitro::NullType, WifiNetwork>>> JHybridMunimWifiSpec::getNetworkInfo(const std::string& ssid) {
|
|
238
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* ssid */)>("getNetworkInfo");
|
|
239
|
+
auto __result = method(_javaPart, jni::make_jstring(ssid));
|
|
240
|
+
return [&]() {
|
|
241
|
+
auto __promise = Promise<std::variant<nitro::NullType, WifiNetwork>>::create();
|
|
242
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
243
|
+
auto __result = jni::static_ref_cast<JVariant_NullType_WifiNetwork>(__boxedResult);
|
|
244
|
+
__promise->resolve(__result->toCpp());
|
|
245
|
+
});
|
|
246
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
247
|
+
jni::JniException __jniError(__throwable);
|
|
248
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
249
|
+
});
|
|
250
|
+
return __promise;
|
|
251
|
+
}();
|
|
252
|
+
}
|
|
253
|
+
void JHybridMunimWifiSpec::addListener(const std::string& eventName) {
|
|
254
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* eventName */)>("addListener");
|
|
255
|
+
method(_javaPart, jni::make_jstring(eventName));
|
|
256
|
+
}
|
|
257
|
+
void JHybridMunimWifiSpec::removeListeners(double count) {
|
|
258
|
+
static const auto method = javaClassStatic()->getMethod<void(double /* count */)>("removeListeners");
|
|
259
|
+
method(_javaPart, count);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
} // namespace margelo::nitro::munimwifi
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridMunimWifiSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridMunimWifiSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::munimwifi {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridMunimWifiSpec: public jni::HybridClass<JHybridMunimWifiSpec, JHybridObject>,
|
|
22
|
+
public virtual HybridMunimWifiSpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimwifi/HybridMunimWifiSpec;";
|
|
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 JHybridMunimWifiSpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridMunimWifiSpec::TAG),
|
|
32
|
+
HybridBase(jThis),
|
|
33
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
~JHybridMunimWifiSpec() 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
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override;
|
|
44
|
+
void dispose() noexcept override;
|
|
45
|
+
std::string toString() override;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
inline const jni::global_ref<JHybridMunimWifiSpec::javaobject>& getJavaPart() const noexcept {
|
|
49
|
+
return _javaPart;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
// Properties
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
// Methods
|
|
58
|
+
std::shared_ptr<Promise<bool>> isWifiEnabled() override;
|
|
59
|
+
std::shared_ptr<Promise<bool>> requestWifiPermission() override;
|
|
60
|
+
std::shared_ptr<Promise<std::vector<WifiNetwork>>> scanNetworks(const std::optional<ScanOptions>& options) override;
|
|
61
|
+
void startScan(const std::optional<ScanOptions>& options) override;
|
|
62
|
+
void stopScan() override;
|
|
63
|
+
std::shared_ptr<Promise<std::vector<std::string>>> getSSIDs() override;
|
|
64
|
+
std::shared_ptr<Promise<WifiFingerprint>> getWifiFingerprint() override;
|
|
65
|
+
std::shared_ptr<Promise<std::variant<nitro::NullType, double>>> getRSSI(const std::string& ssid) override;
|
|
66
|
+
std::shared_ptr<Promise<std::variant<nitro::NullType, std::string>>> getBSSID(const std::string& ssid) override;
|
|
67
|
+
std::shared_ptr<Promise<std::variant<nitro::NullType, ChannelInfo>>> getChannelInfo(const std::string& ssid) override;
|
|
68
|
+
std::shared_ptr<Promise<std::variant<nitro::NullType, WifiNetwork>>> getNetworkInfo(const std::string& ssid) override;
|
|
69
|
+
void addListener(const std::string& eventName) override;
|
|
70
|
+
void removeListeners(double count) override;
|
|
71
|
+
|
|
72
|
+
private:
|
|
73
|
+
friend HybridBase;
|
|
74
|
+
using HybridBase::HybridBase;
|
|
75
|
+
jni::global_ref<JHybridMunimWifiSpec::javaobject> _javaPart;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
} // namespace margelo::nitro::munimwifi
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JLocation.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "Location.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::munimwifi {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "Location" and the the Kotlin data class "Location".
|
|
21
|
+
*/
|
|
22
|
+
struct JLocation final: public jni::JavaClass<JLocation> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimwifi/Location;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct Location by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
Location toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldLatitude = clazz->getField<jni::JDouble>("latitude");
|
|
35
|
+
jni::local_ref<jni::JDouble> latitude = this->getFieldValue(fieldLatitude);
|
|
36
|
+
static const auto fieldLongitude = clazz->getField<jni::JDouble>("longitude");
|
|
37
|
+
jni::local_ref<jni::JDouble> longitude = this->getFieldValue(fieldLongitude);
|
|
38
|
+
return Location(
|
|
39
|
+
latitude != nullptr ? std::make_optional(latitude->value()) : std::nullopt,
|
|
40
|
+
longitude != nullptr ? std::make_optional(longitude->value()) : std::nullopt
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
/**
|
|
46
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
47
|
+
*/
|
|
48
|
+
[[maybe_unused]]
|
|
49
|
+
static jni::local_ref<JLocation::javaobject> fromCpp(const Location& value) {
|
|
50
|
+
using JSignature = JLocation(jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>);
|
|
51
|
+
static const auto clazz = javaClassStatic();
|
|
52
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
53
|
+
return create(
|
|
54
|
+
clazz,
|
|
55
|
+
value.latitude.has_value() ? jni::JDouble::valueOf(value.latitude.value()) : nullptr,
|
|
56
|
+
value.longitude.has_value() ? jni::JDouble::valueOf(value.longitude.value()) : nullptr
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::munimwifi
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JScanOptions.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "ScanOptions.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::munimwifi {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "ScanOptions" and the the Kotlin data class "ScanOptions".
|
|
21
|
+
*/
|
|
22
|
+
struct JScanOptions final: public jni::JavaClass<JScanOptions> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimwifi/ScanOptions;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct ScanOptions by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
ScanOptions toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldMaxResults = clazz->getField<jni::JDouble>("maxResults");
|
|
35
|
+
jni::local_ref<jni::JDouble> maxResults = this->getFieldValue(fieldMaxResults);
|
|
36
|
+
static const auto fieldTimeout = clazz->getField<jni::JDouble>("timeout");
|
|
37
|
+
jni::local_ref<jni::JDouble> timeout = this->getFieldValue(fieldTimeout);
|
|
38
|
+
return ScanOptions(
|
|
39
|
+
maxResults != nullptr ? std::make_optional(maxResults->value()) : std::nullopt,
|
|
40
|
+
timeout != nullptr ? std::make_optional(timeout->value()) : std::nullopt
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
/**
|
|
46
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
47
|
+
*/
|
|
48
|
+
[[maybe_unused]]
|
|
49
|
+
static jni::local_ref<JScanOptions::javaobject> fromCpp(const ScanOptions& value) {
|
|
50
|
+
using JSignature = JScanOptions(jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>);
|
|
51
|
+
static const auto clazz = javaClassStatic();
|
|
52
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
53
|
+
return create(
|
|
54
|
+
clazz,
|
|
55
|
+
value.maxResults.has_value() ? jni::JDouble::valueOf(value.maxResults.value()) : nullptr,
|
|
56
|
+
value.timeout.has_value() ? jni::JDouble::valueOf(value.timeout.value()) : nullptr
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::munimwifi
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JVariant_NullType_ChannelInfo.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JVariant_NullType_ChannelInfo.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::munimwifi {
|
|
11
|
+
/**
|
|
12
|
+
* Converts JVariant_NullType_ChannelInfo to std::variant<nitro::NullType, ChannelInfo>
|
|
13
|
+
*/
|
|
14
|
+
std::variant<nitro::NullType, ChannelInfo> JVariant_NullType_ChannelInfo::toCpp() const {
|
|
15
|
+
if (isInstanceOf(JVariant_NullType_ChannelInfo_impl::First::javaClassStatic())) {
|
|
16
|
+
// It's a `nitro::NullType`
|
|
17
|
+
auto jniValue = static_cast<const JVariant_NullType_ChannelInfo_impl::First*>(this)->getValue();
|
|
18
|
+
return nitro::null;
|
|
19
|
+
} else if (isInstanceOf(JVariant_NullType_ChannelInfo_impl::Second::javaClassStatic())) {
|
|
20
|
+
// It's a `ChannelInfo`
|
|
21
|
+
auto jniValue = static_cast<const JVariant_NullType_ChannelInfo_impl::Second*>(this)->getValue();
|
|
22
|
+
return jniValue->toCpp();
|
|
23
|
+
}
|
|
24
|
+
throw std::invalid_argument("Variant is unknown Kotlin instance!");
|
|
25
|
+
}
|
|
26
|
+
} // namespace margelo::nitro::munimwifi
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JVariant_NullType_ChannelInfo.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <variant>
|
|
12
|
+
|
|
13
|
+
#include <NitroModules/Null.hpp>
|
|
14
|
+
#include "ChannelInfo.hpp"
|
|
15
|
+
#include <variant>
|
|
16
|
+
#include <NitroModules/JNull.hpp>
|
|
17
|
+
#include "JChannelInfo.hpp"
|
|
18
|
+
|
|
19
|
+
namespace margelo::nitro::munimwifi {
|
|
20
|
+
|
|
21
|
+
using namespace facebook;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The C++ JNI bridge between the C++ std::variant and the Java class "Variant_NullType_ChannelInfo".
|
|
25
|
+
*/
|
|
26
|
+
class JVariant_NullType_ChannelInfo: public jni::JavaClass<JVariant_NullType_ChannelInfo> {
|
|
27
|
+
public:
|
|
28
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimwifi/Variant_NullType_ChannelInfo;";
|
|
29
|
+
|
|
30
|
+
static jni::local_ref<JVariant_NullType_ChannelInfo> create_0(jni::alias_ref<JNull> value) {
|
|
31
|
+
static const auto method = javaClassStatic()->getStaticMethod<JVariant_NullType_ChannelInfo(jni::alias_ref<JNull>)>("create");
|
|
32
|
+
return method(javaClassStatic(), value);
|
|
33
|
+
}
|
|
34
|
+
static jni::local_ref<JVariant_NullType_ChannelInfo> create_1(jni::alias_ref<JChannelInfo> value) {
|
|
35
|
+
static const auto method = javaClassStatic()->getStaticMethod<JVariant_NullType_ChannelInfo(jni::alias_ref<JChannelInfo>)>("create");
|
|
36
|
+
return method(javaClassStatic(), value);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static jni::local_ref<JVariant_NullType_ChannelInfo> fromCpp(const std::variant<nitro::NullType, ChannelInfo>& variant) {
|
|
40
|
+
switch (variant.index()) {
|
|
41
|
+
case 0: return create_0(JNull::null());
|
|
42
|
+
case 1: return create_1(JChannelInfo::fromCpp(std::get<1>(variant)));
|
|
43
|
+
default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[[nodiscard]] std::variant<nitro::NullType, ChannelInfo> toCpp() const;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
namespace JVariant_NullType_ChannelInfo_impl {
|
|
51
|
+
class First final: public jni::JavaClass<First, JVariant_NullType_ChannelInfo> {
|
|
52
|
+
public:
|
|
53
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimwifi/Variant_NullType_ChannelInfo$First;";
|
|
54
|
+
|
|
55
|
+
[[nodiscard]] jni::local_ref<JNull> getValue() const {
|
|
56
|
+
static const auto field = javaClassStatic()->getField<JNull>("value");
|
|
57
|
+
return getFieldValue(field);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
class Second final: public jni::JavaClass<Second, JVariant_NullType_ChannelInfo> {
|
|
62
|
+
public:
|
|
63
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimwifi/Variant_NullType_ChannelInfo$Second;";
|
|
64
|
+
|
|
65
|
+
[[nodiscard]] jni::local_ref<JChannelInfo> getValue() const {
|
|
66
|
+
static const auto field = javaClassStatic()->getField<JChannelInfo>("value");
|
|
67
|
+
return getFieldValue(field);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
} // namespace JVariant_NullType_ChannelInfo_impl
|
|
71
|
+
} // namespace margelo::nitro::munimwifi
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JVariant_NullType_Double.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JVariant_NullType_Double.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::munimwifi {
|
|
11
|
+
/**
|
|
12
|
+
* Converts JVariant_NullType_Double to std::variant<nitro::NullType, double>
|
|
13
|
+
*/
|
|
14
|
+
std::variant<nitro::NullType, double> JVariant_NullType_Double::toCpp() const {
|
|
15
|
+
if (isInstanceOf(JVariant_NullType_Double_impl::First::javaClassStatic())) {
|
|
16
|
+
// It's a `nitro::NullType`
|
|
17
|
+
auto jniValue = static_cast<const JVariant_NullType_Double_impl::First*>(this)->getValue();
|
|
18
|
+
return nitro::null;
|
|
19
|
+
} else if (isInstanceOf(JVariant_NullType_Double_impl::Second::javaClassStatic())) {
|
|
20
|
+
// It's a `double`
|
|
21
|
+
auto jniValue = static_cast<const JVariant_NullType_Double_impl::Second*>(this)->getValue();
|
|
22
|
+
return jniValue;
|
|
23
|
+
}
|
|
24
|
+
throw std::invalid_argument("Variant is unknown Kotlin instance!");
|
|
25
|
+
}
|
|
26
|
+
} // namespace margelo::nitro::munimwifi
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JVariant_NullType_Double.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <variant>
|
|
12
|
+
|
|
13
|
+
#include <NitroModules/Null.hpp>
|
|
14
|
+
#include <variant>
|
|
15
|
+
#include <NitroModules/JNull.hpp>
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::munimwifi {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The C++ JNI bridge between the C++ std::variant and the Java class "Variant_NullType_Double".
|
|
23
|
+
*/
|
|
24
|
+
class JVariant_NullType_Double: public jni::JavaClass<JVariant_NullType_Double> {
|
|
25
|
+
public:
|
|
26
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimwifi/Variant_NullType_Double;";
|
|
27
|
+
|
|
28
|
+
static jni::local_ref<JVariant_NullType_Double> create_0(jni::alias_ref<JNull> value) {
|
|
29
|
+
static const auto method = javaClassStatic()->getStaticMethod<JVariant_NullType_Double(jni::alias_ref<JNull>)>("create");
|
|
30
|
+
return method(javaClassStatic(), value);
|
|
31
|
+
}
|
|
32
|
+
static jni::local_ref<JVariant_NullType_Double> create_1(double value) {
|
|
33
|
+
static const auto method = javaClassStatic()->getStaticMethod<JVariant_NullType_Double(double)>("create");
|
|
34
|
+
return method(javaClassStatic(), value);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static jni::local_ref<JVariant_NullType_Double> fromCpp(const std::variant<nitro::NullType, double>& variant) {
|
|
38
|
+
switch (variant.index()) {
|
|
39
|
+
case 0: return create_0(JNull::null());
|
|
40
|
+
case 1: return create_1(std::get<1>(variant));
|
|
41
|
+
default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[[nodiscard]] std::variant<nitro::NullType, double> toCpp() const;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
namespace JVariant_NullType_Double_impl {
|
|
49
|
+
class First final: public jni::JavaClass<First, JVariant_NullType_Double> {
|
|
50
|
+
public:
|
|
51
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimwifi/Variant_NullType_Double$First;";
|
|
52
|
+
|
|
53
|
+
[[nodiscard]] jni::local_ref<JNull> getValue() const {
|
|
54
|
+
static const auto field = javaClassStatic()->getField<JNull>("value");
|
|
55
|
+
return getFieldValue(field);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
class Second final: public jni::JavaClass<Second, JVariant_NullType_Double> {
|
|
60
|
+
public:
|
|
61
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/munimwifi/Variant_NullType_Double$Second;";
|
|
62
|
+
|
|
63
|
+
[[nodiscard]] double getValue() const {
|
|
64
|
+
static const auto field = javaClassStatic()->getField<double>("value");
|
|
65
|
+
return getFieldValue(field);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
} // namespace JVariant_NullType_Double_impl
|
|
69
|
+
} // namespace margelo::nitro::munimwifi
|