summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorTitanSnow <[email protected]>2017-05-07 14:04:59 +0800
committerTitanSnow <[email protected]>2017-05-07 14:04:59 +0800
commite0f42744605dda5dea3fc973b5885c80baa57940 (patch)
tree2576ba65cc64a74cf3ddf50dd260674e2be63b53 /core/src
parentc503f3305999e1657411d01222adf30ee57e3db3 (diff)
add os.features
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/machine.c2
-rw-r--r--core/src/xmake/makefile1
-rw-r--r--core/src/xmake/os/features.c64
3 files changed, 67 insertions, 0 deletions
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c
index 547279bb9..16c3176f6 100644
--- a/core/src/xmake/machine.c
+++ b/core/src/xmake/machine.c
@@ -80,6 +80,7 @@ tb_int_t xm_os_getenv(lua_State* lua);
tb_int_t xm_os_emptydir(lua_State* lua);
tb_int_t xm_os_strerror(lua_State* lua);
tb_int_t xm_os_getwinsize(lua_State* lua);
+tb_int_t xm_os_features(lua_State* lua);
// the path functions
tb_int_t xm_path_relative(lua_State* lua);
@@ -131,6 +132,7 @@ static luaL_Reg const g_os_functions[] =
, { "emptydir", xm_os_emptydir }
, { "strerror", xm_os_strerror }
, { "getwinsize", xm_os_getwinsize}
+, { "features", xm_os_features }
, { tb_null, tb_null }
};
diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile
index f3b2f97c0..f3196a4e5 100644
--- a/core/src/xmake/makefile
+++ b/core/src/xmake/makefile
@@ -36,6 +36,7 @@ xmake_C_FILES += \
os/emptydir \
os/strerror \
os/getwinsize \
+ os/features \
path/relative \
path/absolute \
path/translate \
diff --git a/core/src/xmake/os/features.c b/core/src/xmake/os/features.c
new file mode 100644
index 000000000..9c7ce4033
--- /dev/null
+++ b/core/src/xmake/os/features.c
@@ -0,0 +1,64 @@
+/*!The Make-like Build Utility based on Lua
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 - 2017, TBOOX Open Source Group.
+ *
+ * @author TitanSnow
+ * @file features.c
+ *
+ */
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * trace
+ */
+#define TB_TRACE_MODULE_NAME "features"
+#define TB_TRACE_MODULE_DEBUG (0)
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "prefix.h"
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * implementation
+ */
+
+// get features
+tb_int_t xm_os_features(lua_State* lua)
+{
+ // features
+ const char* features_table[] = {
+# ifdef XM_CONFIG_API_HAVE_READLINE
+ "readline"
+# endif
+ , tb_null
+ };
+
+ // new array
+ lua_newtable(lua);
+
+ // insert
+ for (const char** p = features_table; *p; ++p)
+ {
+ lua_pushstring(lua, *p);
+ lua_rawseti(lua, -2, p - features_table + 1);
+ }
+
+ // ok
+ return 1;
+}