no message

This commit is contained in:
zcy 2021-11-27 17:42:34 +08:00
parent 66ae5b8e0f
commit 553038694d
2 changed files with 11 additions and 17 deletions

View File

@ -51,9 +51,9 @@ int _C_Loger::Debug(string dat,string function,int line){
return 0; return 0;
} }
void _C_Loger::operator<<(const string& wb){ void _C_Loger::operator<<(const string& wb) {
// 还没有过天 // 还没有过天
if(getTimeDate() == this->mCurrentDate){ if(getTimeDate() == this->mCurrentDate) {
string tmp = getTime(); string tmp = getTime();
tmp += ":"; tmp += ":";
tmp += wb; tmp += wb;
@ -80,17 +80,15 @@ void _C_Loger::operator<<(const string& wb){
bool file_existed(string path) { bool file_existed(string path) {
fstream _file; fstream _file;
_file.open(path.c_str(),ios::in); _file.open(path.c_str(),ios::in);
if(!_file) if(!_file) {
{
return false; return false;
} }
else else {
{
_file.close(); _file.close();
return true; return true;
} }
} }
_C_Loger::_C_Loger(FILE *p){ _C_Loger::_C_Loger(FILE *p) {
this->mFile = p; this->mFile = p;
this->mCurrentDate = getTime(); this->mCurrentDate = getTime();
} }

View File

@ -5,8 +5,7 @@ void LuaDelegate::Stop()
} }
int LuaDelegate::DoString(std::string scr) int LuaDelegate::DoString(std::string scr) {
{
if (mVM != nullptr){ if (mVM != nullptr){
int ret = luaL_dostring(mVM,scr.c_str()); int ret = luaL_dostring(mVM,scr.c_str());
if (ret > 0){ if (ret > 0){
@ -18,20 +17,19 @@ int LuaDelegate::DoString(std::string scr)
return 0; return 0;
} }
int LuaDelegate::UpdateScript(std::string scr) int LuaDelegate::UpdateScript(std::string scr) {
{
if(nullptr != mVM){ if(nullptr != mVM){
lua_close(mVM); lua_close(mVM);
} }
free(mVM); free(mVM);
mVM = luaL_newstate(); //打开lua mVM = luaL_newstate(); //打开lua
if(nullptr != mVM){ if(nullptr != mVM) {
printf("shit is nullptr"); printf("shit is nullptr");
} }
for (auto x : mFunc) { for (auto x : mFunc) {
lua_register(mVM, x.first.c_str(), x.second); lua_register(mVM, x.first.c_str(), x.second);
} }
if (mVM != nullptr){ if (mVM != nullptr) {
int ret = luaL_dostring(mVM,scr.c_str()); int ret = luaL_dostring(mVM,scr.c_str());
if (ret > 0){ if (ret > 0){
printf("lua error"); printf("lua error");
@ -42,12 +40,11 @@ int LuaDelegate::UpdateScript(std::string scr)
return 0; return 0;
} }
void LuaDelegate::PrintError(lua_State *L) void LuaDelegate::PrintError(lua_State *L) {
{
std::cout<<"\nFATAL ERROR:%s\n\n"<< lua_tostring(L, -1); std::cout<<"\nFATAL ERROR:%s\n\n"<< lua_tostring(L, -1);
} }
void LuaDelegate::OnSerialData(std::string data){ void LuaDelegate::OnSerialData(std::string data) {
int i = lua_getglobal(mVM,"OnDataReady"); int i = lua_getglobal(mVM,"OnDataReady");
if(i == 0) if(i == 0)
return; return;
@ -56,7 +53,6 @@ void LuaDelegate::OnSerialData(std::string data){
} }
void LuaDelegate::DumpStack() void LuaDelegate::DumpStack()
{ {
static int count = 0; static int count = 0;