summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-07-17 00:48:12 +0800
committerruki <[email protected]>2020-07-17 00:48:12 +0800
commit764e35f2110e9932dfce409ee3949fccfef521ed (patch)
treeca8dfab0344b63d4747e1aa560f0db2c2c772643
parentf34b7e35cc1c636ae9f3656b3deba0597435a726 (diff)
export cjson as json
-rw-r--r--core/src/xmake/engine.c7
-rw-r--r--xmake/core/base/json.lua29
-rw-r--r--xmake/core/sandbox/modules/import/core/base/json.lua24
3 files changed, 60 insertions, 0 deletions
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c
index cf361a8c5..337627047 100644
--- a/core/src/xmake/engine.c
+++ b/core/src/xmake/engine.c
@@ -224,6 +224,9 @@ tb_int_t xm_semver_select(lua_State* lua);
tb_int_t xm_curses_register(lua_State* lua);
#endif
+// open cjson
+tb_int_t luaopen_cjson(lua_State *l);
+
/* //////////////////////////////////////////////////////////////////////////////////////
* globals
*/
@@ -849,6 +852,10 @@ xm_engine_ref_t xm_engine_init(tb_char_t const* name, xm_engine_lni_initalizer_c
lua_setglobal(engine->lua, "curses");
#endif
+ // bind json
+ luaopen_cjson(engine->lua);
+ lua_setglobal(engine->lua, "json");
+
// init host
xm_engine_init_host(engine);
diff --git a/xmake/core/base/json.lua b/xmake/core/base/json.lua
new file mode 100644
index 000000000..26dbce173
--- /dev/null
+++ b/xmake/core/base/json.lua
@@ -0,0 +1,29 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-2020, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file json.lua
+--
+
+-- define module: json
+local json = json or {}
+
+-- hide some cjson members
+json._VERSION = nil
+json._NAME = nil
+
+-- return module: json
+return json
diff --git a/xmake/core/sandbox/modules/import/core/base/json.lua b/xmake/core/sandbox/modules/import/core/base/json.lua
new file mode 100644
index 000000000..c8f428298
--- /dev/null
+++ b/xmake/core/sandbox/modules/import/core/base/json.lua
@@ -0,0 +1,24 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-2020, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file json.lua
+--
+
+-- load modules
+return require("base/json")
+
+