@inoxialabs/react-native-nitro-location-geocoder 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.
Files changed (45) hide show
  1. package/LICENSE +201 -0
  2. package/NitroLocationGeocoder.podspec +28 -0
  3. package/README.md +80 -0
  4. package/android/CMakeLists.txt +25 -0
  5. package/android/build.gradle +129 -0
  6. package/android/fix-prefab.gradle +44 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/src/main/AndroidManifest.xml +2 -0
  9. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  10. package/android/src/main/java/com/margelo/nitro/locationgeocoder/HybridLocationGeocoder.kt +95 -0
  11. package/android/src/main/java/com/margelo/nitro/locationgeocoder/NitroLocationGeocoderPackage.kt +18 -0
  12. package/ios/Bridge.h +1 -0
  13. package/ios/HybridLocationGeocoder.swift +49 -0
  14. package/nitro.json +24 -0
  15. package/nitrogen/generated/.gitattributes +1 -0
  16. package/nitrogen/generated/android/NitroLocationGeocoder+autolinking.cmake +81 -0
  17. package/nitrogen/generated/android/NitroLocationGeocoder+autolinking.gradle +27 -0
  18. package/nitrogen/generated/android/NitroLocationGeocoderOnLoad.cpp +54 -0
  19. package/nitrogen/generated/android/NitroLocationGeocoderOnLoad.hpp +34 -0
  20. package/nitrogen/generated/android/c++/JHybridLocationGeocoderSpec.cpp +69 -0
  21. package/nitrogen/generated/android/c++/JHybridLocationGeocoderSpec.hpp +63 -0
  22. package/nitrogen/generated/android/c++/JLocationGeocoderResult.hpp +77 -0
  23. package/nitrogen/generated/android/kotlin/com/margelo/nitro/locationgeocoder/HybridLocationGeocoderSpec.kt +55 -0
  24. package/nitrogen/generated/android/kotlin/com/margelo/nitro/locationgeocoder/LocationGeocoderResult.kt +53 -0
  25. package/nitrogen/generated/android/kotlin/com/margelo/nitro/locationgeocoder/NitroLocationGeocoderOnLoad.kt +35 -0
  26. package/nitrogen/generated/ios/NitroLocationGeocoder+autolinking.rb +60 -0
  27. package/nitrogen/generated/ios/NitroLocationGeocoder-Swift-Cxx-Bridge.cpp +49 -0
  28. package/nitrogen/generated/ios/NitroLocationGeocoder-Swift-Cxx-Bridge.hpp +114 -0
  29. package/nitrogen/generated/ios/NitroLocationGeocoder-Swift-Cxx-Umbrella.hpp +48 -0
  30. package/nitrogen/generated/ios/NitroLocationGeocoderAutolinking.mm +33 -0
  31. package/nitrogen/generated/ios/NitroLocationGeocoderAutolinking.swift +26 -0
  32. package/nitrogen/generated/ios/c++/HybridLocationGeocoderSpecSwift.cpp +11 -0
  33. package/nitrogen/generated/ios/c++/HybridLocationGeocoderSpecSwift.hpp +85 -0
  34. package/nitrogen/generated/ios/swift/Func_void_LocationGeocoderResult.swift +46 -0
  35. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  36. package/nitrogen/generated/ios/swift/HybridLocationGeocoderSpec.swift +55 -0
  37. package/nitrogen/generated/ios/swift/HybridLocationGeocoderSpec_cxx.swift +145 -0
  38. package/nitrogen/generated/ios/swift/LocationGeocoderResult.swift +54 -0
  39. package/nitrogen/generated/shared/c++/HybridLocationGeocoderSpec.cpp +21 -0
  40. package/nitrogen/generated/shared/c++/HybridLocationGeocoderSpec.hpp +65 -0
  41. package/nitrogen/generated/shared/c++/LocationGeocoderResult.hpp +103 -0
  42. package/package.json +65 -0
  43. package/react-native.config.js +8 -0
  44. package/src/index.ts +21 -0
  45. package/src/specs/LocationGeocoder.nitro.ts +14 -0
