NH пре 1 година
родитељ
комит
c83d79c930
3 измењених фајлова са 90 додато и 0 уклоњено
  1. 2 0
      src/core/modulemanager.cpp
  2. 65 0
      src/module/queue.cpp
  3. 23 0
      src/module/queue.h

+ 2 - 0
src/core/modulemanager.cpp

@@ -39,6 +39,7 @@ If you have any questions, please contact us: 1585346868@qq.com Or visit our web
 #include "module/process.h"
 #include "module/ini.h"
 #include "module/codec.h"
+#include "module/queue.h"
 fastweb::module_manager::module_manager(fastweb::app* app):Interface(app)
 {
 }
@@ -205,6 +206,7 @@ void fastweb::module_manager::load_core(sol::state* lua)
 	module::process::regist(lua);
 	module::ini::regist(lua);
 	module::codec::regist(lua);
+	module::queue::regist(lua);
 
 	app()->global->regist(lua);
 

+ 65 - 0
src/module/queue.cpp

@@ -0,0 +1,65 @@
+/*Software License
+
+Copyright(C) 2024[liuyingjie]
+License Terms
+Usage Rights
+
+Any individual or entity is free to use, copy, and distribute the binary form of this software without modification to the source code, without the need to disclose the source code.
+If the source code is modified, the modifications must be open - sourced under the same license.This means that the modifications must be disclosed and accompanied by a copy of this license.
+Future Versions Updates
+From this version onwards, all future releases will be governed by the terms of the latest version of the license.This license will automatically be nullified and replaced by the new version.
+Users must comply with the terms of the new license issued in future releases.
+Liability and Disclaimer
+This software is provided “as is”, without any express or implied warranties, including but not limited to the warranties of merchantability, fitness for a particular purpose, and non - infringement.In no event shall the author or copyright holder be liable for any claims, damages, or other liabilities, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.
+Contact Information
+If you have any questions, please contact us: 1585346868@qq.com Or visit our website fwlua.com.
+*/
+
+#include "queue.h"
+
+module::queue::queue()
+{
+}
+
+module::queue::~queue()
+{
+}
+
+void module::queue::push(const std::string& value)
+{
+	return m_queue.push(value);
+}
+
+sol::object module::queue::pop(sol::this_state s)
+{
+    std::string value;
+    if (m_queue.pop(value))
+        return  sol::make_object(s, value);
+    else
+        return sol::make_object(s, sol::nil);
+}
+int module::queue::size()
+{
+    return m_queue.size();
+}
+void module::queue::clear()
+{
+    m_queue.clear();
+}
+void module::queue::regist(sol::state* lua)
+{
+    lua->new_usertype<module::queue>("fw_queue",
+        "new", sol::constructors<module::queue()>(),
+        "pop", &module::queue::pop,
+        "push", &module::queue::push,
+        "size", &module::queue::size,
+        "clear", &module::queue::clear,
+        "self", &module::queue::self
+    );
+}
+
+void module::queue::regist_global(const char* name, sol::state* lua)
+{
+    lua->registry()[name] = this;
+    (*lua)[name] = this;
+}

+ 23 - 0
src/module/queue.h

@@ -0,0 +1,23 @@
+#pragma once
+#include "sol/sol.hpp"
+#include "util/queue.hpp"
+#include "module/basemodule.h"
+namespace module
+{
+	class queue: public module::base{
+	public:
+		queue();
+		~queue();
+		void push(const std::string& value);
+		sol::object pop(sol::this_state s);
+		int size();
+		void clear();
+		static void regist(sol::state* lua);
+		virtual void regist_global(const char* name, sol::state* lua) override;
+		virtual void delete_global() { delete this; }
+	private:
+		ylib::queue<std::string> m_queue;
+	};
+
+}
+