Page MenuHomePhabricator

D12736.id.diff
No OneTemporary

D12736.id.diff

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

Mime Type
text/plain
Expires
Tue, Dec 24, 12:40 PM (6 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700024
Default Alt Text
D12736.id.diff (1 KB)

Event Timeline