summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2016-02-01 18:34:59 +0800
committerruki <[email protected]>2016-02-15 19:10:26 +0800
commit0faab8456bcc516a5e09f7cf3647dd9625cbb616 (patch)
tree5e3d21ece8d185ac3e166bf0edd1154e960f6d0b
parentd986b3ac89b3054e256dea9520a6e07ba6ddb5d1 (diff)
add string and utils interfaces for sandbox
-rw-r--r--xmake/core/base/interpreter.lua1
-rw-r--r--xmake/core/sandbox/builtin/abort.lua28
-rw-r--r--xmake/core/sandbox/builtin/assert.lua25
-rw-r--r--xmake/core/sandbox/builtin/dump.lua28
-rw-r--r--xmake/core/sandbox/builtin/printf.lua28
-rw-r--r--xmake/core/sandbox/builtin/string.lua22
6 files changed, 130 insertions, 2 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 3ee1165a2..302424711 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -446,6 +446,7 @@ function interpreter.init()
self:api_register_builtin("print", print)
self:api_register_builtin("pairs", pairs)
self:api_register_builtin("ipairs", ipairs)
+ self:api_register_builtin("printf", utils.printf)
-- register the builtin modules for lua
self:api_register_builtin("path", path)
diff --git a/xmake/core/sandbox/builtin/abort.lua b/xmake/core/sandbox/builtin/abort.lua
new file mode 100644
index 000000000..ea478e007
--- /dev/null
+++ b/xmake/core/sandbox/builtin/abort.lua
@@ -0,0 +1,28 @@
+--!The Automatic Cross-platform Build Tool
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2009 - 2015, ruki All rights reserved.
+--
+-- @author ruki
+-- @file abort.lua
+--
+
+-- load modules
+local utils = require("base/utils")
+
+-- load module
+return utils.abort
+
diff --git a/xmake/core/sandbox/builtin/assert.lua b/xmake/core/sandbox/builtin/assert.lua
new file mode 100644
index 000000000..480271b4f
--- /dev/null
+++ b/xmake/core/sandbox/builtin/assert.lua
@@ -0,0 +1,25 @@
+--!The Automatic Cross-platform Build Tool
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2009 - 2015, ruki All rights reserved.
+--
+-- @author ruki
+-- @file assert.lua
+--
+
+-- load module
+return assert
+
diff --git a/xmake/core/sandbox/builtin/dump.lua b/xmake/core/sandbox/builtin/dump.lua
new file mode 100644
index 000000000..02d2b27c2
--- /dev/null
+++ b/xmake/core/sandbox/builtin/dump.lua
@@ -0,0 +1,28 @@
+--!The Automatic Cross-platform Build Tool
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2009 - 2015, ruki All rights reserved.
+--
+-- @author ruki
+-- @file dump.lua
+--
+
+-- load modules
+local utils = require("base/utils")
+
+-- load module
+return utils.dump
+
diff --git a/xmake/core/sandbox/builtin/printf.lua b/xmake/core/sandbox/builtin/printf.lua
new file mode 100644
index 000000000..e49da1794
--- /dev/null
+++ b/xmake/core/sandbox/builtin/printf.lua
@@ -0,0 +1,28 @@
+--!The Automatic Cross-platform Build Tool
+--
+-- XMake is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU Lesser General Public License as published by
+-- the Free Software Foundation; either version 2.1 of the License, or
+-- (at your option) any later version.
+--
+-- XMake is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Lesser General Public License for more details.
+--
+-- You should have received a copy of the GNU Lesser General Public License
+-- along with XMake;
+-- If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a>
+--
+-- Copyright (C) 2009 - 2015, ruki All rights reserved.
+--
+-- @author ruki
+-- @file printf.lua
+--
+
+-- load modules
+local utils = require("base/utils")
+
+-- load module
+return utils.printf
+
diff --git a/xmake/core/sandbox/builtin/string.lua b/xmake/core/sandbox/builtin/string.lua
index e9e75acb9..562e136f1 100644
--- a/xmake/core/sandbox/builtin/string.lua
+++ b/xmake/core/sandbox/builtin/string.lua
@@ -20,6 +20,24 @@
-- @file string.lua
--
--- load module
-return require("base/string")
+-- load modules
+local string = require("base/string")
+
+-- define module
+local sandbox_builtin_string = sandbox_builtin_string or {}
+
+-- filter string
+function sandbox_builtin_string.filter(format, ...)
+
+end
+
+-- inherit the public interfaces of string
+for k, v in pairs(string) do
+ if not k:startswith("_") and type(v) == "function" then
+ sandbox_builtin_string[k] = v
+ end
+end
+
+-- return module
+return sandbox_builtin_string