@@ -0,0 +1,60 @@
1
+ #
2
+ # NitroLocationGeocoder+autolinking.rb
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
+ # This is a Ruby script that adds all files generated by Nitrogen
9
+ # to the given podspec.
10
+ #
11
+ # To use it, add this to your .podspec:
12
+ # ```ruby
13
+ # Pod::Spec.new do |spec|
14
+ # # ...
15
+ #
16
+ # # Add all files generated by Nitrogen
17
+ # load 'nitrogen/generated/ios/NitroLocationGeocoder+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 NitroLocationGeocoder is boosted by nitro!"
24
+
25
+ spec.dependency "NitroModules"
26
+
27
+ current_source_files = Array(spec.attributes_hash['source_files'])
28
+ spec.source_files = current_source_files + [
29
+ # Generated cross-platform specs
30
+ "nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
31
+ # Generated bridges for the cross-platform specs
32
+ "nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
33
+ ]
34
+
35
+ current_public_header_files = Array(spec.attributes_hash['public_header_files'])
36
+ spec.public_header_files = current_public_header_files + [
37
+ # Generated specs
38
+ "nitrogen/generated/shared/**/*.{h,hpp}",
39
+ # Swift to C++ bridging helpers
40
+ "nitrogen/generated/ios/NitroLocationGeocoder-Swift-Cxx-Bridge.hpp"
41
+ ]
42
+
43
+ current_private_header_files = Array(spec.attributes_hash['private_header_files'])
44
+ spec.private_header_files = current_private_header_files + [
45
+ # iOS specific specs
46
+ "nitrogen/generated/ios/c++/**/*.{h,hpp}",
47
+ # Views are framework-specific and should be private
48
+ "nitrogen/generated/shared/**/views/**/*"
49
+ ]
50
+
51
+ current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
52
+ spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
53
+ # Use C++ 20
54
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
55
+ # Enables C++ <-> Swift interop (by default it's only ObjC)
56
+ "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
57
+ # Enables stricter modular headers
58
+ "DEFINES_MODULE" => "YES",
59
+ })
60
+ end
@@ -0,0 +1,49 @@
1
+ ///
2
+ /// NitroLocationGeocoder-Swift-Cxx-Bridge.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 "NitroLocationGeocoder-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "HybridLocationGeocoderSpecSwift.hpp"
12
+ #include "NitroLocationGeocoder-Swift-Cxx-Umbrella.hpp"
13
+ #include <NitroModules/NitroDefines.hpp>
14
+
15
+ namespace margelo::nitro::locationgeocoder::bridge::swift {
16
+
17
+ // pragma MARK: std::function<void(const LocationGeocoderResult& /* result */)>
18
+ Func_void_LocationGeocoderResult create_Func_void_LocationGeocoderResult(void* NON_NULL swiftClosureWrapper) noexcept {
19
+ auto swiftClosure = NitroLocationGeocoder::Func_void_LocationGeocoderResult::fromUnsafe(swiftClosureWrapper);
20
+ return [swiftClosure = std::move(swiftClosure)](const LocationGeocoderResult& result) mutable -> void {
21
+ swiftClosure.call(result);
22
+ };
23
+ }
24
+
25
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
26
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
27
+ auto swiftClosure = NitroLocationGeocoder::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
28
+ return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
29
+ swiftClosure.call(error);
30
+ };
31
+ }
32
+
33
+ // pragma MARK: std::shared_ptr<HybridLocationGeocoderSpec>
34
+ std::shared_ptr<HybridLocationGeocoderSpec> create_std__shared_ptr_HybridLocationGeocoderSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
35
+ NitroLocationGeocoder::HybridLocationGeocoderSpec_cxx swiftPart = NitroLocationGeocoder::HybridLocationGeocoderSpec_cxx::fromUnsafe(swiftUnsafePointer);
36
+ return std::make_shared<margelo::nitro::locationgeocoder::HybridLocationGeocoderSpecSwift>(swiftPart);
37
+ }
38
+ void* NON_NULL get_std__shared_ptr_HybridLocationGeocoderSpec_(std__shared_ptr_HybridLocationGeocoderSpec_ cppType) {
39
+ std::shared_ptr<margelo::nitro::locationgeocoder::HybridLocationGeocoderSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::locationgeocoder::HybridLocationGeocoderSpecSwift>(cppType);
40
+ #ifdef NITRO_DEBUG
41
+ if (swiftWrapper == nullptr) [[unlikely]] {
42
+ throw std::runtime_error("Class \"HybridLocationGeocoderSpec\" is not implemented in Swift!");
43
+ }
44
+ #endif
45
+ NitroLocationGeocoder::HybridLocationGeocoderSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
46
+ return swiftPart.toUnsafe();
47
+ }
48
+
49
+ } // namespace margelo::nitro::locationgeocoder::bridge::swift
@@ -0,0 +1,114 @@
1
+ ///
2
+ /// NitroLocationGeocoder-Swift-Cxx-Bridge.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
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `HybridLocationGeocoderSpec` to properly resolve imports.
12
+ namespace margelo::nitro::locationgeocoder { class HybridLocationGeocoderSpec; }
13
+ // Forward declaration of `LocationGeocoderResult` to properly resolve imports.
14
+ namespace margelo::nitro::locationgeocoder { struct LocationGeocoderResult; }
15
+
16
+ // Forward declarations of Swift defined types
17
+ // Forward declaration of `HybridLocationGeocoderSpec_cxx` to properly resolve imports.
18
+ namespace NitroLocationGeocoder { class HybridLocationGeocoderSpec_cxx; }
19
+
20
+ // Include C++ defined types
21
+ #include "HybridLocationGeocoderSpec.hpp"
22
+ #include "LocationGeocoderResult.hpp"
23
+ #include <NitroModules/Promise.hpp>
24
+ #include <NitroModules/PromiseHolder.hpp>
25
+ #include <NitroModules/Result.hpp>
26
+ #include <exception>
27
+ #include <functional>
28
+ #include <memory>
29
+ #include <string>
30
+
31
+ /**
32
+ * Contains specialized versions of C++ templated types so they can be accessed from Swift,
33
+ * as well as helper functions to interact with those C++ types from Swift.
34
+ */
35
+ namespace margelo::nitro::locationgeocoder::bridge::swift {
36
+
37
+ // pragma MARK: std::shared_ptr<Promise<LocationGeocoderResult>>
38
+ /**
39
+ * Specialized version of `std::shared_ptr<Promise<LocationGeocoderResult>>`.
40
+ */
41
+ using std__shared_ptr_Promise_LocationGeocoderResult__ = std::shared_ptr<Promise<LocationGeocoderResult>>;
42
+ inline std::shared_ptr<Promise<LocationGeocoderResult>> create_std__shared_ptr_Promise_LocationGeocoderResult__() noexcept {
43
+ return Promise<LocationGeocoderResult>::create();
44
+ }
45
+ inline PromiseHolder<LocationGeocoderResult> wrap_std__shared_ptr_Promise_LocationGeocoderResult__(std::shared_ptr<Promise<LocationGeocoderResult>> promise) noexcept {
46
+ return PromiseHolder<LocationGeocoderResult>(std::move(promise));
47
+ }
48
+
49
+ // pragma MARK: std::function<void(const LocationGeocoderResult& /* result */)>
50
+ /**
51
+ * Specialized version of `std::function<void(const LocationGeocoderResult&)>`.
52
+ */
53
+ using Func_void_LocationGeocoderResult = std::function<void(const LocationGeocoderResult& /* result */)>;
54
+ /**
55
+ * Wrapper class for a `std::function<void(const LocationGeocoderResult& / * result * /)>`, this can be used from Swift.
56
+ */
57
+ class Func_void_LocationGeocoderResult_Wrapper final {
58
+ public:
59
+ explicit Func_void_LocationGeocoderResult_Wrapper(std::function<void(const LocationGeocoderResult& /* result */)>&& func): _function(std::make_unique<std::function<void(const LocationGeocoderResult& /* result */)>>(std::move(func))) {}
60
+ inline void call(LocationGeocoderResult result) const noexcept {
61
+ _function->operator()(result);
62
+ }
63
+ private:
64
+ std::unique_ptr<std::function<void(const LocationGeocoderResult& /* result */)>> _function;
65
+ } SWIFT_NONCOPYABLE;
66
+ Func_void_LocationGeocoderResult create_Func_void_LocationGeocoderResult(void* NON_NULL swiftClosureWrapper) noexcept;
67
+ inline Func_void_LocationGeocoderResult_Wrapper wrap_Func_void_LocationGeocoderResult(Func_void_LocationGeocoderResult value) noexcept {
68
+ return Func_void_LocationGeocoderResult_Wrapper(std::move(value));
69
+ }
70
+
71
+ // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
72
+ /**
73
+ * Specialized version of `std::function<void(const std::exception_ptr&)>`.
74
+ */
75
+ using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
76
+ /**
77
+ * Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
78
+ */
79
+ class Func_void_std__exception_ptr_Wrapper final {
80
+ public:
81
+ explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
82
+ inline void call(std::exception_ptr error) const noexcept {
83
+ _function->operator()(error);
84
+ }
85
+ private:
86
+ std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
87
+ } SWIFT_NONCOPYABLE;
88
+ Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
89
+ inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
90
+ return Func_void_std__exception_ptr_Wrapper(std::move(value));
91
+ }
92
+
93
+ // pragma MARK: std::shared_ptr<HybridLocationGeocoderSpec>
94
+ /**
95
+ * Specialized version of `std::shared_ptr<HybridLocationGeocoderSpec>`.
96
+ */
97
+ using std__shared_ptr_HybridLocationGeocoderSpec_ = std::shared_ptr<HybridLocationGeocoderSpec>;
98
+ std::shared_ptr<HybridLocationGeocoderSpec> create_std__shared_ptr_HybridLocationGeocoderSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
99
+ void* NON_NULL get_std__shared_ptr_HybridLocationGeocoderSpec_(std__shared_ptr_HybridLocationGeocoderSpec_ cppType);
100
+
101
+ // pragma MARK: std::weak_ptr<HybridLocationGeocoderSpec>
102
+ using std__weak_ptr_HybridLocationGeocoderSpec_ = std::weak_ptr<HybridLocationGeocoderSpec>;
103
+ inline std__weak_ptr_HybridLocationGeocoderSpec_ weakify_std__shared_ptr_HybridLocationGeocoderSpec_(const std::shared_ptr<HybridLocationGeocoderSpec>& strong) noexcept { return strong; }
104
+
105
+ // pragma MARK: Result<std::shared_ptr<Promise<LocationGeocoderResult>>>
106
+ using Result_std__shared_ptr_Promise_LocationGeocoderResult___ = Result<std::shared_ptr<Promise<LocationGeocoderResult>>>;
107
+ inline Result_std__shared_ptr_Promise_LocationGeocoderResult___ create_Result_std__shared_ptr_Promise_LocationGeocoderResult___(const std::shared_ptr<Promise<LocationGeocoderResult>>& value) noexcept {
108
+ return Result<std::shared_ptr<Promise<LocationGeocoderResult>>>::withValue(value);
109
+ }
110
+ inline Result_std__shared_ptr_Promise_LocationGeocoderResult___ create_Result_std__shared_ptr_Promise_LocationGeocoderResult___(const std::exception_ptr& error) noexcept {
111
+ return Result<std::shared_ptr<Promise<LocationGeocoderResult>>>::withError(error);
112
+ }
113
+
114
+ } // namespace margelo::nitro::locationgeocoder::bridge::swift
@@ -0,0 +1,48 @@
1
+ ///
2
+ /// NitroLocationGeocoder-Swift-Cxx-Umbrella.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
+ // Forward declarations of C++ defined types
11
+ // Forward declaration of `HybridLocationGeocoderSpec` to properly resolve imports.
12
+ namespace margelo::nitro::locationgeocoder { class HybridLocationGeocoderSpec; }
13
+ // Forward declaration of `LocationGeocoderResult` to properly resolve imports.
14
+ namespace margelo::nitro::locationgeocoder { struct LocationGeocoderResult; }
15
+
16
+ // Include C++ defined types
17
+ #include "HybridLocationGeocoderSpec.hpp"
18
+ #include "LocationGeocoderResult.hpp"
19
+ #include <NitroModules/Promise.hpp>
20
+ #include <NitroModules/Result.hpp>
21
+ #include <exception>
22
+ #include <memory>
23
+ #include <string>
24
+
25
+ // C++ helpers for Swift
26
+ #include "NitroLocationGeocoder-Swift-Cxx-Bridge.hpp"
27
+
28
+ // Common C++ types used in Swift
29
+ #include <NitroModules/ArrayBufferHolder.hpp>
30
+ #include <NitroModules/AnyMapUtils.hpp>
31
+ #include <NitroModules/RuntimeError.hpp>
32
+ #include <NitroModules/DateToChronoDate.hpp>
33
+
34
+ // Forward declarations of Swift defined types
35
+ // Forward declaration of `HybridLocationGeocoderSpec_cxx` to properly resolve imports.
36
+ namespace NitroLocationGeocoder { class HybridLocationGeocoderSpec_cxx; }
37
+
38
+ // Include Swift defined types
39
+ #if __has_include("NitroLocationGeocoder-Swift.h")
40
+ // This header is generated by Xcode/Swift on every app build.
41
+ // If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroLocationGeocoder".
42
+ #include "NitroLocationGeocoder-Swift.h"
43
+ // Same as above, but used when building with frameworks (`use_frameworks`)
44
+ #elif __has_include(<NitroLocationGeocoder/NitroLocationGeocoder-Swift.h>)
45
+ #include <NitroLocationGeocoder/NitroLocationGeocoder-Swift.h>
46
+ #else
47
+ #error NitroLocationGeocoder's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroLocationGeocoder", and try building the app first.
48
+ #endif
@@ -0,0 +1,33 @@
1
+ ///
2
+ /// NitroLocationGeocoderAutolinking.mm
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
+ #import <Foundation/Foundation.h>
9
+ #import <NitroModules/HybridObjectRegistry.hpp>
10
+ #import "NitroLocationGeocoder-Swift-Cxx-Umbrella.hpp"
11
+ #import <type_traits>
12
+
13
+ #include "HybridLocationGeocoderSpecSwift.hpp"
14
+
15
+ @interface NitroLocationGeocoderAutolinking : NSObject
16
+ @end
17
+
18
+ @implementation NitroLocationGeocoderAutolinking
19
+
20
+ + (void) load {
21
+ using namespace margelo::nitro;
22
+ using namespace margelo::nitro::locationgeocoder;
23
+
24
+ HybridObjectRegistry::registerHybridObjectConstructor(
25
+ "LocationGeocoder",
26
+ []() -> std::shared_ptr<HybridObject> {
27
+ std::shared_ptr<HybridLocationGeocoderSpec> hybridObject = NitroLocationGeocoder::NitroLocationGeocoderAutolinking::createLocationGeocoder();
28
+ return hybridObject;
29
+ }
30
+ );
31
+ }
32
+
33
+ @end
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// NitroLocationGeocoderAutolinking.swift
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
+ import NitroModules
9
+
10
+ // TODO: Use empty enums once Swift supports exporting them as namespaces
11
+ // See: https://github.com/swiftlang/swift/pull/83616
12
+ public final class NitroLocationGeocoderAutolinking {
13
+ public typealias bridge = margelo.nitro.locationgeocoder.bridge.swift
14
+
15
+ public static func createLocationGeocoder() -> bridge.std__shared_ptr_HybridLocationGeocoderSpec_ {
16
+ let hybridObject = HybridLocationGeocoder()
17
+ return { () -> bridge.std__shared_ptr_HybridLocationGeocoderSpec_ in
18
+ let __cxxWrapped = hybridObject.getCxxWrapper()
19
+ return __cxxWrapped.getCxxPart()
20
+ }()
21
+ }
22
+
23
+ public static func isLocationGeocoderRecyclable() -> Bool {
24
+ return HybridLocationGeocoder.self is any RecyclableView.Type
25
+ }
26
+ }
@@ -0,0 +1,11 @@
1
+ ///
2
+ /// HybridLocationGeocoderSpecSwift.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 "HybridLocationGeocoderSpecSwift.hpp"
9
+
10
+ namespace margelo::nitro::locationgeocoder {
11
+ } // namespace margelo::nitro::locationgeocoder
@@ -0,0 +1,85 @@
1
+ ///
2
+ /// HybridLocationGeocoderSpecSwift.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 "HybridLocationGeocoderSpec.hpp"
11
+
12
+ // Forward declaration of `HybridLocationGeocoderSpec_cxx` to properly resolve imports.
13
+ namespace NitroLocationGeocoder { class HybridLocationGeocoderSpec_cxx; }
14
+
15
+ // Forward declaration of `LocationGeocoderResult` to properly resolve imports.
16
+ namespace margelo::nitro::locationgeocoder { struct LocationGeocoderResult; }
17
+
18
+ #include "LocationGeocoderResult.hpp"
19
+ #include <NitroModules/Promise.hpp>
20
+ #include <string>
21
+
22
+ #include "NitroLocationGeocoder-Swift-Cxx-Umbrella.hpp"
23
+
24
+ namespace margelo::nitro::locationgeocoder {
25
+
26
+ /**
27
+ * The C++ part of HybridLocationGeocoderSpec_cxx.swift.
28
+ *
29
+ * HybridLocationGeocoderSpecSwift (C++) accesses HybridLocationGeocoderSpec_cxx (Swift), and might
30
+ * contain some additional bridging code for C++ <> Swift interop.
31
+ *
32
+ * Since this obviously introduces an overhead, I hope at some point in
33
+ * the future, HybridLocationGeocoderSpec_cxx can directly inherit from the C++ class HybridLocationGeocoderSpec
34
+ * to simplify the whole structure and memory management.
35
+ */
36
+ class HybridLocationGeocoderSpecSwift: public virtual HybridLocationGeocoderSpec {
37
+ public:
38
+ // Constructor from a Swift instance
39
+ explicit HybridLocationGeocoderSpecSwift(const NitroLocationGeocoder::HybridLocationGeocoderSpec_cxx& swiftPart):
40
+ HybridObject(HybridLocationGeocoderSpec::TAG),
41
+ _swiftPart(swiftPart) { }
42
+
43
+ public:
44
+ // Get the Swift part
45
+ inline NitroLocationGeocoder::HybridLocationGeocoderSpec_cxx& getSwiftPart() noexcept {
46
+ return _swiftPart;
47
+ }
48
+
49
+ public:
50
+ inline size_t getExternalMemorySize() noexcept override {
51
+ return _swiftPart.getMemorySize();
52
+ }
53
+ bool equals(const std::shared_ptr<HybridObject>& other) override {
54
+ if (auto otherCast = std::dynamic_pointer_cast<HybridLocationGeocoderSpecSwift>(other)) {
55
+ return _swiftPart.equals(otherCast->_swiftPart);
56
+ }
57
+ return false;
58
+ }
59
+ void dispose() noexcept override {
60
+ _swiftPart.dispose();
61
+ }
62
+ std::string toString() override {
63
+ return _swiftPart.toString();
64
+ }
65
+
66
+ public:
67
+ // Properties
68
+
69
+
70
+ public:
71
+ // Methods
72
+ inline std::shared_ptr<Promise<LocationGeocoderResult>> reverseGeocode(double latitude, double longitude, const std::string& locale) override {
73
+ auto __result = _swiftPart.reverseGeocode(std::forward<decltype(latitude)>(latitude), std::forward<decltype(longitude)>(longitude), locale);
74
+ if (__result.hasError()) [[unlikely]] {
75
+ std::rethrow_exception(__result.error());
76
+ }
77
+ auto __value = std::move(__result.value());
78
+ return __value;
79
+ }
80
+
81
+ private:
82
+ NitroLocationGeocoder::HybridLocationGeocoderSpec_cxx _swiftPart;
83
+ };
84
+
85
+ } // namespace margelo::nitro::locationgeocoder
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_LocationGeocoderResult.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ value: LocationGeocoderResult) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_LocationGeocoderResult {
15
+ public typealias bridge = margelo.nitro.locationgeocoder.bridge.swift
16
+
17
+ private let closure: (_ value: LocationGeocoderResult) -> Void
18
+
19
+ public init(_ closure: @escaping (_ value: LocationGeocoderResult) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(value: LocationGeocoderResult) -> Void {
25
+ self.closure(value)
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_LocationGeocoderResult`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_LocationGeocoderResult>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_LocationGeocoderResult {
44
+ return Unmanaged<Func_void_LocationGeocoderResult>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,46 @@
1
+ ///
2
+ /// Func_void_std__exception_ptr.swift
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
+ import NitroModules
9
+
10
+ /**
11
+ * Wraps a Swift `(_ error: Error) -> Void` as a class.
12
+ * This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
13
+ */
14
+ public final class Func_void_std__exception_ptr {
15
+ public typealias bridge = margelo.nitro.locationgeocoder.bridge.swift
16
+
17
+ private let closure: (_ error: Error) -> Void
18
+
19
+ public init(_ closure: @escaping (_ error: Error) -> Void) {
20
+ self.closure = closure
21
+ }
22
+
23
+ @inline(__always)
24
+ public func call(error: std.exception_ptr) -> Void {
25
+ self.closure(RuntimeError.from(cppError: error))
26
+ }
27
+
28
+ /**
29
+ * Casts this instance to a retained unsafe raw pointer.
30
+ * This acquires one additional strong reference on the object!
31
+ */
32
+ @inline(__always)
33
+ public func toUnsafe() -> UnsafeMutableRawPointer {
34
+ return Unmanaged.passRetained(self).toOpaque()
35
+ }
36
+
37
+ /**
38
+ * Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
39
+ * The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
40
+ * This removes one strong reference from the object!
41
+ */
42
+ @inline(__always)
43
+ public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
44
+ return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
45
+ }
46
+ }
@@ -0,0 +1,55 @@
1
+ ///
2
+ /// HybridLocationGeocoderSpec.swift
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
+ import NitroModules
9
+
10
+ /// See ``HybridLocationGeocoderSpec``
11
+ public protocol HybridLocationGeocoderSpec_protocol: HybridObject {
12
+ // Properties
13
+
14
+
15
+ // Methods
16
+ func reverseGeocode(latitude: Double, longitude: Double, locale: String) throws -> Promise<LocationGeocoderResult>
17
+ }
18
+
19
+ public extension HybridLocationGeocoderSpec_protocol {
20
+ /// Default implementation of ``HybridObject.toString``
21
+ func toString() -> String {
22
+ return "[HybridObject LocationGeocoder]"
23
+ }
24
+ }
25
+
26
+ /// See ``HybridLocationGeocoderSpec``
27
+ open class HybridLocationGeocoderSpec_base {
28
+ private weak var cxxWrapper: HybridLocationGeocoderSpec_cxx? = nil
29
+ public init() { }
30
+ public func getCxxWrapper() -> HybridLocationGeocoderSpec_cxx {
31
+ #if DEBUG
32
+ guard self is any HybridLocationGeocoderSpec else {
33
+ fatalError("`self` is not a `HybridLocationGeocoderSpec`! Did you accidentally inherit from `HybridLocationGeocoderSpec_base` instead of `HybridLocationGeocoderSpec`?")
34
+ }
35
+ #endif
36
+ if let cxxWrapper = self.cxxWrapper {
37
+ return cxxWrapper
38
+ } else {
39
+ let cxxWrapper = HybridLocationGeocoderSpec_cxx(self as! any HybridLocationGeocoderSpec)
40
+ self.cxxWrapper = cxxWrapper
41
+ return cxxWrapper
42
+ }
43
+ }
44
+ }
45
+
46
+ /**
47
+ * A Swift base-protocol representing the LocationGeocoder HybridObject.
48
+ * Implement this protocol to create Swift-based instances of LocationGeocoder.
49
+ * ```swift
50
+ * class HybridLocationGeocoder : HybridLocationGeocoderSpec {
51
+ * // ...
52
+ * }
53
+ * ```
54
+ */
55
+ public typealias HybridLocationGeocoderSpec = HybridLocationGeocoderSpec_protocol & HybridLocationGeocoderSpec_base