Skip to content

Commit

Permalink
[web] add SQLiteQueryExecutor bindings and type
Browse files Browse the repository at this point in the history
Summary:
Binds `SQLiteQueryExecutor` to WASM module and calls its constructor.

Depends on D8552, D8547, D8489, D8472

Test Plan: Call constructor and logs on worker console should be the same as in native's migration code.

Reviewers: michal, tomek, jon

Reviewed By: michal

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D8553
  • Loading branch information
xsanm committed Jul 27, 2023
1 parent eead12d commit 8e34b77
Show file tree
Hide file tree
Showing 6 changed files with 204 additions and 129 deletions.
40 changes: 40 additions & 0 deletions web/cpp/SQLiteQueryExecutorBindings.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
#include "SQLiteQueryExecutor.cpp"
#include <emscripten/bind.h>
#include <vector>

namespace comm {

using namespace emscripten;

EMSCRIPTEN_BINDINGS(SQLiteQueryExecutor) {
value_object<Draft>("Draft")
.field("key", &Draft::key)
.field("text", &Draft::text);
value_object<Report>("Report")
.field("id", &Report::id)
.field("report", &Report::report);
value_object<PersistItem>("PersistItem")
.field("key", &PersistItem::key)
.field("item", &PersistItem::item);

class_<SQLiteQueryExecutor>("SQLiteQueryExecutor")
.constructor<std::string>()
.function("updateDraft", &SQLiteQueryExecutor::updateDraft)
.function("moveDraft", &SQLiteQueryExecutor::moveDraft)
.function("getAllDrafts", &SQLiteQueryExecutor::getAllDrafts)
.function("removeAllDrafts", &SQLiteQueryExecutor::removeAllDrafts)
.function("setMetadata", &SQLiteQueryExecutor::setMetadata)
.function("clearMetadata", &SQLiteQueryExecutor::clearMetadata)
.function("getMetadata", &SQLiteQueryExecutor::getMetadata)
.function("replaceReport", &SQLiteQueryExecutor::replaceReport)
.function("removeReports", &SQLiteQueryExecutor::removeReports)
.function("removeAllReports", &SQLiteQueryExecutor::removeAllReports)
.function("getAllReports", &SQLiteQueryExecutor::getAllReports)
.function(
"setPersistStorageItem", &SQLiteQueryExecutor::setPersistStorageItem)
.function(
"removePersistStorageItem",
&SQLiteQueryExecutor::removePersistStorageItem)
.function(
"getPersistStorageItem", &SQLiteQueryExecutor::getPersistStorageItem);
}

} // namespace comm

namespace emscripten {
namespace internal {

Expand Down
Loading

0 comments on commit 8e34b77

Please sign in to comment.