Skip to content

Commit

Permalink
Use utf-8 for source code
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Aug 26, 2023
1 parent 5a1a840 commit e1f0b53
Show file tree
Hide file tree
Showing 493 changed files with 7,182 additions and 7,185 deletions.
64 changes: 32 additions & 32 deletions 3rdParty/lua/wrapper/DMLua.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extern "C" {
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
Expand All @@ -7,7 +7,7 @@ extern "C" {
#include "DMLua.h"
namespace DMLUA
{
// 辅助函数
// 辅助函数
static int tostring_s64(lua_State *L)
{
char temp[64];
Expand Down Expand Up @@ -137,7 +137,7 @@ namespace DMLUA
lua_pushcclosure(L, tostring_u64, 0);
lua_rawset(L, -3);

// 比较只会两边元表都是相同的元素才会进入比较
// 比较只会两边元表都是相同的元素才会进入比较
lua_pushstring(L, "__eq");
lua_pushcclosure(L, eq_u64, 0);
lua_rawset(L, -3);
Expand All @@ -161,7 +161,7 @@ namespace DMLUA

void close(lua_State *L)
{
//销毁指定 Lua 状态机中的所有对象(如果有垃圾收集相关的元方法的话,会调用它们),并且释放状态机中使用的所有动态内存
//销毁指定 Lua 状态机中的所有对象(如果有垃圾收集相关的元方法的话,会调用它们),并且释放状态机中使用的所有动态内存
lua_close(L);
}

Expand Down Expand Up @@ -689,92 +689,92 @@ namespace DMLUA
// --------------------------------------------------------
int meta_get(lua_State *L)
{
// 传入表 和 索引参数
// stack: 1.类(userdata) 2.变量(string)
// 传入表 和 索引参数
// stack: 1.类(userdata) 2.变量(string)
lua_getmetatable(L,1);
// stack: 1.类(userdata) 2.变量(string) 3.meta(table)
// stack: 1.类(userdata) 2.变量(string) 3.meta(table)
lua_pushvalue(L,2);
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.变量(string)
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.变量(string)
lua_rawget(L,-2);
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.meta[变量]value值(userdata)
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.meta[变量]value值(userdata)

// 如果存在userdata 存在该变量
// 如果存在userdata 存在该变量
if(lua_isuserdata(L,-1))
{
user2type<var_base*>::invoke(L,-1)->get(L);
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.meta[变量]value值(userdata) 5.实际值
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.meta[变量]value值(userdata) 5.实际值
lua_remove(L, -2);
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.实际值
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.实际值
}
else if(lua_isnil(L,-1))
{
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.nil
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.nil
lua_remove(L,-1);
// stack: 1.类(userdata) 2.变量(string) 3.meta(table)
// stack: 1.类(userdata) 2.变量(string) 3.meta(table)
invoke_parent(L);
// fix bug by fergus
// 调用父类也需调用get
// 调用父类也需调用get
if(lua_isuserdata(L,-1))
{
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.父类中的变量(userdata)
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.父类中的变量(userdata)
user2type<var_base*>::invoke(L,-1)->get(L);
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.父类中的变量(userdata) 5.实际值
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.父类中的变量(userdata) 5.实际值
lua_remove(L, -2);
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.实际值
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.实际值
}
else if(lua_isnil(L,-1))
{
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.nil
// stack: 1.类(userdata) 2.变量(string) 3.meta(table) 4.nil
lua_pushfstring(L, "can't find '%s' class variable. (forgot registering class variable ?)", lua_tostring(L, 2));
lua_error(L);
}
}

lua_remove(L,-2);
// stack: 1.类(userdata) 2.变量(string) 3.实际值
// stack: 1.类(userdata) 2.变量(string) 3.实际值

return 1;
}

int meta_set(lua_State *L)
{
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值
lua_getmetatable(L,1);
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table)
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table)
lua_pushvalue(L,2);
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.变量(string)
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.变量(string)
lua_rawget(L,-2);
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.meta[变量](userdata mem_var指针)
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.meta[变量](userdata mem_var指针)

if(lua_isuserdata(L,-1))
{
user2type<var_base*>::invoke(L,-1)->set(L);
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.meta[变量](userdata mem_var指针)
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.meta[变量](userdata mem_var指针)
}
else if(lua_isnil(L, -1))
{
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.nil
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.nil
lua_remove(L,-1);
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table)
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table)
lua_pushvalue(L,2);
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.变量(string)
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.变量(string)
lua_pushvalue(L,4);
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.变量(string) 6.类meta(table)
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.变量(string) 6.类meta(table)
invoke_parent(L);
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.变量(string) 6.类meta(table) 7.获取到父类的变量(userdata mem_var指针)
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.变量(string) 6.类meta(table) 7.获取到父类的变量(userdata mem_var指针)
if(lua_isuserdata(L,-1))
{
user2type<var_base*>::invoke(L,-1)->set(L);
}
else if(lua_isnil(L,-1))
{
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.变量(string) 6.类meta(table) 7.nil
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值 4.类meta(table) 5.变量(string) 6.类meta(table) 7.nil
lua_pushfstring(L, "can't find '%s' class variable. (forgot registering class variable ?)", lua_tostring(L, 2));
lua_error(L);
}
}
lua_settop(L, 3);
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值
// stack: 1.类(userdata) 2.变量(string) 3.要赋的值
return 0;
}

