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,195 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// RustCUdp-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 `HybridUdpDriverSpec` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::udp { class HybridUdpDriverSpec; }
|
|
15
|
+
// Forward declaration of `HybridUdpSocketDriverSpec` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::udp { class HybridUdpSocketDriverSpec; }
|
|
17
|
+
|
|
18
|
+
// Forward declarations of Swift defined types
|
|
19
|
+
// Forward declaration of `HybridUdpDriverSpec_cxx` to properly resolve imports.
|
|
20
|
+
namespace RustCUdp { class HybridUdpDriverSpec_cxx; }
|
|
21
|
+
// Forward declaration of `HybridUdpSocketDriverSpec_cxx` to properly resolve imports.
|
|
22
|
+
namespace RustCUdp { class HybridUdpSocketDriverSpec_cxx; }
|
|
23
|
+
|
|
24
|
+
// Include C++ defined types
|
|
25
|
+
#include "HybridUdpDriverSpec.hpp"
|
|
26
|
+
#include "HybridUdpSocketDriverSpec.hpp"
|
|
27
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
28
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
29
|
+
#include <NitroModules/Result.hpp>
|
|
30
|
+
#include <exception>
|
|
31
|
+
#include <functional>
|
|
32
|
+
#include <memory>
|
|
33
|
+
#include <optional>
|
|
34
|
+
#include <string>
|
|
35
|
+
#include <vector>
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
39
|
+
* as well as helper functions to interact with those C++ types from Swift.
|
|
40
|
+
*/
|
|
41
|
+
namespace margelo::nitro::udp::bridge::swift {
|
|
42
|
+
|
|
43
|
+
// pragma MARK: std::vector<std::shared_ptr<ArrayBuffer>>
|
|
44
|
+
/**
|
|
45
|
+
* Specialized version of `std::vector<std::shared_ptr<ArrayBuffer>>`.
|
|
46
|
+
*/
|
|
47
|
+
using std__vector_std__shared_ptr_ArrayBuffer__ = std::vector<std::shared_ptr<ArrayBuffer>>;
|
|
48
|
+
inline std::vector<std::shared_ptr<ArrayBuffer>> create_std__vector_std__shared_ptr_ArrayBuffer__(size_t size) noexcept {
|
|
49
|
+
std::vector<std::shared_ptr<ArrayBuffer>> vector;
|
|
50
|
+
vector.reserve(size);
|
|
51
|
+
return vector;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// pragma MARK: std::optional<std::string>
|
|
55
|
+
/**
|
|
56
|
+
* Specialized version of `std::optional<std::string>`.
|
|
57
|
+
*/
|
|
58
|
+
using std__optional_std__string_ = std::optional<std::string>;
|
|
59
|
+
inline std::optional<std::string> create_std__optional_std__string_(const std::string& value) noexcept {
|
|
60
|
+
return std::optional<std::string>(value);
|
|
61
|
+
}
|
|
62
|
+
inline bool has_value_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
63
|
+
return optional.has_value();
|
|
64
|
+
}
|
|
65
|
+
inline std::string get_std__optional_std__string_(const std::optional<std::string>& optional) noexcept {
|
|
66
|
+
return *optional;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// pragma MARK: std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* address */, double /* port */)>
|
|
70
|
+
/**
|
|
71
|
+
* Specialized version of `std::function<void(const std::shared_ptr<ArrayBuffer>&, const std::string&, double)>`.
|
|
72
|
+
*/
|
|
73
|
+
using Func_void_std__shared_ptr_ArrayBuffer__std__string_double = std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* address */, double /* port */)>;
|
|
74
|
+
/**
|
|
75
|
+
* Wrapper class for a `std::function<void(const std::shared_ptr<ArrayBuffer>& / * data * /, const std::string& / * address * /, double / * port * /)>`, this can be used from Swift.
|
|
76
|
+
*/
|
|
77
|
+
class Func_void_std__shared_ptr_ArrayBuffer__std__string_double_Wrapper final {
|
|
78
|
+
public:
|
|
79
|
+
explicit Func_void_std__shared_ptr_ArrayBuffer__std__string_double_Wrapper(std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* address */, double /* port */)>&& func): _function(std::make_unique<std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* address */, double /* port */)>>(std::move(func))) {}
|
|
80
|
+
inline void call(ArrayBufferHolder data, std::string address, double port) const noexcept {
|
|
81
|
+
_function->operator()(data.getArrayBuffer(), address, port);
|
|
82
|
+
}
|
|
83
|
+
private:
|
|
84
|
+
std::unique_ptr<std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* address */, double /* port */)>> _function;
|
|
85
|
+
} SWIFT_NONCOPYABLE;
|
|
86
|
+
Func_void_std__shared_ptr_ArrayBuffer__std__string_double create_Func_void_std__shared_ptr_ArrayBuffer__std__string_double(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
87
|
+
inline Func_void_std__shared_ptr_ArrayBuffer__std__string_double_Wrapper wrap_Func_void_std__shared_ptr_ArrayBuffer__std__string_double(Func_void_std__shared_ptr_ArrayBuffer__std__string_double value) noexcept {
|
|
88
|
+
return Func_void_std__shared_ptr_ArrayBuffer__std__string_double_Wrapper(std::move(value));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// pragma MARK: std::function<void()>
|
|
92
|
+
/**
|
|
93
|
+
* Specialized version of `std::function<void()>`.
|
|
94
|
+
*/
|
|
95
|
+
using Func_void = std::function<void()>;
|
|
96
|
+
/**
|
|
97
|
+
* Wrapper class for a `std::function<void()>`, this can be used from Swift.
|
|
98
|
+
*/
|
|
99
|
+
class Func_void_Wrapper final {
|
|
100
|
+
public:
|
|
101
|
+
explicit Func_void_Wrapper(std::function<void()>&& func): _function(std::make_unique<std::function<void()>>(std::move(func))) {}
|
|
102
|
+
inline void call() const noexcept {
|
|
103
|
+
_function->operator()();
|
|
104
|
+
}
|
|
105
|
+
private:
|
|
106
|
+
std::unique_ptr<std::function<void()>> _function;
|
|
107
|
+
} SWIFT_NONCOPYABLE;
|
|
108
|
+
Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
109
|
+
inline Func_void_Wrapper wrap_Func_void(Func_void value) noexcept {
|
|
110
|
+
return Func_void_Wrapper(std::move(value));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// pragma MARK: std::function<void(const std::string& /* error */)>
|
|
114
|
+
/**
|
|
115
|
+
* Specialized version of `std::function<void(const std::string&)>`.
|
|
116
|
+
*/
|
|
117
|
+
using Func_void_std__string = std::function<void(const std::string& /* error */)>;
|
|
118
|
+
/**
|
|
119
|
+
* Wrapper class for a `std::function<void(const std::string& / * error * /)>`, this can be used from Swift.
|
|
120
|
+
*/
|
|
121
|
+
class Func_void_std__string_Wrapper final {
|
|
122
|
+
public:
|
|
123
|
+
explicit Func_void_std__string_Wrapper(std::function<void(const std::string& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::string& /* error */)>>(std::move(func))) {}
|
|
124
|
+
inline void call(std::string error) const noexcept {
|
|
125
|
+
_function->operator()(error);
|
|
126
|
+
}
|
|
127
|
+
private:
|
|
128
|
+
std::unique_ptr<std::function<void(const std::string& /* error */)>> _function;
|
|
129
|
+
} SWIFT_NONCOPYABLE;
|
|
130
|
+
Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
131
|
+
inline Func_void_std__string_Wrapper wrap_Func_void_std__string(Func_void_std__string value) noexcept {
|
|
132
|
+
return Func_void_std__string_Wrapper(std::move(value));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// pragma MARK: std::shared_ptr<HybridUdpSocketDriverSpec>
|
|
136
|
+
/**
|
|
137
|
+
* Specialized version of `std::shared_ptr<HybridUdpSocketDriverSpec>`.
|
|
138
|
+
*/
|
|
139
|
+
using std__shared_ptr_HybridUdpSocketDriverSpec_ = std::shared_ptr<HybridUdpSocketDriverSpec>;
|
|
140
|
+
std::shared_ptr<HybridUdpSocketDriverSpec> create_std__shared_ptr_HybridUdpSocketDriverSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
141
|
+
void* NON_NULL get_std__shared_ptr_HybridUdpSocketDriverSpec_(std__shared_ptr_HybridUdpSocketDriverSpec_ cppType);
|
|
142
|
+
|
|
143
|
+
// pragma MARK: std::weak_ptr<HybridUdpSocketDriverSpec>
|
|
144
|
+
using std__weak_ptr_HybridUdpSocketDriverSpec_ = std::weak_ptr<HybridUdpSocketDriverSpec>;
|
|
145
|
+
inline std__weak_ptr_HybridUdpSocketDriverSpec_ weakify_std__shared_ptr_HybridUdpSocketDriverSpec_(const std::shared_ptr<HybridUdpSocketDriverSpec>& strong) noexcept { return strong; }
|
|
146
|
+
|
|
147
|
+
// pragma MARK: Result<double>
|
|
148
|
+
using Result_double_ = Result<double>;
|
|
149
|
+
inline Result_double_ create_Result_double_(double value) noexcept {
|
|
150
|
+
return Result<double>::withValue(std::move(value));
|
|
151
|
+
}
|
|
152
|
+
inline Result_double_ create_Result_double_(const std::exception_ptr& error) noexcept {
|
|
153
|
+
return Result<double>::withError(error);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// pragma MARK: Result<void>
|
|
157
|
+
using Result_void_ = Result<void>;
|
|
158
|
+
inline Result_void_ create_Result_void_() noexcept {
|
|
159
|
+
return Result<void>::withValue();
|
|
160
|
+
}
|
|
161
|
+
inline Result_void_ create_Result_void_(const std::exception_ptr& error) noexcept {
|
|
162
|
+
return Result<void>::withError(error);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// pragma MARK: Result<std::string>
|
|
166
|
+
using Result_std__string_ = Result<std::string>;
|
|
167
|
+
inline Result_std__string_ create_Result_std__string_(const std::string& value) noexcept {
|
|
168
|
+
return Result<std::string>::withValue(value);
|
|
169
|
+
}
|
|
170
|
+
inline Result_std__string_ create_Result_std__string_(const std::exception_ptr& error) noexcept {
|
|
171
|
+
return Result<std::string>::withError(error);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// pragma MARK: std::shared_ptr<HybridUdpDriverSpec>
|
|
175
|
+
/**
|
|
176
|
+
* Specialized version of `std::shared_ptr<HybridUdpDriverSpec>`.
|
|
177
|
+
*/
|
|
178
|
+
using std__shared_ptr_HybridUdpDriverSpec_ = std::shared_ptr<HybridUdpDriverSpec>;
|
|
179
|
+
std::shared_ptr<HybridUdpDriverSpec> create_std__shared_ptr_HybridUdpDriverSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
180
|
+
void* NON_NULL get_std__shared_ptr_HybridUdpDriverSpec_(std__shared_ptr_HybridUdpDriverSpec_ cppType);
|
|
181
|
+
|
|
182
|
+
// pragma MARK: std::weak_ptr<HybridUdpDriverSpec>
|
|
183
|
+
using std__weak_ptr_HybridUdpDriverSpec_ = std::weak_ptr<HybridUdpDriverSpec>;
|
|
184
|
+
inline std__weak_ptr_HybridUdpDriverSpec_ weakify_std__shared_ptr_HybridUdpDriverSpec_(const std::shared_ptr<HybridUdpDriverSpec>& strong) noexcept { return strong; }
|
|
185
|
+
|
|
186
|
+
// pragma MARK: Result<std::shared_ptr<HybridUdpSocketDriverSpec>>
|
|
187
|
+
using Result_std__shared_ptr_HybridUdpSocketDriverSpec__ = Result<std::shared_ptr<HybridUdpSocketDriverSpec>>;
|
|
188
|
+
inline Result_std__shared_ptr_HybridUdpSocketDriverSpec__ create_Result_std__shared_ptr_HybridUdpSocketDriverSpec__(const std::shared_ptr<HybridUdpSocketDriverSpec>& value) noexcept {
|
|
189
|
+
return Result<std::shared_ptr<HybridUdpSocketDriverSpec>>::withValue(value);
|
|
190
|
+
}
|
|
191
|
+
inline Result_std__shared_ptr_HybridUdpSocketDriverSpec__ create_Result_std__shared_ptr_HybridUdpSocketDriverSpec__(const std::exception_ptr& error) noexcept {
|
|
192
|
+
return Result<std::shared_ptr<HybridUdpSocketDriverSpec>>::withError(error);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
} // namespace margelo::nitro::udp::bridge::swift
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// RustCUdp-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 `HybridUdpDriverSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::udp { class HybridUdpDriverSpec; }
|
|
13
|
+
// Forward declaration of `HybridUdpSocketDriverSpec` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::udp { class HybridUdpSocketDriverSpec; }
|
|
15
|
+
|
|
16
|
+
// Include C++ defined types
|
|
17
|
+
#include "HybridUdpDriverSpec.hpp"
|
|
18
|
+
#include "HybridUdpSocketDriverSpec.hpp"
|
|
19
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
20
|
+
#include <NitroModules/Result.hpp>
|
|
21
|
+
#include <exception>
|
|
22
|
+
#include <functional>
|
|
23
|
+
#include <memory>
|
|
24
|
+
#include <optional>
|
|
25
|
+
#include <string>
|
|
26
|
+
#include <vector>
|
|
27
|
+
|
|
28
|
+
// C++ helpers for Swift
|
|
29
|
+
#include "RustCUdp-Swift-Cxx-Bridge.hpp"
|
|
30
|
+
|
|
31
|
+
// Common C++ types used in Swift
|
|
32
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
33
|
+
#include <NitroModules/AnyMapUtils.hpp>
|
|
34
|
+
#include <NitroModules/RuntimeError.hpp>
|
|
35
|
+
#include <NitroModules/DateToChronoDate.hpp>
|
|
36
|
+
|
|
37
|
+
// Forward declarations of Swift defined types
|
|
38
|
+
// Forward declaration of `HybridUdpDriverSpec_cxx` to properly resolve imports.
|
|
39
|
+
namespace RustCUdp { class HybridUdpDriverSpec_cxx; }
|
|
40
|
+
// Forward declaration of `HybridUdpSocketDriverSpec_cxx` to properly resolve imports.
|
|
41
|
+
namespace RustCUdp { class HybridUdpSocketDriverSpec_cxx; }
|
|
42
|
+
|
|
43
|
+
// Include Swift defined types
|
|
44
|
+
#if __has_include("RustCUdp-Swift.h")
|
|
45
|
+
// This header is generated by Xcode/Swift on every app build.
|
|
46
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "RustCUdp".
|
|
47
|
+
#include "RustCUdp-Swift.h"
|
|
48
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
49
|
+
#elif __has_include(<RustCUdp/RustCUdp-Swift.h>)
|
|
50
|
+
#include <RustCUdp/RustCUdp-Swift.h>
|
|
51
|
+
#else
|
|
52
|
+
#error RustCUdp's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "RustCUdp", and try building the app first.
|
|
53
|
+
#endif
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// RustCUdpAutolinking.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
|
+
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridUdpDriver.hpp"
|
|
14
|
+
|
|
15
|
+
@interface RustCUdpAutolinking : NSObject
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation RustCUdpAutolinking
|
|
19
|
+
|
|
20
|
+
+ (void) load {
|
|
21
|
+
using namespace margelo::nitro;
|
|
22
|
+
using namespace margelo::nitro::udp;
|
|
23
|
+
|
|
24
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
+
"UdpDriver",
|
|
26
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
+
static_assert(std::is_default_constructible_v<HybridUdpDriver>,
|
|
28
|
+
"The HybridObject \"HybridUdpDriver\" is not default-constructible! "
|
|
29
|
+
"Create a public constructor that takes zero arguments to be able to autolink this HybridObject.");
|
|
30
|
+
return std::make_shared<HybridUdpDriver>();
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// RustCUdpAutolinking.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 RustCUdpAutolinking {
|
|
9
|
+
public typealias bridge = margelo.nitro.udp.bridge.swift
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUdpDriverSpecSwift.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 "HybridUdpDriverSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::udp {
|
|
11
|
+
} // namespace margelo::nitro::udp
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUdpDriverSpecSwift.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 "HybridUdpDriverSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridUdpDriverSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace RustCUdp { class HybridUdpDriverSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `HybridUdpSocketDriverSpec` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::udp { class HybridUdpSocketDriverSpec; }
|
|
17
|
+
|
|
18
|
+
#include <memory>
|
|
19
|
+
#include "HybridUdpSocketDriverSpec.hpp"
|
|
20
|
+
#include <string>
|
|
21
|
+
#include <optional>
|
|
22
|
+
|
|
23
|
+
#include "RustCUdp-Swift-Cxx-Umbrella.hpp"
|
|
24
|
+
|
|
25
|
+
namespace margelo::nitro::udp {
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The C++ part of HybridUdpDriverSpec_cxx.swift.
|
|
29
|
+
*
|
|
30
|
+
* HybridUdpDriverSpecSwift (C++) accesses HybridUdpDriverSpec_cxx (Swift), and might
|
|
31
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
32
|
+
*
|
|
33
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
34
|
+
* the future, HybridUdpDriverSpec_cxx can directly inherit from the C++ class HybridUdpDriverSpec
|
|
35
|
+
* to simplify the whole structure and memory management.
|
|
36
|
+
*/
|
|
37
|
+
class HybridUdpDriverSpecSwift: public virtual HybridUdpDriverSpec {
|
|
38
|
+
public:
|
|
39
|
+
// Constructor from a Swift instance
|
|
40
|
+
explicit HybridUdpDriverSpecSwift(const RustCUdp::HybridUdpDriverSpec_cxx& swiftPart):
|
|
41
|
+
HybridObject(HybridUdpDriverSpec::TAG),
|
|
42
|
+
_swiftPart(swiftPart) { }
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
// Get the Swift part
|
|
46
|
+
inline RustCUdp::HybridUdpDriverSpec_cxx& getSwiftPart() noexcept {
|
|
47
|
+
return _swiftPart;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
52
|
+
return _swiftPart.getMemorySize();
|
|
53
|
+
}
|
|
54
|
+
void dispose() noexcept override {
|
|
55
|
+
_swiftPart.dispose();
|
|
56
|
+
}
|
|
57
|
+
std::string toString() override {
|
|
58
|
+
return _swiftPart.toString();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
// Properties
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
public:
|
|
66
|
+
// Methods
|
|
67
|
+
inline std::shared_ptr<HybridUdpSocketDriverSpec> createSocket(const std::optional<std::string>& id) override {
|
|
68
|
+
auto __result = _swiftPart.createSocket(id);
|
|
69
|
+
if (__result.hasError()) [[unlikely]] {
|
|
70
|
+
std::rethrow_exception(__result.error());
|
|
71
|
+
}
|
|
72
|
+
auto __value = std::move(__result.value());
|
|
73
|
+
return __value;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private:
|
|
77
|
+
RustCUdp::HybridUdpDriverSpec_cxx _swiftPart;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro::udp
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridUdpSocketDriverSpecSwift.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 "HybridUdpSocketDriverSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::udp {
|
|
11
|
+
} // namespace margelo::nitro::udp
|