react-native-nitro-compass 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/NitroCompass.podspec +31 -0
- package/README.md +206 -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 +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +9 -0
- package/android/src/main/java/com/margelo/nitro/nitrocompass/HybridNitroCompass.kt +481 -0
- package/android/src/main/java/com/margelo/nitro/nitrocompass/NitroCompassPackage.kt +18 -0
- package/app.plugin.js +16 -0
- package/ios/Bridge.h +8 -0
- package/ios/HybridNitroCompass.swift +473 -0
- package/lib/commonjs/hook.js +69 -0
- package/lib/commonjs/hook.js.map +1 -0
- package/lib/commonjs/index.js +39 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/multiplex.js +109 -0
- package/lib/commonjs/multiplex.js.map +1 -0
- package/lib/commonjs/native.js +9 -0
- package/lib/commonjs/native.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/NitroCompass.nitro.js +6 -0
- package/lib/commonjs/specs/NitroCompass.nitro.js.map +1 -0
- package/lib/module/hook.js +65 -0
- package/lib/module/hook.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/multiplex.js +103 -0
- package/lib/module/multiplex.js.map +1 -0
- package/lib/module/native.js +5 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/specs/NitroCompass.nitro.js +4 -0
- package/lib/module/specs/NitroCompass.nitro.js.map +1 -0
- package/lib/typescript/src/hook.d.ts +49 -0
- package/lib/typescript/src/hook.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +8 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/multiplex.d.ts +38 -0
- package/lib/typescript/src/multiplex.d.ts.map +1 -0
- package/lib/typescript/src/native.d.ts +3 -0
- package/lib/typescript/src/native.d.ts.map +1 -0
- package/lib/typescript/src/specs/NitroCompass.nitro.d.ts +176 -0
- package/lib/typescript/src/specs/NitroCompass.nitro.d.ts.map +1 -0
- package/nitro.json +30 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroCompass+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroCompass+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroCompassOnLoad.cpp +60 -0
- package/nitrogen/generated/android/NitroCompassOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JAccuracyQuality.hpp +64 -0
- package/nitrogen/generated/android/c++/JCompassSample.hpp +61 -0
- package/nitrogen/generated/android/c++/JFunc_void_AccuracyQuality.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_CompassSample.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
- package/nitrogen/generated/android/c++/JHybridNitroCompassSpec.cpp +143 -0
- package/nitrogen/generated/android/c++/JHybridNitroCompassSpec.hpp +75 -0
- package/nitrogen/generated/android/c++/JPermissionStatus.hpp +61 -0
- package/nitrogen/generated/android/c++/JSensorDiagnostics.hpp +58 -0
- package/nitrogen/generated/android/c++/JSensorKind.hpp +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/AccuracyQuality.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/CompassSample.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/Func_void_AccuracyQuality.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/Func_void_CompassSample.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/Func_void_bool.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/HybridNitroCompassSpec.kt +118 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/NitroCompassOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/PermissionStatus.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/SensorDiagnostics.kt +51 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/SensorKind.kt +24 -0
- package/nitrogen/generated/ios/NitroCompass+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroCompass-Swift-Cxx-Bridge.cpp +73 -0
- package/nitrogen/generated/ios/NitroCompass-Swift-Cxx-Bridge.hpp +267 -0
- package/nitrogen/generated/ios/NitroCompass-Swift-Cxx-Umbrella.hpp +61 -0
- package/nitrogen/generated/ios/NitroCompassAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroCompassAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridNitroCompassSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroCompassSpecSwift.hpp +180 -0
- package/nitrogen/generated/ios/swift/AccuracyQuality.swift +48 -0
- package/nitrogen/generated/ios/swift/CompassSample.swift +34 -0
- package/nitrogen/generated/ios/swift/Func_void_AccuracyQuality.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_CompassSample.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_PermissionStatus.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridNitroCompassSpec.swift +67 -0
- package/nitrogen/generated/ios/swift/HybridNitroCompassSpec_cxx.swift +309 -0
- package/nitrogen/generated/ios/swift/PermissionStatus.swift +44 -0
- package/nitrogen/generated/ios/swift/SensorDiagnostics.swift +29 -0
- package/nitrogen/generated/ios/swift/SensorKind.swift +44 -0
- package/nitrogen/generated/shared/c++/AccuracyQuality.hpp +84 -0
- package/nitrogen/generated/shared/c++/CompassSample.hpp +87 -0
- package/nitrogen/generated/shared/c++/HybridNitroCompassSpec.cpp +33 -0
- package/nitrogen/generated/shared/c++/HybridNitroCompassSpec.hpp +87 -0
- package/nitrogen/generated/shared/c++/PermissionStatus.hpp +80 -0
- package/nitrogen/generated/shared/c++/SensorDiagnostics.hpp +84 -0
- package/nitrogen/generated/shared/c++/SensorKind.hpp +80 -0
- package/package.json +136 -0
- package/react-native.config.js +11 -0
- package/src/hook.ts +118 -0
- package/src/index.ts +28 -0
- package/src/multiplex.ts +117 -0
- package/src/native.ts +5 -0
- package/src/specs/NitroCompass.nitro.ts +193 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridNitroCompassSpec.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 "JHybridNitroCompassSpec.hpp"
|
|
9
|
+
|
|
10
|
+
// Forward declaration of `SensorDiagnostics` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::nitrocompass { struct SensorDiagnostics; }
|
|
12
|
+
// Forward declaration of `SensorKind` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::nitrocompass { enum class SensorKind; }
|
|
14
|
+
// Forward declaration of `CompassSample` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::nitrocompass { struct CompassSample; }
|
|
16
|
+
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::nitrocompass { enum class PermissionStatus; }
|
|
18
|
+
// Forward declaration of `AccuracyQuality` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::nitrocompass { enum class AccuracyQuality; }
|
|
20
|
+
|
|
21
|
+
#include "SensorDiagnostics.hpp"
|
|
22
|
+
#include <optional>
|
|
23
|
+
#include "JSensorDiagnostics.hpp"
|
|
24
|
+
#include "SensorKind.hpp"
|
|
25
|
+
#include "JSensorKind.hpp"
|
|
26
|
+
#include "CompassSample.hpp"
|
|
27
|
+
#include "JCompassSample.hpp"
|
|
28
|
+
#include "PermissionStatus.hpp"
|
|
29
|
+
#include "JPermissionStatus.hpp"
|
|
30
|
+
#include <NitroModules/Promise.hpp>
|
|
31
|
+
#include <NitroModules/JPromise.hpp>
|
|
32
|
+
#include <functional>
|
|
33
|
+
#include "JFunc_void_CompassSample.hpp"
|
|
34
|
+
#include <NitroModules/JNICallable.hpp>
|
|
35
|
+
#include "AccuracyQuality.hpp"
|
|
36
|
+
#include "JFunc_void_AccuracyQuality.hpp"
|
|
37
|
+
#include "JAccuracyQuality.hpp"
|
|
38
|
+
#include "JFunc_void_bool.hpp"
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro::nitrocompass {
|
|
41
|
+
|
|
42
|
+
std::shared_ptr<JHybridNitroCompassSpec> JHybridNitroCompassSpec::JavaPart::getJHybridNitroCompassSpec() {
|
|
43
|
+
auto hybridObject = JHybridObject::JavaPart::getJHybridObject();
|
|
44
|
+
auto castHybridObject = std::dynamic_pointer_cast<JHybridNitroCompassSpec>(hybridObject);
|
|
45
|
+
if (castHybridObject == nullptr) [[unlikely]] {
|
|
46
|
+
throw std::runtime_error("Failed to downcast JHybridObject to JHybridNitroCompassSpec!");
|
|
47
|
+
}
|
|
48
|
+
return castHybridObject;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
jni::local_ref<JHybridNitroCompassSpec::CxxPart::jhybriddata> JHybridNitroCompassSpec::CxxPart::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
52
|
+
return makeCxxInstance(jThis);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
std::shared_ptr<JHybridObject> JHybridNitroCompassSpec::CxxPart::createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) {
|
|
56
|
+
auto castJavaPart = jni::dynamic_ref_cast<JHybridNitroCompassSpec::JavaPart>(javaPart);
|
|
57
|
+
if (castJavaPart == nullptr) [[unlikely]] {
|
|
58
|
+
throw std::runtime_error("Failed to cast JHybridObject::JavaPart to JHybridNitroCompassSpec::JavaPart!");
|
|
59
|
+
}
|
|
60
|
+
return std::make_shared<JHybridNitroCompassSpec>(castJavaPart);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void JHybridNitroCompassSpec::CxxPart::registerNatives() {
|
|
64
|
+
registerHybrid({
|
|
65
|
+
makeNativeMethod("initHybrid", JHybridNitroCompassSpec::CxxPart::initHybrid),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Properties
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
// Methods
|
|
73
|
+
void JHybridNitroCompassSpec::start(double filterDegrees, const std::function<void(const CompassSample& /* sample */)>& onHeading) {
|
|
74
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* filterDegrees */, jni::alias_ref<JFunc_void_CompassSample::javaobject> /* onHeading */)>("start_cxx");
|
|
75
|
+
method(_javaPart, filterDegrees, JFunc_void_CompassSample_cxx::fromCpp(onHeading));
|
|
76
|
+
}
|
|
77
|
+
void JHybridNitroCompassSpec::stop() {
|
|
78
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void()>("stop");
|
|
79
|
+
method(_javaPart);
|
|
80
|
+
}
|
|
81
|
+
bool JHybridNitroCompassSpec::isStarted() {
|
|
82
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("isStarted");
|
|
83
|
+
auto __result = method(_javaPart);
|
|
84
|
+
return static_cast<bool>(__result);
|
|
85
|
+
}
|
|
86
|
+
void JHybridNitroCompassSpec::setFilter(double degrees) {
|
|
87
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* degrees */)>("setFilter");
|
|
88
|
+
method(_javaPart, degrees);
|
|
89
|
+
}
|
|
90
|
+
std::optional<SensorDiagnostics> JHybridNitroCompassSpec::getDiagnostics() {
|
|
91
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JSensorDiagnostics>()>("getDiagnostics");
|
|
92
|
+
auto __result = method(_javaPart);
|
|
93
|
+
return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
|
|
94
|
+
}
|
|
95
|
+
bool JHybridNitroCompassSpec::hasCompass() {
|
|
96
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jboolean()>("hasCompass");
|
|
97
|
+
auto __result = method(_javaPart);
|
|
98
|
+
return static_cast<bool>(__result);
|
|
99
|
+
}
|
|
100
|
+
std::optional<CompassSample> JHybridNitroCompassSpec::getCurrentHeading() {
|
|
101
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JCompassSample>()>("getCurrentHeading");
|
|
102
|
+
auto __result = method(_javaPart);
|
|
103
|
+
return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
|
|
104
|
+
}
|
|
105
|
+
void JHybridNitroCompassSpec::setDeclination(double degrees) {
|
|
106
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* degrees */)>("setDeclination");
|
|
107
|
+
method(_javaPart, degrees);
|
|
108
|
+
}
|
|
109
|
+
void JHybridNitroCompassSpec::setOnCalibrationNeeded(const std::function<void(AccuracyQuality /* quality */)>& onChange) {
|
|
110
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_AccuracyQuality::javaobject> /* onChange */)>("setOnCalibrationNeeded_cxx");
|
|
111
|
+
method(_javaPart, JFunc_void_AccuracyQuality_cxx::fromCpp(onChange));
|
|
112
|
+
}
|
|
113
|
+
void JHybridNitroCompassSpec::setOnInterferenceDetected(const std::function<void(bool /* interferenceDetected */)>& onChange) {
|
|
114
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_bool::javaobject> /* onChange */)>("setOnInterferenceDetected_cxx");
|
|
115
|
+
method(_javaPart, JFunc_void_bool_cxx::fromCpp(onChange));
|
|
116
|
+
}
|
|
117
|
+
void JHybridNitroCompassSpec::setPauseOnBackground(bool enabled) {
|
|
118
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jboolean /* enabled */)>("setPauseOnBackground");
|
|
119
|
+
method(_javaPart, enabled);
|
|
120
|
+
}
|
|
121
|
+
PermissionStatus JHybridNitroCompassSpec::getPermissionStatus() {
|
|
122
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPermissionStatus>()>("getPermissionStatus");
|
|
123
|
+
auto __result = method(_javaPart);
|
|
124
|
+
return __result->toCpp();
|
|
125
|
+
}
|
|
126
|
+
std::shared_ptr<Promise<PermissionStatus>> JHybridNitroCompassSpec::requestPermission() {
|
|
127
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("requestPermission");
|
|
128
|
+
auto __result = method(_javaPart);
|
|
129
|
+
return [&]() {
|
|
130
|
+
auto __promise = Promise<PermissionStatus>::create();
|
|
131
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
132
|
+
auto __result = jni::static_ref_cast<JPermissionStatus>(__boxedResult);
|
|
133
|
+
__promise->resolve(__result->toCpp());
|
|
134
|
+
});
|
|
135
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
136
|
+
jni::JniException __jniError(__throwable);
|
|
137
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
138
|
+
});
|
|
139
|
+
return __promise;
|
|
140
|
+
}();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
} // namespace margelo::nitro::nitrocompass
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroCompassSpec.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 "HybridNitroCompassSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::nitrocompass {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridNitroCompassSpec: public virtual HybridNitroCompassSpec, public virtual JHybridObject {
|
|
22
|
+
public:
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrocompass/HybridNitroCompassSpec;";
|
|
25
|
+
std::shared_ptr<JHybridNitroCompassSpec> getJHybridNitroCompassSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrocompass/HybridNitroCompassSpec$CxxPart;";
|
|
29
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
|
+
static void registerNatives();
|
|
31
|
+
using HybridBase::HybridBase;
|
|
32
|
+
protected:
|
|
33
|
+
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
explicit JHybridNitroCompassSpec(const jni::local_ref<JHybridNitroCompassSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridNitroCompassSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
41
|
+
~JHybridNitroCompassSpec() override {
|
|
42
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
43
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline const jni::global_ref<JHybridNitroCompassSpec::JavaPart>& getJavaPart() const noexcept {
|
|
48
|
+
return _javaPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Methods
|
|
57
|
+
void start(double filterDegrees, const std::function<void(const CompassSample& /* sample */)>& onHeading) override;
|
|
58
|
+
void stop() override;
|
|
59
|
+
bool isStarted() override;
|
|
60
|
+
void setFilter(double degrees) override;
|
|
61
|
+
std::optional<SensorDiagnostics> getDiagnostics() override;
|
|
62
|
+
bool hasCompass() override;
|
|
63
|
+
std::optional<CompassSample> getCurrentHeading() override;
|
|
64
|
+
void setDeclination(double degrees) override;
|
|
65
|
+
void setOnCalibrationNeeded(const std::function<void(AccuracyQuality /* quality */)>& onChange) override;
|
|
66
|
+
void setOnInterferenceDetected(const std::function<void(bool /* interferenceDetected */)>& onChange) override;
|
|
67
|
+
void setPauseOnBackground(bool enabled) override;
|
|
68
|
+
PermissionStatus getPermissionStatus() override;
|
|
69
|
+
std::shared_ptr<Promise<PermissionStatus>> requestPermission() override;
|
|
70
|
+
|
|
71
|
+
private:
|
|
72
|
+
jni::global_ref<JHybridNitroCompassSpec::JavaPart> _javaPart;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro::nitrocompass
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JPermissionStatus.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 "PermissionStatus.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitrocompass {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "PermissionStatus" and the the Kotlin enum "PermissionStatus".
|
|
19
|
+
*/
|
|
20
|
+
struct JPermissionStatus final: public jni::JavaClass<JPermissionStatus> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrocompass/PermissionStatus;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum PermissionStatus.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
PermissionStatus toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<PermissionStatus>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JPermissionStatus> fromCpp(PermissionStatus value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case PermissionStatus::GRANTED:
|
|
46
|
+
static const auto fieldGRANTED = clazz->getStaticField<JPermissionStatus>("GRANTED");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldGRANTED);
|
|
48
|
+
case PermissionStatus::DENIED:
|
|
49
|
+
static const auto fieldDENIED = clazz->getStaticField<JPermissionStatus>("DENIED");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldDENIED);
|
|
51
|
+
case PermissionStatus::UNKNOWN:
|
|
52
|
+
static const auto fieldUNKNOWN = clazz->getStaticField<JPermissionStatus>("UNKNOWN");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldUNKNOWN);
|
|
54
|
+
default:
|
|
55
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
56
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::nitrocompass
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSensorDiagnostics.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 "SensorDiagnostics.hpp"
|
|
12
|
+
|
|
13
|
+
#include "JSensorKind.hpp"
|
|
14
|
+
#include "SensorKind.hpp"
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::nitrocompass {
|
|
17
|
+
|
|
18
|
+
using namespace facebook;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The C++ JNI bridge between the C++ struct "SensorDiagnostics" and the the Kotlin data class "SensorDiagnostics".
|
|
22
|
+
*/
|
|
23
|
+
struct JSensorDiagnostics final: public jni::JavaClass<JSensorDiagnostics> {
|
|
24
|
+
public:
|
|
25
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrocompass/SensorDiagnostics;";
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
/**
|
|
29
|
+
* Convert this Java/Kotlin-based struct to the C++ struct SensorDiagnostics by copying all values to C++.
|
|
30
|
+
*/
|
|
31
|
+
[[maybe_unused]]
|
|
32
|
+
[[nodiscard]]
|
|
33
|
+
SensorDiagnostics toCpp() const {
|
|
34
|
+
static const auto clazz = javaClassStatic();
|
|
35
|
+
static const auto fieldSensor = clazz->getField<JSensorKind>("sensor");
|
|
36
|
+
jni::local_ref<JSensorKind> sensor = this->getFieldValue(fieldSensor);
|
|
37
|
+
return SensorDiagnostics(
|
|
38
|
+
sensor->toCpp()
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
/**
|
|
44
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
45
|
+
*/
|
|
46
|
+
[[maybe_unused]]
|
|
47
|
+
static jni::local_ref<JSensorDiagnostics::javaobject> fromCpp(const SensorDiagnostics& value) {
|
|
48
|
+
using JSignature = JSensorDiagnostics(jni::alias_ref<JSensorKind>);
|
|
49
|
+
static const auto clazz = javaClassStatic();
|
|
50
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
51
|
+
return create(
|
|
52
|
+
clazz,
|
|
53
|
+
JSensorKind::fromCpp(value.sensor)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::nitrocompass
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JSensorKind.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 "SensorKind.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitrocompass {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "SensorKind" and the the Kotlin enum "SensorKind".
|
|
19
|
+
*/
|
|
20
|
+
struct JSensorKind final: public jni::JavaClass<JSensorKind> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitrocompass/SensorKind;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum SensorKind.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
SensorKind toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<SensorKind>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JSensorKind> fromCpp(SensorKind value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case SensorKind::ROTATIONVECTOR:
|
|
46
|
+
static const auto fieldROTATIONVECTOR = clazz->getStaticField<JSensorKind>("ROTATIONVECTOR");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldROTATIONVECTOR);
|
|
48
|
+
case SensorKind::GEOMAGNETICROTATIONVECTOR:
|
|
49
|
+
static const auto fieldGEOMAGNETICROTATIONVECTOR = clazz->getStaticField<JSensorKind>("GEOMAGNETICROTATIONVECTOR");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldGEOMAGNETICROTATIONVECTOR);
|
|
51
|
+
case SensorKind::CORELOCATION:
|
|
52
|
+
static const auto fieldCORELOCATION = clazz->getStaticField<JSensorKind>("CORELOCATION");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldCORELOCATION);
|
|
54
|
+
default:
|
|
55
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
56
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::nitrocompass
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AccuracyQuality.kt
|
|
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
|
+
package com.margelo.nitro.nitrocompass
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "AccuracyQuality".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class AccuracyQuality(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
HIGH(0),
|
|
20
|
+
MEDIUM(1),
|
|
21
|
+
LOW(2),
|
|
22
|
+
UNRELIABLE(3);
|
|
23
|
+
|
|
24
|
+
companion object
|
|
25
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CompassSample.kt
|
|
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
|
+
package com.margelo.nitro.nitrocompass
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import java.util.Objects
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "CompassSample".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class CompassSample(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val heading: Double,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val accuracy: Double
|
|
27
|
+
) {
|
|
28
|
+
/* primary constructor */
|
|
29
|
+
|
|
30
|
+
override fun equals(other: Any?): Boolean {
|
|
31
|
+
if (this === other) return true
|
|
32
|
+
if (other !is CompassSample) return false
|
|
33
|
+
return Objects.deepEquals(this.heading, other.heading)
|
|
34
|
+
&& Objects.deepEquals(this.accuracy, other.accuracy)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
override fun hashCode(): Int {
|
|
38
|
+
return arrayOf(
|
|
39
|
+
heading,
|
|
40
|
+
accuracy
|
|
41
|
+
).contentDeepHashCode()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
companion object {
|
|
45
|
+
/**
|
|
46
|
+
* Constructor called from C++
|
|
47
|
+
*/
|
|
48
|
+
@DoNotStrip
|
|
49
|
+
@Keep
|
|
50
|
+
@Suppress("unused")
|
|
51
|
+
@JvmStatic
|
|
52
|
+
private fun fromCpp(heading: Double, accuracy: Double): CompassSample {
|
|
53
|
+
return CompassSample(heading, accuracy)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_AccuracyQuality.kt
|
|
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
|
+
package com.margelo.nitro.nitrocompass
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents the JavaScript callback `(quality: enum) => void`.
|
|
18
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
19
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
24
|
+
fun interface Func_void_AccuracyQuality: (AccuracyQuality) -> Unit {
|
|
25
|
+
/**
|
|
26
|
+
* Call the given JS callback.
|
|
27
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
28
|
+
*/
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
override fun invoke(quality: AccuracyQuality): Unit
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `(quality: enum) => void`.
|
|
36
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
37
|
+
* The callback might be coming from JS.
|
|
38
|
+
*/
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
@Suppress(
|
|
42
|
+
"KotlinJniMissingFunction", "unused",
|
|
43
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
44
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
45
|
+
)
|
|
46
|
+
class Func_void_AccuracyQuality_cxx: Func_void_AccuracyQuality {
|
|
47
|
+
@DoNotStrip
|
|
48
|
+
@Keep
|
|
49
|
+
private val mHybridData: HybridData
|
|
50
|
+
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
@Keep
|
|
53
|
+
private constructor(hybridData: HybridData) {
|
|
54
|
+
mHybridData = hybridData
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
override fun invoke(quality: AccuracyQuality): Unit
|
|
60
|
+
= invoke_cxx(quality)
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(quality: AccuracyQuality): Unit
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `(quality: enum) => void`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `(AccuracyQuality) -> Unit`.
|
|
69
|
+
* The callback is always coming from native.
|
|
70
|
+
*/
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
+
class Func_void_AccuracyQuality_java(private val function: (AccuracyQuality) -> Unit): Func_void_AccuracyQuality {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(quality: AccuracyQuality): Unit {
|
|
78
|
+
return this.function(quality)
|
|
79
|
+
}
|
|
80
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocompass/Func_void_CompassSample.kt
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_CompassSample.kt
|
|
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
|
+
package com.margelo.nitro.nitrocompass
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represents the JavaScript callback `(sample: struct) => void`.
|
|
18
|
+
* This can be either implemented in C++ (in which case it might be a callback coming from JS),
|
|
19
|
+
* or in Kotlin/Java (in which case it is a native callback).
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress("ClassName", "RedundantUnitReturnType")
|
|
24
|
+
fun interface Func_void_CompassSample: (CompassSample) -> Unit {
|
|
25
|
+
/**
|
|
26
|
+
* Call the given JS callback.
|
|
27
|
+
* @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
|
|
28
|
+
*/
|
|
29
|
+
@DoNotStrip
|
|
30
|
+
@Keep
|
|
31
|
+
override fun invoke(sample: CompassSample): Unit
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Represents the JavaScript callback `(sample: struct) => void`.
|
|
36
|
+
* This is implemented in C++, via a `std::function<...>`.
|
|
37
|
+
* The callback might be coming from JS.
|
|
38
|
+
*/
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
@Suppress(
|
|
42
|
+
"KotlinJniMissingFunction", "unused",
|
|
43
|
+
"RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
|
|
44
|
+
"ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
|
|
45
|
+
)
|
|
46
|
+
class Func_void_CompassSample_cxx: Func_void_CompassSample {
|
|
47
|
+
@DoNotStrip
|
|
48
|
+
@Keep
|
|
49
|
+
private val mHybridData: HybridData
|
|
50
|
+
|
|
51
|
+
@DoNotStrip
|
|
52
|
+
@Keep
|
|
53
|
+
private constructor(hybridData: HybridData) {
|
|
54
|
+
mHybridData = hybridData
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
override fun invoke(sample: CompassSample): Unit
|
|
60
|
+
= invoke_cxx(sample)
|
|
61
|
+
|
|
62
|
+
@FastNative
|
|
63
|
+
private external fun invoke_cxx(sample: CompassSample): Unit
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents the JavaScript callback `(sample: struct) => void`.
|
|
68
|
+
* This is implemented in Java/Kotlin, via a `(CompassSample) -> Unit`.
|
|
69
|
+
* The callback is always coming from native.
|
|
70
|
+
*/
|
|
71
|
+
@DoNotStrip
|
|
72
|
+
@Keep
|
|
73
|
+
@Suppress("ClassName", "RedundantUnitReturnType", "unused")
|
|
74
|
+
class Func_void_CompassSample_java(private val function: (CompassSample) -> Unit): Func_void_CompassSample {
|
|
75
|
+
@DoNotStrip
|
|
76
|
+
@Keep
|
|
77
|
+
override fun invoke(sample: CompassSample): Unit {
|
|
78
|
+
return this.function(sample)
|
|
79
|
+
}
|
|
80
|
+
}
|