@ohah/hwpjs 0.1.0-rc.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/Hwpjs.podspec +27 -0
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/android/CMakeLists.txt +50 -0
- package/android/build.gradle +110 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/java/rs/craby/hwpjs/HwpjsPackage.kt +59 -0
- package/android/src/main/jni/OnLoad.cpp +22 -0
- package/android/src/main/jni/include/CrabySignals.h +53 -0
- package/android/src/main/jni/include/cxx.h +1150 -0
- package/android/src/main/jni/include/ffi.rs.h +1041 -0
- package/android/src/main/jni/libs/arm64-v8a/libhwpjs-prebuilt.a +0 -0
- package/android/src/main/jni/libs/arm64-v8a/libreactnative-prebuilt.a +0 -0
- package/android/src/main/jni/libs/armeabi-v7a/libhwpjs-prebuilt.a +0 -0
- package/android/src/main/jni/libs/armeabi-v7a/libreactnative-prebuilt.a +0 -0
- package/android/src/main/jni/libs/x86/libhwpjs-prebuilt.a +0 -0
- package/android/src/main/jni/libs/x86/libreactnative-prebuilt.a +0 -0
- package/android/src/main/jni/libs/x86_64/libhwpjs-prebuilt.a +0 -0
- package/android/src/main/jni/libs/x86_64/libreactnative-prebuilt.a +0 -0
- package/android/src/main/jni/src/ffi.rs.cc +1179 -0
- package/android/stubs/CMakeLists.txt +31 -0
- package/android/stubs/Hwpjs_stub.cpp +9 -0
- package/android/stubs/Hwpjs_stub.h +12 -0
- package/cpp/CrabyUtils.hpp +91 -0
- package/cpp/CxxHwpjsModule.cpp +125 -0
- package/cpp/CxxHwpjsModule.hpp +53 -0
- package/cpp/bridging-generated.hpp +158 -0
- package/dist/browser.js +1 -0
- package/dist/hwpjs-napi.wasi-browser.js +61 -0
- package/dist/hwpjs-napi.wasi.cjs +113 -0
- package/dist/hwpjs.wasi-browser.js +61 -0
- package/dist/hwpjs.wasi.cjs +113 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +577 -0
- package/dist/react-native/index.cjs +40 -0
- package/dist/react-native/index.cjs.map +1 -0
- package/dist/react-native/index.d.cts +22 -0
- package/dist/react-native/index.d.mts +22 -0
- package/dist/react-native/index.mjs +40 -0
- package/dist/react-native/index.mjs.map +1 -0
- package/dist/wasi-worker-browser.mjs +32 -0
- package/dist/wasi-worker.mjs +63 -0
- package/ios/HwpjsModuleProvider.mm +47 -0
- package/ios/framework/libhwpjs.xcframework/Info.plist +44 -0
- package/ios/framework/libhwpjs.xcframework/ios-arm64/libhwpjs-prebuilt.a +0 -0
- package/ios/framework/libhwpjs.xcframework/ios-arm64_x86_64-simulator/libhwpjs-prebuilt.a +0 -0
- package/ios/framework/libreactnative.xcframework/Info.plist +44 -0
- package/ios/framework/libreactnative.xcframework/ios-arm64/libreactnative-prebuilt.a +0 -0
- package/ios/framework/libreactnative.xcframework/ios-arm64_x86_64-simulator/libreactnative-prebuilt.a +0 -0
- package/ios/include/CrabySignals.h +53 -0
- package/ios/include/cxx.h +1150 -0
- package/ios/include/ffi.rs.h +1041 -0
- package/ios/src/ffi.rs.cc +1179 -0
- package/package.json +147 -0
- package/react-native.config.js +24 -0
|
@@ -0,0 +1,1041 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <algorithm>
|
|
3
|
+
#include <array>
|
|
4
|
+
#include <cassert>
|
|
5
|
+
#include <cstddef>
|
|
6
|
+
#include <cstdint>
|
|
7
|
+
#include <initializer_list>
|
|
8
|
+
#include <iterator>
|
|
9
|
+
#include <new>
|
|
10
|
+
#include <stdexcept>
|
|
11
|
+
#include <string>
|
|
12
|
+
#include <type_traits>
|
|
13
|
+
#include <utility>
|
|
14
|
+
#if __cplusplus >= 201703L
|
|
15
|
+
#include <string_view>
|
|
16
|
+
#endif
|
|
17
|
+
#if __cplusplus >= 202002L
|
|
18
|
+
#include <ranges>
|
|
19
|
+
#endif
|
|
20
|
+
|
|
21
|
+
#ifdef __clang__
|
|
22
|
+
#pragma clang diagnostic push
|
|
23
|
+
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
|
|
24
|
+
#endif // __clang__
|
|
25
|
+
|
|
26
|
+
namespace rust {
|
|
27
|
+
inline namespace cxxbridge1 {
|
|
28
|
+
// #include "rust/cxx.h"
|
|
29
|
+
|
|
30
|
+
#ifndef CXXBRIDGE1_PANIC
|
|
31
|
+
#define CXXBRIDGE1_PANIC
|
|
32
|
+
template <typename Exception>
|
|
33
|
+
void panic [[noreturn]] (const char *msg);
|
|
34
|
+
#endif // CXXBRIDGE1_PANIC
|
|
35
|
+
|
|
36
|
+
struct unsafe_bitcopy_t;
|
|
37
|
+
|
|
38
|
+
namespace {
|
|
39
|
+
template <typename T>
|
|
40
|
+
class impl;
|
|
41
|
+
} // namespace
|
|
42
|
+
|
|
43
|
+
template <typename T>
|
|
44
|
+
::std::size_t size_of();
|
|
45
|
+
template <typename T>
|
|
46
|
+
::std::size_t align_of();
|
|
47
|
+
|
|
48
|
+
#ifndef CXXBRIDGE1_RUST_STRING
|
|
49
|
+
#define CXXBRIDGE1_RUST_STRING
|
|
50
|
+
class String final {
|
|
51
|
+
public:
|
|
52
|
+
String() noexcept;
|
|
53
|
+
String(const String &) noexcept;
|
|
54
|
+
String(String &&) noexcept;
|
|
55
|
+
~String() noexcept;
|
|
56
|
+
|
|
57
|
+
String(const std::string &);
|
|
58
|
+
String(const char *);
|
|
59
|
+
String(const char *, std::size_t);
|
|
60
|
+
String(const char16_t *);
|
|
61
|
+
String(const char16_t *, std::size_t);
|
|
62
|
+
#ifdef __cpp_char8_t
|
|
63
|
+
String(const char8_t *s);
|
|
64
|
+
String(const char8_t *s, std::size_t len);
|
|
65
|
+
#endif
|
|
66
|
+
|
|
67
|
+
static String lossy(const std::string &) noexcept;
|
|
68
|
+
static String lossy(const char *) noexcept;
|
|
69
|
+
static String lossy(const char *, std::size_t) noexcept;
|
|
70
|
+
static String lossy(const char16_t *) noexcept;
|
|
71
|
+
static String lossy(const char16_t *, std::size_t) noexcept;
|
|
72
|
+
|
|
73
|
+
String &operator=(const String &) & noexcept;
|
|
74
|
+
String &operator=(String &&) & noexcept;
|
|
75
|
+
|
|
76
|
+
explicit operator std::string() const;
|
|
77
|
+
|
|
78
|
+
const char *data() const noexcept;
|
|
79
|
+
std::size_t size() const noexcept;
|
|
80
|
+
std::size_t length() const noexcept;
|
|
81
|
+
bool empty() const noexcept;
|
|
82
|
+
|
|
83
|
+
const char *c_str() noexcept;
|
|
84
|
+
|
|
85
|
+
std::size_t capacity() const noexcept;
|
|
86
|
+
void reserve(size_t new_cap) noexcept;
|
|
87
|
+
|
|
88
|
+
using iterator = char *;
|
|
89
|
+
iterator begin() noexcept;
|
|
90
|
+
iterator end() noexcept;
|
|
91
|
+
|
|
92
|
+
using const_iterator = const char *;
|
|
93
|
+
const_iterator begin() const noexcept;
|
|
94
|
+
const_iterator end() const noexcept;
|
|
95
|
+
const_iterator cbegin() const noexcept;
|
|
96
|
+
const_iterator cend() const noexcept;
|
|
97
|
+
|
|
98
|
+
bool operator==(const String &) const noexcept;
|
|
99
|
+
bool operator!=(const String &) const noexcept;
|
|
100
|
+
bool operator<(const String &) const noexcept;
|
|
101
|
+
bool operator<=(const String &) const noexcept;
|
|
102
|
+
bool operator>(const String &) const noexcept;
|
|
103
|
+
bool operator>=(const String &) const noexcept;
|
|
104
|
+
|
|
105
|
+
void swap(String &) noexcept;
|
|
106
|
+
|
|
107
|
+
String(unsafe_bitcopy_t, const String &) noexcept;
|
|
108
|
+
|
|
109
|
+
private:
|
|
110
|
+
struct lossy_t;
|
|
111
|
+
String(lossy_t, const char *, std::size_t) noexcept;
|
|
112
|
+
String(lossy_t, const char16_t *, std::size_t) noexcept;
|
|
113
|
+
friend void swap(String &lhs, String &rhs) noexcept { lhs.swap(rhs); }
|
|
114
|
+
|
|
115
|
+
std::array<std::uintptr_t, 3> repr;
|
|
116
|
+
};
|
|
117
|
+
#endif // CXXBRIDGE1_RUST_STRING
|
|
118
|
+
|
|
119
|
+
#ifndef CXXBRIDGE1_RUST_STR
|
|
120
|
+
#define CXXBRIDGE1_RUST_STR
|
|
121
|
+
class Str final {
|
|
122
|
+
public:
|
|
123
|
+
Str() noexcept;
|
|
124
|
+
Str(const String &) noexcept;
|
|
125
|
+
Str(const std::string &);
|
|
126
|
+
Str(const char *);
|
|
127
|
+
Str(const char *, std::size_t);
|
|
128
|
+
|
|
129
|
+
Str &operator=(const Str &) & noexcept = default;
|
|
130
|
+
|
|
131
|
+
explicit operator std::string() const;
|
|
132
|
+
#if __cplusplus >= 201703L
|
|
133
|
+
explicit operator std::string_view() const;
|
|
134
|
+
#endif
|
|
135
|
+
|
|
136
|
+
const char *data() const noexcept;
|
|
137
|
+
std::size_t size() const noexcept;
|
|
138
|
+
std::size_t length() const noexcept;
|
|
139
|
+
bool empty() const noexcept;
|
|
140
|
+
|
|
141
|
+
Str(const Str &) noexcept = default;
|
|
142
|
+
~Str() noexcept = default;
|
|
143
|
+
|
|
144
|
+
using iterator = const char *;
|
|
145
|
+
using const_iterator = const char *;
|
|
146
|
+
const_iterator begin() const noexcept;
|
|
147
|
+
const_iterator end() const noexcept;
|
|
148
|
+
const_iterator cbegin() const noexcept;
|
|
149
|
+
const_iterator cend() const noexcept;
|
|
150
|
+
|
|
151
|
+
bool operator==(const Str &) const noexcept;
|
|
152
|
+
bool operator!=(const Str &) const noexcept;
|
|
153
|
+
bool operator<(const Str &) const noexcept;
|
|
154
|
+
bool operator<=(const Str &) const noexcept;
|
|
155
|
+
bool operator>(const Str &) const noexcept;
|
|
156
|
+
bool operator>=(const Str &) const noexcept;
|
|
157
|
+
|
|
158
|
+
void swap(Str &) noexcept;
|
|
159
|
+
|
|
160
|
+
private:
|
|
161
|
+
class uninit;
|
|
162
|
+
Str(uninit) noexcept;
|
|
163
|
+
friend impl<Str>;
|
|
164
|
+
|
|
165
|
+
std::array<std::uintptr_t, 2> repr;
|
|
166
|
+
};
|
|
167
|
+
#endif // CXXBRIDGE1_RUST_STR
|
|
168
|
+
|
|
169
|
+
#ifndef CXXBRIDGE1_RUST_SLICE
|
|
170
|
+
#define CXXBRIDGE1_RUST_SLICE
|
|
171
|
+
namespace detail {
|
|
172
|
+
template <bool>
|
|
173
|
+
struct copy_assignable_if {};
|
|
174
|
+
|
|
175
|
+
template <>
|
|
176
|
+
struct copy_assignable_if<false> {
|
|
177
|
+
copy_assignable_if() noexcept = default;
|
|
178
|
+
copy_assignable_if(const copy_assignable_if &) noexcept = default;
|
|
179
|
+
copy_assignable_if &operator=(const copy_assignable_if &) & noexcept = delete;
|
|
180
|
+
copy_assignable_if &operator=(copy_assignable_if &&) & noexcept = default;
|
|
181
|
+
};
|
|
182
|
+
} // namespace detail
|
|
183
|
+
|
|
184
|
+
template <typename T>
|
|
185
|
+
class Slice final
|
|
186
|
+
: private detail::copy_assignable_if<std::is_const<T>::value> {
|
|
187
|
+
public:
|
|
188
|
+
using value_type = T;
|
|
189
|
+
|
|
190
|
+
Slice() noexcept;
|
|
191
|
+
Slice(T *, std::size_t count) noexcept;
|
|
192
|
+
|
|
193
|
+
template <typename C>
|
|
194
|
+
explicit Slice(C &c) : Slice(c.data(), c.size()) {}
|
|
195
|
+
|
|
196
|
+
Slice &operator=(const Slice<T> &) & noexcept = default;
|
|
197
|
+
Slice &operator=(Slice<T> &&) & noexcept = default;
|
|
198
|
+
|
|
199
|
+
T *data() const noexcept;
|
|
200
|
+
std::size_t size() const noexcept;
|
|
201
|
+
std::size_t length() const noexcept;
|
|
202
|
+
bool empty() const noexcept;
|
|
203
|
+
|
|
204
|
+
T &operator[](std::size_t n) const noexcept;
|
|
205
|
+
T &at(std::size_t n) const;
|
|
206
|
+
T &front() const noexcept;
|
|
207
|
+
T &back() const noexcept;
|
|
208
|
+
|
|
209
|
+
Slice(const Slice<T> &) noexcept = default;
|
|
210
|
+
~Slice() noexcept = default;
|
|
211
|
+
|
|
212
|
+
class iterator;
|
|
213
|
+
iterator begin() const noexcept;
|
|
214
|
+
iterator end() const noexcept;
|
|
215
|
+
|
|
216
|
+
void swap(Slice &) noexcept;
|
|
217
|
+
|
|
218
|
+
private:
|
|
219
|
+
class uninit;
|
|
220
|
+
Slice(uninit) noexcept;
|
|
221
|
+
friend impl<Slice>;
|
|
222
|
+
friend void sliceInit(void *, const void *, std::size_t) noexcept;
|
|
223
|
+
friend void *slicePtr(const void *) noexcept;
|
|
224
|
+
friend std::size_t sliceLen(const void *) noexcept;
|
|
225
|
+
|
|
226
|
+
std::array<std::uintptr_t, 2> repr;
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
#ifdef __cpp_deduction_guides
|
|
230
|
+
template <typename C>
|
|
231
|
+
explicit Slice(C &c)
|
|
232
|
+
-> Slice<std::remove_reference_t<decltype(*std::declval<C>().data())>>;
|
|
233
|
+
#endif // __cpp_deduction_guides
|
|
234
|
+
|
|
235
|
+
template <typename T>
|
|
236
|
+
class Slice<T>::iterator final {
|
|
237
|
+
public:
|
|
238
|
+
#if __cplusplus >= 202002L
|
|
239
|
+
using iterator_category = std::contiguous_iterator_tag;
|
|
240
|
+
#else
|
|
241
|
+
using iterator_category = std::random_access_iterator_tag;
|
|
242
|
+
#endif
|
|
243
|
+
using value_type = T;
|
|
244
|
+
using difference_type = std::ptrdiff_t;
|
|
245
|
+
using pointer = typename std::add_pointer<T>::type;
|
|
246
|
+
using reference = typename std::add_lvalue_reference<T>::type;
|
|
247
|
+
|
|
248
|
+
reference operator*() const noexcept;
|
|
249
|
+
pointer operator->() const noexcept;
|
|
250
|
+
reference operator[](difference_type) const noexcept;
|
|
251
|
+
|
|
252
|
+
iterator &operator++() noexcept;
|
|
253
|
+
iterator operator++(int) noexcept;
|
|
254
|
+
iterator &operator--() noexcept;
|
|
255
|
+
iterator operator--(int) noexcept;
|
|
256
|
+
|
|
257
|
+
iterator &operator+=(difference_type) noexcept;
|
|
258
|
+
iterator &operator-=(difference_type) noexcept;
|
|
259
|
+
iterator operator+(difference_type) const noexcept;
|
|
260
|
+
friend inline iterator operator+(difference_type lhs, iterator rhs) noexcept {
|
|
261
|
+
return rhs + lhs;
|
|
262
|
+
}
|
|
263
|
+
iterator operator-(difference_type) const noexcept;
|
|
264
|
+
difference_type operator-(const iterator &) const noexcept;
|
|
265
|
+
|
|
266
|
+
bool operator==(const iterator &) const noexcept;
|
|
267
|
+
bool operator!=(const iterator &) const noexcept;
|
|
268
|
+
bool operator<(const iterator &) const noexcept;
|
|
269
|
+
bool operator<=(const iterator &) const noexcept;
|
|
270
|
+
bool operator>(const iterator &) const noexcept;
|
|
271
|
+
bool operator>=(const iterator &) const noexcept;
|
|
272
|
+
|
|
273
|
+
private:
|
|
274
|
+
friend class Slice;
|
|
275
|
+
void *pos;
|
|
276
|
+
std::size_t stride;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
#if __cplusplus >= 202002L
|
|
280
|
+
static_assert(std::ranges::contiguous_range<rust::Slice<const uint8_t>>);
|
|
281
|
+
static_assert(std::contiguous_iterator<rust::Slice<const uint8_t>::iterator>);
|
|
282
|
+
#endif
|
|
283
|
+
|
|
284
|
+
template <typename T>
|
|
285
|
+
Slice<T>::Slice() noexcept {
|
|
286
|
+
sliceInit(this, reinterpret_cast<void *>(align_of<T>()), 0);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
template <typename T>
|
|
290
|
+
Slice<T>::Slice(T *s, std::size_t count) noexcept {
|
|
291
|
+
assert(s != nullptr || count == 0);
|
|
292
|
+
sliceInit(this,
|
|
293
|
+
s == nullptr && count == 0
|
|
294
|
+
? reinterpret_cast<void *>(align_of<T>())
|
|
295
|
+
: const_cast<typename std::remove_const<T>::type *>(s),
|
|
296
|
+
count);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
template <typename T>
|
|
300
|
+
T *Slice<T>::data() const noexcept {
|
|
301
|
+
return reinterpret_cast<T *>(slicePtr(this));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
template <typename T>
|
|
305
|
+
std::size_t Slice<T>::size() const noexcept {
|
|
306
|
+
return sliceLen(this);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
template <typename T>
|
|
310
|
+
std::size_t Slice<T>::length() const noexcept {
|
|
311
|
+
return this->size();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
template <typename T>
|
|
315
|
+
bool Slice<T>::empty() const noexcept {
|
|
316
|
+
return this->size() == 0;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
template <typename T>
|
|
320
|
+
T &Slice<T>::operator[](std::size_t n) const noexcept {
|
|
321
|
+
assert(n < this->size());
|
|
322
|
+
auto ptr = static_cast<char *>(slicePtr(this)) + size_of<T>() * n;
|
|
323
|
+
return *reinterpret_cast<T *>(ptr);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
template <typename T>
|
|
327
|
+
T &Slice<T>::at(std::size_t n) const {
|
|
328
|
+
if (n >= this->size()) {
|
|
329
|
+
panic<std::out_of_range>("rust::Slice index out of range");
|
|
330
|
+
}
|
|
331
|
+
return (*this)[n];
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
template <typename T>
|
|
335
|
+
T &Slice<T>::front() const noexcept {
|
|
336
|
+
assert(!this->empty());
|
|
337
|
+
return (*this)[0];
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
template <typename T>
|
|
341
|
+
T &Slice<T>::back() const noexcept {
|
|
342
|
+
assert(!this->empty());
|
|
343
|
+
return (*this)[this->size() - 1];
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
template <typename T>
|
|
347
|
+
typename Slice<T>::iterator::reference
|
|
348
|
+
Slice<T>::iterator::operator*() const noexcept {
|
|
349
|
+
return *static_cast<T *>(this->pos);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
template <typename T>
|
|
353
|
+
typename Slice<T>::iterator::pointer
|
|
354
|
+
Slice<T>::iterator::operator->() const noexcept {
|
|
355
|
+
return static_cast<T *>(this->pos);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
template <typename T>
|
|
359
|
+
typename Slice<T>::iterator::reference Slice<T>::iterator::operator[](
|
|
360
|
+
typename Slice<T>::iterator::difference_type n) const noexcept {
|
|
361
|
+
auto ptr = static_cast<char *>(this->pos) + this->stride * n;
|
|
362
|
+
return *reinterpret_cast<T *>(ptr);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
template <typename T>
|
|
366
|
+
typename Slice<T>::iterator &Slice<T>::iterator::operator++() noexcept {
|
|
367
|
+
this->pos = static_cast<char *>(this->pos) + this->stride;
|
|
368
|
+
return *this;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
template <typename T>
|
|
372
|
+
typename Slice<T>::iterator Slice<T>::iterator::operator++(int) noexcept {
|
|
373
|
+
auto ret = iterator(*this);
|
|
374
|
+
this->pos = static_cast<char *>(this->pos) + this->stride;
|
|
375
|
+
return ret;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
template <typename T>
|
|
379
|
+
typename Slice<T>::iterator &Slice<T>::iterator::operator--() noexcept {
|
|
380
|
+
this->pos = static_cast<char *>(this->pos) - this->stride;
|
|
381
|
+
return *this;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
template <typename T>
|
|
385
|
+
typename Slice<T>::iterator Slice<T>::iterator::operator--(int) noexcept {
|
|
386
|
+
auto ret = iterator(*this);
|
|
387
|
+
this->pos = static_cast<char *>(this->pos) - this->stride;
|
|
388
|
+
return ret;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
template <typename T>
|
|
392
|
+
typename Slice<T>::iterator &Slice<T>::iterator::operator+=(
|
|
393
|
+
typename Slice<T>::iterator::difference_type n) noexcept {
|
|
394
|
+
this->pos = static_cast<char *>(this->pos) + this->stride * n;
|
|
395
|
+
return *this;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
template <typename T>
|
|
399
|
+
typename Slice<T>::iterator &Slice<T>::iterator::operator-=(
|
|
400
|
+
typename Slice<T>::iterator::difference_type n) noexcept {
|
|
401
|
+
this->pos = static_cast<char *>(this->pos) - this->stride * n;
|
|
402
|
+
return *this;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
template <typename T>
|
|
406
|
+
typename Slice<T>::iterator Slice<T>::iterator::operator+(
|
|
407
|
+
typename Slice<T>::iterator::difference_type n) const noexcept {
|
|
408
|
+
auto ret = iterator(*this);
|
|
409
|
+
ret.pos = static_cast<char *>(this->pos) + this->stride * n;
|
|
410
|
+
return ret;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
template <typename T>
|
|
414
|
+
typename Slice<T>::iterator Slice<T>::iterator::operator-(
|
|
415
|
+
typename Slice<T>::iterator::difference_type n) const noexcept {
|
|
416
|
+
auto ret = iterator(*this);
|
|
417
|
+
ret.pos = static_cast<char *>(this->pos) - this->stride * n;
|
|
418
|
+
return ret;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
template <typename T>
|
|
422
|
+
typename Slice<T>::iterator::difference_type
|
|
423
|
+
Slice<T>::iterator::operator-(const iterator &other) const noexcept {
|
|
424
|
+
auto diff = std::distance(static_cast<char *>(other.pos),
|
|
425
|
+
static_cast<char *>(this->pos));
|
|
426
|
+
return diff / static_cast<typename Slice<T>::iterator::difference_type>(
|
|
427
|
+
this->stride);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
template <typename T>
|
|
431
|
+
bool Slice<T>::iterator::operator==(const iterator &other) const noexcept {
|
|
432
|
+
return this->pos == other.pos;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
template <typename T>
|
|
436
|
+
bool Slice<T>::iterator::operator!=(const iterator &other) const noexcept {
|
|
437
|
+
return this->pos != other.pos;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
template <typename T>
|
|
441
|
+
bool Slice<T>::iterator::operator<(const iterator &other) const noexcept {
|
|
442
|
+
return this->pos < other.pos;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
template <typename T>
|
|
446
|
+
bool Slice<T>::iterator::operator<=(const iterator &other) const noexcept {
|
|
447
|
+
return this->pos <= other.pos;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
template <typename T>
|
|
451
|
+
bool Slice<T>::iterator::operator>(const iterator &other) const noexcept {
|
|
452
|
+
return this->pos > other.pos;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
template <typename T>
|
|
456
|
+
bool Slice<T>::iterator::operator>=(const iterator &other) const noexcept {
|
|
457
|
+
return this->pos >= other.pos;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
template <typename T>
|
|
461
|
+
typename Slice<T>::iterator Slice<T>::begin() const noexcept {
|
|
462
|
+
iterator it;
|
|
463
|
+
it.pos = slicePtr(this);
|
|
464
|
+
it.stride = size_of<T>();
|
|
465
|
+
return it;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
template <typename T>
|
|
469
|
+
typename Slice<T>::iterator Slice<T>::end() const noexcept {
|
|
470
|
+
iterator it = this->begin();
|
|
471
|
+
it.pos = static_cast<char *>(it.pos) + it.stride * this->size();
|
|
472
|
+
return it;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
template <typename T>
|
|
476
|
+
void Slice<T>::swap(Slice &rhs) noexcept {
|
|
477
|
+
std::swap(*this, rhs);
|
|
478
|
+
}
|
|
479
|
+
#endif // CXXBRIDGE1_RUST_SLICE
|
|
480
|
+
|
|
481
|
+
#ifndef CXXBRIDGE1_RUST_BOX
|
|
482
|
+
#define CXXBRIDGE1_RUST_BOX
|
|
483
|
+
template <typename T>
|
|
484
|
+
class Box final {
|
|
485
|
+
public:
|
|
486
|
+
using element_type = T;
|
|
487
|
+
using const_pointer =
|
|
488
|
+
typename std::add_pointer<typename std::add_const<T>::type>::type;
|
|
489
|
+
using pointer = typename std::add_pointer<T>::type;
|
|
490
|
+
|
|
491
|
+
Box() = delete;
|
|
492
|
+
Box(Box &&) noexcept;
|
|
493
|
+
~Box() noexcept;
|
|
494
|
+
|
|
495
|
+
explicit Box(const T &);
|
|
496
|
+
explicit Box(T &&);
|
|
497
|
+
|
|
498
|
+
Box &operator=(Box &&) & noexcept;
|
|
499
|
+
|
|
500
|
+
const T *operator->() const noexcept;
|
|
501
|
+
const T &operator*() const noexcept;
|
|
502
|
+
T *operator->() noexcept;
|
|
503
|
+
T &operator*() noexcept;
|
|
504
|
+
|
|
505
|
+
template <typename... Fields>
|
|
506
|
+
static Box in_place(Fields &&...);
|
|
507
|
+
|
|
508
|
+
void swap(Box &) noexcept;
|
|
509
|
+
|
|
510
|
+
static Box from_raw(T *) noexcept;
|
|
511
|
+
|
|
512
|
+
T *into_raw() noexcept;
|
|
513
|
+
|
|
514
|
+
/* Deprecated */ using value_type = element_type;
|
|
515
|
+
|
|
516
|
+
private:
|
|
517
|
+
class uninit;
|
|
518
|
+
class allocation;
|
|
519
|
+
Box(uninit) noexcept;
|
|
520
|
+
void drop() noexcept;
|
|
521
|
+
|
|
522
|
+
friend void swap(Box &lhs, Box &rhs) noexcept { lhs.swap(rhs); }
|
|
523
|
+
|
|
524
|
+
T *ptr;
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
template <typename T>
|
|
528
|
+
class Box<T>::uninit {};
|
|
529
|
+
|
|
530
|
+
template <typename T>
|
|
531
|
+
class Box<T>::allocation {
|
|
532
|
+
static T *alloc() noexcept;
|
|
533
|
+
static void dealloc(T *) noexcept;
|
|
534
|
+
|
|
535
|
+
public:
|
|
536
|
+
allocation() noexcept : ptr(alloc()) {}
|
|
537
|
+
~allocation() noexcept {
|
|
538
|
+
if (this->ptr) {
|
|
539
|
+
dealloc(this->ptr);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
T *ptr;
|
|
543
|
+
};
|
|
544
|
+
|
|
545
|
+
template <typename T>
|
|
546
|
+
Box<T>::Box(Box &&other) noexcept : ptr(other.ptr) {
|
|
547
|
+
other.ptr = nullptr;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
template <typename T>
|
|
551
|
+
Box<T>::Box(const T &val) {
|
|
552
|
+
allocation alloc;
|
|
553
|
+
::new (alloc.ptr) T(val);
|
|
554
|
+
this->ptr = alloc.ptr;
|
|
555
|
+
alloc.ptr = nullptr;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
template <typename T>
|
|
559
|
+
Box<T>::Box(T &&val) {
|
|
560
|
+
allocation alloc;
|
|
561
|
+
::new (alloc.ptr) T(std::move(val));
|
|
562
|
+
this->ptr = alloc.ptr;
|
|
563
|
+
alloc.ptr = nullptr;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
template <typename T>
|
|
567
|
+
Box<T>::~Box() noexcept {
|
|
568
|
+
if (this->ptr) {
|
|
569
|
+
this->drop();
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
template <typename T>
|
|
574
|
+
Box<T> &Box<T>::operator=(Box &&other) & noexcept {
|
|
575
|
+
if (this->ptr) {
|
|
576
|
+
this->drop();
|
|
577
|
+
}
|
|
578
|
+
this->ptr = other.ptr;
|
|
579
|
+
other.ptr = nullptr;
|
|
580
|
+
return *this;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
template <typename T>
|
|
584
|
+
const T *Box<T>::operator->() const noexcept {
|
|
585
|
+
return this->ptr;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
template <typename T>
|
|
589
|
+
const T &Box<T>::operator*() const noexcept {
|
|
590
|
+
return *this->ptr;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
template <typename T>
|
|
594
|
+
T *Box<T>::operator->() noexcept {
|
|
595
|
+
return this->ptr;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
template <typename T>
|
|
599
|
+
T &Box<T>::operator*() noexcept {
|
|
600
|
+
return *this->ptr;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
template <typename T>
|
|
604
|
+
template <typename... Fields>
|
|
605
|
+
Box<T> Box<T>::in_place(Fields &&...fields) {
|
|
606
|
+
allocation alloc;
|
|
607
|
+
auto ptr = alloc.ptr;
|
|
608
|
+
::new (ptr) T{std::forward<Fields>(fields)...};
|
|
609
|
+
alloc.ptr = nullptr;
|
|
610
|
+
return from_raw(ptr);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
template <typename T>
|
|
614
|
+
void Box<T>::swap(Box &rhs) noexcept {
|
|
615
|
+
using std::swap;
|
|
616
|
+
swap(this->ptr, rhs.ptr);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
template <typename T>
|
|
620
|
+
Box<T> Box<T>::from_raw(T *raw) noexcept {
|
|
621
|
+
Box box = uninit{};
|
|
622
|
+
box.ptr = raw;
|
|
623
|
+
return box;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
template <typename T>
|
|
627
|
+
T *Box<T>::into_raw() noexcept {
|
|
628
|
+
T *raw = this->ptr;
|
|
629
|
+
this->ptr = nullptr;
|
|
630
|
+
return raw;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
template <typename T>
|
|
634
|
+
Box<T>::Box(uninit) noexcept {}
|
|
635
|
+
#endif // CXXBRIDGE1_RUST_BOX
|
|
636
|
+
|
|
637
|
+
#ifndef CXXBRIDGE1_RUST_BITCOPY_T
|
|
638
|
+
#define CXXBRIDGE1_RUST_BITCOPY_T
|
|
639
|
+
struct unsafe_bitcopy_t final {
|
|
640
|
+
explicit unsafe_bitcopy_t() = default;
|
|
641
|
+
};
|
|
642
|
+
#endif // CXXBRIDGE1_RUST_BITCOPY_T
|
|
643
|
+
|
|
644
|
+
#ifndef CXXBRIDGE1_RUST_VEC
|
|
645
|
+
#define CXXBRIDGE1_RUST_VEC
|
|
646
|
+
template <typename T>
|
|
647
|
+
class Vec final {
|
|
648
|
+
public:
|
|
649
|
+
using value_type = T;
|
|
650
|
+
|
|
651
|
+
Vec() noexcept;
|
|
652
|
+
Vec(std::initializer_list<T>);
|
|
653
|
+
Vec(const Vec &);
|
|
654
|
+
Vec(Vec &&) noexcept;
|
|
655
|
+
~Vec() noexcept;
|
|
656
|
+
|
|
657
|
+
Vec &operator=(Vec &&) & noexcept;
|
|
658
|
+
Vec &operator=(const Vec &) &;
|
|
659
|
+
|
|
660
|
+
std::size_t size() const noexcept;
|
|
661
|
+
bool empty() const noexcept;
|
|
662
|
+
const T *data() const noexcept;
|
|
663
|
+
T *data() noexcept;
|
|
664
|
+
std::size_t capacity() const noexcept;
|
|
665
|
+
|
|
666
|
+
const T &operator[](std::size_t n) const noexcept;
|
|
667
|
+
const T &at(std::size_t n) const;
|
|
668
|
+
const T &front() const noexcept;
|
|
669
|
+
const T &back() const noexcept;
|
|
670
|
+
|
|
671
|
+
T &operator[](std::size_t n) noexcept;
|
|
672
|
+
T &at(std::size_t n);
|
|
673
|
+
T &front() noexcept;
|
|
674
|
+
T &back() noexcept;
|
|
675
|
+
|
|
676
|
+
void reserve(std::size_t new_cap);
|
|
677
|
+
void push_back(const T &value);
|
|
678
|
+
void push_back(T &&value);
|
|
679
|
+
template <typename... Args>
|
|
680
|
+
void emplace_back(Args &&...args);
|
|
681
|
+
void truncate(std::size_t len);
|
|
682
|
+
void clear();
|
|
683
|
+
|
|
684
|
+
using iterator = typename Slice<T>::iterator;
|
|
685
|
+
iterator begin() noexcept;
|
|
686
|
+
iterator end() noexcept;
|
|
687
|
+
|
|
688
|
+
using const_iterator = typename Slice<const T>::iterator;
|
|
689
|
+
const_iterator begin() const noexcept;
|
|
690
|
+
const_iterator end() const noexcept;
|
|
691
|
+
const_iterator cbegin() const noexcept;
|
|
692
|
+
const_iterator cend() const noexcept;
|
|
693
|
+
|
|
694
|
+
void swap(Vec &) noexcept;
|
|
695
|
+
|
|
696
|
+
Vec(unsafe_bitcopy_t, const Vec &) noexcept;
|
|
697
|
+
|
|
698
|
+
private:
|
|
699
|
+
void reserve_total(std::size_t new_cap) noexcept;
|
|
700
|
+
void set_len(std::size_t len) noexcept;
|
|
701
|
+
void drop() noexcept;
|
|
702
|
+
|
|
703
|
+
friend void swap(Vec &lhs, Vec &rhs) noexcept { lhs.swap(rhs); }
|
|
704
|
+
|
|
705
|
+
std::array<std::uintptr_t, 3> repr;
|
|
706
|
+
};
|
|
707
|
+
|
|
708
|
+
template <typename T>
|
|
709
|
+
Vec<T>::Vec(std::initializer_list<T> init) : Vec{} {
|
|
710
|
+
this->reserve_total(init.size());
|
|
711
|
+
std::move(init.begin(), init.end(), std::back_inserter(*this));
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
template <typename T>
|
|
715
|
+
Vec<T>::Vec(const Vec &other) : Vec() {
|
|
716
|
+
this->reserve_total(other.size());
|
|
717
|
+
std::copy(other.begin(), other.end(), std::back_inserter(*this));
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
template <typename T>
|
|
721
|
+
Vec<T>::Vec(Vec &&other) noexcept : repr(other.repr) {
|
|
722
|
+
new (&other) Vec();
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
template <typename T>
|
|
726
|
+
Vec<T>::~Vec() noexcept {
|
|
727
|
+
this->drop();
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
template <typename T>
|
|
731
|
+
Vec<T> &Vec<T>::operator=(Vec &&other) & noexcept {
|
|
732
|
+
this->drop();
|
|
733
|
+
this->repr = other.repr;
|
|
734
|
+
new (&other) Vec();
|
|
735
|
+
return *this;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
template <typename T>
|
|
739
|
+
Vec<T> &Vec<T>::operator=(const Vec &other) & {
|
|
740
|
+
if (this != &other) {
|
|
741
|
+
this->drop();
|
|
742
|
+
new (this) Vec(other);
|
|
743
|
+
}
|
|
744
|
+
return *this;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
template <typename T>
|
|
748
|
+
bool Vec<T>::empty() const noexcept {
|
|
749
|
+
return this->size() == 0;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
template <typename T>
|
|
753
|
+
T *Vec<T>::data() noexcept {
|
|
754
|
+
return const_cast<T *>(const_cast<const Vec<T> *>(this)->data());
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
template <typename T>
|
|
758
|
+
const T &Vec<T>::operator[](std::size_t n) const noexcept {
|
|
759
|
+
assert(n < this->size());
|
|
760
|
+
auto data = reinterpret_cast<const char *>(this->data());
|
|
761
|
+
return *reinterpret_cast<const T *>(data + n * size_of<T>());
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
template <typename T>
|
|
765
|
+
const T &Vec<T>::at(std::size_t n) const {
|
|
766
|
+
if (n >= this->size()) {
|
|
767
|
+
panic<std::out_of_range>("rust::Vec index out of range");
|
|
768
|
+
}
|
|
769
|
+
return (*this)[n];
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
template <typename T>
|
|
773
|
+
const T &Vec<T>::front() const noexcept {
|
|
774
|
+
assert(!this->empty());
|
|
775
|
+
return (*this)[0];
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
template <typename T>
|
|
779
|
+
const T &Vec<T>::back() const noexcept {
|
|
780
|
+
assert(!this->empty());
|
|
781
|
+
return (*this)[this->size() - 1];
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
template <typename T>
|
|
785
|
+
T &Vec<T>::operator[](std::size_t n) noexcept {
|
|
786
|
+
assert(n < this->size());
|
|
787
|
+
auto data = reinterpret_cast<char *>(this->data());
|
|
788
|
+
return *reinterpret_cast<T *>(data + n * size_of<T>());
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
template <typename T>
|
|
792
|
+
T &Vec<T>::at(std::size_t n) {
|
|
793
|
+
if (n >= this->size()) {
|
|
794
|
+
panic<std::out_of_range>("rust::Vec index out of range");
|
|
795
|
+
}
|
|
796
|
+
return (*this)[n];
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
template <typename T>
|
|
800
|
+
T &Vec<T>::front() noexcept {
|
|
801
|
+
assert(!this->empty());
|
|
802
|
+
return (*this)[0];
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
template <typename T>
|
|
806
|
+
T &Vec<T>::back() noexcept {
|
|
807
|
+
assert(!this->empty());
|
|
808
|
+
return (*this)[this->size() - 1];
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
template <typename T>
|
|
812
|
+
void Vec<T>::reserve(std::size_t new_cap) {
|
|
813
|
+
this->reserve_total(new_cap);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
template <typename T>
|
|
817
|
+
void Vec<T>::push_back(const T &value) {
|
|
818
|
+
this->emplace_back(value);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
template <typename T>
|
|
822
|
+
void Vec<T>::push_back(T &&value) {
|
|
823
|
+
this->emplace_back(std::move(value));
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
template <typename T>
|
|
827
|
+
template <typename... Args>
|
|
828
|
+
void Vec<T>::emplace_back(Args &&...args) {
|
|
829
|
+
auto size = this->size();
|
|
830
|
+
this->reserve_total(size + 1);
|
|
831
|
+
::new (reinterpret_cast<T *>(reinterpret_cast<char *>(this->data()) +
|
|
832
|
+
size * size_of<T>()))
|
|
833
|
+
T(std::forward<Args>(args)...);
|
|
834
|
+
this->set_len(size + 1);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
template <typename T>
|
|
838
|
+
void Vec<T>::clear() {
|
|
839
|
+
this->truncate(0);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
template <typename T>
|
|
843
|
+
typename Vec<T>::iterator Vec<T>::begin() noexcept {
|
|
844
|
+
return Slice<T>(this->data(), this->size()).begin();
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
template <typename T>
|
|
848
|
+
typename Vec<T>::iterator Vec<T>::end() noexcept {
|
|
849
|
+
return Slice<T>(this->data(), this->size()).end();
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
template <typename T>
|
|
853
|
+
typename Vec<T>::const_iterator Vec<T>::begin() const noexcept {
|
|
854
|
+
return this->cbegin();
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
template <typename T>
|
|
858
|
+
typename Vec<T>::const_iterator Vec<T>::end() const noexcept {
|
|
859
|
+
return this->cend();
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
template <typename T>
|
|
863
|
+
typename Vec<T>::const_iterator Vec<T>::cbegin() const noexcept {
|
|
864
|
+
return Slice<const T>(this->data(), this->size()).begin();
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
template <typename T>
|
|
868
|
+
typename Vec<T>::const_iterator Vec<T>::cend() const noexcept {
|
|
869
|
+
return Slice<const T>(this->data(), this->size()).end();
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
template <typename T>
|
|
873
|
+
void Vec<T>::swap(Vec &rhs) noexcept {
|
|
874
|
+
using std::swap;
|
|
875
|
+
swap(this->repr, rhs.repr);
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
template <typename T>
|
|
879
|
+
Vec<T>::Vec(unsafe_bitcopy_t, const Vec &bits) noexcept : repr(bits.repr) {}
|
|
880
|
+
#endif // CXXBRIDGE1_RUST_VEC
|
|
881
|
+
|
|
882
|
+
#ifndef CXXBRIDGE1_RUST_OPAQUE
|
|
883
|
+
#define CXXBRIDGE1_RUST_OPAQUE
|
|
884
|
+
class Opaque {
|
|
885
|
+
public:
|
|
886
|
+
Opaque() = delete;
|
|
887
|
+
Opaque(const Opaque &) = delete;
|
|
888
|
+
~Opaque() = delete;
|
|
889
|
+
};
|
|
890
|
+
#endif // CXXBRIDGE1_RUST_OPAQUE
|
|
891
|
+
|
|
892
|
+
#ifndef CXXBRIDGE1_IS_COMPLETE
|
|
893
|
+
#define CXXBRIDGE1_IS_COMPLETE
|
|
894
|
+
namespace detail {
|
|
895
|
+
namespace {
|
|
896
|
+
template <typename T, typename = std::size_t>
|
|
897
|
+
struct is_complete : std::false_type {};
|
|
898
|
+
template <typename T>
|
|
899
|
+
struct is_complete<T, decltype(sizeof(T))> : std::true_type {};
|
|
900
|
+
} // namespace
|
|
901
|
+
} // namespace detail
|
|
902
|
+
#endif // CXXBRIDGE1_IS_COMPLETE
|
|
903
|
+
|
|
904
|
+
#ifndef CXXBRIDGE1_LAYOUT
|
|
905
|
+
#define CXXBRIDGE1_LAYOUT
|
|
906
|
+
class layout {
|
|
907
|
+
template <typename T>
|
|
908
|
+
friend std::size_t size_of();
|
|
909
|
+
template <typename T>
|
|
910
|
+
friend std::size_t align_of();
|
|
911
|
+
template <typename T>
|
|
912
|
+
static typename std::enable_if<std::is_base_of<Opaque, T>::value,
|
|
913
|
+
std::size_t>::type
|
|
914
|
+
do_size_of() {
|
|
915
|
+
return T::layout::size();
|
|
916
|
+
}
|
|
917
|
+
template <typename T>
|
|
918
|
+
static typename std::enable_if<!std::is_base_of<Opaque, T>::value,
|
|
919
|
+
std::size_t>::type
|
|
920
|
+
do_size_of() {
|
|
921
|
+
return sizeof(T);
|
|
922
|
+
}
|
|
923
|
+
template <typename T>
|
|
924
|
+
static
|
|
925
|
+
typename std::enable_if<detail::is_complete<T>::value, std::size_t>::type
|
|
926
|
+
size_of() {
|
|
927
|
+
return do_size_of<T>();
|
|
928
|
+
}
|
|
929
|
+
template <typename T>
|
|
930
|
+
static typename std::enable_if<std::is_base_of<Opaque, T>::value,
|
|
931
|
+
std::size_t>::type
|
|
932
|
+
do_align_of() {
|
|
933
|
+
return T::layout::align();
|
|
934
|
+
}
|
|
935
|
+
template <typename T>
|
|
936
|
+
static typename std::enable_if<!std::is_base_of<Opaque, T>::value,
|
|
937
|
+
std::size_t>::type
|
|
938
|
+
do_align_of() {
|
|
939
|
+
return alignof(T);
|
|
940
|
+
}
|
|
941
|
+
template <typename T>
|
|
942
|
+
static
|
|
943
|
+
typename std::enable_if<detail::is_complete<T>::value, std::size_t>::type
|
|
944
|
+
align_of() {
|
|
945
|
+
return do_align_of<T>();
|
|
946
|
+
}
|
|
947
|
+
};
|
|
948
|
+
|
|
949
|
+
template <typename T>
|
|
950
|
+
std::size_t size_of() {
|
|
951
|
+
return layout::size_of<T>();
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
template <typename T>
|
|
955
|
+
std::size_t align_of() {
|
|
956
|
+
return layout::align_of<T>();
|
|
957
|
+
}
|
|
958
|
+
#endif // CXXBRIDGE1_LAYOUT
|
|
959
|
+
} // namespace cxxbridge1
|
|
960
|
+
} // namespace rust
|
|
961
|
+
|
|
962
|
+
#if __cplusplus >= 201402L
|
|
963
|
+
#define CXX_DEFAULT_VALUE(value) = value
|
|
964
|
+
#else
|
|
965
|
+
#define CXX_DEFAULT_VALUE(value)
|
|
966
|
+
#endif
|
|
967
|
+
|
|
968
|
+
namespace craby {
|
|
969
|
+
namespace hwpjs {
|
|
970
|
+
namespace bridging {
|
|
971
|
+
struct NullableString;
|
|
972
|
+
struct ToMarkdownResult;
|
|
973
|
+
struct ToMarkdownOptions;
|
|
974
|
+
struct Hwpjs;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
namespace craby {
|
|
980
|
+
namespace hwpjs {
|
|
981
|
+
namespace bridging {
|
|
982
|
+
#ifndef CXXBRIDGE1_STRUCT_craby$hwpjs$bridging$NullableString
|
|
983
|
+
#define CXXBRIDGE1_STRUCT_craby$hwpjs$bridging$NullableString
|
|
984
|
+
struct NullableString final {
|
|
985
|
+
bool null CXX_DEFAULT_VALUE(false);
|
|
986
|
+
::rust::String val;
|
|
987
|
+
|
|
988
|
+
using IsRelocatable = ::std::true_type;
|
|
989
|
+
};
|
|
990
|
+
#endif // CXXBRIDGE1_STRUCT_craby$hwpjs$bridging$NullableString
|
|
991
|
+
|
|
992
|
+
#ifndef CXXBRIDGE1_STRUCT_craby$hwpjs$bridging$ToMarkdownResult
|
|
993
|
+
#define CXXBRIDGE1_STRUCT_craby$hwpjs$bridging$ToMarkdownResult
|
|
994
|
+
struct ToMarkdownResult final {
|
|
995
|
+
::rust::String markdown;
|
|
996
|
+
|
|
997
|
+
using IsRelocatable = ::std::true_type;
|
|
998
|
+
};
|
|
999
|
+
#endif // CXXBRIDGE1_STRUCT_craby$hwpjs$bridging$ToMarkdownResult
|
|
1000
|
+
|
|
1001
|
+
#ifndef CXXBRIDGE1_STRUCT_craby$hwpjs$bridging$ToMarkdownOptions
|
|
1002
|
+
#define CXXBRIDGE1_STRUCT_craby$hwpjs$bridging$ToMarkdownOptions
|
|
1003
|
+
struct ToMarkdownOptions final {
|
|
1004
|
+
::craby::hwpjs::bridging::NullableString image_output_dir;
|
|
1005
|
+
::craby::hwpjs::bridging::NullableString image;
|
|
1006
|
+
bool use_html CXX_DEFAULT_VALUE(false);
|
|
1007
|
+
bool include_version CXX_DEFAULT_VALUE(false);
|
|
1008
|
+
bool include_page_info CXX_DEFAULT_VALUE(false);
|
|
1009
|
+
|
|
1010
|
+
using IsRelocatable = ::std::true_type;
|
|
1011
|
+
};
|
|
1012
|
+
#endif // CXXBRIDGE1_STRUCT_craby$hwpjs$bridging$ToMarkdownOptions
|
|
1013
|
+
|
|
1014
|
+
#ifndef CXXBRIDGE1_STRUCT_craby$hwpjs$bridging$Hwpjs
|
|
1015
|
+
#define CXXBRIDGE1_STRUCT_craby$hwpjs$bridging$Hwpjs
|
|
1016
|
+
struct Hwpjs final : public ::rust::Opaque {
|
|
1017
|
+
~Hwpjs() = delete;
|
|
1018
|
+
|
|
1019
|
+
private:
|
|
1020
|
+
friend ::rust::layout;
|
|
1021
|
+
struct layout {
|
|
1022
|
+
static ::std::size_t size() noexcept;
|
|
1023
|
+
static ::std::size_t align() noexcept;
|
|
1024
|
+
};
|
|
1025
|
+
};
|
|
1026
|
+
#endif // CXXBRIDGE1_STRUCT_craby$hwpjs$bridging$Hwpjs
|
|
1027
|
+
|
|
1028
|
+
::rust::Box<::craby::hwpjs::bridging::Hwpjs> createHwpjs(::std::size_t id, ::rust::Str data_path) noexcept;
|
|
1029
|
+
|
|
1030
|
+
::rust::String fileHeader(::craby::hwpjs::bridging::Hwpjs &it_, ::rust::Vec<double> data);
|
|
1031
|
+
|
|
1032
|
+
::rust::String toJson(::craby::hwpjs::bridging::Hwpjs &it_, ::rust::Vec<double> data);
|
|
1033
|
+
|
|
1034
|
+
::craby::hwpjs::bridging::ToMarkdownResult toMarkdown(::craby::hwpjs::bridging::Hwpjs &it_, ::rust::Vec<double> data, ::craby::hwpjs::bridging::ToMarkdownOptions options);
|
|
1035
|
+
} // namespace bridging
|
|
1036
|
+
} // namespace hwpjs
|
|
1037
|
+
} // namespace craby
|
|
1038
|
+
|
|
1039
|
+
#ifdef __clang__
|
|
1040
|
+
#pragma clang diagnostic pop
|
|
1041
|
+
#endif // __clang__
|