Expand Down
22 changes: 11 additions & 11 deletions 3rdParty/lua/wrapper/DMLua.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// ----------------------------------------------------------------
// ----------------------------------------------------------------
// Copyright (c) tencent
// All rights reserved.
//
// File name: DMLua.h
// File mark: 资料:https://github.com/zfengzhen/lua_tinker_5.2.git/
// File summary:重新整理代码
// File mark: 资料:https://github.com/zfengzhen/lua_tinker_5.2.git/
// File summary:重新整理代码

// Author: guoyouhuang
// Edition: 1.0
Expand All @@ -26,7 +26,7 @@ namespace DMLUA
{

/// -------------------------------------------------
/// @brief 初始化lua
/// @brief 初始化lua
/// @param[in] L
/// @remark
/// @return
Expand All @@ -35,14 +35,14 @@ namespace DMLUA
void init_u64(lua_State *L);

/// -------------------------------------------------
/// @brief 创建/关闭一个Lua状态机
/// @brief 创建/关闭一个Lua状态机
/// @remark
/// @return Lua状态机
/// @return Lua状态机
lua_State *open();
void close(lua_State *L);

/// -------------------------------------------------
/// @brief 开启基础库、字符串库、数学库、协程库、操作系统库
/// @brief 开启基础库、字符串库、数学库、协程库、操作系统库
/// @param[in] L
/// @remark
/// @return
Expand All @@ -53,7 +53,7 @@ namespace DMLUA
void open_os(lua_State *L);

/// -------------------------------------------------
/// @brief 三种执行方式
/// @brief 三种执行方式
/// @param[in] L
/// @param[in] buff
/// @remark
Expand All @@ -64,7 +64,7 @@ namespace DMLUA


/// -------------------------------------------------
/// @brief 打印错误
/// @brief 打印错误
/// @param[in] L
/// @remark
/// @return
Expand All @@ -78,7 +78,7 @@ namespace DMLUA
void push_meta(lua_State* L, const char* name);

/// <summary>
/// 动态类型扩展
/// 动态类型扩展
/// </summary>
class lua_value
{
Expand Down Expand Up @@ -1096,7 +1096,7 @@ namespace DMLUA


/// <summary>
/// 简单的封装
/// 简单的封装
/// </summary>
class lua_context
{
Expand Down
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ PROJECT(DM)

message(STATUS "CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}")

add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

# 支持简版if else
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)

Expand Down
22 changes: 11 additions & 11 deletions DMMultSingletonT.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@


//-------------------------------------------------------
// Copyright (c) DuiMagic
// All rights reserved.
//
// File Name: DMSingletonT.h
// File Des: 单例模式
// File Des: 单例模式
// File Summary:
// Cur Version: 1.0
// Author:
// Create Data:
// History:
// <Author> <Time> <Version> <Des>
// guoyou 2014-9-12 1.0
// guoyou 2015-01-09 1.1 增加帮助chm注释
// guoyou 2015-01-09 1.1 增加帮助chm注释
//-------------------------------------------------------
#pragma once
#include <assert.h>
Expand All @@ -21,7 +21,7 @@ __pragma(warning(disable: 4661))
namespace DM
{
/// <summary>
/// 多线程单例模式模板类
/// 多线程单例模式模板类
/// </summary>
template <typename T>
class DMSingletonT
Expand All @@ -34,7 +34,7 @@ namespace DM
{
if (m_Map.IsKeyExist(::GetCurrentThreadId()))
{
DMASSERT_EXPR(false,L"不要初始化多次DMApp对象");
DMASSERT_EXPR(false,L"不要初始化多次DMApp对象");
}
T* pObj = static_cast<T*>(this);
m_Map.AddKey(::GetCurrentThreadId(),pObj);
Expand All @@ -45,29 +45,29 @@ namespace DM
}

/// <summary>
/// 获取单例模式的对象
/// 获取单例模式的对象
/// </summary>
/// <returns>单例模式的对象</returns>
/// <returns>单例模式的对象</returns>
static T& getSingleton()
{
T* pObj = NULL;
if (!m_Map.GetObjByKey(::GetCurrentThreadId(),pObj))
{
DMASSERT_EXPR(false,L"当前线程未创建DMApp对象");
DMASSERT_EXPR(false,L"当前线程未创建DMApp对象");
}
return *pObj;
}

/// <summary>
/// 获取单例模式的对象指针
/// 获取单例模式的对象指针
/// </summary>
/// <returns>单例模式的对象指针</returns>
/// <returns>单例模式的对象指针</returns>
static T* getSingletonPtr()
{
T* pObj = NULL;
if (!m_Map.GetObjByKey(::GetCurrentThreadId(),pObj))
{
DMASSERT_EXPR(false,L"当前线程未创建DMApp对象");
DMASSERT_EXPR(false,L"当前线程未创建DMApp对象");
}
return pObj;
}
Expand Down
18 changes: 9 additions & 9 deletions DmMain/inc/Common/ActiveX/DMActiveXBase.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//-------------------------------------------------------
//-------------------------------------------------------
// Copyright (c) DuiMagic
// All rights reserved.
//
Expand All @@ -18,7 +18,7 @@

namespace DM
{
// 多线程使用
// 多线程使用
class GITControl
{
public:
Expand Down Expand Up @@ -165,7 +165,7 @@ namespace DM
public:
DWORD m_git_dwViewObjectType;
DMComPtr<IUnknown> m_pUnknown;
DWORD m_dwGitCookie; ///< 记录GIT
DWORD m_dwGitCookie; ///< 记录GIT
DMLock m_Lock;
};

Expand Down Expand Up @@ -226,8 +226,8 @@ namespace DM
public:
DMActiveXSite()
:m_pAxHostDelegate(NULL)
,m_bSupportMultThread(false)// 默认不支持多线程
,m_bAllowResize(true)// 默认支持重设大小
,m_bSupportMultThread(false)// 默认不支持多线程
,m_bAllowResize(true)// 默认支持重设大小
,m_bVisible(true)
,m_bInplaceActive(false)
,m_dwMiscStatus(0)
Expand Down Expand Up @@ -571,7 +571,7 @@ namespace DM
HWND hWnd = m_pAxHostDelegate->GetAxHostWindow();
if (FALSE==::IsWindow(hWnd))
{
LOG_ERR("[mid]hgy:窗口没初始化时不要初始化activeX,已被坑一次了!!!!!!!!!!!!!!");
LOG_ERR("[mid]hgy:窗口没初始化时不要初始化activeX,已被坑一次了!!!!!!!!!!!!!!");
hr = S_FALSE;
break;
}
Expand All @@ -593,7 +593,7 @@ namespace DM
HWND hWnd = m_pAxHostDelegate->GetAxHostWindow();
if (FALSE==::IsWindow(hWnd))
{
LOG_ERR("[mid]hgy:窗口没初始化时不要初始化activeX,已被坑一次了!!!!!!!!!!!!!!");
LOG_ERR("[mid]hgy:窗口没初始化时不要初始化activeX,已被坑一次了!!!!!!!!!!!!!!");
hr = S_FALSE;
break;
}
Expand Down Expand Up @@ -944,7 +944,7 @@ namespace DM
{
pRect = &m_rcPos;
}
m_pAxHostDelegate->OnAxInvalidate(pRect,fErase);// 此处刷新
m_pAxHostDelegate->OnAxInvalidate(pRect,fErase);// 此处刷新
return S_OK;
}

Expand Down Expand Up @@ -1273,7 +1273,7 @@ namespace DM
}

public:
bool m_bSupportMultThread; ///< 是否支持多线程
bool m_bSupportMultThread; ///< 是否支持多线程
bool m_bAllowResize;
bool m_bVisible;
bool m_bInplaceActive;
Expand Down
Loading

0 comments on commit e1f0b53

Please sign in to comment.