Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3367967
D8552.id29115.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
D8552.id29115.diff
View Options
diff --git a/web/cpp/SQLiteQueryExecutorBindings.cpp b/web/cpp/SQLiteQueryExecutorBindings.cpp
new file mode 100644
--- /dev/null
+++ b/web/cpp/SQLiteQueryExecutorBindings.cpp
@@ -0,0 +1,36 @@
+#include <emscripten/bind.h>
+#include <vector>
+
+namespace emscripten {
+namespace internal {
+
+template <typename T, typename Allocator>
+struct BindingType<std::vector<T, Allocator>> {
+ using ValBinding = BindingType<val>;
+ using WireType = ValBinding::WireType;
+
+ static WireType toWireType(const std::vector<T, Allocator> &vec) {
+ std::vector<val> valVec(vec.begin(), vec.end());
+ return BindingType<val>::toWireType(val::array(valVec));
+ }
+
+ static std::vector<T, Allocator> fromWireType(WireType value) {
+ return vecFromJSArray<T>(ValBinding::fromWireType(value));
+ }
+};
+
+template <typename T>
+struct TypeID<
+ T,
+ typename std::enable_if_t<std::is_same<
+ typename Canonicalized<T>::type,
+ std::vector<
+ typename Canonicalized<T>::type::value_type,
+ typename Canonicalized<T>::type::allocator_type>>::value>> {
+ static constexpr TYPEID get() {
+ return TypeID<val>::get();
+ }
+};
+
+} // namespace internal
+} // namespace emscripten
diff --git a/web/scripts/run_emscripten.sh b/web/scripts/run_emscripten.sh
--- a/web/scripts/run_emscripten.sh
+++ b/web/scripts/run_emscripten.sh
@@ -87,6 +87,7 @@
)
INPUT_FILES=(
+ "${WEB_CPP_DIR}SQLiteQueryExecutorBindings.cpp"
"${INPUT_DIR}CommQueryExecutor.cpp"
"${INPUT_DIR}SQLiteQueryExecutor.cpp"
"${WEB_CPP_DIR}Logger.cpp"
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 5:35 PM (15 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585314
Default Alt Text
D8552.id29115.diff (1 KB)
Attached To
Mode
D8552: [web] add `std::vector` (C++) <-> `Array` (JS) marshalling
Attached
Detach File
Event Timeline
Log In to Comment