react-native-nitro-dgram 0.1.4
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/android/CMakeLists.txt +24 -0
- package/android/OnLoad.cpp +6 -0
- package/android/build.gradle +64 -0
- package/android/libs/arm64-v8a/librust_c_udp.so +0 -0
- package/android/libs/armeabi-v7a/librust_c_udp.so +0 -0
- package/android/libs/x86/librust_c_udp.so +0 -0
- package/android/libs/x86_64/librust_c_udp.so +0 -0
- package/android/src/main/java/com/margelo/nitro/udp/NitroUdpPackage.java +25 -0
- package/cpp/HybridUdpDriver.cpp +21 -0
- package/cpp/HybridUdpDriver.hpp +18 -0
- package/cpp/HybridUdpSocketDriver.cpp +252 -0
- package/cpp/HybridUdpSocketDriver.hpp +88 -0
- package/cpp/UdpBindings.hpp +83 -0
- package/cpp/UdpManager.hpp +108 -0
- package/ios/Frameworks/RustCUdp.xcframework/Info.plist +44 -0
- package/ios/Frameworks/RustCUdp.xcframework/ios-arm64/RustCUdp.framework/Info.plist +20 -0
- package/ios/Frameworks/RustCUdp.xcframework/ios-arm64/RustCUdp.framework/RustCUdp +0 -0
- package/ios/Frameworks/RustCUdp.xcframework/ios-arm64_x86_64-simulator/RustCUdp.framework/Info.plist +20 -0
- package/ios/Frameworks/RustCUdp.xcframework/ios-arm64_x86_64-simulator/RustCUdp.framework/RustCUdp +0 -0
- package/lib/Driver.d.ts +2 -0
- package/lib/Driver.js +6 -0
- package/lib/Driver.js.map +1 -0
- package/lib/Udp.nitro.d.ts +54 -0
- package/lib/Udp.nitro.js +3 -0
- package/lib/Udp.nitro.js.map +1 -0
- package/lib/index.d.ts +82 -0
- package/lib/index.js +375 -0
- package/lib/index.js.map +1 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/RustCUdp+autolinking.cmake +84 -0
- package/nitrogen/generated/android/RustCUdp+autolinking.gradle +27 -0
- package/nitrogen/generated/android/RustCUdpOnLoad.cpp +53 -0
- package/nitrogen/generated/android/RustCUdpOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__shared_ptr_ArrayBuffer__std__string_double.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
- package/nitrogen/generated/android/c++/JHybridUdpDriverSpec.cpp +57 -0
- package/nitrogen/generated/android/c++/JHybridUdpDriverSpec.hpp +65 -0
- package/nitrogen/generated/android/c++/JHybridUdpSocketDriverSpec.cpp +261 -0
- package/nitrogen/generated/android/c++/JHybridUdpSocketDriverSpec.hpp +97 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/udp/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/udp/Func_void_std__shared_ptr_ArrayBuffer__std__string_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/udp/Func_void_std__string.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/udp/HybridUdpDriverSpec.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/udp/HybridUdpSocketDriverSpec.kt +212 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/udp/RustCUdpOnLoad.kt +35 -0
- package/nitrogen/generated/ios/RustCUdp+autolinking.rb +60 -0
- package/nitrogen/generated/ios/RustCUdp-Swift-Cxx-Bridge.cpp +74 -0
- package/nitrogen/generated/ios/RustCUdp-Swift-Cxx-Bridge.hpp +195 -0
- package/nitrogen/generated/ios/RustCUdp-Swift-Cxx-Umbrella.hpp +53 -0
- package/nitrogen/generated/ios/RustCUdpAutolinking.mm +35 -0
- package/nitrogen/generated/ios/RustCUdpAutolinking.swift +12 -0
- package/nitrogen/generated/ios/c++/HybridUdpDriverSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridUdpDriverSpecSwift.hpp +80 -0
- package/nitrogen/generated/ios/c++/HybridUdpSocketDriverSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridUdpSocketDriverSpecSwift.hpp +302 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_ArrayBuffer__std__string_double.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridUdpDriverSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridUdpDriverSpec_cxx.swift +141 -0
- package/nitrogen/generated/ios/swift/HybridUdpSocketDriverSpec.swift +84 -0
- package/nitrogen/generated/ios/swift/HybridUdpSocketDriverSpec_cxx.swift +527 -0
- package/nitrogen/generated/shared/c++/HybridNitroBufferSpec.cpp +32 -0
- package/nitrogen/generated/shared/c++/HybridNitroBufferSpec.hpp +74 -0
- package/nitrogen/generated/shared/c++/HybridUdpDriverSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridUdpDriverSpec.hpp +66 -0
- package/nitrogen/generated/shared/c++/HybridUdpSocketDriverSpec.cpp +54 -0
- package/nitrogen/generated/shared/c++/HybridUdpSocketDriverSpec.hpp +98 -0
- package/package.json +59 -0
- package/react-native-nitro-dgram.podspec +45 -0
- package/src/Driver.ts +4 -0
- package/src/Udp.nitro.ts +55 -0
- package/src/index.ts +414 -0
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUdpSocketDriverSpecSwift.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 "HybridUdpSocketDriverSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridUdpSocketDriverSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace RustCUdp { class HybridUdpSocketDriverSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
|
|
16
|
+
namespace NitroModules { class ArrayBufferHolder; }
|
|
17
|
+
|
|
18
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
19
|
+
#include <string>
|
|
20
|
+
#include <functional>
|
|
21
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
22
|
+
#include <vector>
|
|
23
|
+
#include <optional>
|
|
24
|
+
|
|
25
|
+
#include "RustCUdp-Swift-Cxx-Umbrella.hpp"
|
|
26
|
+
|
|
27
|
+
namespace margelo::nitro::udp {
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The C++ part of HybridUdpSocketDriverSpec_cxx.swift.
|
|
31
|
+
*
|
|
32
|
+
* HybridUdpSocketDriverSpecSwift (C++) accesses HybridUdpSocketDriverSpec_cxx (Swift), and might
|
|
33
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
34
|
+
*
|
|
35
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
36
|
+
* the future, HybridUdpSocketDriverSpec_cxx can directly inherit from the C++ class HybridUdpSocketDriverSpec
|
|
37
|
+
* to simplify the whole structure and memory management.
|
|
38
|
+
*/
|
|
39
|
+
class HybridUdpSocketDriverSpecSwift: public virtual HybridUdpSocketDriverSpec {
|
|
40
|
+
public:
|
|
41
|
+
// Constructor from a Swift instance
|
|
42
|
+
explicit HybridUdpSocketDriverSpecSwift(const RustCUdp::HybridUdpSocketDriverSpec_cxx& swiftPart):
|
|
43
|
+
HybridObject(HybridUdpSocketDriverSpec::TAG),
|
|
44
|
+
_swiftPart(swiftPart) { }
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
// Get the Swift part
|
|
48
|
+
inline RustCUdp::HybridUdpSocketDriverSpec_cxx& getSwiftPart() noexcept {
|
|
49
|
+
return _swiftPart;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
54
|
+
return _swiftPart.getMemorySize();
|
|
55
|
+
}
|
|
56
|
+
void dispose() noexcept override {
|
|
57
|
+
_swiftPart.dispose();
|
|
58
|
+
}
|
|
59
|
+
std::string toString() override {
|
|
60
|
+
return _swiftPart.toString();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public:
|
|
64
|
+
// Properties
|
|
65
|
+
inline double getId() noexcept override {
|
|
66
|
+
return _swiftPart.getId();
|
|
67
|
+
}
|
|
68
|
+
inline std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* address */, double /* port */)> getOnMessage() noexcept override {
|
|
69
|
+
auto __result = _swiftPart.getOnMessage();
|
|
70
|
+
return __result;
|
|
71
|
+
}
|
|
72
|
+
inline void setOnMessage(const std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* address */, double /* port */)>& onMessage) noexcept override {
|
|
73
|
+
_swiftPart.setOnMessage(onMessage);
|
|
74
|
+
}
|
|
75
|
+
inline std::function<void()> getOnConnect() noexcept override {
|
|
76
|
+
auto __result = _swiftPart.getOnConnect();
|
|
77
|
+
return __result;
|
|
78
|
+
}
|
|
79
|
+
inline void setOnConnect(const std::function<void()>& onConnect) noexcept override {
|
|
80
|
+
_swiftPart.setOnConnect(onConnect);
|
|
81
|
+
}
|
|
82
|
+
inline std::function<void(const std::string& /* error */)> getOnError() noexcept override {
|
|
83
|
+
auto __result = _swiftPart.getOnError();
|
|
84
|
+
return __result;
|
|
85
|
+
}
|
|
86
|
+
inline void setOnError(const std::function<void(const std::string& /* error */)>& onError) noexcept override {
|
|
87
|
+
_swiftPart.setOnError(onError);
|
|
88
|
+
}
|
|
89
|
+
inline std::function<void()> getOnClose() noexcept override {
|
|
90
|
+
auto __result = _swiftPart.getOnClose();
|
|
91
|
+
return __result;
|
|
92
|
+
}
|
|
93
|
+
inline void setOnClose(const std::function<void()>& onClose) noexcept override {
|
|
94
|
+
_swiftPart.setOnClose(onClose);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public:
|
|
98
|
+
// Methods
|
|
99
|
+
inline double bind(double port, const std::string& address, bool ipv6Only) override {
|
|
100
|
+
auto __result = _swiftPart.bind(std::forward<decltype(port)>(port), address, std::forward<decltype(ipv6Only)>(ipv6Only));
|
|
101
|
+
if (__result.hasError()) [[unlikely]] {
|
|
102
|
+
std::rethrow_exception(__result.error());
|
|
103
|
+
}
|
|
104
|
+
auto __value = std::move(__result.value());
|
|
105
|
+
return __value;
|
|
106
|
+
}
|
|
107
|
+
inline double connect(double port, const std::string& address) override {
|
|
108
|
+
auto __result = _swiftPart.connect(std::forward<decltype(port)>(port), address);
|
|
109
|
+
if (__result.hasError()) [[unlikely]] {
|
|
110
|
+
std::rethrow_exception(__result.error());
|
|
111
|
+
}
|
|
112
|
+
auto __value = std::move(__result.value());
|
|
113
|
+
return __value;
|
|
114
|
+
}
|
|
115
|
+
inline double disconnect() override {
|
|
116
|
+
auto __result = _swiftPart.disconnect();
|
|
117
|
+
if (__result.hasError()) [[unlikely]] {
|
|
118
|
+
std::rethrow_exception(__result.error());
|
|
119
|
+
}
|
|
120
|
+
auto __value = std::move(__result.value());
|
|
121
|
+
return __value;
|
|
122
|
+
}
|
|
123
|
+
inline double send(const std::shared_ptr<ArrayBuffer>& data, double port, const std::string& address) override {
|
|
124
|
+
auto __result = _swiftPart.send(ArrayBufferHolder(data), std::forward<decltype(port)>(port), address);
|
|
125
|
+
if (__result.hasError()) [[unlikely]] {
|
|
126
|
+
std::rethrow_exception(__result.error());
|
|
127
|
+
}
|
|
128
|
+
auto __value = std::move(__result.value());
|
|
129
|
+
return __value;
|
|
130
|
+
}
|
|
131
|
+
inline double sendMultiple(const std::vector<std::shared_ptr<ArrayBuffer>>& data, double port, const std::string& address) override {
|
|
132
|
+
auto __result = _swiftPart.sendMultiple(data, std::forward<decltype(port)>(port), address);
|
|
133
|
+
if (__result.hasError()) [[unlikely]] {
|
|
134
|
+
std::rethrow_exception(__result.error());
|
|
135
|
+
}
|
|
136
|
+
auto __value = std::move(__result.value());
|
|
137
|
+
return __value;
|
|
138
|
+
}
|
|
139
|
+
inline void close() override {
|
|
140
|
+
auto __result = _swiftPart.close();
|
|
141
|
+
if (__result.hasError()) [[unlikely]] {
|
|
142
|
+
std::rethrow_exception(__result.error());
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
inline double setBroadcast(bool flag) override {
|
|
146
|
+
auto __result = _swiftPart.setBroadcast(std::forward<decltype(flag)>(flag));
|
|
147
|
+
if (__result.hasError()) [[unlikely]] {
|
|
148
|
+
std::rethrow_exception(__result.error());
|
|
149
|
+
}
|
|
150
|
+
auto __value = std::move(__result.value());
|
|
151
|
+
return __value;
|
|
152
|
+
}
|
|
153
|
+
inline double setTTL(double ttl) override {
|
|
154
|
+
auto __result = _swiftPart.setTTL(std::forward<decltype(ttl)>(ttl));
|
|
155
|
+
if (__result.hasError()) [[unlikely]] {
|
|
156
|
+
std::rethrow_exception(__result.error());
|
|
157
|
+
}
|
|
158
|
+
auto __value = std::move(__result.value());
|
|
159
|
+
return __value;
|
|
160
|
+
}
|
|
161
|
+
inline double setMulticastTTL(double ttl) override {
|
|
162
|
+
auto __result = _swiftPart.setMulticastTTL(std::forward<decltype(ttl)>(ttl));
|
|
163
|
+
if (__result.hasError()) [[unlikely]] {
|
|
164
|
+
std::rethrow_exception(__result.error());
|
|
165
|
+
}
|
|
166
|
+
auto __value = std::move(__result.value());
|
|
167
|
+
return __value;
|
|
168
|
+
}
|
|
169
|
+
inline double setMulticastLoopback(bool flag) override {
|
|
170
|
+
auto __result = _swiftPart.setMulticastLoopback(std::forward<decltype(flag)>(flag));
|
|
171
|
+
if (__result.hasError()) [[unlikely]] {
|
|
172
|
+
std::rethrow_exception(__result.error());
|
|
173
|
+
}
|
|
174
|
+
auto __value = std::move(__result.value());
|
|
175
|
+
return __value;
|
|
176
|
+
}
|
|
177
|
+
inline double setMulticastInterface(const std::string& interfaceAddress) override {
|
|
178
|
+
auto __result = _swiftPart.setMulticastInterface(interfaceAddress);
|
|
179
|
+
if (__result.hasError()) [[unlikely]] {
|
|
180
|
+
std::rethrow_exception(__result.error());
|
|
181
|
+
}
|
|
182
|
+
auto __value = std::move(__result.value());
|
|
183
|
+
return __value;
|
|
184
|
+
}
|
|
185
|
+
inline double addMembership(const std::string& multicastAddress, const std::optional<std::string>& interfaceAddress) override {
|
|
186
|
+
auto __result = _swiftPart.addMembership(multicastAddress, interfaceAddress);
|
|
187
|
+
if (__result.hasError()) [[unlikely]] {
|
|
188
|
+
std::rethrow_exception(__result.error());
|
|
189
|
+
}
|
|
190
|
+
auto __value = std::move(__result.value());
|
|
191
|
+
return __value;
|
|
192
|
+
}
|
|
193
|
+
inline double dropMembership(const std::string& multicastAddress, const std::optional<std::string>& interfaceAddress) override {
|
|
194
|
+
auto __result = _swiftPart.dropMembership(multicastAddress, interfaceAddress);
|
|
195
|
+
if (__result.hasError()) [[unlikely]] {
|
|
196
|
+
std::rethrow_exception(__result.error());
|
|
197
|
+
}
|
|
198
|
+
auto __value = std::move(__result.value());
|
|
199
|
+
return __value;
|
|
200
|
+
}
|
|
201
|
+
inline double addSourceSpecificMembership(const std::string& sourceAddress, const std::string& groupAddress, const std::optional<std::string>& interfaceAddress) override {
|
|
202
|
+
auto __result = _swiftPart.addSourceSpecificMembership(sourceAddress, groupAddress, interfaceAddress);
|
|
203
|
+
if (__result.hasError()) [[unlikely]] {
|
|
204
|
+
std::rethrow_exception(__result.error());
|
|
205
|
+
}
|
|
206
|
+
auto __value = std::move(__result.value());
|
|
207
|
+
return __value;
|
|
208
|
+
}
|
|
209
|
+
inline double dropSourceSpecificMembership(const std::string& sourceAddress, const std::string& groupAddress, const std::optional<std::string>& interfaceAddress) override {
|
|
210
|
+
auto __result = _swiftPart.dropSourceSpecificMembership(sourceAddress, groupAddress, interfaceAddress);
|
|
211
|
+
if (__result.hasError()) [[unlikely]] {
|
|
212
|
+
std::rethrow_exception(__result.error());
|
|
213
|
+
}
|
|
214
|
+
auto __value = std::move(__result.value());
|
|
215
|
+
return __value;
|
|
216
|
+
}
|
|
217
|
+
inline std::string getLocalAddress() override {
|
|
218
|
+
auto __result = _swiftPart.getLocalAddress();
|
|
219
|
+
if (__result.hasError()) [[unlikely]] {
|
|
220
|
+
std::rethrow_exception(__result.error());
|
|
221
|
+
}
|
|
222
|
+
auto __value = std::move(__result.value());
|
|
223
|
+
return __value;
|
|
224
|
+
}
|
|
225
|
+
inline double getLocalPort() override {
|
|
226
|
+
auto __result = _swiftPart.getLocalPort();
|
|
227
|
+
if (__result.hasError()) [[unlikely]] {
|
|
228
|
+
std::rethrow_exception(__result.error());
|
|
229
|
+
}
|
|
230
|
+
auto __value = std::move(__result.value());
|
|
231
|
+
return __value;
|
|
232
|
+
}
|
|
233
|
+
inline std::string getRemoteAddress() override {
|
|
234
|
+
auto __result = _swiftPart.getRemoteAddress();
|
|
235
|
+
if (__result.hasError()) [[unlikely]] {
|
|
236
|
+
std::rethrow_exception(__result.error());
|
|
237
|
+
}
|
|
238
|
+
auto __value = std::move(__result.value());
|
|
239
|
+
return __value;
|
|
240
|
+
}
|
|
241
|
+
inline double getRemotePort() override {
|
|
242
|
+
auto __result = _swiftPart.getRemotePort();
|
|
243
|
+
if (__result.hasError()) [[unlikely]] {
|
|
244
|
+
std::rethrow_exception(__result.error());
|
|
245
|
+
}
|
|
246
|
+
auto __value = std::move(__result.value());
|
|
247
|
+
return __value;
|
|
248
|
+
}
|
|
249
|
+
inline double getRecvBufferSize() override {
|
|
250
|
+
auto __result = _swiftPart.getRecvBufferSize();
|
|
251
|
+
if (__result.hasError()) [[unlikely]] {
|
|
252
|
+
std::rethrow_exception(__result.error());
|
|
253
|
+
}
|
|
254
|
+
auto __value = std::move(__result.value());
|
|
255
|
+
return __value;
|
|
256
|
+
}
|
|
257
|
+
inline double setRecvBufferSize(double size) override {
|
|
258
|
+
auto __result = _swiftPart.setRecvBufferSize(std::forward<decltype(size)>(size));
|
|
259
|
+
if (__result.hasError()) [[unlikely]] {
|
|
260
|
+
std::rethrow_exception(__result.error());
|
|
261
|
+
}
|
|
262
|
+
auto __value = std::move(__result.value());
|
|
263
|
+
return __value;
|
|
264
|
+
}
|
|
265
|
+
inline double getSendBufferSize() override {
|
|
266
|
+
auto __result = _swiftPart.getSendBufferSize();
|
|
267
|
+
if (__result.hasError()) [[unlikely]] {
|
|
268
|
+
std::rethrow_exception(__result.error());
|
|
269
|
+
}
|
|
270
|
+
auto __value = std::move(__result.value());
|
|
271
|
+
return __value;
|
|
272
|
+
}
|
|
273
|
+
inline double setSendBufferSize(double size) override {
|
|
274
|
+
auto __result = _swiftPart.setSendBufferSize(std::forward<decltype(size)>(size));
|
|
275
|
+
if (__result.hasError()) [[unlikely]] {
|
|
276
|
+
std::rethrow_exception(__result.error());
|
|
277
|
+
}
|
|
278
|
+
auto __value = std::move(__result.value());
|
|
279
|
+
return __value;
|
|
280
|
+
}
|
|
281
|
+
inline double getSendQueueCount() override {
|
|
282
|
+
auto __result = _swiftPart.getSendQueueCount();
|
|
283
|
+
if (__result.hasError()) [[unlikely]] {
|
|
284
|
+
std::rethrow_exception(__result.error());
|
|
285
|
+
}
|
|
286
|
+
auto __value = std::move(__result.value());
|
|
287
|
+
return __value;
|
|
288
|
+
}
|
|
289
|
+
inline double getSendQueueSize() override {
|
|
290
|
+
auto __result = _swiftPart.getSendQueueSize();
|
|
291
|
+
if (__result.hasError()) [[unlikely]] {
|
|
292
|
+
std::rethrow_exception(__result.error());
|
|
293
|
+
}
|
|
294
|
+
auto __value = std::move(__result.value());
|
|
295
|
+
return __value;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
private:
|
|
299
|
+
RustCUdp::HybridUdpSocketDriverSpec_cxx _swiftPart;
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
} // namespace margelo::nitro::udp
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `() -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void {
|
|
16
|
+
public typealias bridge = margelo.nitro.udp.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: () -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping () -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call() -> Void {
|
|
26
|
+
self.closure()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void {
|
|
45
|
+
return Unmanaged<Func_void>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_ArrayBuffer__std__string_double.swift
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__shared_ptr_ArrayBuffer__std__string_double.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ data: ArrayBuffer, _ address: String, _ port: Double) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__shared_ptr_ArrayBuffer__std__string_double {
|
|
16
|
+
public typealias bridge = margelo.nitro.udp.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ data: ArrayBuffer, _ address: String, _ port: Double) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ data: ArrayBuffer, _ address: String, _ port: Double) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(data: ArrayBuffer, address: std.string, port: Double) -> Void {
|
|
26
|
+
self.closure(data, String(address), port)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_std__shared_ptr_ArrayBuffer__std__string_double`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__shared_ptr_ArrayBuffer__std__string_double>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__shared_ptr_ArrayBuffer__std__string_double {
|
|
45
|
+
return Unmanaged<Func_void_std__shared_ptr_ArrayBuffer__std__string_double>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__string.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wraps a Swift `(_ error: String) -> Void` as a class.
|
|
13
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
14
|
+
*/
|
|
15
|
+
public final class Func_void_std__string {
|
|
16
|
+
public typealias bridge = margelo.nitro.udp.bridge.swift
|
|
17
|
+
|
|
18
|
+
private let closure: (_ error: String) -> Void
|
|
19
|
+
|
|
20
|
+
public init(_ closure: @escaping (_ error: String) -> Void) {
|
|
21
|
+
self.closure = closure
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@inline(__always)
|
|
25
|
+
public func call(error: std.string) -> Void {
|
|
26
|
+
self.closure(String(error))
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
31
|
+
* This acquires one additional strong reference on the object!
|
|
32
|
+
*/
|
|
33
|
+
@inline(__always)
|
|
34
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
35
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Casts an unsafe pointer to a `Func_void_std__string`.
|
|
40
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__string>`.
|
|
41
|
+
* This removes one strong reference from the object!
|
|
42
|
+
*/
|
|
43
|
+
@inline(__always)
|
|
44
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__string {
|
|
45
|
+
return Unmanaged<Func_void_std__string>.fromOpaque(pointer).takeRetainedValue()
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUdpDriverSpec.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridUdpDriverSpec``
|
|
12
|
+
public protocol HybridUdpDriverSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
func createSocket(id: String?) throws -> (any HybridUdpSocketDriverSpec)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public extension HybridUdpDriverSpec_protocol {
|
|
21
|
+
/// Default implementation of ``HybridObject.toString``
|
|
22
|
+
func toString() -> String {
|
|
23
|
+
return "[HybridObject UdpDriver]"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// See ``HybridUdpDriverSpec``
|
|
28
|
+
open class HybridUdpDriverSpec_base {
|
|
29
|
+
private weak var cxxWrapper: HybridUdpDriverSpec_cxx? = nil
|
|
30
|
+
public init() { }
|
|
31
|
+
public func getCxxWrapper() -> HybridUdpDriverSpec_cxx {
|
|
32
|
+
#if DEBUG
|
|
33
|
+
guard self is HybridUdpDriverSpec else {
|
|
34
|
+
fatalError("`self` is not a `HybridUdpDriverSpec`! Did you accidentally inherit from `HybridUdpDriverSpec_base` instead of `HybridUdpDriverSpec`?")
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
38
|
+
return cxxWrapper
|
|
39
|
+
} else {
|
|
40
|
+
let cxxWrapper = HybridUdpDriverSpec_cxx(self as! HybridUdpDriverSpec)
|
|
41
|
+
self.cxxWrapper = cxxWrapper
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A Swift base-protocol representing the UdpDriver HybridObject.
|
|
49
|
+
* Implement this protocol to create Swift-based instances of UdpDriver.
|
|
50
|
+
* ```swift
|
|
51
|
+
* class HybridUdpDriver : HybridUdpDriverSpec {
|
|
52
|
+
* // ...
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
public typealias HybridUdpDriverSpec = HybridUdpDriverSpec_protocol & HybridUdpDriverSpec_base
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUdpDriverSpec_cxx.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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class implementation that bridges HybridUdpDriverSpec over to C++.
|
|
13
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
14
|
+
*
|
|
15
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
16
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
17
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
18
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
19
|
+
*/
|
|
20
|
+
open class HybridUdpDriverSpec_cxx {
|
|
21
|
+
/**
|
|
22
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::udp::bridge::swift`)
|
|
23
|
+
* from `RustCUdp-Swift-Cxx-Bridge.hpp`.
|
|
24
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
25
|
+
*/
|
|
26
|
+
public typealias bridge = margelo.nitro.udp.bridge.swift
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Holds an instance of the `HybridUdpDriverSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridUdpDriverSpec
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
35
|
+
*/
|
|
36
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridUdpDriverSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridUdpDriverSpec_cxx` that wraps the given `HybridUdpDriverSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridUdpDriverSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridUdpDriverSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridUdpDriverSpec() -> any HybridUdpDriverSpec {
|
|
53
|
+
return __implementation
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
58
|
+
* This acquires one additional strong reference on the object!
|
|
59
|
+
*/
|
|
60
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
61
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Casts an unsafe pointer to a `HybridUdpDriverSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridUdpDriverSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridUdpDriverSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridUdpDriverSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
75
|
+
* The C++ part is a `std::shared_ptr<HybridUdpDriverSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridUdpDriverSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridUdpDriverSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridUdpDriverSpec_(newCxxPart)
|
|
84
|
+
return newCxxPart
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
92
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
93
|
+
*/
|
|
94
|
+
@inline(__always)
|
|
95
|
+
public var memorySize: Int {
|
|
96
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Call dispose() on the Swift class.
|
|
101
|
+
* This _may_ be called manually from JS.
|
|
102
|
+
*/
|
|
103
|
+
@inline(__always)
|
|
104
|
+
public func dispose() {
|
|
105
|
+
self.__implementation.dispose()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Call toString() on the Swift class.
|
|
110
|
+
*/
|
|
111
|
+
@inline(__always)
|
|
112
|
+
public func toString() -> String {
|
|
113
|
+
return self.__implementation.toString()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Properties
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
// Methods
|
|
120
|
+
@inline(__always)
|
|
121
|
+
public final func createSocket(id: bridge.std__optional_std__string_) -> bridge.Result_std__shared_ptr_HybridUdpSocketDriverSpec__ {
|
|
122
|
+
do {
|
|
123
|
+
let __result = try self.__implementation.createSocket(id: { () -> String? in
|
|
124
|
+
if bridge.has_value_std__optional_std__string_(id) {
|
|
125
|
+
let __unwrapped = bridge.get_std__optional_std__string_(id)
|
|
126
|
+
return String(__unwrapped)
|
|
127
|
+
} else {
|
|
128
|
+
return nil
|
|
129
|
+
}
|
|
130
|
+
}())
|
|
131
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_HybridUdpSocketDriverSpec_ in
|
|
132
|
+
let __cxxWrapped = __result.getCxxWrapper()
|
|
133
|
+
return __cxxWrapped.getCxxPart()
|
|
134
|
+
}()
|
|
135
|
+
return bridge.create_Result_std__shared_ptr_HybridUdpSocketDriverSpec__(__resultCpp)
|
|
136
|
+
} catch (let __error) {
|
|
137
|
+
let __exceptionPtr = __error.toCpp()
|
|
138
|
+
return bridge.create_Result_std__shared_ptr_HybridUdpSocketDriverSpec__(__exceptionPtr)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|