-
-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathAsyncImageLoadOptions.hpp
More file actions
126 lines (114 loc) · 8.93 KB
/
AsyncImageLoadOptions.hpp
File metadata and controls
126 lines (114 loc) · 8.93 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
///
/// AsyncImageLoadOptions.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///
#pragma once
#if __has_include(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
// Forward declaration of `AsyncImagePriority` to properly resolve imports.
namespace margelo::nitro::web::image { enum class AsyncImagePriority; }
#include "AsyncImagePriority.hpp"
#include <optional>
#include <string>
namespace margelo::nitro::web::image {
/**
* A struct which can be represented as a JavaScript object (AsyncImageLoadOptions).
*/
struct AsyncImageLoadOptions final {
public:
std::optional<AsyncImagePriority> priority SWIFT_PRIVATE;
std::optional<bool> forceRefresh SWIFT_PRIVATE;
std::optional<std::string> cacheKey SWIFT_PRIVATE;
std::optional<bool> continueInBackground SWIFT_PRIVATE;
std::optional<bool> allowInvalidSSLCertificates SWIFT_PRIVATE;
std::optional<bool> scaleDownLargeImages SWIFT_PRIVATE;
std::optional<bool> queryMemoryDataSync SWIFT_PRIVATE;
std::optional<bool> queryDiskDataSync SWIFT_PRIVATE;
std::optional<bool> decodeImage SWIFT_PRIVATE;
std::optional<bool> allowHardware SWIFT_PRIVATE;
std::optional<bool> progressive SWIFT_PRIVATE;
public:
AsyncImageLoadOptions() = default;
explicit AsyncImageLoadOptions(std::optional<AsyncImagePriority> priority, std::optional<bool> forceRefresh, std::optional<std::string> cacheKey, std::optional<bool> continueInBackground, std::optional<bool> allowInvalidSSLCertificates, std::optional<bool> scaleDownLargeImages, std::optional<bool> queryMemoryDataSync, std::optional<bool> queryDiskDataSync, std::optional<bool> decodeImage, std::optional<bool> allowHardware, std::optional<bool> progressive): priority(priority), forceRefresh(forceRefresh), cacheKey(cacheKey), continueInBackground(continueInBackground), allowInvalidSSLCertificates(allowInvalidSSLCertificates), scaleDownLargeImages(scaleDownLargeImages), queryMemoryDataSync(queryMemoryDataSync), queryDiskDataSync(queryDiskDataSync), decodeImage(decodeImage), allowHardware(allowHardware), progressive(progressive) {}
public:
friend bool operator==(const AsyncImageLoadOptions& lhs, const AsyncImageLoadOptions& rhs) = default;
};
} // namespace margelo::nitro::web::image
namespace margelo::nitro {
// C++ AsyncImageLoadOptions <> JS AsyncImageLoadOptions (object)
template <>
struct JSIConverter<margelo::nitro::web::image::AsyncImageLoadOptions> final {
static inline margelo::nitro::web::image::AsyncImageLoadOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
jsi::Object obj = arg.asObject(runtime);
return margelo::nitro::web::image::AsyncImageLoadOptions(
JSIConverter<std::optional<margelo::nitro::web::image::AsyncImagePriority>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "priority"))),
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "forceRefresh"))),
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cacheKey"))),
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "continueInBackground"))),
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowInvalidSSLCertificates"))),
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scaleDownLargeImages"))),
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "queryMemoryDataSync"))),
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "queryDiskDataSync"))),
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "decodeImage"))),
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowHardware"))),
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progressive")))
);
}
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::web::image::AsyncImageLoadOptions& arg) {
jsi::Object obj(runtime);
obj.setProperty(runtime, PropNameIDCache::get(runtime, "priority"), JSIConverter<std::optional<margelo::nitro::web::image::AsyncImagePriority>>::toJSI(runtime, arg.priority));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "forceRefresh"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.forceRefresh));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "cacheKey"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.cacheKey));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "continueInBackground"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.continueInBackground));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "allowInvalidSSLCertificates"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.allowInvalidSSLCertificates));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "scaleDownLargeImages"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.scaleDownLargeImages));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "queryMemoryDataSync"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.queryMemoryDataSync));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "queryDiskDataSync"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.queryDiskDataSync));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "decodeImage"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.decodeImage));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "allowHardware"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.allowHardware));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "progressive"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.progressive));
return obj;
}
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
if (!value.isObject()) {
return false;
}
jsi::Object obj = value.getObject(runtime);
if (!nitro::isPlainObject(runtime, obj)) {
return false;
}
if (!JSIConverter<std::optional<margelo::nitro::web::image::AsyncImagePriority>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "priority")))) return false;
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "forceRefresh")))) return false;
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cacheKey")))) return false;
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "continueInBackground")))) return false;
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowInvalidSSLCertificates")))) return false;
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scaleDownLargeImages")))) return false;
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "queryMemoryDataSync")))) return false;
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "queryDiskDataSync")))) return false;
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "decodeImage")))) return false;
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "allowHardware")))) return false;
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "progressive")))) return false;
return true;
}
};
} // namespace margelo::nitro