Skip to content

Commit

Permalink
Add syntax highlight (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurSonzogni authored Dec 19, 2022
1 parent 0a6f1b9 commit cd7d96e
Show file tree
Hide file tree
Showing 17 changed files with 918 additions and 552 deletions.
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

0 comments on commit cd7d96e

Please sign in to comment.