支持sys模块

支持decimal

增加系统模块
This commit is contained in:
xx
2024-05-31 18:06:25 +08:00
parent 984d9bc56a
commit 56ac174fea
5 changed files with 90 additions and 73 deletions

View File

@@ -22,6 +22,7 @@
#include "module/codec.h"
#include "module/time.h"
#include "module/file.h"
#include "module/sys.h"
#define LOOP_STATE_USE 1
bool state_manager::start()
{
@@ -82,6 +83,7 @@ sol::state* state_manager::create_state()
module::codec::regist(lua);
module::time::regist(lua);
module::file::regist(lua);
module::sys::regist(lua);
global::getInstance()->regist_lua(lua);
return lua;

View File

@@ -567,7 +567,11 @@ VarType module::mysql_result::get(sol::object obj, sol::this_state s)
{
GET_VALUE(get_int64);
}
return sol::make_object(s, sol::nil);
else if (type == "decimal")
{
GET_VALUE(get_double);
}
return sol::make_object(s, sol::nil);
}

12
src/module/sys.cpp Normal file
View File

@@ -0,0 +1,12 @@
#include "sys.h"
#include "util/system.h"
std::string module::sys::current_dir()
{
return system::current_dir();
}
void module::sys::regist(sol::state* lua)
{
lua->new_usertype<module::sys>("sys",
"current_dir", &module::sys::current_dir
);
}

17
src/module/sys.h Normal file
View File

@@ -0,0 +1,17 @@
#pragma once
#include "sol/sol.hpp"
#include "imodule.h"
namespace module
{
/// <summary>
/// 系统
/// </summary>
class sys:public module::imodule {
public:
static std::string current_dir();
static void regist(sol::state* lua);
};
}