-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathJHybridRiveViewSpec.cpp
More file actions
296 lines (284 loc) · 16.9 KB
/
JHybridRiveViewSpec.cpp
File metadata and controls
296 lines (284 loc) · 16.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
///
/// JHybridRiveViewSpec.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///
#include "JHybridRiveViewSpec.hpp"
// Forward declaration of `HybridRiveFileSpec` to properly resolve imports.
namespace margelo::nitro::rive { class HybridRiveFileSpec; }
// Forward declaration of `Alignment` to properly resolve imports.
namespace margelo::nitro::rive { enum class Alignment; }
// Forward declaration of `Fit` to properly resolve imports.
namespace margelo::nitro::rive { enum class Fit; }
// Forward declaration of `HybridViewModelInstanceSpec` to properly resolve imports.
namespace margelo::nitro::rive { class HybridViewModelInstanceSpec; }
// Forward declaration of `DataBindMode` to properly resolve imports.
namespace margelo::nitro::rive { enum class DataBindMode; }
// Forward declaration of `DataBindByName` to properly resolve imports.
namespace margelo::nitro::rive { struct DataBindByName; }
// Forward declaration of `RiveError` to properly resolve imports.
namespace margelo::nitro::rive { struct RiveError; }
// Forward declaration of `RiveErrorType` to properly resolve imports.
namespace margelo::nitro::rive { enum class RiveErrorType; }
// Forward declaration of `UnifiedRiveEvent` to properly resolve imports.
namespace margelo::nitro::rive { struct UnifiedRiveEvent; }
// Forward declaration of `RiveEventType` to properly resolve imports.
namespace margelo::nitro::rive { enum class RiveEventType; }
#include <string>
#include <optional>
#include <memory>
#include "HybridRiveFileSpec.hpp"
#include "JHybridRiveFileSpec.hpp"
#include "Alignment.hpp"
#include "JAlignment.hpp"
#include "Fit.hpp"
#include "JFit.hpp"
#include "HybridViewModelInstanceSpec.hpp"
#include "DataBindMode.hpp"
#include "DataBindByName.hpp"
#include <variant>
#include "JVariant_HybridViewModelInstanceSpec_DataBindMode_DataBindByName.hpp"
#include "JHybridViewModelInstanceSpec.hpp"
#include "JDataBindMode.hpp"
#include "JDataBindByName.hpp"
#include "RiveError.hpp"
#include <functional>
#include "JFunc_void_RiveError.hpp"
#include "JRiveError.hpp"
#include "RiveErrorType.hpp"
#include "JRiveErrorType.hpp"
#include <NitroModules/Promise.hpp>
#include <NitroModules/JPromise.hpp>
#include "UnifiedRiveEvent.hpp"
#include "JFunc_void_UnifiedRiveEvent.hpp"
#include "JUnifiedRiveEvent.hpp"
#include "RiveEventType.hpp"
#include "JRiveEventType.hpp"
#include <unordered_map>
#include "JEventPropertiesOutput.hpp"
namespace margelo::nitro::rive {
jni::local_ref<JHybridRiveViewSpec::jhybriddata> JHybridRiveViewSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
return makeCxxInstance(jThis);
}
void JHybridRiveViewSpec::registerNatives() {
registerHybrid({
makeNativeMethod("initHybrid", JHybridRiveViewSpec::initHybrid),
});
}
size_t JHybridRiveViewSpec::getExternalMemorySize() noexcept {
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
return method(_javaPart);
}
void JHybridRiveViewSpec::dispose() noexcept {
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
method(_javaPart);
}
std::string JHybridRiveViewSpec::toString() {
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
auto javaString = method(_javaPart);
return javaString->toStdString();
}
// Properties
std::optional<std::string> JHybridRiveViewSpec::getArtboardName() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getArtboardName");
auto __result = method(_javaPart);
return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
}
void JHybridRiveViewSpec::setArtboardName(const std::optional<std::string>& artboardName) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* artboardName */)>("setArtboardName");
method(_javaPart, artboardName.has_value() ? jni::make_jstring(artboardName.value()) : nullptr);
}
std::optional<std::string> JHybridRiveViewSpec::getStateMachineName() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>()>("getStateMachineName");
auto __result = method(_javaPart);
return __result != nullptr ? std::make_optional(__result->toStdString()) : std::nullopt;
}
void JHybridRiveViewSpec::setStateMachineName(const std::optional<std::string>& stateMachineName) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* stateMachineName */)>("setStateMachineName");
method(_javaPart, stateMachineName.has_value() ? jni::make_jstring(stateMachineName.value()) : nullptr);
}
std::optional<bool> JHybridRiveViewSpec::getAutoPlay() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JBoolean>()>("getAutoPlay");
auto __result = method(_javaPart);
return __result != nullptr ? std::make_optional(static_cast<bool>(__result->value())) : std::nullopt;
}
void JHybridRiveViewSpec::setAutoPlay(std::optional<bool> autoPlay) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JBoolean> /* autoPlay */)>("setAutoPlay");
method(_javaPart, autoPlay.has_value() ? jni::JBoolean::valueOf(autoPlay.value()) : nullptr);
}
std::shared_ptr<HybridRiveFileSpec> JHybridRiveViewSpec::getFile() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JHybridRiveFileSpec::javaobject>()>("getFile");
auto __result = method(_javaPart);
return __result->cthis()->shared_cast<JHybridRiveFileSpec>();
}
void JHybridRiveViewSpec::setFile(const std::shared_ptr<HybridRiveFileSpec>& file) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JHybridRiveFileSpec::javaobject> /* file */)>("setFile");
method(_javaPart, std::dynamic_pointer_cast<JHybridRiveFileSpec>(file)->getJavaPart());
}
std::optional<Alignment> JHybridRiveViewSpec::getAlignment() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JAlignment>()>("getAlignment");
auto __result = method(_javaPart);
return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
}
void JHybridRiveViewSpec::setAlignment(std::optional<Alignment> alignment) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JAlignment> /* alignment */)>("setAlignment");
method(_javaPart, alignment.has_value() ? JAlignment::fromCpp(alignment.value()) : nullptr);
}
std::optional<Fit> JHybridRiveViewSpec::getFit() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFit>()>("getFit");
auto __result = method(_javaPart);
return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
}
void JHybridRiveViewSpec::setFit(std::optional<Fit> fit) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFit> /* fit */)>("setFit");
method(_javaPart, fit.has_value() ? JFit::fromCpp(fit.value()) : nullptr);
}
std::optional<double> JHybridRiveViewSpec::getLayoutScaleFactor() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JDouble>()>("getLayoutScaleFactor");
auto __result = method(_javaPart);
return __result != nullptr ? std::make_optional(__result->value()) : std::nullopt;
}
void JHybridRiveViewSpec::setLayoutScaleFactor(std::optional<double> layoutScaleFactor) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JDouble> /* layoutScaleFactor */)>("setLayoutScaleFactor");
method(_javaPart, layoutScaleFactor.has_value() ? jni::JDouble::valueOf(layoutScaleFactor.value()) : nullptr);
}
std::optional<std::variant<std::shared_ptr<HybridViewModelInstanceSpec>, DataBindMode, DataBindByName>> JHybridRiveViewSpec::getDataBind() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JVariant_HybridViewModelInstanceSpec_DataBindMode_DataBindByName>()>("getDataBind");
auto __result = method(_javaPart);
return __result != nullptr ? std::make_optional(__result->toCpp()) : std::nullopt;
}
void JHybridRiveViewSpec::setDataBind(const std::optional<std::variant<std::shared_ptr<HybridViewModelInstanceSpec>, DataBindMode, DataBindByName>>& dataBind) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JVariant_HybridViewModelInstanceSpec_DataBindMode_DataBindByName> /* dataBind */)>("setDataBind");
method(_javaPart, dataBind.has_value() ? JVariant_HybridViewModelInstanceSpec_DataBindMode_DataBindByName::fromCpp(dataBind.value()) : nullptr);
}
std::function<void(const RiveError& /* error */)> JHybridRiveViewSpec::getOnError() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void_RiveError::javaobject>()>("getOnError_cxx");
auto __result = method(_javaPart);
return [&]() -> std::function<void(const RiveError& /* error */)> {
if (__result->isInstanceOf(JFunc_void_RiveError_cxx::javaClassStatic())) [[likely]] {
auto downcast = jni::static_ref_cast<JFunc_void_RiveError_cxx::javaobject>(__result);
return downcast->cthis()->getFunction();
} else {
auto __resultRef = jni::make_global(__result);
return [__resultRef](RiveError error) -> void {
return __resultRef->invoke(error);
};
}
}();
}
void JHybridRiveViewSpec::setOnError(const std::function<void(const RiveError& /* error */)>& onError) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_RiveError::javaobject> /* onError */)>("setOnError_cxx");
method(_javaPart, JFunc_void_RiveError_cxx::fromCpp(onError));
}
// Methods
std::shared_ptr<Promise<bool>> JHybridRiveViewSpec::awaitViewReady() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("awaitViewReady");
auto __result = method(_javaPart);
return [&]() {
auto __promise = Promise<bool>::create();
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
auto __result = jni::static_ref_cast<jni::JBoolean>(__boxedResult);
__promise->resolve(static_cast<bool>(__result->value()));
});
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
jni::JniException __jniError(__throwable);
__promise->reject(std::make_exception_ptr(__jniError));
});
return __promise;
}();
}
void JHybridRiveViewSpec::bindViewModelInstance(const std::shared_ptr<HybridViewModelInstanceSpec>& viewModelInstance) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JHybridViewModelInstanceSpec::javaobject> /* viewModelInstance */)>("bindViewModelInstance");
method(_javaPart, std::dynamic_pointer_cast<JHybridViewModelInstanceSpec>(viewModelInstance)->getJavaPart());
}
std::optional<std::shared_ptr<HybridViewModelInstanceSpec>> JHybridRiveViewSpec::getViewModelInstance() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JHybridViewModelInstanceSpec::javaobject>()>("getViewModelInstance");
auto __result = method(_javaPart);
return __result != nullptr ? std::make_optional(__result->cthis()->shared_cast<JHybridViewModelInstanceSpec>()) : std::nullopt;
}
std::shared_ptr<Promise<void>> JHybridRiveViewSpec::play() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("play");
auto __result = method(_javaPart);
return [&]() {
auto __promise = Promise<void>::create();
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
__promise->resolve();
});
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
jni::JniException __jniError(__throwable);
__promise->reject(std::make_exception_ptr(__jniError));
});
return __promise;
}();
}
std::shared_ptr<Promise<void>> JHybridRiveViewSpec::pause() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("pause");
auto __result = method(_javaPart);
return [&]() {
auto __promise = Promise<void>::create();
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
__promise->resolve();
});
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
jni::JniException __jniError(__throwable);
__promise->reject(std::make_exception_ptr(__jniError));
});
return __promise;
}();
}
std::shared_ptr<Promise<void>> JHybridRiveViewSpec::reset() {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("reset");
auto __result = method(_javaPart);
return [&]() {
auto __promise = Promise<void>::create();
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& /* unit */) {
__promise->resolve();
});
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
jni::JniException __jniError(__throwable);
__promise->reject(std::make_exception_ptr(__jniError));
});
return __promise;
}();
}
void JHybridRiveViewSpec::onEventListener(const std::function<void(const UnifiedRiveEvent& /* event */)>& onEvent) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFunc_void_UnifiedRiveEvent::javaobject> /* onEvent */)>("onEventListener_cxx");
method(_javaPart, JFunc_void_UnifiedRiveEvent_cxx::fromCpp(onEvent));
}
void JHybridRiveViewSpec::removeEventListeners() {
static const auto method = javaClassStatic()->getMethod<void()>("removeEventListeners");
method(_javaPart);
}
void JHybridRiveViewSpec::setNumberInputValue(const std::string& name, double value, const std::optional<std::string>& path) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* name */, double /* value */, jni::alias_ref<jni::JString> /* path */)>("setNumberInputValue");
method(_javaPart, jni::make_jstring(name), value, path.has_value() ? jni::make_jstring(path.value()) : nullptr);
}
double JHybridRiveViewSpec::getNumberInputValue(const std::string& name, const std::optional<std::string>& path) {
static const auto method = javaClassStatic()->getMethod<double(jni::alias_ref<jni::JString> /* name */, jni::alias_ref<jni::JString> /* path */)>("getNumberInputValue");
auto __result = method(_javaPart, jni::make_jstring(name), path.has_value() ? jni::make_jstring(path.value()) : nullptr);
return __result;
}
void JHybridRiveViewSpec::setBooleanInputValue(const std::string& name, bool value, const std::optional<std::string>& path) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* name */, jboolean /* value */, jni::alias_ref<jni::JString> /* path */)>("setBooleanInputValue");
method(_javaPart, jni::make_jstring(name), value, path.has_value() ? jni::make_jstring(path.value()) : nullptr);
}
bool JHybridRiveViewSpec::getBooleanInputValue(const std::string& name, const std::optional<std::string>& path) {
static const auto method = javaClassStatic()->getMethod<jboolean(jni::alias_ref<jni::JString> /* name */, jni::alias_ref<jni::JString> /* path */)>("getBooleanInputValue");
auto __result = method(_javaPart, jni::make_jstring(name), path.has_value() ? jni::make_jstring(path.value()) : nullptr);
return static_cast<bool>(__result);
}
void JHybridRiveViewSpec::triggerInput(const std::string& name, const std::optional<std::string>& path) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* name */, jni::alias_ref<jni::JString> /* path */)>("triggerInput");
method(_javaPart, jni::make_jstring(name), path.has_value() ? jni::make_jstring(path.value()) : nullptr);
}
void JHybridRiveViewSpec::setTextRunValue(const std::string& name, const std::string& value, const std::optional<std::string>& path) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* name */, jni::alias_ref<jni::JString> /* value */, jni::alias_ref<jni::JString> /* path */)>("setTextRunValue");
method(_javaPart, jni::make_jstring(name), jni::make_jstring(value), path.has_value() ? jni::make_jstring(path.value()) : nullptr);
}
std::string JHybridRiveViewSpec::getTextRunValue(const std::string& name, const std::optional<std::string>& path) {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>(jni::alias_ref<jni::JString> /* name */, jni::alias_ref<jni::JString> /* path */)>("getTextRunValue");
auto __result = method(_javaPart, jni::make_jstring(name), path.has_value() ? jni::make_jstring(path.value()) : nullptr);
return __result->toStdString();
}
} // namespace margelo::nitro::rive