diff --git a/CODEBUDDY.md b/CODEBUDDY.md index a962f60..a853dbb 100644 --- a/CODEBUDDY.md +++ b/CODEBUDDY.md @@ -144,6 +144,16 @@ set_debug_post_build( "" ".arx") - 改完自检:`python -c "print(open('f.cpp','rb').read(3))"` 应为 `b'\xef\xbb\xbf'`;再查 `raw.count(b'\xef\xbf\xbd')`,非 0 说明中文已被写坏(不可逆),用 `git checkout HEAD -- ` 还原重做。 - 若遇到仍是 GBK/UTF-16 的老文件(从旧分支检出),先探明编码再改,不要假设。 +## 编码规范 + +- **文件内私有函数用匿名 `namespace`**:只在一个 `.cpp` 内使用的函数,直接实现在该文件的匿名 `namespace { }` 中,不要写成文件级 `static`,也不要放进头文件。 + + ```cpp + namespace { + CString MakeTempSatPath() { ... } + } + ``` + ## 测试 / 静态检查 本仓库**没有单元测试框架**(无 gtest/Catch2),也没有 lint 配置。验证方式是编译对应 preset,并在 CAD 中加载 `.arx` / `.zrx` 实测。 diff --git a/SourceCode/Code2026/CoreCommand/CoreTools.cpp b/SourceCode/Code2026/CoreCommand/CoreTools.cpp index 2dbcc52..e26d1f1 100644 --- a/SourceCode/Code2026/CoreCommand/CoreTools.cpp +++ b/SourceCode/Code2026/CoreCommand/CoreTools.cpp @@ -3034,10 +3034,12 @@ AcDbRegion* CoreTools::createRegion(AcDbEntity *pEnt) return (AcDbRegion*)segs[0]; } +namespace +{ // 生成唯一的临时 SAT 文件路径。 // 用 PID + 进程内原子序号,避免多个 CAD 实例或多线程互相覆盖同名文件。 // 调用方负责在 acisOut/acisIn 结束后 DeleteFile。 -static CString MakeTempSatPath() +CString MakeTempSatPath() { static LONG s_nSeq = 0; LONG nSeq = ::InterlockedIncrement(&s_nSeq); @@ -3050,6 +3052,7 @@ static CString MakeTempSatPath() sName.Format(_T("\\x3d_%lu_%ld.sat"), (unsigned long)::GetCurrentProcessId(), nSeq); return sPath + sName; } +} Adesk::UInt64 CoreTools::RegionToString(const AcDbRegion *pReg, char *& pszTxt) {