Why it's .cpp file?
This code does not work when added to .h file (emscripten does not parse it then and has no reflection in generated module).
Why it's called SQLiteQueryExecutorBindings.cpp?
This code to work (for some reason) needs to be placed along with binding, in next diff I am adding SQLiteQueryExecutor bindings to this file.
Why this idea?
We can automate using JS array <-> std::vector marshalling. Without this will need to:
- bind each vector type (for emscripten std::vector<int> and std::vector<std::string> are two different types.
- passing data to .wasm module, we will have to create vector objects in JS, add data to it using put() method
- parse data returned from .wasm module
This makes this process cleaner and easier for devs.
Inspiration
This issue: 11070
How it works?
- It uses Template Specialization concept
- it uses SFINAE to ensure it behaves properly for std::vector and ignores other types without an error
Sources:
Depends on D8551