react-native-nitro-fetch 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/NitroFetch.podspec +30 -0
- package/README.md +134 -0
- package/android/CMakeLists.txt +70 -0
- package/android/build.gradle +131 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/nitrofetch/AutoPrefetcher.kt +91 -0
- package/android/src/main/java/com/margelo/nitro/nitrofetch/FetchCache.kt +48 -0
- package/android/src/main/java/com/margelo/nitro/nitrofetch/NitroFetch.kt +94 -0
- package/android/src/main/java/com/margelo/nitro/nitrofetch/NitroFetchClient.kt +256 -0
- package/android/src/main/java/com/margelo/nitro/nitrofetch/NitroFetchPackage.kt +22 -0
- package/ios/FetchCache.swift +56 -0
- package/ios/NitroAutoPrefetcher.swift +81 -0
- package/ios/NitroBootstrap.mm +27 -0
- package/ios/NitroFetch.swift +9 -0
- package/ios/NitroFetchClient.swift +205 -0
- package/lib/module/NitroFetch.nitro.js +7 -0
- package/lib/module/NitroFetch.nitro.js.map +1 -0
- package/lib/module/NitroInstances.js +6 -0
- package/lib/module/NitroInstances.js.map +1 -0
- package/lib/module/fetch.js +441 -0
- package/lib/module/fetch.js.map +1 -0
- package/lib/module/index.js +12 -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/NitroFetch.nitro.d.ts +39 -0
- package/lib/typescript/src/NitroFetch.nitro.d.ts.map +1 -0
- package/lib/typescript/src/NitroInstances.d.ts +3 -0
- package/lib/typescript/src/NitroInstances.d.ts.map +1 -0
- package/lib/typescript/src/fetch.d.ts +26 -0
- package/lib/typescript/src/fetch.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +21 -0
- package/nitrogen/generated/android/c++/JHybridNitroFetchClientSpec.cpp +96 -0
- package/nitrogen/generated/android/c++/JHybridNitroFetchClientSpec.hpp +65 -0
- package/nitrogen/generated/android/c++/JHybridNitroFetchSpec.cpp +49 -0
- package/nitrogen/generated/android/c++/JHybridNitroFetchSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JNitroHeader.hpp +57 -0
- package/nitrogen/generated/android/c++/JNitroRequest.hpp +103 -0
- package/nitrogen/generated/android/c++/JNitroRequestMethod.hpp +74 -0
- package/nitrogen/generated/android/c++/JNitroResponse.hpp +105 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/HybridNitroFetchClientSpec.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/HybridNitroFetchSpec.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroHeader.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroRequest.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroRequestMethod.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/NitroResponse.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrofetch/nitrofetchOnLoad.kt +35 -0
- package/nitrogen/generated/android/nitrofetch+autolinking.cmake +80 -0
- package/nitrogen/generated/android/nitrofetch+autolinking.gradle +27 -0
- package/nitrogen/generated/android/nitrofetchOnLoad.cpp +54 -0
- package/nitrogen/generated/android/nitrofetchOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/NitroFetch+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroFetch-Swift-Cxx-Bridge.cpp +73 -0
- package/nitrogen/generated/ios/NitroFetch-Swift-Cxx-Bridge.hpp +298 -0
- package/nitrogen/generated/ios/NitroFetch-Swift-Cxx-Umbrella.hpp +67 -0
- package/nitrogen/generated/ios/NitroFetchAutolinking.mm +41 -0
- package/nitrogen/generated/ios/NitroFetchAutolinking.swift +40 -0
- package/nitrogen/generated/ios/c++/HybridNitroFetchClientSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroFetchClientSpecSwift.hpp +101 -0
- package/nitrogen/generated/ios/c++/HybridNitroFetchSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroFetchSpecSwift.hpp +75 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_NitroResponse.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridNitroFetchClientSpec.swift +50 -0
- package/nitrogen/generated/ios/swift/HybridNitroFetchClientSpec_cxx.swift +149 -0
- package/nitrogen/generated/ios/swift/HybridNitroFetchSpec.swift +49 -0
- package/nitrogen/generated/ios/swift/HybridNitroFetchSpec_cxx.swift +126 -0
- package/nitrogen/generated/ios/swift/NitroHeader.swift +46 -0
- package/nitrogen/generated/ios/swift/NitroRequest.swift +199 -0
- package/nitrogen/generated/ios/swift/NitroRequestMethod.swift +60 -0
- package/nitrogen/generated/ios/swift/NitroResponse.swift +155 -0
- package/nitrogen/generated/shared/c++/HybridNitroFetchClientSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridNitroFetchClientSpec.hpp +68 -0
- package/nitrogen/generated/shared/c++/HybridNitroFetchSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridNitroFetchSpec.hpp +64 -0
- package/nitrogen/generated/shared/c++/NitroHeader.hpp +71 -0
- package/nitrogen/generated/shared/c++/NitroRequest.hpp +101 -0
- package/nitrogen/generated/shared/c++/NitroRequestMethod.hpp +96 -0
- package/nitrogen/generated/shared/c++/NitroResponse.hpp +102 -0
- package/package.json +177 -0
- package/src/NitroFetch.nitro.ts +57 -0
- package/src/NitroInstances.ts +8 -0
- package/src/fetch.ts +426 -0
- package/src/index.tsx +17 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroFetch-Swift-Cxx-Bridge.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
|
|
12
|
+
namespace NitroModules { class ArrayBufferHolder; }
|
|
13
|
+
// Forward declaration of `ArrayBuffer` to properly resolve imports.
|
|
14
|
+
namespace NitroModules { class ArrayBuffer; }
|
|
15
|
+
// Forward declaration of `HybridNitroFetchClientSpec` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrofetch { class HybridNitroFetchClientSpec; }
|
|
17
|
+
// Forward declaration of `HybridNitroFetchSpec` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::nitrofetch { class HybridNitroFetchSpec; }
|
|
19
|
+
// Forward declaration of `NitroHeader` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::nitrofetch { struct NitroHeader; }
|
|
21
|
+
// Forward declaration of `NitroRequestMethod` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::nitrofetch { enum class NitroRequestMethod; }
|
|
23
|
+
// Forward declaration of `NitroResponse` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::nitrofetch { struct NitroResponse; }
|
|
25
|
+
|
|
26
|
+
// Forward declarations of Swift defined types
|
|
27
|
+
// Forward declaration of `HybridNitroFetchClientSpec_cxx` to properly resolve imports.
|
|
28
|
+
namespace NitroFetch { class HybridNitroFetchClientSpec_cxx; }
|
|
29
|
+
// Forward declaration of `HybridNitroFetchSpec_cxx` to properly resolve imports.
|
|
30
|
+
namespace NitroFetch { class HybridNitroFetchSpec_cxx; }
|
|
31
|
+
|
|
32
|
+
// Include C++ defined types
|
|
33
|
+
#include "HybridNitroFetchClientSpec.hpp"
|
|
34
|
+
#include "HybridNitroFetchSpec.hpp"
|
|
35
|
+
#include "NitroHeader.hpp"
|
|
36
|
+
#include "NitroRequestMethod.hpp"
|
|
37
|
+
#include "NitroResponse.hpp"
|
|
38
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
39
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
40
|
+
#include <NitroModules/Promise.hpp>
|
|
41
|
+
#include <NitroModules/PromiseHolder.hpp>
|
|
42
|
+
#include <NitroModules/Result.hpp>
|
|
43
|
+
#include <exception>
|
|
44
|
+
#include <functional>
|
|
45
|
+
#include <memory>
|
|
46
|
+
#include <optional>
|
|
47
|
+
#include <string>
|
|
48
|
+
#include <vector>
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
52
|
+
* as well as helper functions to interact with those C++ types from Swift.
|
|
53
|
+
*/
|
|
54
|
+
namespace margelo::nitro::nitrofetch::bridge::swift {
|
|
55
|
+
|
|
56
|
+
// pragma MARK: std::vector<NitroHeader>
|
|
57
|
+
/**
|
|
58
|
+
* Specialized version of `std::vector<NitroHeader>`.
|
|
59
|
+
*/
|
|
60
|
+
using std__vector_NitroHeader_ = std::vector<NitroHeader>;
|
|
61
|
+
inline std::vector<NitroHeader> create_std__vector_NitroHeader_(size_t size) noexcept {
|
|
62
|
+
std::vector<NitroHeader> vector;
|
|
63
|
+
vector.reserve(size);
|
|
64
|
+
return vector;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// pragma MARK: std::optional<std::string>
|
|
68
|
+
/**
|
|
69
|
+
* Specialized version of `std::optional<std::string>`.
|
|
70
|
+
*/
|
|
71
|
+
using std__optional_std__string_ = std::optional<std::string>;
|
|
72
|
+
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
|
|
73
|
+
return std::optional<std::string>(value);
|
|
74
|
+
}
|
|
75
|
+
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
76
|
+
return optional.has_value();
|
|
77
|
+
}
|
|
78
|
+
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
79
|
+
return *optional;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// pragma MARK: std::optional<std::shared_ptr<ArrayBuffer>>
|
|
83
|
+
/**
|
|
84
|
+
* Specialized version of `std::optional<std::shared_ptr<ArrayBuffer>>`.
|
|
85
|
+
*/
|
|
86
|
+
using std__optional_std__shared_ptr_ArrayBuffer__ = std::optional<std::shared_ptr<ArrayBuffer>>;
|
|
87
|
+
inline std::optional<std::shared_ptr<ArrayBuffer>> create_std__optional_std__shared_ptr_ArrayBuffer__(const std::shared_ptr<ArrayBuffer>& value) noexcept {
|
|
88
|
+
return std::optional<std::shared_ptr<ArrayBuffer>>(value);
|
|
89
|
+
}
|
|
90
|
+
inline bool has_value_std__optional_std__shared_ptr_ArrayBuffer__(const std::optional<std::shared_ptr<ArrayBuffer>>& optional) noexcept {
|
|
91
|
+
return optional.has_value();
|
|
92
|
+
}
|
|
93
|
+
inline std::shared_ptr<ArrayBuffer> get_std__optional_std__shared_ptr_ArrayBuffer__(const std::optional<std::shared_ptr<ArrayBuffer>>& optional) noexcept {
|
|
94
|
+
return *optional;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// pragma MARK: std::shared_ptr<Promise<NitroResponse>>
|
|
98
|
+
/**
|
|
99
|
+
* Specialized version of `std::shared_ptr<Promise<NitroResponse>>`.
|
|
100
|
+
*/
|
|
101
|
+
using std__shared_ptr_Promise_NitroResponse__ = std::shared_ptr<Promise<NitroResponse>>;
|
|
102
|
+
inline std::shared_ptr<Promise<NitroResponse>> create_std__shared_ptr_Promise_NitroResponse__() noexcept {
|
|
103
|
+
return Promise<NitroResponse>::create();
|
|
104
|
+
}
|
|
105
|
+
inline PromiseHolder<NitroResponse> wrap_std__shared_ptr_Promise_NitroResponse__(std::shared_ptr<Promise<NitroResponse>> promise) noexcept {
|
|
106
|
+
return PromiseHolder<NitroResponse>(std::move(promise));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// pragma MARK: std::function<void(const NitroResponse& /* result */)>
|
|
110
|
+
/**
|
|
111
|
+
* Specialized version of `std::function<void(const NitroResponse&)>`.
|
|
112
|
+
*/
|
|
113
|
+
using Func_void_NitroResponse = std::function<void(const NitroResponse& /* result */)>;
|
|
114
|
+
/**
|
|
115
|
+
* Wrapper class for a `std::function<void(const NitroResponse& / * result * /)>`, this can be used from Swift.
|
|
116
|
+
*/
|
|
117
|
+
class Func_void_NitroResponse_Wrapper final {
|
|
118
|
+
public:
|
|
119
|
+
explicit Func_void_NitroResponse_Wrapper(std::function<void(const NitroResponse& /* result */)>&& func): _function(std::make_unique<std::function<void(const NitroResponse& /* result */)>>(std::move(func))) {}
|
|
120
|
+
inline void call(NitroResponse result) const noexcept {
|
|
121
|
+
_function->operator()(result);
|
|
122
|
+
}
|
|
123
|
+
private:
|
|
124
|
+
std::unique_ptr<std::function<void(const NitroResponse& /* result */)>> _function;
|
|
125
|
+
} SWIFT_NONCOPYABLE;
|
|
126
|
+
Func_void_NitroResponse create_Func_void_NitroResponse(void* _Nonnull swiftClosureWrapper) noexcept;
|
|
127
|
+
inline Func_void_NitroResponse_Wrapper wrap_Func_void_NitroResponse(Func_void_NitroResponse value) noexcept {
|
|
128
|
+
return Func_void_NitroResponse_Wrapper(std::move(value));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
|
|
132
|
+
/**
|
|
133
|
+
* Specialized version of `std::function<void(const std::exception_ptr&)>`.
|
|
134
|
+
*/
|
|
135
|
+
using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
|
|
136
|
+
/**
|
|
137
|
+
* Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
|
|
138
|
+
*/
|
|
139
|
+
class Func_void_std__exception_ptr_Wrapper final {
|
|
140
|
+
public:
|
|
141
|
+
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))) {}
|
|
142
|
+
inline void call(std::exception_ptr error) const noexcept {
|
|
143
|
+
_function->operator()(error);
|
|
144
|
+
}
|
|
145
|
+
private:
|
|
146
|
+
std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
|
|
147
|
+
} SWIFT_NONCOPYABLE;
|
|
148
|
+
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* _Nonnull swiftClosureWrapper) noexcept;
|
|
149
|
+
inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
|
|
150
|
+
return Func_void_std__exception_ptr_Wrapper(std::move(value));
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// pragma MARK: std::optional<NitroRequestMethod>
|
|
154
|
+
/**
|
|
155
|
+
* Specialized version of `std::optional<NitroRequestMethod>`.
|
|
156
|
+
*/
|
|
157
|
+
using std__optional_NitroRequestMethod_ = std::optional<NitroRequestMethod>;
|
|
158
|
+
inline std::optional<NitroRequestMethod> create_std__optional_NitroRequestMethod_(const NitroRequestMethod& value) noexcept {
|
|
159
|
+
return std::optional<NitroRequestMethod>(value);
|
|
160
|
+
}
|
|
161
|
+
inline bool has_value_std__optional_NitroRequestMethod_(const std::optional<NitroRequestMethod>& optional) noexcept {
|
|
162
|
+
return optional.has_value();
|
|
163
|
+
}
|
|
164
|
+
inline NitroRequestMethod get_std__optional_NitroRequestMethod_(const std::optional<NitroRequestMethod>& optional) noexcept {
|
|
165
|
+
return *optional;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// pragma MARK: std::optional<std::vector<NitroHeader>>
|
|
169
|
+
/**
|
|
170
|
+
* Specialized version of `std::optional<std::vector<NitroHeader>>`.
|
|
171
|
+
*/
|
|
172
|
+
using std__optional_std__vector_NitroHeader__ = std::optional<std::vector<NitroHeader>>;
|
|
173
|
+
inline std::optional<std::vector<NitroHeader>> create_std__optional_std__vector_NitroHeader__(const std::vector<NitroHeader>& value) noexcept {
|
|
174
|
+
return std::optional<std::vector<NitroHeader>>(value);
|
|
175
|
+
}
|
|
176
|
+
inline bool has_value_std__optional_std__vector_NitroHeader__(const std::optional<std::vector<NitroHeader>>& optional) noexcept {
|
|
177
|
+
return optional.has_value();
|
|
178
|
+
}
|
|
179
|
+
inline std::vector<NitroHeader> get_std__optional_std__vector_NitroHeader__(const std::optional<std::vector<NitroHeader>>& optional) noexcept {
|
|
180
|
+
return *optional;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// pragma MARK: std::optional<double>
|
|
184
|
+
/**
|
|
185
|
+
* Specialized version of `std::optional<double>`.
|
|
186
|
+
*/
|
|
187
|
+
using std__optional_double_ = std::optional<double>;
|
|
188
|
+
inline std::optional<double> create_std__optional_double_(const double& value) noexcept {
|
|
189
|
+
return std::optional<double>(value);
|
|
190
|
+
}
|
|
191
|
+
inline bool has_value_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
192
|
+
return optional.has_value();
|
|
193
|
+
}
|
|
194
|
+
inline double get_std__optional_double_(const std::optional<double>& optional) noexcept {
|
|
195
|
+
return *optional;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// pragma MARK: std::optional<bool>
|
|
199
|
+
/**
|
|
200
|
+
* Specialized version of `std::optional<bool>`.
|
|
201
|
+
*/
|
|
202
|
+
using std__optional_bool_ = std::optional<bool>;
|
|
203
|
+
inline std::optional<bool> create_std__optional_bool_(const bool& value) noexcept {
|
|
204
|
+
return std::optional<bool>(value);
|
|
205
|
+
}
|
|
206
|
+
inline bool has_value_std__optional_bool_(const std::optional<bool>& optional) noexcept {
|
|
207
|
+
return optional.has_value();
|
|
208
|
+
}
|
|
209
|
+
inline bool get_std__optional_bool_(const std::optional<bool>& optional) noexcept {
|
|
210
|
+
return *optional;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// pragma MARK: std::shared_ptr<Promise<void>>
|
|
214
|
+
/**
|
|
215
|
+
* Specialized version of `std::shared_ptr<Promise<void>>`.
|
|
216
|
+
*/
|
|
217
|
+
using std__shared_ptr_Promise_void__ = std::shared_ptr<Promise<void>>;
|
|
218
|
+
inline std::shared_ptr<Promise<void>> create_std__shared_ptr_Promise_void__() noexcept {
|
|
219
|
+
return Promise<void>::create();
|
|
220
|
+
}
|
|
221
|
+
inline PromiseHolder<void> wrap_std__shared_ptr_Promise_void__(std::shared_ptr<Promise<void>> promise) noexcept {
|
|
222
|
+
return PromiseHolder<void>(std::move(promise));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// pragma MARK: std::function<void()>
|
|
226
|
+
/**
|
|
227
|
+
* Specialized version of `std::function<void()>`.
|
|
228
|
+
*/
|
|
229
|
+
using Func_void = std::function<void()>;
|
|
230
|
+
/**
|
|
231
|
+
* Wrapper class for a `std::function<void()>`, this can be used from Swift.
|
|
232
|
+
*/
|
|
233
|
+
class Func_void_Wrapper final {
|
|
234
|
+
public:
|
|
235
|
+
explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
|
|
236
|
+
inline void call() const noexcept {
|
|
237
|
+
_function->operator()();
|
|
238
|
+
}
|
|
239
|
+
private:
|
|
240
|
+
std::unique_ptr<std::function<void()>> _function;
|
|
241
|
+
} SWIFT_NONCOPYABLE;
|
|
242
|
+
Func_void create_Func_void(void* _Nonnull swiftClosureWrapper) noexcept;
|
|
243
|
+
inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
|
|
244
|
+
return Func_void_Wrapper(std::move(value));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// pragma MARK: std::shared_ptr<HybridNitroFetchClientSpec>
|
|
248
|
+
/**
|
|
249
|
+
* Specialized version of `std::shared_ptr<HybridNitroFetchClientSpec>`.
|
|
250
|
+
*/
|
|
251
|
+
using std__shared_ptr_HybridNitroFetchClientSpec_ = std::shared_ptr<HybridNitroFetchClientSpec>;
|
|
252
|
+
std::shared_ptr<HybridNitroFetchClientSpec> create_std__shared_ptr_HybridNitroFetchClientSpec_(void* _Nonnull swiftUnsafePointer) noexcept;
|
|
253
|
+
void* _Nonnull get_std__shared_ptr_HybridNitroFetchClientSpec_(std__shared_ptr_HybridNitroFetchClientSpec_ cppType) noexcept;
|
|
254
|
+
|
|
255
|
+
// pragma MARK: std::weak_ptr<HybridNitroFetchClientSpec>
|
|
256
|
+
using std__weak_ptr_HybridNitroFetchClientSpec_ = std::weak_ptr<HybridNitroFetchClientSpec>;
|
|
257
|
+
inline std__weak_ptr_HybridNitroFetchClientSpec_ weakify_std__shared_ptr_HybridNitroFetchClientSpec_(const std::shared_ptr<HybridNitroFetchClientSpec>& strong) noexcept { return strong; }
|
|
258
|
+
|
|
259
|
+
// pragma MARK: Result<std::shared_ptr<Promise<NitroResponse>>>
|
|
260
|
+
using Result_std__shared_ptr_Promise_NitroResponse___ = Result<std::shared_ptr<Promise<NitroResponse>>>;
|
|
261
|
+
inline Result_std__shared_ptr_Promise_NitroResponse___ create_Result_std__shared_ptr_Promise_NitroResponse___(const std::shared_ptr<Promise<NitroResponse>>& value) noexcept {
|
|
262
|
+
return Result<std::shared_ptr<Promise<NitroResponse>>>::withValue(value);
|
|
263
|
+
}
|
|
264
|
+
inline Result_std__shared_ptr_Promise_NitroResponse___ create_Result_std__shared_ptr_Promise_NitroResponse___(const std::exception_ptr& error) noexcept {
|
|
265
|
+
return Result<std::shared_ptr<Promise<NitroResponse>>>::withError(error);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// pragma MARK: Result<std::shared_ptr<Promise<void>>>
|
|
269
|
+
using Result_std__shared_ptr_Promise_void___ = Result<std::shared_ptr<Promise<void>>>;
|
|
270
|
+
inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::shared_ptr<Promise<void>>& value) noexcept {
|
|
271
|
+
return Result<std::shared_ptr<Promise<void>>>::withValue(value);
|
|
272
|
+
}
|
|
273
|
+
inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
|
|
274
|
+
return Result<std::shared_ptr<Promise<void>>>::withError(error);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// pragma MARK: std::shared_ptr<HybridNitroFetchSpec>
|
|
278
|
+
/**
|
|
279
|
+
* Specialized version of `std::shared_ptr<HybridNitroFetchSpec>`.
|
|
280
|
+
*/
|
|
281
|
+
using std__shared_ptr_HybridNitroFetchSpec_ = std::shared_ptr<HybridNitroFetchSpec>;
|
|
282
|
+
std::shared_ptr<HybridNitroFetchSpec> create_std__shared_ptr_HybridNitroFetchSpec_(void* _Nonnull swiftUnsafePointer) noexcept;
|
|
283
|
+
void* _Nonnull get_std__shared_ptr_HybridNitroFetchSpec_(std__shared_ptr_HybridNitroFetchSpec_ cppType) noexcept;
|
|
284
|
+
|
|
285
|
+
// pragma MARK: std::weak_ptr<HybridNitroFetchSpec>
|
|
286
|
+
using std__weak_ptr_HybridNitroFetchSpec_ = std::weak_ptr<HybridNitroFetchSpec>;
|
|
287
|
+
inline std__weak_ptr_HybridNitroFetchSpec_ weakify_std__shared_ptr_HybridNitroFetchSpec_(const std::shared_ptr<HybridNitroFetchSpec>& strong) noexcept { return strong; }
|
|
288
|
+
|
|
289
|
+
// pragma MARK: Result<std::shared_ptr<HybridNitroFetchClientSpec>>
|
|
290
|
+
using Result_std__shared_ptr_HybridNitroFetchClientSpec__ = Result<std::shared_ptr<HybridNitroFetchClientSpec>>;
|
|
291
|
+
inline Result_std__shared_ptr_HybridNitroFetchClientSpec__ create_Result_std__shared_ptr_HybridNitroFetchClientSpec__(const std::shared_ptr<HybridNitroFetchClientSpec>& value) noexcept {
|
|
292
|
+
return Result<std::shared_ptr<HybridNitroFetchClientSpec>>::withValue(value);
|
|
293
|
+
}
|
|
294
|
+
inline Result_std__shared_ptr_HybridNitroFetchClientSpec__ create_Result_std__shared_ptr_HybridNitroFetchClientSpec__(const std::exception_ptr& error) noexcept {
|
|
295
|
+
return Result<std::shared_ptr<HybridNitroFetchClientSpec>>::withError(error);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
} // namespace margelo::nitro::nitrofetch::bridge::swift
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroFetch-Swift-Cxx-Umbrella.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `ArrayBuffer` to properly resolve imports.
|
|
12
|
+
namespace NitroModules { class ArrayBuffer; }
|
|
13
|
+
// Forward declaration of `HybridNitroFetchClientSpec` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::nitrofetch { class HybridNitroFetchClientSpec; }
|
|
15
|
+
// Forward declaration of `HybridNitroFetchSpec` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrofetch { class HybridNitroFetchSpec; }
|
|
17
|
+
// Forward declaration of `NitroHeader` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::nitrofetch { struct NitroHeader; }
|
|
19
|
+
// Forward declaration of `NitroRequestMethod` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::nitrofetch { enum class NitroRequestMethod; }
|
|
21
|
+
// Forward declaration of `NitroRequest` to properly resolve imports.
|
|
22
|
+
namespace margelo::nitro::nitrofetch { struct NitroRequest; }
|
|
23
|
+
// Forward declaration of `NitroResponse` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::nitrofetch { struct NitroResponse; }
|
|
25
|
+
|
|
26
|
+
// Include C++ defined types
|
|
27
|
+
#include "HybridNitroFetchClientSpec.hpp"
|
|
28
|
+
#include "HybridNitroFetchSpec.hpp"
|
|
29
|
+
#include "NitroHeader.hpp"
|
|
30
|
+
#include "NitroRequest.hpp"
|
|
31
|
+
#include "NitroRequestMethod.hpp"
|
|
32
|
+
#include "NitroResponse.hpp"
|
|
33
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
34
|
+
#include <NitroModules/Promise.hpp>
|
|
35
|
+
#include <NitroModules/Result.hpp>
|
|
36
|
+
#include <exception>
|
|
37
|
+
#include <memory>
|
|
38
|
+
#include <optional>
|
|
39
|
+
#include <string>
|
|
40
|
+
#include <vector>
|
|
41
|
+
|
|
42
|
+
// C++ helpers for Swift
|
|
43
|
+
#include "NitroFetch-Swift-Cxx-Bridge.hpp"
|
|
44
|
+
|
|
45
|
+
// Common C++ types used in Swift
|
|
46
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
47
|
+
#include <NitroModules/AnyMapUtils.hpp>
|
|
48
|
+
#include <NitroModules/RuntimeError.hpp>
|
|
49
|
+
#include <NitroModules/DateToChronoDate.hpp>
|
|
50
|
+
|
|
51
|
+
// Forward declarations of Swift defined types
|
|
52
|
+
// Forward declaration of `HybridNitroFetchClientSpec_cxx` to properly resolve imports.
|
|
53
|
+
namespace NitroFetch { class HybridNitroFetchClientSpec_cxx; }
|
|
54
|
+
// Forward declaration of `HybridNitroFetchSpec_cxx` to properly resolve imports.
|
|
55
|
+
namespace NitroFetch { class HybridNitroFetchSpec_cxx; }
|
|
56
|
+
|
|
57
|
+
// Include Swift defined types
|
|
58
|
+
#if __has_include("NitroFetch-Swift.h")
|
|
59
|
+
// This header is generated by Xcode/Swift on every app build.
|
|
60
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroFetch".
|
|
61
|
+
#include "NitroFetch-Swift.h"
|
|
62
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
63
|
+
#elif __has_include(<NitroFetch/NitroFetch-Swift.h>)
|
|
64
|
+
#include <NitroFetch/NitroFetch-Swift.h>
|
|
65
|
+
#else
|
|
66
|
+
#error NitroFetch's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroFetch", and try building the app first.
|
|
67
|
+
#endif
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroFetchAutolinking.mm
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
+
#import "NitroFetch-Swift-Cxx-Umbrella.hpp"
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridNitroFetchSpecSwift.hpp"
|
|
14
|
+
#include "HybridNitroFetchClientSpecSwift.hpp"
|
|
15
|
+
|
|
16
|
+
@interface NitroFetchAutolinking : NSObject
|
|
17
|
+
@end
|
|
18
|
+
|
|
19
|
+
@implementation NitroFetchAutolinking
|
|
20
|
+
|
|
21
|
+
+ (void) load {
|
|
22
|
+
using namespace margelo::nitro;
|
|
23
|
+
using namespace margelo::nitro::nitrofetch;
|
|
24
|
+
|
|
25
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
26
|
+
"NitroFetch",
|
|
27
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
28
|
+
std::shared_ptr<HybridNitroFetchSpec> hybridObject = NitroFetch::NitroFetchAutolinking::createNitroFetch();
|
|
29
|
+
return hybridObject;
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
33
|
+
"NitroFetchClient",
|
|
34
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
35
|
+
std::shared_ptr<HybridNitroFetchClientSpec> hybridObject = NitroFetch::NitroFetchAutolinking::createNitroFetchClient();
|
|
36
|
+
return hybridObject;
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroFetchAutolinking.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
public final class NitroFetchAutolinking {
|
|
9
|
+
public typealias bridge = margelo.nitro.nitrofetch.bridge.swift
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of a Swift class that implements `HybridNitroFetchSpec`,
|
|
13
|
+
* and wraps it in a Swift class that can directly interop with C++ (`HybridNitroFetchSpec_cxx`)
|
|
14
|
+
*
|
|
15
|
+
* This is generated by Nitrogen and will initialize the class specified
|
|
16
|
+
* in the `"autolinking"` property of `nitro.json` (in this case, `NitroFetch`).
|
|
17
|
+
*/
|
|
18
|
+
public static func createNitroFetch() -> bridge.std__shared_ptr_HybridNitroFetchSpec_ {
|
|
19
|
+
let hybridObject = NitroFetch()
|
|
20
|
+
return { () -> bridge.std__shared_ptr_HybridNitroFetchSpec_ in
|
|
21
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
22
|
+
return __cxxWrapped.getCxxPart()
|
|
23
|
+
}()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Creates an instance of a Swift class that implements `HybridNitroFetchClientSpec`,
|
|
28
|
+
* and wraps it in a Swift class that can directly interop with C++ (`HybridNitroFetchClientSpec_cxx`)
|
|
29
|
+
*
|
|
30
|
+
* This is generated by Nitrogen and will initialize the class specified
|
|
31
|
+
* in the `"autolinking"` property of `nitro.json` (in this case, `NitroFetchClient`).
|
|
32
|
+
*/
|
|
33
|
+
public static func createNitroFetchClient() -> bridge.std__shared_ptr_HybridNitroFetchClientSpec_ {
|
|
34
|
+
let hybridObject = NitroFetchClient()
|
|
35
|
+
return { () -> bridge.std__shared_ptr_HybridNitroFetchClientSpec_ in
|
|
36
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
37
|
+
return __cxxWrapped.getCxxPart()
|
|
38
|
+
}()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroFetchClientSpecSwift.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridNitroFetchClientSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitrofetch {
|
|
11
|
+
} // namespace margelo::nitro::nitrofetch
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroFetchClientSpecSwift.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "HybridNitroFetchClientSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridNitroFetchClientSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroFetch { class HybridNitroFetchClientSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `NitroResponse` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrofetch { struct NitroResponse; }
|
|
17
|
+
// Forward declaration of `NitroHeader` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::nitrofetch { struct NitroHeader; }
|
|
19
|
+
// Forward declaration of `ArrayBuffer` to properly resolve imports.
|
|
20
|
+
namespace NitroModules { class ArrayBuffer; }
|
|
21
|
+
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
|
|
22
|
+
namespace NitroModules { class ArrayBufferHolder; }
|
|
23
|
+
// Forward declaration of `NitroRequest` to properly resolve imports.
|
|
24
|
+
namespace margelo::nitro::nitrofetch { struct NitroRequest; }
|
|
25
|
+
// Forward declaration of `NitroRequestMethod` to properly resolve imports.
|
|
26
|
+
namespace margelo::nitro::nitrofetch { enum class NitroRequestMethod; }
|
|
27
|
+
|
|
28
|
+
#include "NitroResponse.hpp"
|
|
29
|
+
#include <NitroModules/Promise.hpp>
|
|
30
|
+
#include <string>
|
|
31
|
+
#include "NitroHeader.hpp"
|
|
32
|
+
#include <vector>
|
|
33
|
+
#include <optional>
|
|
34
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
35
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
36
|
+
#include "NitroRequest.hpp"
|
|
37
|
+
#include "NitroRequestMethod.hpp"
|
|
38
|
+
|
|
39
|
+
#include "NitroFetch-Swift-Cxx-Umbrella.hpp"
|
|
40
|
+
|
|
41
|
+
namespace margelo::nitro::nitrofetch {
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The C++ part of HybridNitroFetchClientSpec_cxx.swift.
|
|
45
|
+
*
|
|
46
|
+
* HybridNitroFetchClientSpecSwift (C++) accesses HybridNitroFetchClientSpec_cxx (Swift), and might
|
|
47
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
48
|
+
*
|
|
49
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
50
|
+
* the future, HybridNitroFetchClientSpec_cxx can directly inherit from the C++ class HybridNitroFetchClientSpec
|
|
51
|
+
* to simplify the whole structure and memory management.
|
|
52
|
+
*/
|
|
53
|
+
class HybridNitroFetchClientSpecSwift: public virtual HybridNitroFetchClientSpec {
|
|
54
|
+
public:
|
|
55
|
+
// Constructor from a Swift instance
|
|
56
|
+
explicit HybridNitroFetchClientSpecSwift(const NitroFetch::HybridNitroFetchClientSpec_cxx& swiftPart):
|
|
57
|
+
HybridObject(HybridNitroFetchClientSpec::TAG),
|
|
58
|
+
_swiftPart(swiftPart) { }
|
|
59
|
+
|
|
60
|
+
public:
|
|
61
|
+
// Get the Swift part
|
|
62
|
+
inline NitroFetch::HybridNitroFetchClientSpec_cxx& getSwiftPart() noexcept {
|
|
63
|
+
return _swiftPart;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public:
|
|
67
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
68
|
+
return _swiftPart.getMemorySize();
|
|
69
|
+
}
|
|
70
|
+
void dispose() noexcept override {
|
|
71
|
+
_swiftPart.dispose();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public:
|
|
75
|
+
// Properties
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
public:
|
|
79
|
+
// Methods
|
|
80
|
+
inline std::shared_ptr<Promise<NitroResponse>> request(const NitroRequest& req) override {
|
|
81
|
+
auto __result = _swiftPart.request(req);
|
|
82
|
+
if (__result.hasError()) [[unlikely]] {
|
|
83
|
+
std::rethrow_exception(__result.error());
|
|
84
|
+
}
|
|
85
|
+
auto __value = std::move(__result.value());
|
|
86
|
+
return __value;
|
|
87
|
+
}
|
|
88
|
+
inline std::shared_ptr<Promise<void>> prefetch(const NitroRequest& req) override {
|
|
89
|
+
auto __result = _swiftPart.prefetch(req);
|
|
90
|
+
if (__result.hasError()) [[unlikely]] {
|
|
91
|
+
std::rethrow_exception(__result.error());
|
|
92
|
+
}
|
|
93
|
+
auto __value = std::move(__result.value());
|
|
94
|
+
return __value;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private:
|
|
98
|
+
NitroFetch::HybridNitroFetchClientSpec_cxx _swiftPart;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
} // namespace margelo::nitro::nitrofetch
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroFetchSpecSwift.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridNitroFetchSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitrofetch {
|
|
11
|
+
} // namespace margelo::nitro::nitrofetch
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroFetchSpecSwift.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "HybridNitroFetchSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridNitroFetchSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroFetch { class HybridNitroFetchSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `HybridNitroFetchClientSpec` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::nitrofetch { class HybridNitroFetchClientSpec; }
|
|
17
|
+
|
|
18
|
+
#include <memory>
|
|
19
|
+
#include "HybridNitroFetchClientSpec.hpp"
|
|
20
|
+
|
|
21
|
+
#include "NitroFetch-Swift-Cxx-Umbrella.hpp"
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::nitrofetch {
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The C++ part of HybridNitroFetchSpec_cxx.swift.
|
|
27
|
+
*
|
|
28
|
+
* HybridNitroFetchSpecSwift (C++) accesses HybridNitroFetchSpec_cxx (Swift), and might
|
|
29
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
30
|
+
*
|
|
31
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
32
|
+
* the future, HybridNitroFetchSpec_cxx can directly inherit from the C++ class HybridNitroFetchSpec
|
|
33
|
+
* to simplify the whole structure and memory management.
|
|
34
|
+
*/
|
|
35
|
+
class HybridNitroFetchSpecSwift: public virtual HybridNitroFetchSpec {
|
|
36
|
+
public:
|
|
37
|
+
// Constructor from a Swift instance
|
|
38
|
+
explicit HybridNitroFetchSpecSwift(const NitroFetch::HybridNitroFetchSpec_cxx& swiftPart):
|
|
39
|
+
HybridObject(HybridNitroFetchSpec::TAG),
|
|
40
|
+
_swiftPart(swiftPart) { }
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
// Get the Swift part
|
|
44
|
+
inline NitroFetch::HybridNitroFetchSpec_cxx& getSwiftPart() noexcept {
|
|
45
|
+
return _swiftPart;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
50
|
+
return _swiftPart.getMemorySize();
|
|
51
|
+
}
|
|
52
|
+
void dispose() noexcept override {
|
|
53
|
+
_swiftPart.dispose();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public:
|
|
57
|
+
// Properties
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
public:
|
|
61
|
+
// Methods
|
|
62
|
+
inline std::shared_ptr<HybridNitroFetchClientSpec> createClient() override {
|
|
63
|
+
auto __result = _swiftPart.createClient();
|
|
64
|
+
if (__result.hasError()) [[unlikely]] {
|
|
65
|
+
std::rethrow_exception(__result.error());
|
|
66
|
+
}
|
|
67
|
+
auto __value = std::move(__result.value());
|
|
68
|
+
return __value;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private:
|
|
72
|
+
NitroFetch::HybridNitroFetchSpec_cxx _swiftPart;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro::nitrofetch
|