Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add highlighter and improve style #54

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ function(target_set_common target)
CXX_STANDARD 17
)
if (EMSCRIPTEN)
target_compile_options(${target} PRIVATE "-fwasm-exceptions")
target_link_options(${target} PRIVATE "-fwasm-exceptions")
# Nothing
elseif (MSVC)
target_compile_options(${target} PRIVATE "/wd4244")
Expand Down Expand Up @@ -155,8 +157,7 @@ if (EMSCRIPTEN)
#string(APPEND CMAKE_CXX_FLAGS " -s WASM_ASYNC_COMPILATION=0")
#string(APPEND CMAKE_CXX_FLAGS " -s SIDE_MODULE=1")
#string(APPEND CMAKE_CXX_FLAGS " -s DISABLE_EXCEPTION_CATCHING=0")
string(APPEND CMAKE_CXX_FLAGS " -s EXPORTED_FUNCTIONS='[\"_translate\", \"_main\", \"_API\"]'")
string(APPEND CMAKE_CXX_FLAGS " -s EXTRA_EXPORTED_RUNTIME_METHODS='[\"ccall\",\"cwrap\"]'")
string(APPEND CMAKE_CXX_FLAGS " -s EXPORTED_RUNTIME_METHODS='[\"ccall\",\"cwrap\"]'")

option(ADD_GOOGLE_ANALYTICS "Build the static library" ON)
if (ADD_GOOGLE_ANALYTICS)
Expand Down
7 changes: 7 additions & 0 deletions src/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

using json = nlohmann::json;

#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#else
#define EMSCRIPTEN_KEEPALIVE
#endif

template <class T>
json API(const std::vector<T>& container) {
auto json = json::array();
Expand Down Expand Up @@ -50,6 +56,7 @@ json API(const TranslatorPtr& translator) {
return json;
}

EMSCRIPTEN_KEEPALIVE
extern "C" const char* API() {
static std::string out;
if (out.size() == 0)
Expand Down
Loading