Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3524471
D12736.id42269.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.id42269.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
Tue, Dec 24, 12:40 PM (7 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700024
Default Alt Text
D12736.id42269.diff (1 KB)
Attached To
Mode
D12736: [web] add std::optional (C++) <-> undefined (JS) marshalling
Attached
Detach File
Event Timeline
Log In to Comment