aboutsummaryrefslogtreecommitdiff
path: root/src/yue_wasm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/yue_wasm.cpp')
-rw-r--r--src/yue_wasm.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/yue_wasm.cpp b/src/yue_wasm.cpp
index 8c93eb1..395388b 100644
--- a/src/yue_wasm.cpp
+++ b/src/yue_wasm.cpp
@@ -9,8 +9,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
9#include "yuescript/yue_compiler.h" 9#include "yuescript/yue_compiler.h"
10 10
11extern "C" { 11extern "C" {
12#include "lua.h"
13#include "lauxlib.h" 12#include "lauxlib.h"
13#include "lua.h"
14#include "lualib.h" 14#include "lualib.h"
15int luaopen_yue(lua_State* L); 15int luaopen_yue(lua_State* L);
16} // extern "C" 16} // extern "C"
@@ -23,15 +23,14 @@ static void openlibs(void* state) {
23 lua_pop(L, 1); 23 lua_pop(L, 1);
24} 24}
25 25
26#define YUE_ARGS nullptr,openlibs 26#define YUE_ARGS nullptr, openlibs
27 27
28#include <string_view> 28#include <string_view>
29using namespace std::string_view_literals; 29using namespace std::string_view_literals;
30#include <emscripten/bind.h> 30#include <emscripten/bind.h>
31using namespace emscripten; 31using namespace emscripten;
32 32
33struct YueResult 33struct YueResult {
34{
35 std::string codes; 34 std::string codes;
36 std::string err; 35 std::string err;
37}; 36};
@@ -47,8 +46,8 @@ YueResult tolua(const std::string& codes, bool reserveLineNumber = true, bool im
47 46
48std::string version() { return std::string(yue::version); } 47std::string version() { return std::string(yue::version); }
49 48
50#define _DEFER(code,line) std::shared_ptr<void> _defer_##line(nullptr, [&](auto){code;}) 49#define _DEFER(code, line) std::shared_ptr<void> _defer_##line(nullptr, [&](auto) { code; })
51#define DEFER(code) _DEFER(code,__LINE__) 50#define DEFER(code) _DEFER(code, __LINE__)
52 51
53void pushYue(lua_State* L, std::string_view name) { 52void pushYue(lua_State* L, std::string_view name) {
54 lua_getglobal(L, "package"); // package 53 lua_getglobal(L, "package"); // package
@@ -167,4 +166,3 @@ EMSCRIPTEN_BINDINGS(yue) {
167 function("exec", &exec); 166 function("exec", &exec);
168 function("version", &version); 167 function("version", &version);
169} 168}
170