summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-07-23 00:43:11 +0800
committerruki <[email protected]>2022-07-23 00:43:11 +0800
commit2882d942dd406f1443bf171424f06513c6f7d4e5 (patch)
treeea03b37fe5b88444adaddabd51d3e80d78dfc340
parent08f1f473ba31ac3720c3ecf3cc5afac04947eab6 (diff)
add fwatcher open/close
-rw-r--r--core/src/xmake/engine.c15
-rw-r--r--core/src/xmake/fwatcher/close.c57
-rw-r--r--core/src/xmake/fwatcher/open.c46
-rw-r--r--core/src/xmake/fwatcher/prefix.h31
-rw-r--r--core/src/xmake/makefile2
5 files changed, 151 insertions, 0 deletions
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c
index d275c21f8..9bd925a03 100644
--- a/core/src/xmake/engine.c
+++ b/core/src/xmake/engine.c
@@ -245,6 +245,10 @@ tb_int_t xm_process_wait(lua_State* lua);
tb_int_t xm_process_kill(lua_State* lua);
tb_int_t xm_process_close(lua_State* lua);
+// the fwatcher functions
+tb_int_t xm_fwatcher_open(lua_State* lua);
+tb_int_t xm_fwatcher_close(lua_State* lua);
+
// the sandbox functions
tb_int_t xm_sandbox_interactive(lua_State* lua);
@@ -488,6 +492,14 @@ static luaL_Reg const g_process_functions[] =
, { tb_null, tb_null }
};
+// the fwatcher functions
+static luaL_Reg const g_fwatcher_functions[] =
+{
+ { "open", xm_fwatcher_open }
+, { "close", xm_fwatcher_close }
+, { tb_null, tb_null }
+};
+
// the sandbox functions
static luaL_Reg const g_sandbox_functions[] =
{
@@ -1025,6 +1037,9 @@ xm_engine_ref_t xm_engine_init(tb_char_t const* name, xm_engine_lni_initalizer_c
// bind process functions
xm_lua_register(engine->lua, "process", g_process_functions);
+ // bind fwatcher functions
+ xm_lua_register(engine->lua, "fwatcher", g_fwatcher_functions);
+
// bind sandbox functions
xm_lua_register(engine->lua, "sandbox", g_sandbox_functions);
diff --git a/core/src/xmake/fwatcher/close.c b/core/src/xmake/fwatcher/close.c
new file mode 100644
index 000000000..0430afa00
--- /dev/null
+++ b/core/src/xmake/fwatcher/close.c
@@ -0,0 +1,57 @@
+/*!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-present, TBOOX Open Source Group.
+ *
+ * @author ruki
+ * @file close.c
+ *
+ */
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * trace
+ */
+#define TB_TRACE_MODULE_NAME "fwatcher.close"
+#define TB_TRACE_MODULE_DEBUG (0)
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "prefix.h"
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * implementation
+ */
+
+// fwatcher.close(p)
+tb_int_t xm_fwatcher_close(lua_State* lua)
+{
+ // check
+ tb_assert_and_check_return_val(lua, 0);
+
+ // is pointer?
+ if (!xm_lua_ispointer(lua, 1))
+ return 0;
+
+ // get the fwatcher
+ tb_fwatcher_ref_t fwatcher = (tb_fwatcher_ref_t)xm_lua_topointer(lua, 1);
+ tb_check_return_val(fwatcher, 0);
+
+ // exit fwatcher
+ tb_fwatcher_exit(fwatcher);
+
+ // save result: ok
+ lua_pushboolean(lua, tb_true);
+ return 1;
+}
diff --git a/core/src/xmake/fwatcher/open.c b/core/src/xmake/fwatcher/open.c
new file mode 100644
index 000000000..431762922
--- /dev/null
+++ b/core/src/xmake/fwatcher/open.c
@@ -0,0 +1,46 @@
+/*!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-present, TBOOX Open Source Group.
+ *
+ * @author ruki
+ * @file open.c
+ *
+ */
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * trace
+ */
+#define TB_TRACE_MODULE_NAME "fwatcher.open"
+#define TB_TRACE_MODULE_DEBUG (0)
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "prefix.h"
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * implementation
+ */
+tb_int_t xm_fwatcher_open(lua_State* lua)
+{
+ // check
+ tb_assert_and_check_return_val(lua, 0);
+
+ // init fwatcher
+ tb_fwatcher_ref_t fwatcher = (tb_fwatcher_ref_t)tb_fwatcher_init();
+ if (fwatcher) xm_lua_pushpointer(lua, (tb_pointer_t)fwatcher);
+ else lua_pushnil(lua);
+ return 1;
+}
diff --git a/core/src/xmake/fwatcher/prefix.h b/core/src/xmake/fwatcher/prefix.h
new file mode 100644
index 000000000..b203a555e
--- /dev/null
+++ b/core/src/xmake/fwatcher/prefix.h
@@ -0,0 +1,31 @@
+/*!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-present, TBOOX Open Source Group.
+ *
+ * @author ruki
+ * @file prefix.h
+ *
+ */
+#ifndef XM_FWATCHER_PREFIX_H
+#define XM_FWATCHER_PREFIX_H
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "../prefix.h"
+
+#endif
+
+
diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile
index 996b76578..bccb7a2ba 100644
--- a/core/src/xmake/makefile
+++ b/core/src/xmake/makefile
@@ -115,6 +115,8 @@ xmake_C_FILES += \
process/wait \
process/kill \
process/close \
+ fwatcher/open \
+ fwatcher/close \
sandbox/interactive \
semver/parse \
semver/compare \