react-native-nitro-country-picker 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 +20 -0
- package/NitroCountryPicker.podspec +37 -0
- package/README.md +164 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +149 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +8 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/nitrocountrypicker/CountryPickerActivity.kt +95 -0
- package/android/src/main/java/com/margelo/nitro/nitrocountrypicker/NitroCountryPicker.kt +132 -0
- package/android/src/main/java/com/margelo/nitro/nitrocountrypicker/NitroCountryPickerPackage.kt +36 -0
- package/ios/NitroCountryPicker.swift +94 -0
- package/lib/module/NitroCountryPicker.nitro.js +4 -0
- package/lib/module/NitroCountryPicker.nitro.js.map +1 -0
- package/lib/module/index.js +11 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NitroCountryPicker.nitro.d.ts +17 -0
- package/lib/typescript/src/NitroCountryPicker.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JHybridNitroCountryPickerSpec.cpp +83 -0
- package/nitrogen/generated/android/c++/JHybridNitroCountryPickerSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JIPickedCountry.hpp +65 -0
- package/nitrogen/generated/android/c++/JPickCountryOptions.hpp +58 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_IPickedCountry.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_IPickedCountry.hpp +72 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocountrypicker/HybridNitroCountryPickerSpec.kt +60 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocountrypicker/IPickedCountry.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocountrypicker/PickCountryOptions.kt +38 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocountrypicker/Variant_NullType_IPickedCountry.kt +53 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrocountrypicker/nitrocountrypickerOnLoad.kt +35 -0
- package/nitrogen/generated/android/nitrocountrypicker+autolinking.cmake +82 -0
- package/nitrogen/generated/android/nitrocountrypicker+autolinking.gradle +27 -0
- package/nitrogen/generated/android/nitrocountrypickerOnLoad.cpp +54 -0
- package/nitrogen/generated/android/nitrocountrypickerOnLoad.hpp +34 -0
- package/nitrogen/generated/ios/NitroCountryPicker+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroCountryPicker-Swift-Cxx-Bridge.cpp +49 -0
- package/nitrogen/generated/ios/NitroCountryPicker-Swift-Cxx-Bridge.hpp +188 -0
- package/nitrogen/generated/ios/NitroCountryPicker-Swift-Cxx-Umbrella.hpp +54 -0
- package/nitrogen/generated/ios/NitroCountryPickerAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroCountryPickerAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridNitroCountryPickerSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroCountryPickerSpecSwift.hpp +99 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__IPickedCountry_.swift +58 -0
- package/nitrogen/generated/ios/swift/HybridNitroCountryPickerSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroCountryPickerSpec_cxx.swift +171 -0
- package/nitrogen/generated/ios/swift/IPickedCountry.swift +39 -0
- package/nitrogen/generated/ios/swift/PickCountryOptions.swift +42 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_IPickedCountry.swift +18 -0
- package/nitrogen/generated/shared/c++/HybridNitroCountryPickerSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroCountryPickerSpec.hpp +71 -0
- package/nitrogen/generated/shared/c++/IPickedCountry.hpp +91 -0
- package/nitrogen/generated/shared/c++/PickCountryOptions.hpp +84 -0
- package/package.json +175 -0
- package/src/NitroCountryPicker.nitro.ts +20 -0
- package/src/index.tsx +19 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroCountryPicker-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 `HybridNitroCountryPickerSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::nitrocountrypicker { class HybridNitroCountryPickerSpec; }
|
|
13
|
+
// Forward declaration of `IPickedCountry` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::nitrocountrypicker { struct IPickedCountry; }
|
|
15
|
+
// Forward declaration of `PickCountryOptions` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrocountrypicker { struct PickCountryOptions; }
|
|
17
|
+
|
|
18
|
+
// Include C++ defined types
|
|
19
|
+
#include "HybridNitroCountryPickerSpec.hpp"
|
|
20
|
+
#include "IPickedCountry.hpp"
|
|
21
|
+
#include "PickCountryOptions.hpp"
|
|
22
|
+
#include <NitroModules/Null.hpp>
|
|
23
|
+
#include <NitroModules/Promise.hpp>
|
|
24
|
+
#include <NitroModules/Result.hpp>
|
|
25
|
+
#include <exception>
|
|
26
|
+
#include <memory>
|
|
27
|
+
#include <optional>
|
|
28
|
+
#include <string>
|
|
29
|
+
#include <variant>
|
|
30
|
+
|
|
31
|
+
// C++ helpers for Swift
|
|
32
|
+
#include "NitroCountryPicker-Swift-Cxx-Bridge.hpp"
|
|
33
|
+
|
|
34
|
+
// Common C++ types used in Swift
|
|
35
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
36
|
+
#include <NitroModules/AnyMapUtils.hpp>
|
|
37
|
+
#include <NitroModules/RuntimeError.hpp>
|
|
38
|
+
#include <NitroModules/DateToChronoDate.hpp>
|
|
39
|
+
|
|
40
|
+
// Forward declarations of Swift defined types
|
|
41
|
+
// Forward declaration of `HybridNitroCountryPickerSpec_cxx` to properly resolve imports.
|
|
42
|
+
namespace NitroCountryPicker { class HybridNitroCountryPickerSpec_cxx; }
|
|
43
|
+
|
|
44
|
+
// Include Swift defined types
|
|
45
|
+
#if __has_include("NitroCountryPicker-Swift.h")
|
|
46
|
+
// This header is generated by Xcode/Swift on every app build.
|
|
47
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroCountryPicker".
|
|
48
|
+
#include "NitroCountryPicker-Swift.h"
|
|
49
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
50
|
+
#elif __has_include(<NitroCountryPicker/NitroCountryPicker-Swift.h>)
|
|
51
|
+
#include <NitroCountryPicker/NitroCountryPicker-Swift.h>
|
|
52
|
+
#else
|
|
53
|
+
#error NitroCountryPicker's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroCountryPicker", and try building the app first.
|
|
54
|
+
#endif
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroCountryPickerAutolinking.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 "NitroCountryPicker-Swift-Cxx-Umbrella.hpp"
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridNitroCountryPickerSpecSwift.hpp"
|
|
14
|
+
|
|
15
|
+
@interface NitroCountryPickerAutolinking : NSObject
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation NitroCountryPickerAutolinking
|
|
19
|
+
|
|
20
|
+
+ (void) load {
|
|
21
|
+
using namespace margelo::nitro;
|
|
22
|
+
using namespace margelo::nitro::nitrocountrypicker;
|
|
23
|
+
|
|
24
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
+
"NitroCountryPicker",
|
|
26
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
+
std::shared_ptr<HybridNitroCountryPickerSpec> hybridObject = NitroCountryPicker::NitroCountryPickerAutolinking::createNitroCountryPicker();
|
|
28
|
+
return hybridObject;
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroCountryPickerAutolinking.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 NitroCountryPickerAutolinking {
|
|
13
|
+
public typealias bridge = margelo.nitro.nitrocountrypicker.bridge.swift
|
|
14
|
+
|
|
15
|
+
public static func createNitroCountryPicker() -> bridge.std__shared_ptr_HybridNitroCountryPickerSpec_ {
|
|
16
|
+
let hybridObject = NitroCountryPicker()
|
|
17
|
+
return { () -> bridge.std__shared_ptr_HybridNitroCountryPickerSpec_ in
|
|
18
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
19
|
+
return __cxxWrapped.getCxxPart()
|
|
20
|
+
}()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public static func isNitroCountryPickerRecyclable() -> Bool {
|
|
24
|
+
return NitroCountryPicker.self is any RecyclableView.Type
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroCountryPickerSpecSwift.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 "HybridNitroCountryPickerSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitrocountrypicker {
|
|
11
|
+
} // namespace margelo::nitro::nitrocountrypicker
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroCountryPickerSpecSwift.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 "HybridNitroCountryPickerSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridNitroCountryPickerSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroCountryPicker { class HybridNitroCountryPickerSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `IPickedCountry` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrocountrypicker { struct IPickedCountry; }
|
|
17
|
+
// Forward declaration of `PickCountryOptions` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::nitrocountrypicker { struct PickCountryOptions; }
|
|
19
|
+
|
|
20
|
+
#include <NitroModules/Null.hpp>
|
|
21
|
+
#include "IPickedCountry.hpp"
|
|
22
|
+
#include <variant>
|
|
23
|
+
#include <NitroModules/Promise.hpp>
|
|
24
|
+
#include <string>
|
|
25
|
+
#include "PickCountryOptions.hpp"
|
|
26
|
+
#include <optional>
|
|
27
|
+
|
|
28
|
+
#include "NitroCountryPicker-Swift-Cxx-Umbrella.hpp"
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::nitrocountrypicker {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The C++ part of HybridNitroCountryPickerSpec_cxx.swift.
|
|
34
|
+
*
|
|
35
|
+
* HybridNitroCountryPickerSpecSwift (C++) accesses HybridNitroCountryPickerSpec_cxx (Swift), and might
|
|
36
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
37
|
+
*
|
|
38
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
39
|
+
* the future, HybridNitroCountryPickerSpec_cxx can directly inherit from the C++ class HybridNitroCountryPickerSpec
|
|
40
|
+
* to simplify the whole structure and memory management.
|
|
41
|
+
*/
|
|
42
|
+
class HybridNitroCountryPickerSpecSwift: public virtual HybridNitroCountryPickerSpec {
|
|
43
|
+
public:
|
|
44
|
+
// Constructor from a Swift instance
|
|
45
|
+
explicit HybridNitroCountryPickerSpecSwift(const NitroCountryPicker::HybridNitroCountryPickerSpec_cxx& swiftPart):
|
|
46
|
+
HybridObject(HybridNitroCountryPickerSpec::TAG),
|
|
47
|
+
_swiftPart(swiftPart) { }
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
// Get the Swift part
|
|
51
|
+
inline NitroCountryPicker::HybridNitroCountryPickerSpec_cxx& getSwiftPart() noexcept {
|
|
52
|
+
return _swiftPart;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
57
|
+
return _swiftPart.getMemorySize();
|
|
58
|
+
}
|
|
59
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
60
|
+
if (auto otherCast = std::dynamic_pointer_cast<HybridNitroCountryPickerSpecSwift>(other)) {
|
|
61
|
+
return _swiftPart.equals(otherCast->_swiftPart);
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
void dispose() noexcept override {
|
|
66
|
+
_swiftPart.dispose();
|
|
67
|
+
}
|
|
68
|
+
std::string toString() override {
|
|
69
|
+
return _swiftPart.toString();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public:
|
|
73
|
+
// Properties
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
public:
|
|
77
|
+
// Methods
|
|
78
|
+
inline std::shared_ptr<Promise<std::variant<nitro::NullType, IPickedCountry>>> pickCountry(const std::optional<PickCountryOptions>& options) override {
|
|
79
|
+
auto __result = _swiftPart.pickCountry(options);
|
|
80
|
+
if (__result.hasError()) [[unlikely]] {
|
|
81
|
+
std::rethrow_exception(__result.error());
|
|
82
|
+
}
|
|
83
|
+
auto __value = std::move(__result.value());
|
|
84
|
+
return __value;
|
|
85
|
+
}
|
|
86
|
+
inline std::variant<nitro::NullType, IPickedCountry> getLastPickedCountry() override {
|
|
87
|
+
auto __result = _swiftPart.getLastPickedCountry();
|
|
88
|
+
if (__result.hasError()) [[unlikely]] {
|
|
89
|
+
std::rethrow_exception(__result.error());
|
|
90
|
+
}
|
|
91
|
+
auto __value = std::move(__result.value());
|
|
92
|
+
return __value;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private:
|
|
96
|
+
NitroCountryPicker::HybridNitroCountryPickerSpec_cxx _swiftPart;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
} // namespace margelo::nitro::nitrocountrypicker
|
|
@@ -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.nitrocountrypicker.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
|
+
}
|
package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__IPickedCountry_.swift
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__variant_nitro__NullType__IPickedCountry_.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: Variant_NullType_IPickedCountry) -> 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__variant_nitro__NullType__IPickedCountry_ {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitrocountrypicker.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: Variant_NullType_IPickedCountry) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: Variant_NullType_IPickedCountry) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: bridge.std__variant_nitro__NullType__IPickedCountry_) -> Void {
|
|
25
|
+
self.closure({ () -> Variant_NullType_IPickedCountry in
|
|
26
|
+
let __variant = value
|
|
27
|
+
switch __variant.index() {
|
|
28
|
+
case 0:
|
|
29
|
+
let __actual = __variant.get_0()
|
|
30
|
+
return .first(NullType.null)
|
|
31
|
+
case 1:
|
|
32
|
+
let __actual = __variant.get_1()
|
|
33
|
+
return .second(__actual)
|
|
34
|
+
default:
|
|
35
|
+
fatalError("Variant can never have index \(__variant.index())!")
|
|
36
|
+
}
|
|
37
|
+
}())
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
42
|
+
* This acquires one additional strong reference on the object!
|
|
43
|
+
*/
|
|
44
|
+
@inline(__always)
|
|
45
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
46
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Casts an unsafe pointer to a `Func_void_std__variant_nitro__NullType__IPickedCountry_`.
|
|
51
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__variant_nitro__NullType__IPickedCountry_>`.
|
|
52
|
+
* This removes one strong reference from the object!
|
|
53
|
+
*/
|
|
54
|
+
@inline(__always)
|
|
55
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__variant_nitro__NullType__IPickedCountry_ {
|
|
56
|
+
return Unmanaged<Func_void_std__variant_nitro__NullType__IPickedCountry_>.fromOpaque(pointer).takeRetainedValue()
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroCountryPickerSpec.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 ``HybridNitroCountryPickerSpec``
|
|
11
|
+
public protocol HybridNitroCountryPickerSpec_protocol: HybridObject {
|
|
12
|
+
// Properties
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// Methods
|
|
16
|
+
func pickCountry(options: PickCountryOptions?) throws -> Promise<Variant_NullType_IPickedCountry>
|
|
17
|
+
func getLastPickedCountry() throws -> Variant_NullType_IPickedCountry
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public extension HybridNitroCountryPickerSpec_protocol {
|
|
21
|
+
/// Default implementation of ``HybridObject.toString``
|
|
22
|
+
func toString() -> String {
|
|
23
|
+
return "[HybridObject NitroCountryPicker]"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// See ``HybridNitroCountryPickerSpec``
|
|
28
|
+
open class HybridNitroCountryPickerSpec_base {
|
|
29
|
+
private weak var cxxWrapper: HybridNitroCountryPickerSpec_cxx? = nil
|
|
30
|
+
public init() { }
|
|
31
|
+
public func getCxxWrapper() -> HybridNitroCountryPickerSpec_cxx {
|
|
32
|
+
#if DEBUG
|
|
33
|
+
guard self is any HybridNitroCountryPickerSpec else {
|
|
34
|
+
fatalError("`self` is not a `HybridNitroCountryPickerSpec`! Did you accidentally inherit from `HybridNitroCountryPickerSpec_base` instead of `HybridNitroCountryPickerSpec`?")
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
38
|
+
return cxxWrapper
|
|
39
|
+
} else {
|
|
40
|
+
let cxxWrapper = HybridNitroCountryPickerSpec_cxx(self as! any HybridNitroCountryPickerSpec)
|
|
41
|
+
self.cxxWrapper = cxxWrapper
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A Swift base-protocol representing the NitroCountryPicker HybridObject.
|
|
49
|
+
* Implement this protocol to create Swift-based instances of NitroCountryPicker.
|
|
50
|
+
* ```swift
|
|
51
|
+
* class HybridNitroCountryPicker : HybridNitroCountryPickerSpec {
|
|
52
|
+
* // ...
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
public typealias HybridNitroCountryPickerSpec = HybridNitroCountryPickerSpec_protocol & HybridNitroCountryPickerSpec_base
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroCountryPickerSpec_cxx.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
|
+
* A class implementation that bridges HybridNitroCountryPickerSpec over to C++.
|
|
12
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
13
|
+
*
|
|
14
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
15
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
16
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
17
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
18
|
+
*/
|
|
19
|
+
open class HybridNitroCountryPickerSpec_cxx {
|
|
20
|
+
/**
|
|
21
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::nitrocountrypicker::bridge::swift`)
|
|
22
|
+
* from `NitroCountryPicker-Swift-Cxx-Bridge.hpp`.
|
|
23
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
24
|
+
*/
|
|
25
|
+
public typealias bridge = margelo.nitro.nitrocountrypicker.bridge.swift
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Holds an instance of the `HybridNitroCountryPickerSpec` Swift protocol.
|
|
29
|
+
*/
|
|
30
|
+
private var __implementation: any HybridNitroCountryPickerSpec
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
34
|
+
*/
|
|
35
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridNitroCountryPickerSpec_
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a new `HybridNitroCountryPickerSpec_cxx` that wraps the given `HybridNitroCountryPickerSpec`.
|
|
39
|
+
* All properties and methods bridge to C++ types.
|
|
40
|
+
*/
|
|
41
|
+
public init(_ implementation: any HybridNitroCountryPickerSpec) {
|
|
42
|
+
self.__implementation = implementation
|
|
43
|
+
self.__cxxPart = .init()
|
|
44
|
+
/* no base class */
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the actual `HybridNitroCountryPickerSpec` instance this class wraps.
|
|
49
|
+
*/
|
|
50
|
+
@inline(__always)
|
|
51
|
+
public func getHybridNitroCountryPickerSpec() -> any HybridNitroCountryPickerSpec {
|
|
52
|
+
return __implementation
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
57
|
+
* This acquires one additional strong reference on the object!
|
|
58
|
+
*/
|
|
59
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
60
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Casts an unsafe pointer to a `HybridNitroCountryPickerSpec_cxx`.
|
|
65
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridNitroCountryPickerSpec_cxx>`.
|
|
66
|
+
* This removes one strong reference from the object!
|
|
67
|
+
*/
|
|
68
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridNitroCountryPickerSpec_cxx {
|
|
69
|
+
return Unmanaged<HybridNitroCountryPickerSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
74
|
+
* The C++ part is a `std::shared_ptr<HybridNitroCountryPickerSpec>`.
|
|
75
|
+
*/
|
|
76
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridNitroCountryPickerSpec_ {
|
|
77
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
78
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
79
|
+
return cachedCxxPart
|
|
80
|
+
} else {
|
|
81
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridNitroCountryPickerSpec_(self.toUnsafe())
|
|
82
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridNitroCountryPickerSpec_(newCxxPart)
|
|
83
|
+
return newCxxPart
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
91
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
92
|
+
*/
|
|
93
|
+
@inline(__always)
|
|
94
|
+
public var memorySize: Int {
|
|
95
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Compares this object with the given [other] object for reference equality.
|
|
100
|
+
*/
|
|
101
|
+
@inline(__always)
|
|
102
|
+
public func equals(other: HybridNitroCountryPickerSpec_cxx) -> Bool {
|
|
103
|
+
return self.__implementation === other.__implementation
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Call dispose() on the Swift class.
|
|
108
|
+
* This _may_ be called manually from JS.
|
|
109
|
+
*/
|
|
110
|
+
@inline(__always)
|
|
111
|
+
public func dispose() {
|
|
112
|
+
self.__implementation.dispose()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Call toString() on the Swift class.
|
|
117
|
+
*/
|
|
118
|
+
@inline(__always)
|
|
119
|
+
public func toString() -> String {
|
|
120
|
+
return self.__implementation.toString()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Properties
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
// Methods
|
|
127
|
+
@inline(__always)
|
|
128
|
+
public final func pickCountry(options: bridge.std__optional_PickCountryOptions_) -> bridge.Result_std__shared_ptr_Promise_std__variant_nitro__NullType__IPickedCountry____ {
|
|
129
|
+
do {
|
|
130
|
+
let __result = try self.__implementation.pickCountry(options: options.value)
|
|
131
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_Promise_std__variant_nitro__NullType__IPickedCountry___ in
|
|
132
|
+
let __promise = bridge.create_std__shared_ptr_Promise_std__variant_nitro__NullType__IPickedCountry___()
|
|
133
|
+
let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_std__variant_nitro__NullType__IPickedCountry___(__promise)
|
|
134
|
+
__result
|
|
135
|
+
.then({ __result in __promiseHolder.resolve({ () -> bridge.std__variant_nitro__NullType__IPickedCountry_ in
|
|
136
|
+
switch __result {
|
|
137
|
+
case .first(let __value):
|
|
138
|
+
return bridge.create_std__variant_nitro__NullType__IPickedCountry_(margelo.nitro.NullType.null)
|
|
139
|
+
case .second(let __value):
|
|
140
|
+
return bridge.create_std__variant_nitro__NullType__IPickedCountry_(__value)
|
|
141
|
+
}
|
|
142
|
+
}().variant) })
|
|
143
|
+
.catch({ __error in __promiseHolder.reject(__error.toCpp()) })
|
|
144
|
+
return __promise
|
|
145
|
+
}()
|
|
146
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__IPickedCountry____(__resultCpp)
|
|
147
|
+
} catch (let __error) {
|
|
148
|
+
let __exceptionPtr = __error.toCpp()
|
|
149
|
+
return bridge.create_Result_std__shared_ptr_Promise_std__variant_nitro__NullType__IPickedCountry____(__exceptionPtr)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
@inline(__always)
|
|
154
|
+
public final func getLastPickedCountry() -> bridge.Result_std__variant_nitro__NullType__IPickedCountry__ {
|
|
155
|
+
do {
|
|
156
|
+
let __result = try self.__implementation.getLastPickedCountry()
|
|
157
|
+
let __resultCpp = { () -> bridge.std__variant_nitro__NullType__IPickedCountry_ in
|
|
158
|
+
switch __result {
|
|
159
|
+
case .first(let __value):
|
|
160
|
+
return bridge.create_std__variant_nitro__NullType__IPickedCountry_(margelo.nitro.NullType.null)
|
|
161
|
+
case .second(let __value):
|
|
162
|
+
return bridge.create_std__variant_nitro__NullType__IPickedCountry_(__value)
|
|
163
|
+
}
|
|
164
|
+
}().variant
|
|
165
|
+
return bridge.create_Result_std__variant_nitro__NullType__IPickedCountry__(__resultCpp)
|
|
166
|
+
} catch (let __error) {
|
|
167
|
+
let __exceptionPtr = __error.toCpp()
|
|
168
|
+
return bridge.create_Result_std__variant_nitro__NullType__IPickedCountry__(__exceptionPtr)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IPickedCountry.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
|
+
* Represents an instance of `IPickedCountry`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias IPickedCountry = margelo.nitro.nitrocountrypicker.IPickedCountry
|
|
14
|
+
|
|
15
|
+
public extension IPickedCountry {
|
|
16
|
+
private typealias bridge = margelo.nitro.nitrocountrypicker.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `IPickedCountry`.
|
|
20
|
+
*/
|
|
21
|
+
init(name: String, dialCode: String, code: String) {
|
|
22
|
+
self.init(std.string(name), std.string(dialCode), std.string(code))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var name: String {
|
|
27
|
+
return String(self.__name)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var dialCode: String {
|
|
32
|
+
return String(self.__dialCode)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@inline(__always)
|
|
36
|
+
var code: String {
|
|
37
|
+
return String(self.__code)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PickCountryOptions.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
|
+
* Represents an instance of `PickCountryOptions`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias PickCountryOptions = margelo.nitro.nitrocountrypicker.PickCountryOptions
|
|
14
|
+
|
|
15
|
+
public extension PickCountryOptions {
|
|
16
|
+
private typealias bridge = margelo.nitro.nitrocountrypicker.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `PickCountryOptions`.
|
|
20
|
+
*/
|
|
21
|
+
init(headerTitle: String?) {
|
|
22
|
+
self.init({ () -> bridge.std__optional_std__string_ in
|
|
23
|
+
if let __unwrappedValue = headerTitle {
|
|
24
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}())
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@inline(__always)
|
|
32
|
+
var headerTitle: String? {
|
|
33
|
+
return { () -> String? in
|
|
34
|
+
if bridge.has_value_std__optional_std__string_(self.__headerTitle) {
|
|
35
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__headerTitle)
|
|
36
|
+
return String(__unwrapped)
|
|
37
|
+
} else {
|
|
38
|
+
return nil
|
|
39
|
+
}
|
|
40
|
+
}()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Variant_NullType_IPickedCountry.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
|
+
* An Swift enum with associated values representing a Variant/Union type.
|
|
12
|
+
* JS type: `null | struct`
|
|
13
|
+
*/
|
|
14
|
+
@frozen
|
|
15
|
+
public indirect enum Variant_NullType_IPickedCountry {
|
|
16
|
+
case first(NullType)
|
|
17
|
+
case second(IPickedCountry)
|
|
18
|
+
}
|