-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathJHybridViewModelImagePropertySpec.cpp
More file actions
75 lines (62 loc) · 2.95 KB
/
JHybridViewModelImagePropertySpec.cpp
File metadata and controls
75 lines (62 loc) · 2.95 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
///
/// JHybridViewModelImagePropertySpec.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2026 Marc Rousavy @ Margelo
///
#include "JHybridViewModelImagePropertySpec.hpp"
// Forward declaration of `HybridRiveImageSpec` to properly resolve imports.
namespace margelo::nitro::rive { class HybridRiveImageSpec; }
#include <functional>
#include "JFunc_void.hpp"
#include <NitroModules/JNICallable.hpp>
#include <memory>
#include "HybridRiveImageSpec.hpp"
#include <optional>
#include "JHybridRiveImageSpec.hpp"
namespace margelo::nitro::rive {
jni::local_ref<JHybridViewModelImagePropertySpec::jhybriddata> JHybridViewModelImagePropertySpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
return makeCxxInstance(jThis);
}
void JHybridViewModelImagePropertySpec::registerNatives() {
registerHybrid({
makeNativeMethod("initHybrid", JHybridViewModelImagePropertySpec::initHybrid),
});
}
size_t JHybridViewModelImagePropertySpec::getExternalMemorySize() noexcept {
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
return method(_javaPart);
}
void JHybridViewModelImagePropertySpec::dispose() noexcept {
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
method(_javaPart);
}
std::string JHybridViewModelImagePropertySpec::toString() {
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
auto javaString = method(_javaPart);
return javaString->toStdString();
}
// Properties
// Methods
void JHybridViewModelImagePropertySpec::set(const std::optional<std::shared_ptr<HybridRiveImageSpec>>& image) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JHybridRiveImageSpec::javaobject> /* image */)>("set");
method(_javaPart, image.has_value() ? std::dynamic_pointer_cast<JHybridRiveImageSpec>(image.value())->getJavaPart() : nullptr);
}
std::function<void()> JHybridViewModelImagePropertySpec::addListener(const std::function<void()>& onChanged) {
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>(jni::alias_ref<JFunc_void::javaobject> /* onChanged */)>("addListener_cxx");
auto __result = method(_javaPart, JFunc_void_cxx::fromCpp(onChanged));
return [&]() -> std::function<void()> {
if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
return downcast->cthis()->getFunction();
} else {
auto __resultRef = jni::make_global(__result);
return JNICallable<JFunc_void, void()>(std::move(__resultRef));
}
}();
}
void JHybridViewModelImagePropertySpec::removeListeners() {
static const auto method = javaClassStatic()->getMethod<void()>("removeListeners");
method(_javaPart);
}
} // namespace margelo::nitro::rive