Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3181547
D12736.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D12736.diff
View Options
diff --git a/web/cpp/SQLiteQueryExecutorBindings.cpp b/web/cpp/SQLiteQueryExecutorBindings.cpp
--- a/web/cpp/SQLiteQueryExecutorBindings.cpp
+++ b/web/cpp/SQLiteQueryExecutorBindings.cpp
@@ -4,6 +4,7 @@
#include "entities/OutboundP2PMessage.h"
#include <emscripten/bind.h>
+#include <optional>
#include <vector>
namespace comm {
@@ -345,5 +346,55 @@
}
};
+template <typename T> struct TypeID<std::optional<T>> {
+ static constexpr TYPEID get() {
+ return LightTypeID<val>::get();
+ }
+};
+
+template <typename T> struct TypeID<const std::optional<T>> {
+ static constexpr TYPEID get() {
+ return LightTypeID<val>::get();
+ }
+};
+
+template <typename T> struct TypeID<std::optional<T> &> {
+ static constexpr TYPEID get() {
+ return LightTypeID<val>::get();
+ }
+};
+
+template <typename T> struct TypeID<std::optional<T> &&> {
+ static constexpr TYPEID get() {
+ return LightTypeID<val>::get();
+ }
+};
+
+template <typename T> struct TypeID<const std::optional<T> &> {
+ static constexpr TYPEID get() {
+ return LightTypeID<val>::get();
+ }
+};
+
+template <typename T> struct BindingType<std::optional<T>> {
+ using ValBinding = BindingType<val>;
+ using WireType = ValBinding::WireType;
+
+ static WireType toWireType(std::optional<T> const &opt) {
+ if (!opt.has_value()) {
+ return ValBinding::toWireType(val::null());
+ }
+ return ValBinding::toWireType(val(opt.value()));
+ }
+
+ static std::optional<T> fromWireType(WireType value) {
+ val convertedVal = ValBinding::fromWireType(value);
+ if (convertedVal.isNull() || convertedVal.isUndefined()) {
+ return std::nullopt;
+ }
+ return std::make_optional<T>(convertedVal.as<T>());
+ }
+};
+
} // namespace internal
} // namespace emscripten
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 9, 6:26 AM (19 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2449691
Default Alt Text
D12736.diff (1 KB)
Attached To
Mode
D12736: [web] add std::optional (C++) <-> undefined (JS) marshalling
Attached
Detach File
Event Timeline
Log In to Comment