Преглед изворни кода

refactor: 调整文件命名和文件依赖

SongZihuan пре 3 година
родитељ
комит
e8bcc7547d
74 измењених фајлова са 294 додато и 256 уклоњено
  1. 17 10
      CMakeLists.txt
  2. 4 4
      cmake/CMakeFindExternalProject/WindowsInstall.cmake
  3. 11 3
      include/base.h.in
  4. 14 0
      include/core/aFuncore.h
  5. 6 6
      include/core/activation.h
  6. 5 5
      include/core/code.h
  7. 6 4
      include/core/core.h
  8. 4 4
      include/core/env-var.h
  9. 4 4
      include/core/gc.h
  10. 4 4
      include/core/init.h
  11. 5 5
      include/core/inter.h
  12. 5 5
      include/core/msg.h
  13. 6 6
      include/core/value.h
  14. 6 6
      include/core/var.h
  15. 30 0
      include/tool/aFuntool.h
  16. 0 0
      include/tool/byte.h
  17. 3 3
      include/tool/dlc.h
  18. 4 31
      include/tool/exception.h
  19. 0 0
      include/tool/exit_.h
  20. 3 3
      include/tool/file.h
  21. 3 3
      include/tool/hash.h
  22. 3 3
      include/tool/log-m.h
  23. 6 7
      include/tool/log.h
  24. 8 6
      include/tool/macro.h
  25. 3 3
      include/tool/md5.h
  26. 4 4
      include/tool/mem.h
  27. 4 4
      include/tool/path.h
  28. 0 0
      include/tool/regex.h
  29. 1 1
      include/tool/stdio_.h
  30. 3 3
      include/tool/str.h
  31. 0 0
      include/tool/time_.h
  32. 6 7
      lang/hgt.cmake
  33. 2 2
      src/CMakeLists.txt
  34. 13 13
      src/core/CMakeLists.txt
  35. 8 8
      src/core/activation.cpp
  36. 2 2
      src/core/code.cpp
  37. 1 1
      src/core/env-var.cpp
  38. 1 1
      src/core/gc.cpp
  39. 1 25
      src/core/init.cpp
  40. 6 6
      src/core/inter.cpp
  41. 4 4
      src/core/msg.cpp
  42. 2 2
      src/core/value.cpp
  43. 2 2
      src/core/var.cpp
  44. 4 4
      src/runtime/CMakeLists.txt
  45. 2 2
      src/tool/CMakeLists.txt
  46. 0 0
      src/tool/__md5.h
  47. 5 3
      src/tool/byte.cpp
  48. 2 2
      src/tool/dlc.cpp
  49. 2 1
      src/tool/exit_.cpp
  50. 7 1
      src/tool/file.cpp
  51. 3 1
      src/tool/hash.cpp
  52. 11 1
      src/tool/log.cpp
  53. 7 2
      src/tool/md5.cpp
  54. 5 2
      src/tool/regex.cpp
  55. 2 1
      src/tool/stdio_.cpp
  56. 3 1
      src/tool/string.cpp
  57. 3 1
      src/tool/time.cpp
  58. 0 0
      test/lib/dlc-lib.cpp
  59. 3 3
      test/src/CMakeLists.txt
  60. 1 1
      test/src/core-code.cpp
  61. 1 1
      test/src/core-down-msg.cpp
  62. 1 1
      test/src/core-env-var.cpp
  63. 1 1
      test/src/core-init.cpp
  64. 1 1
      test/src/core-up-msg.cpp
  65. 1 7
      test/src/run-code.cpp
  66. 1 1
      test/src/tool-byte.cpp
  67. 1 1
      test/src/tool-dlc.cpp
  68. 1 1
      test/src/tool-exit.cpp
  69. 1 1
      test/src/tool-hash.cpp
  70. 1 1
      test/src/tool-logger.cpp
  71. 1 1
      test/src/tool-md5.cpp
  72. 1 1
      test/src/tool-mem.cpp
  73. 1 1
      test/src/tool-regex.cpp
  74. 1 1
      test/src/tool-utf.cpp

+ 17 - 10
CMakeLists.txt

@@ -75,44 +75,51 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
 set(CMAKE_MACOSX_RPATH TRUE)
 include_directories(${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR})  # 添加默认的include路径
 
-set(base_compile_definitions
+set(definitions
+
     aFunVersion="${PROJECT_VERSION}"
     aFunDescription="${PROJECT_DESCRIPTION}"
+
     systemName="${CMAKE_SYSTEM_NAME}"
     compilerID="${CMAKE_C_COMPILER_ID}"
+
     aFunMajorVersion=${PROJECT_VERSION_MAJOR}
     aFunMinorVersion=${PROJECT_VERSION_MINOR}
     aFunPatchVersion=${PROJECT_VERSION_PATCH}
-    aFunLogDir="${INSTALL_LOGDIR_NATIVE}"
-    aFunVarLibDir="${INSTALL_LOCALSTATEDIR_NATIVE}"
-    aFunLangDir="${INSTALL_LANGDIR_NATIVE}"
+
     aFunSharePrefix="${CMAKE_SHARED_LIBRARY_PREFIX}"
     aFunShareSuffix="${CMAKE_SHARED_LIBRARY_SUFFIX}"
     aFunStaticPrefix="${CMAKE_STATIC_LIBRARY_PREFIX}"
     aFunStaticSuffix="${CMAKE_STATIC_LIBRARY_SUFFIX}"
-    aFunExeSuffix="${CMAKE_EXECUTABLE_SUFFIX}")  # 默认的预定义宏
+    aFunExeSuffix="${CMAKE_EXECUTABLE_SUFFIX}"
+
+    aFunLogDir="${INSTALL_LOGDIR_NATIVE}"
+    aFunVarLibDir="${INSTALL_LOCALSTATEDIR_NATIVE}"
+    aFunLangDir="${INSTALL_LANGDIR_NATIVE}")  # 默认的预定义宏
 
 if (WIN32 OR CYGWIN)
-    list(APPEND base_compile_definitions aFunWIN32=1)
+    list(APPEND definitions aFunWIN32=1)
     set(aFunWIN32 1)
 endif()
 
 if (WIN32 AND NOT CYGWIN)
-    list(APPEND base_compile_definitions aFunWIN32_NO_CYGWIN=1)
+    list(APPEND definitions aFunWIN32_NO_CYGWIN=1)
     set(aFunWIN32_NO_CYGWIN 1)
 endif()
 
 if (CYGWIN)
-    list(APPEND base_compile_definitions aFunCYGWIN=1)
+    list(APPEND definitions aFunCYGWIN=1)
     set(aFunCYGWIN 1)
 endif()
 
 if (CMAKE_BUILD_TYPE STREQUAL Debug)
-    list(APPEND base_compile_definitions aFunDEBUG=1)
+    list(APPEND definitions aFunDEBUG=1)
     set(aFunDEBUG 1)
 endif()
 
-configure_file(${CMAKE_SOURCE_DIR}/include/base.h.in ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/base.h @ONLY)
+configure_file(${CMAKE_SOURCE_DIR}/include/base.h.in
+               ${CMAKE_BINARY_DIR}/${INSTALL_INCLUDEDIR}/aFunbase.h
+               @ONLY)
 
 include(${CMAKE_CURRENT_LIST_DIR}/deps/deps.cmake)  # 安装依赖
 include(${CMAKE_CURRENT_LIST_DIR}/lang/hgt.cmake)  # 安装lang库

+ 4 - 4
cmake/CMakeFindExternalProject/WindowsInstall.cmake

@@ -104,13 +104,13 @@ endfunction()
 
 # 添加 target
 if (NOT TARGET import_build)
-    add_custom_target(import_build ALL COMMENT "Copy import target.")
+#    add_custom_target(import_build ALL COMMENT "Copy import target.")
 endif()
 
 macro(set_copy_command target a b)
-    add_custom_command(TARGET ${target} POST_BUILD
-                       COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${a}" "${b}"
-                       COMMENT "Copy ${a}.")
+#    add_custom_command(TARGET ${target} POST_BUILD
+#                       COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${a}" "${b}"
+#                       COMMENT "Copy ${a}.")
 endmacro()
 
 function(_wi_build_import_inline target run lib)

+ 11 - 3
include/base.h.in

@@ -4,22 +4,30 @@
 #ifndef AFUN_BASE_H_IN_H
 #define AFUN_BASE_H_IN_H
 
+// aFun 信息
 #define aFunVersion "@PROJECT_VERSION@"
 #define aFunDescription "@PROJECT_DESCRIPTION@"
+
+// 平台信息
 #define systemName "@CMAKE_SYSTEM_NAME@"
 #define compilerID "@CMAKE_C_COMPILER_ID@"
+
+// 版本信息
 #define aFunMajorVersion @PROJECT_VERSION_MAJOR@
 #define aFunMinorVersion @PROJECT_VERSION_MINOR@
 #define aFunPatchVersion @PROJECT_VERSION_PATCH@
-#define aFunLogDir "@INSTALL_LOGDIR_NATIVE@"
-#define aFunVarLibDir "@INSTALL_LOCALSTATEDIR_NATIVE@"
-#define aFunLangDir "@INSTALL_LANGDIR_NATIVE@"
+
+// 系统信息
 #define aFunSharePrefix "@CMAKE_SHARED_LIBRARY_PREFIX@"
 #define aFunShareSuffix "@CMAKE_SHARED_LIBRARY_SUFFIX@"
 #define aFunStaticPrefix "@CMAKE_STATIC_LIBRARY_PREFIX@"
 #define aFunStaticSuffix "@CMAKE_STATIC_LIBRARY_SUFFIX@"
 #define aFunExeSuffix "@CMAKE_EXECUTABLE_SUFFIX@"
 
+// 运行路径
+#define aFunLogDir "@INSTALL_LOGDIR_NATIVE@"
+#define aFunVarLibDir "@INSTALL_LOCALSTATEDIR_NATIVE@"
+#define aFunLangDir "@INSTALL_LANGDIR_NATIVE@"
 
 #cmakedefine aFunWIN32
 #cmakedefine aFunWIN32_NO_CYGWIN

+ 14 - 0
include/core/aFuncore.h

@@ -0,0 +1,14 @@
+#ifndef AFUN_AFUNCORE_H
+#define AFUN_AFUNCORE_H
+
+#include "init.h"
+#include "code.h"
+#include "inter.h"
+#include "gc.h"
+#include "msg.h"
+#include "env-var.h"
+#include "value.h"
+#include "var.h"
+#include "activation.h"
+
+#endif //AFUN_AFUNCORE_H

+ 6 - 6
include/core/activation.hpp → include/core/activation.h

@@ -1,9 +1,9 @@
-#ifndef AFUN_ACTIVATION_HPP
-#define AFUN_ACTIVATION_HPP
-#include "tool.hpp"
+#ifndef AFUN_ACTIVATION_H
+#define AFUN_ACTIVATION_H
+#include "aFuntool.h"
 #include "aFunCoreExport.h"
-#include "core.hpp"
-#include "value.hpp"
+#include "core.h"
+#include "value.h"
 
 namespace aFuncore {
     AFUN_CORE_EXPORT class Activation {
@@ -77,4 +77,4 @@ namespace aFuncore {
     };
 }
 
-#endif //AFUN_ACTIVATION_HPP
+#endif //AFUN_ACTIVATION_H

+ 5 - 5
include/core/code.hpp → include/core/code.h

@@ -1,8 +1,8 @@
-#ifndef AFUN_CODE_HPP
-#define AFUN_CODE_HPP
-#include "tool.hpp"
+#ifndef AFUN_CODE_H
+#define AFUN_CODE_H
+#include "aFuntool.h"
 #include "aFunCoreExport.h"
-#include "core.hpp"
+#include "core.h"
 
 namespace aFuncore {
     AFUN_CORE_EXPORT class Code {
@@ -77,4 +77,4 @@ namespace aFuncore {
     };
 }
 
-#endif //AFUN_CODE_HPP
+#endif //AFUN_CODE_H

+ 6 - 4
include/core/core.hpp → include/core/core.h

@@ -1,8 +1,10 @@
-#ifndef AFUN_CORE_HPP
-#define AFUN_CORE_HPP
-#include "tool.hpp"
+#ifndef AFUN_CORE_H
+#define AFUN_CORE_H
+#include "aFuntool.h"
 
 namespace aFuncore {
+    using namespace aFuntool;
+
     typedef enum CodeType {
         code_start = 0,
         code_element = 1,
@@ -81,4 +83,4 @@ namespace aFuncore {
     } VarOperationFlat;
 }
 
-#endif //AFUN_CORE_HPP
+#endif //AFUN_CORE_H

+ 4 - 4
include/core/env-var.hpp → include/core/env-var.h

@@ -1,6 +1,6 @@
-#ifndef AFUN_ENV_VAR_HPP
-#define AFUN_ENV_VAR_HPP
-#include "tool.hpp"
+#ifndef AFUN_ENV_VAR_H
+#define AFUN_ENV_VAR_H
+#include "aFuntool.h"
 #include "aFunCoreExport.h"
 
 namespace aFuncore {
@@ -32,4 +32,4 @@ namespace aFuncore {
 }
 
 
-#endif //AFUN_ENV_VAR_HPP
+#endif //AFUN_ENV_VAR_H

+ 4 - 4
include/core/gc.hpp → include/core/gc.h

@@ -1,6 +1,6 @@
-#ifndef AFUN_GC_HPP
-#define AFUN_GC_HPP
-#include "tool.hpp"
+#ifndef AFUN_GC_H
+#define AFUN_GC_H
+#include "aFuntool.h"
 #include "aFunCoreExport.h"
 #include "queue"
 
@@ -67,4 +67,4 @@ namespace aFuncore {
 };
 
 
-#endif //AFUN_GC_HPP
+#endif //AFUN_GC_H

+ 4 - 4
include/core/init.hpp → include/core/init.h

@@ -1,6 +1,6 @@
-#ifndef AFUN_INIT_HPP
-#define AFUN_INIT_HPP
-#include "tool.hpp"
+#ifndef AFUN_INIT_H
+#define AFUN_INIT_H
+#include "aFuntool.h"
 #include "aFunCoreExport.h"
 
 namespace aFuncore {
@@ -18,4 +18,4 @@ namespace aFuncore {
     AFUN_CORE_EXPORT bool aFunCoreInit(InitInfo *info);
 }
 
-#endif //AFUN_INIT_HPP
+#endif //AFUN_INIT_H

+ 5 - 5
include/core/inter.hpp → include/core/inter.h

@@ -1,9 +1,9 @@
-#ifndef AFUN_INTER_HPP
-#define AFUN_INTER_HPP
+#ifndef AFUN_INTER_H
+#define AFUN_INTER_H
 #include <list>
-#include "tool.hpp"
+#include "aFuntool.h"
 #include "aFunCoreExport.h"
-#include "core.hpp"
+#include "core.h"
 
 namespace aFuncore {
     AFUN_CORE_EXPORT class Inter {
@@ -81,4 +81,4 @@ namespace aFuncore {
     };
 }
 
-#endif //AFUN_INTER_HPP
+#endif //AFUN_INTER_H

+ 5 - 5
include/core/msg.hpp → include/core/msg.h

@@ -1,8 +1,8 @@
-#ifndef AFUN_MSG_HPP
-#define AFUN_MSG_HPP
-#include "tool.hpp"
+#ifndef AFUN_MSG_H
+#define AFUN_MSG_H
+#include "aFuntool.h"
 #include "aFunCoreExport.h"
-#include "core.hpp"
+#include "core.h"
 #include "list"
 
 namespace aFuncore {
@@ -95,4 +95,4 @@ namespace aFuncore {
 }
 
 
-#endif //AFUN_MSG_HPP
+#endif //AFUN_MSG_H

+ 6 - 6
include/core/value.hpp → include/core/value.h

@@ -1,10 +1,10 @@
-#ifndef AFUN_VALUE_HPP
-#define AFUN_VALUE_HPP
-#include "tool.hpp"
+#ifndef AFUN_VALUE_H
+#define AFUN_VALUE_H
+#include "aFuntool.h"
 #include "aFunCoreExport.h"
 #include "list"
-#include "core.hpp"
-#include "gc.hpp"
+#include "core.h"
+#include "gc.h"
 
 namespace aFuncore {
     AFUN_CORE_EXPORT class Object : public GcObject<class Object> {
@@ -54,4 +54,4 @@ namespace aFuncore {
     };
 };
 
-#endif //AFUN_VALUE_HPP
+#endif //AFUN_VALUE_H

+ 6 - 6
include/core/var.hpp → include/core/var.h

@@ -1,9 +1,9 @@
-#ifndef AFUN_VAR_HPP
-#define AFUN_VAR_HPP
-#include "tool.hpp"
+#ifndef AFUN_VAR_H
+#define AFUN_VAR_H
+#include "aFuntool.h"
 #include "aFunCoreExport.h"
-#include "core.hpp"
-#include "gc.hpp"
+#include "core.h"
+#include "gc.h"
 #include <list>
 
 namespace aFuncore {
@@ -87,4 +87,4 @@ namespace aFuncore {
     };
 }
 
-#endif //AFUN_VAR_HPP
+#endif //AFUN_VAR_H

+ 30 - 0
include/tool/aFuntool.h

@@ -0,0 +1,30 @@
+/*
+ * 文件名: tool.h
+ * 目标: aFun tool公共API
+ * aFunTool是aFun实用工具库, 内含aFun调用的实用函数
+ */
+
+#ifndef AFUN_AFUNTOOL_H
+#define AFUN_AFUNTOOL_H
+
+#include "macro.h"
+#include "aFunToolExport.h"
+
+#include "pthread.h"
+#include "fflags.h"
+
+#include "exception.h"
+#include "stdio_.h"
+#include "exit_.h"
+#include "byte.h"
+#include "dlc.h"
+#include "file.h"
+#include "hash.h"
+#include "md5.h"
+#include "path.h"
+#include "regex.h"
+#include "str.h"
+#include "time_.h"
+#include "log.h"
+
+#endif //AFUN_AFUNTOOL_H

+ 0 - 0
include/tool/btye.hpp → include/tool/byte.h


+ 3 - 3
include/tool/dlc.hpp → include/tool/dlc.h

@@ -1,5 +1,5 @@
-#ifndef AFUN_DLC_HPP
-#define AFUN_DLC_HPP
+#ifndef AFUN_DLC_H
+#define AFUN_DLC_H
 #include <iostream>
 #include "aFunToolExport.h"
 #include "dlfcn.h"  // CMake 处理 dlfcn.h 的位置
@@ -131,4 +131,4 @@ namespace aFuntool {
     };
 }
 
-#endif //AFUN_DLC_HPP
+#endif //AFUN_DLC_H

+ 4 - 31
include/tool/tool.hpp → include/tool/exception.h

@@ -1,14 +1,6 @@
-/*
- * 文件名: tool.h
- * 目标: aFun tool公共API
- * aFunTool是aFun实用工具库, 内含aFun调用的实用函数
- */
-
-#ifndef AFUN_TOOL_HPP
-#define AFUN_TOOL_HPP
-
-#include "macro.hpp"
-#include "aFunToolExport.h"
+#ifndef AFUN_EXCEPTION_H
+#define AFUN_EXCEPTION_H
+#include "macro.h"
 
 namespace aFuntool {
     class FileOpenException : public std::exception {
@@ -34,23 +26,4 @@ namespace aFuntool {
     };
 }
 
-#include "pthread.h"
-#include "fflags.h"
-#include "aFun_ht.h"
-
-#include "mem.hpp"
-
-#include "stdio_.hpp"
-#include "exit_.hpp"
-#include "btye.hpp"
-#include "dlc.hpp"
-#include "file.hpp"
-#include "hash.hpp"
-#include "md5.hpp"
-#include "path.hpp"
-#include "regex.hpp"
-#include "str.hpp"
-#include "time_.hpp"
-#include "log.hpp"
-
-#endif //AFUN_TOOL_HPP
+#endif //AFUN_EXCEPTION_H

+ 0 - 0
include/tool/exit_.hpp → include/tool/exit_.h


+ 3 - 3
include/tool/file.hpp → include/tool/file.h

@@ -1,5 +1,5 @@
-#ifndef AFUN_FILE_HPP
-#define AFUN_FILE_HPP
+#ifndef AFUN_FILE_H
+#define AFUN_FILE_H
 #include "aFunToolExport.h"
 
 /* 文件处理工具 */
@@ -21,4 +21,4 @@ namespace aFuntool {
     AFUN_TOOL_EXPORT FILE *fileOpen(const char *path_, const char *mode_);
     AFUN_TOOL_EXPORT int fileClose(FILE *file);
 }
-#endif //AFUN_FILE_HPP
+#endif //AFUN_FILE_H

+ 3 - 3
include/tool/hash.hpp → include/tool/hash.h

@@ -1,5 +1,5 @@
-#ifndef AFUN_HASH_HPP
-#define AFUN_HASH_HPP
+#ifndef AFUN_HASH_H
+#define AFUN_HASH_H
 #include "aFunToolExport.h"
 
 /* 哈希工具 */
@@ -9,4 +9,4 @@ namespace aFuntool {
     AFUN_TOOL_EXPORT time33_t time33(const std::string &str);
 }
 
-#endif //AFUN_HASH_HPP
+#endif //AFUN_HASH_H

+ 3 - 3
include/tool/log-m.hpp → include/tool/log-m.h

@@ -1,5 +1,5 @@
-#ifndef AFUN_LOG_M_HPP
-#define AFUN_LOG_M_HPP
+#ifndef AFUN_LOG_M_H
+#define AFUN_LOG_M_H
 
 #if (defined aFunOFFAllLog || defined aFunOFFLog)
 
@@ -144,4 +144,4 @@
 #define aFunConsoleFatalError 1
 #endif
 
-#endif //AFUN_LOG_M_HPP
+#endif //AFUN_LOG_M_H

+ 6 - 7
include/tool/log.hpp → include/tool/log.h

@@ -1,12 +1,9 @@
-#ifndef AFUN_LOG_HPP
-#define AFUN_LOG_HPP
+#ifndef AFUN_LOG_H
+#define AFUN_LOG_H
 
 #include <iostream>
 #include "aFunToolExport.h"
-#include "macro.hpp"
-#include "log-m.hpp"
-
-using namespace aFuntool;
+#include "macro.h"
 
 namespace aFuntool {
     enum LogLevel {
@@ -92,6 +89,8 @@ namespace aFuntool {
 
 #ifndef NO_DEFINE_LOG_MACRO
 
+#include "log-m.h"
+
 #define getLogger(logger) ((logger) == nullptr ? &aFuntool::log_factory.sys_log : (logger))
 
 #if aFunWriteTrack
@@ -145,4 +144,4 @@ namespace aFuntool {
 #endif
 
 #endif
-#endif //AFUN_LOG_HPP
+#endif //AFUN_LOG_H

+ 8 - 6
include/tool/macro.hpp → include/tool/macro.h

@@ -3,20 +3,22 @@
  * 目标: 定义公共宏 和 公共头文件
  */
 
-#ifndef AFUN_MACRO_HPP
-#define AFUN_MACRO_HPP
+#ifndef AFUN_MACRO_H
+#define AFUN_MACRO_H
 #include <iostream>
 #include <cinttypes>
 #include <cstdarg>
-#include "base.h"
-
-#define NUL ((char)0)
+#include "aFunbase.h"
 
 namespace aFuntool {
+    static const char NUL = 0;
+
     typedef uint32_t FileLine;  // 文件行号
     typedef char *FilePath;  // 文件路径  (用于多处内存存储场景)
     typedef std::string StringFilePath;  // 文件路径  (用于单处内存存储场景)
     typedef const std::string &ConstFilePath;  // 文件路径  (用于参数)
 }
 
-#endif //AFUN_MACRO_HPP
+#include "mem.h"
+
+#endif //AFUN_MACRO_H

+ 3 - 3
include/tool/md5.hpp → include/tool/md5.h

@@ -1,5 +1,5 @@
-#ifndef AFUN_MD5_HPP
-#define AFUN_MD5_HPP
+#ifndef AFUN_MD5_H
+#define AFUN_MD5_H
 #include "aFunToolExport.h"
 
 /* md5计算工具 */
@@ -20,4 +20,4 @@ namespace aFuntool {
     T getFileMd5 (T &path);
 }
 
-#endif //AFUN_MD5_HPP
+#endif //AFUN_MD5_H

+ 4 - 4
include/tool/mem.hpp → include/tool/mem.h

@@ -3,11 +3,11 @@
  * 目标: 内存管理工具的头文件
  */
 
-#ifndef AFUN_MEM_HPP
-#define AFUN_MEM_HPP
+#ifndef AFUN_MEM_H
+#define AFUN_MEM_H
 
 #include <cstdlib>
-#include "log.hpp"
+#include "log.h"
 
 
 /* 取代calloc函数 */
@@ -37,4 +37,4 @@ namespace aFuntool {
 #define calloc_size(n, size) (aFuntool::safeCalloc(n, size))
 #endif
 
-#endif  // AFUN_MEM_HPP
+#endif  // AFUN_MEM_H

+ 4 - 4
include/tool/path.hpp → include/tool/path.h

@@ -1,6 +1,6 @@
-#ifndef AFUN_PATH_HPP
-#define AFUN_PATH_HPP
-#include "base.h"
+#ifndef AFUN_PATH_H
+#define AFUN_PATH_H
+#include "macro.h"
 
 /* 路径工具 */
 #ifdef aFunWIN32_NO_CYGWIN
@@ -29,4 +29,4 @@ namespace aFuntool {
     static const char *EXE_SUFFIX = aFunExeSuffix;
 }
 
-#endif //AFUN_PATH_HPP
+#endif //AFUN_PATH_H

+ 0 - 0
include/tool/regex.hpp → include/tool/regex.h


+ 1 - 1
include/tool/stdio_.hpp → include/tool/stdio_.h

@@ -1,7 +1,7 @@
 #ifndef AFUN_STDIO_H
 #define AFUN_STDIO_H
 #include <cstdio>
-#include "base.h"
+#include "macro.h"
 #include "aFunToolExport.h"
 
 namespace aFuntool {

+ 3 - 3
include/tool/str.hpp → include/tool/str.h

@@ -1,5 +1,5 @@
-#ifndef AFUN_STR_HPP
-#define AFUN_STR_HPP
+#ifndef AFUN_STR_H
+#define AFUN_STR_H
 #include <cwchar>
 #include <cstring>
 #include "aFunToolExport.h"
@@ -14,4 +14,4 @@ namespace aFuntool {
     AFUN_TOOL_EXPORT char *convertToStr(const wchar_t *wstr, bool free_old);
 }
 
-#endif //AFUN_STR_HPP
+#endif //AFUN_STR_H

+ 0 - 0
include/tool/time_.hpp → include/tool/time_.h


+ 6 - 7
lang/hgt.cmake

@@ -27,7 +27,7 @@ unset(include_n)
 add_custom_target(hgt ALL)
 add_custom_command(TARGET hgt POST_BUILD
                    COMMAND ${HGT_COMMAND}
-                   COMMENT "The hgt_generate_file: base")
+                   COMMENT "The hgt generate file: base")
 
 execute_process(COMMAND ${HGT_COMMAND}
                 RESULT_VARIABLE re
@@ -77,6 +77,11 @@ function(build_lang)
         cmake_path(GET src STEM name)
         add_library(hgt-${name} SHARED ${src})
         add_dependencies(hgt-${name} hgt-base)
+        add_custom_command(TARGET hgt-${name} POST_BUILD
+                           COMMAND ${CMAKE_COMMAND} -E echo "$<TARGET_FILE_BASE_NAME:hgt-${name}>" ">>" "LANG"
+                           WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_LANGDIR}"
+                           COMMENT "Creat file ${CMAKE_BINARY_DIR}/${INSTALL_LANGDIR}/LANG")
+
         set_target_properties(hgt-${name} PROPERTIES OUTPUT_NAME "${name}")
 
         target_compile_definitions(hgt-${name} PRIVATE hgt_base_EXPORTS)
@@ -89,10 +94,4 @@ function(build_lang)
 endfunction()
 
 build_lang()  # 使用函数防止 CMAKE_RUNTIME_OUTPUT_DIRECTORY 影响外部
-
-add_custom_command(TARGET hgt-zh_cn
-                   COMMAND ${CMAKE_COMMAND} -E echo "$<TARGET_FILE_BASE_NAME:hgt-zh_cn>" ">>" "LANG"
-                   WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_LANGDIR}"
-                   COMMENT "Creat file ${CMAKE_BINARY_DIR}/${INSTALL_LANGDIR}/LANG")
-
 unset(hgt-name)

+ 2 - 2
src/CMakeLists.txt

@@ -35,11 +35,11 @@ add_subdirectory(core)  # core 依赖 tool
 #
 #file(GLOB private_h
 #     LIST_DIRECTORIES FALSE
-#     ${CMAKE_CURRENT_LIST_DIR}/*.hpp)
+#     ${CMAKE_CURRENT_LIST_DIR}/*.h)
 #
 #file(GLOB include_h
 #     LIST_DIRECTORIES FALSE
-#     "${PROJECT_SOURCE_DIR}/include/*.hpp")
+#     "${PROJECT_SOURCE_DIR}/include/*.h")
 #
 #add_executable(aFun-xx "")  # xx表示均为动态链接
 #add_executable(aFun-ct "")  # ct表示均静态链接

+ 13 - 13
src/core/CMakeLists.txt

@@ -4,12 +4,12 @@
 
 file(GLOB private_h
      LIST_DIRECTORIES FALSE
-     ${CMAKE_CURRENT_LIST_DIR}/*.hpp)
+     ${CMAKE_CURRENT_LIST_DIR}/*.h)
 
 file(GLOB public_h
      LIST_DIRECTORIES FALSE
      RELATIVE "${build_include_core}"
-     "${build_include_core}/*.hpp")
+     "${build_include_core}/*.h")
 
 file(GLOB public_h_info
      LIST_DIRECTORIES FALSE
@@ -43,16 +43,16 @@ foreach(tgt core-shared core-static)
     define_FILENAME(${tgt})
 endforeach()
 
-set_target_properties(core-shared PROPERTIES OUTPUT_NAME "aFuncore")
-set_target_properties(core-static PROPERTIES OUTPUT_NAME "aFuncore-s")
-
+#set_target_properties(core-shared PROPERTIES OUTPUT_NAME "aFuncore")
+#set_target_properties(core-static PROPERTIES OUTPUT_NAME "aFuncore-s")
+#
 target_link_libraries(core-shared PUBLIC tool-shared)
 target_link_libraries(core-static PUBLIC tool-static)
-
-install(TARGETS core-shared core-static
-        EXPORT aFunlang
-        RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT base-runtime
-        ARCHIVE DESTINATION ${INSTALL_LIBDIR} COMPONENT dev
-        LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT base-runtime
-        PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT dev
-        PRIVATE_HEADER DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT advanced-dev)
+#
+#install(TARGETS core-shared core-static
+#        EXPORT aFunlang
+#        RUNTIME DESTINATION ${INSTALL_BINDIR} COMPONENT base-runtime
+#        ARCHIVE DESTINATION ${INSTALL_LIBDIR} COMPONENT dev
+#        LIBRARY DESTINATION ${INSTALL_LIBDIR} COMPONENT base-runtime
+#        PUBLIC_HEADER DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT dev
+#        PRIVATE_HEADER DESTINATION ${INSTALL_INCLUDEDIR} COMPONENT advanced-dev)

+ 8 - 8
src/core/activation.cpp

@@ -1,11 +1,11 @@
-#include "activation.hpp"
-#include "value.hpp"
-#include "inter.hpp"
-#include "init.hpp"
-#include "msg.hpp"
-#include "var.hpp"
-#include "code.hpp"
-#include "env-var.hpp"
+#include "activation.h"
+#include "value.h"
+#include "inter.h"
+#include "init.h"
+#include "msg.h"
+#include "var.h"
+#include "code.h"
+#include "env-var.h"
 
 using namespace aFuncore;
 using namespace aFuntool;

+ 2 - 2
src/core/code.cpp

@@ -1,5 +1,5 @@
-#include "code.hpp"
-#include "init.hpp"
+#include "code.h"
+#include "init.h"
 using namespace aFuncore;
 using namespace aFuntool;
 

+ 1 - 1
src/core/env-var.cpp

@@ -1,4 +1,4 @@
-#include "env-var.hpp"
+#include "env-var.h"
 using namespace aFuncore;
 using namespace aFuntool;
 

+ 1 - 1
src/core/gc.cpp

@@ -1,4 +1,4 @@
-#include "gc.hpp"
+#include "gc.h"
 using namespace aFuncore;
 using namespace aFuntool;
 

+ 1 - 25
src/core/init.cpp

@@ -1,11 +1,10 @@
 #include <clocale>
-#include "init.hpp"
+#include "init.h"
 using namespace aFuncore;
 using namespace aFuntool;
 
 namespace aFuncore {
     std::string log_path;
-    std::string lang_path;
     std::string varlib_path;
     aFuntool::Logger *aFunCoreLogger;
 };
@@ -30,7 +29,6 @@ bool aFuncore::aFunCoreInit(aFuncore::InitInfo *info) {
         return false;
 
     log_path = info->base_dir + SEP + aFunLogDir + SEP;
-    lang_path = info->base_dir + SEP + aFunLangDir + SEP;
     varlib_path = info->base_dir + SEP + aFunVarLibDir + SEP;
 
     std::string log = log_path + "aFunlang";
@@ -43,29 +41,7 @@ bool aFuncore::aFunCoreInit(aFuncore::InitInfo *info) {
 
     debugLog(aFunCoreLogger, "aFunCore log path: %s", log_path.c_str());
     debugLog(aFunCoreLogger, "aFunCore var.lib path: %s", varlib_path.c_str());
-    debugLog(aFunCoreLogger, "aFunCore lang path: %s", lang_path.c_str());
 
-    char LANG_path[218] = {0};
-    snprintf(LANG_path, 218, "%sLANG", lang_path.c_str());
-
-    FILE *LANG_file = fileOpen(LANG_path, "r");
-    if (LANG_file != nullptr) {
-        char LANG[100] = {0};
-        fgets(LANG, 100, LANG_file);
-        if (LANG[strlen(LANG) - 1] == '\n')
-            LANG[strlen(LANG) - 1] = NUL;  // 去除`\n`
-        debugLog(aFunCoreLogger, "language = %s", LANG);
-
-        char LANG_lib[218] = {0};
-        std::string tmp = std::string("%s") + SHARED_PREFIX + "%s" + SHARED_SUFFIX;
-        snprintf(LANG_lib, 218, tmp.c_str(), lang_path.c_str(), LANG);
-        if (HT_initaFunGetText(LANG_lib) == 0)
-            debugLog(aFunCoreLogger, "aFunCore lang init success: %s", LANG_lib);
-        else
-            debugLog(aFunCoreLogger, "aFunCore lang init failed: %s", LANG_lib);
-        fileClose(LANG_file);
-    } else
-        HT_initaFunGetText(nullptr);
     debugLog(aFunCoreLogger, "aFunCore init success");
     return true;
 }

+ 6 - 6
src/core/inter.cpp

@@ -1,9 +1,9 @@
-#include "inter.hpp"
-#include "activation.hpp"
-#include "init.hpp"
-#include "env-var.hpp"
-#include "var.hpp"
-#include "msg.hpp"
+#include "inter.h"
+#include "activation.h"
+#include "init.h"
+#include "env-var.h"
+#include "var.h"
+#include "msg.h"
 
 using namespace aFuncore;
 using namespace aFuntool;

+ 4 - 4
src/core/msg.cpp

@@ -1,7 +1,7 @@
-#include "msg.hpp"
-#include "activation.hpp"
-#include "inter.hpp"
-#include "env-var.hpp"
+#include "msg.h"
+#include "activation.h"
+#include "inter.h"
+#include "env-var.h"
 
 using namespace aFuncore;
 using namespace aFuntool;

+ 2 - 2
src/core/value.cpp

@@ -1,5 +1,5 @@
-#include "value.hpp"
-#include "inter.hpp"
+#include "value.h"
+#include "inter.h"
 
 using namespace aFuncore;
 using namespace aFuntool;

+ 2 - 2
src/core/var.cpp

@@ -1,5 +1,5 @@
-#include "var.hpp"
-#include "inter.hpp"
+#include "var.h"
+#include "inter.h"
 
 using namespace aFuncore;
 using namespace aFuntool;

+ 4 - 4
src/runtime/CMakeLists.txt

@@ -8,20 +8,20 @@ file(GLOB source_tool
 
 file(GLOB private_h
      LIST_DIRECTORIES FALSE
-     ${CMAKE_CURRENT_LIST_DIR}/*.hpp)
+     ${CMAKE_CURRENT_LIST_DIR}/*.h)
 
 file(GLOB private_tool_h
      LIST_DIRECTORIES FALSE
-     ${CMAKE_CURRENT_LIST_DIR}/*/*.hpp)
+     ${CMAKE_CURRENT_LIST_DIR}/*/*.h)
 
 file(GLOB private_h_core
      LIST_DIRECTORIES FALSE
-     ${CMAKE_CURRENT_LIST_DIR}/../core/*.hpp)  # 需要使用 core 的特定头文件 (高级开发)
+     ${CMAKE_CURRENT_LIST_DIR}/../core/*.h)  # 需要使用 core 的特定头文件 (高级开发)
 
 file(GLOB public_h
      LIST_DIRECTORIES FALSE
      RELATIVE "${build_include_runtime}"
-     "${build_include_runtime}/*.hpp")
+     "${build_include_runtime}/*.h")
 
 set(public_h_build)
 set(public_h_install)

+ 2 - 2
src/tool/CMakeLists.txt

@@ -7,12 +7,12 @@ file(GLOB source
 
 file(GLOB private_h
      LIST_DIRECTORIES FALSE
-     ${CMAKE_CURRENT_LIST_DIR}/*.hpp)
+     ${CMAKE_CURRENT_LIST_DIR}/*.h)
 
 file(GLOB public_h
      LIST_DIRECTORIES FALSE
      RELATIVE "${build_include_tool}"
-     "${build_include_tool}/*.hpp")
+     "${build_include_tool}/*.h")
 
 set(public_h_build)
 set(public_h_install)

+ 0 - 0
src/tool/__md5.hpp → src/tool/__md5.h


+ 5 - 3
src/tool/byte.cpp

@@ -2,7 +2,9 @@
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
-#include "tool.hpp"
+#include "macro.h"
+#include "byte.h"
+
 using namespace aFuntool;
 
 namespace aFuntool {
@@ -37,7 +39,7 @@ void aFuntool::getEndian() {
 template <typename T>
 bool aFuntool::byteWriteInt(FILE *file, T num) {
     if (endian != save_as) {
-        const size_t len = sizeof(T) / sizeof(uint8_t);
+        const size_t len = sizeof(T) / sizeof(uint8_t);  // NOLINT 允许 size(T) / size(T)
         union {
             T a;//元素a,占2个字节
             uint8_t b[len];//元素b,占1个字节,b在内存中的地址为a最低字节的地址
@@ -63,7 +65,7 @@ bool aFuntool::byteReadInt(FILE *file, T *num) {
     size_t re = fread(num, sizeof(T), 1, file);
 
     if (endian != save_as) {
-        const size_t len = sizeof(T) / sizeof(uint8_t);
+        const size_t len = sizeof(T) / sizeof(uint8_t);  // NOLINT 允许 size(T) / size(T)
         union {
             T a;//元素a,占2个字节
             uint8_t b[len];//元素b,占1个字节,b在内存中的地址为a最低字节的地址

+ 2 - 2
src/tool/dlc.cpp

@@ -1,5 +1,5 @@
-#include "tool.hpp"
-#include "dlc.hpp"
+#include "macro.h"
+#include "dlc.h"
 using namespace aFuntool;
 
 static DlcHandle *dlc_l = nullptr;

+ 2 - 1
src/tool/exit_.cpp

@@ -1,4 +1,5 @@
-#include "tool.hpp"
+#include "macro.h"
+#include "exit_.h"
 #include "pthread.h"
 using namespace aFuntool;
 

+ 7 - 1
src/tool/file.cpp

@@ -8,7 +8,13 @@
 #include <cstdio>
 #include <cstdlib>
 
-#include "tool.hpp"
+#include "macro.h"
+#include "file.h"
+#include "path.h"
+#include "str.h"
+#include "log.h"
+#include "stdio_.h"
+
 using namespace aFuntool;
 
 #ifdef aFunWIN32_NO_CYGWIN

+ 3 - 1
src/tool/hash.cpp

@@ -3,7 +3,9 @@
  * 目标: 关于哈希表的实用函数
  */
 
-#include "tool.hpp"
+#include "macro.h"
+#include "hash.h"
+
 using namespace aFuntool;
 
 time33_t aFuntool::time33(const char *str) {

+ 11 - 1
src/tool/log.cpp

@@ -16,7 +16,17 @@
 #include <cstdlib>
 #include <cstdarg>
 #include <cstring>
-#include "tool.hpp"
+#include "macro.h"
+#include "log.h"
+#include "exception.h"
+#include "log-m.h"
+#include "time_.h"
+#include "file.h"
+#include "stdio_.h"
+#include "str.h"
+#include "exit_.h"
+#include "pthread.h"
+
 using namespace aFuntool;
 
 #ifdef aFunWIN32

+ 7 - 2
src/tool/md5.cpp

@@ -4,9 +4,14 @@
  */
 
 #include <cstdio>
+#include <cstring>
+
+#include "macro.h"
+#include "md5.h"
+#include "file.h"
+#include "exception.h"
+#include "__md5.h"
 
-#include "tool.hpp"
-#include "__md5.hpp"
 using namespace aFuntool;
 
 namespace aFuntool {

+ 5 - 2
src/tool/regex.cpp

@@ -1,9 +1,12 @@
 #include <cstdio>
-#include "tool.hpp"
+#include <cstring>
+#include "macro.h"
+#include "exception.h"
+#include "file.h"
 
 #define PCRE2_CODE_UNIT_WIDTH 8
 #include "pcre2.h"
-#include "regex.hpp"
+#include "regex.h"
 using namespace aFuntool;
 
 aFuntool::Regex::Regex(const std::string &pattern_) : pattern {pattern_} {

+ 2 - 1
src/tool/stdio_.cpp

@@ -8,7 +8,8 @@
 #include <cstring>
 #include <cstdarg>
 #include <csignal>
-#include "tool.hpp"
+#include "macro.h"
+#include "stdio_.h"
 using namespace aFuntool;
 
 /* 注意:

+ 3 - 1
src/tool/string.cpp

@@ -5,7 +5,9 @@
 
 #include <cstdlib>
 #include <cstring>
-#include "tool.hpp"
+#include "macro.h"
+#include "str.h"
+
 using namespace aFuntool;
 
 #define EQ_STR(str1, str2) (!strcmp((str1), (str2)))

+ 3 - 1
src/tool/time.cpp

@@ -4,7 +4,9 @@
  */
 
 #include <ctime>
-#include "tool.hpp"
+#include "macro.h"
+#include "time_.h"
+#include "stdio_.h"
 
 /**
  * 等待指定的秒数(ms) 支持小数

+ 0 - 0
test/lib/dlc_lib.cpp → test/lib/dlc-lib.cpp


+ 3 - 3
test/src/CMakeLists.txt

@@ -5,9 +5,9 @@ foreach(src IN LISTS src_list)
     cmake_path(GET src STEM file_name)
     add_executable(${file_name})
     target_sources(${file_name} PRIVATE ${src})
-    target_link_libraries(${file_name} PUBLIC core-static)  # 链接静态库 (导出所有符号)
+    target_link_libraries(${file_name} PUBLIC tool-static core-static)  # 链接静态库 (导出所有符号)
     set_target_properties(${file_name}
-                          PROPERTIES OUTPUT_NAME "test_${file_name}")
+                          PROPERTIES OUTPUT_NAME "test-${file_name}")
     target_compile_definitions(${file_name} PRIVATE IN_CTEST)
     define_FILENAME(${file_name})
     unset(file_name)
@@ -17,7 +17,7 @@ endforeach()
 file(MD5 "${CMAKE_CURRENT_LIST_DIR}/../share/md5.txt" TOOL_MD5_ANS)
 add_new_test(tool-byte COMMAND "$<TARGET_FILE:tool-byte>")
 add_new_test(tool-mem COMMAND "$<TARGET_FILE:tool-mem>")
-add_new_test(tool-dlc COMMAND "$<TARGET_FILE:tool-byte>" "$<TARGET_FILE:dlc_lib>")
+add_new_test(tool-dlc COMMAND "$<TARGET_FILE:tool-byte>" "$<TARGET_FILE:dlc-lib>")
 add_new_test(tool-regex COMMAND "$<TARGET_FILE:tool-regex>")
 add_new_test(tool-md5 COMMAND "$<TARGET_FILE:tool-md5>" "${TOOL_MD5_ANS}" "${CMAKE_CURRENT_LIST_DIR}/../share/md5.txt")
 add_new_test(tool-logger COMMAND "$<TARGET_FILE:tool-logger>")

+ 1 - 1
test/src/core-code.cpp

@@ -1,4 +1,4 @@
-#include "code.hpp"
+#include "code.h"
 using namespace aFuncore;
 using namespace aFuntool;
 

+ 1 - 1
test/src/core-down-msg.cpp

@@ -1,4 +1,4 @@
-#include "msg.hpp"
+#include "msg.h"
 using namespace aFuncore;
 using namespace aFuntool;
 

+ 1 - 1
test/src/core-env-var.cpp

@@ -1,4 +1,4 @@
-#include "env-var.hpp"
+#include "env-var.h"
 using namespace aFuncore;
 using namespace aFuntool;
 

+ 1 - 1
test/src/core-init.cpp

@@ -1,4 +1,4 @@
-#include "init.hpp"
+#include "init.h"
 using namespace aFuncore;
 using namespace aFuntool;
 

+ 1 - 1
test/src/core-up-msg.cpp

@@ -1,4 +1,4 @@
-#include "msg.hpp"
+#include "msg.h"
 using namespace aFuncore;
 using namespace aFuntool;
 

+ 1 - 7
test/src/run-code.cpp

@@ -1,10 +1,4 @@
-#include "inter.hpp"
-#include "value.hpp"
-#include "var.hpp"
-#include "code.hpp"
-#include "msg.hpp"
-#include "activation.hpp"
-#include "env-var.hpp"
+#include "aFuncore.h"
 
 using namespace aFuncore;
 using namespace aFuntool;

+ 1 - 1
test/src/tool-byte.cpp

@@ -1,5 +1,5 @@
 #include <cstdio>
-#include "tool.hpp"
+#include "aFuntool.h"
 using namespace aFuntool;
 
 

+ 1 - 1
test/src/tool-dlc.cpp

@@ -1,6 +1,6 @@
 #include <cstdio>
 #include <cstdlib>
-#include "tool.hpp"
+#include "aFuntool.h"
 using namespace aFuntool;
 
 int test_func() {

+ 1 - 1
test/src/tool-exit.cpp

@@ -1,5 +1,5 @@
 #include <iostream>
-#include "tool.hpp"
+#include "aFuntool.h"
 using namespace aFuntool;
 
 void exit_func(void *) {

+ 1 - 1
test/src/tool-hash.cpp

@@ -1,4 +1,4 @@
-#include "tool.hpp"
+#include "aFuntool.h"
 using namespace aFuntool;
 
 int main(int argc, char **argv) {

+ 1 - 1
test/src/tool-logger.cpp

@@ -1,4 +1,4 @@
-#include "tool.hpp"
+#include "aFuntool.h"
 using namespace aFuntool;
 
 int main(int argc, char **argv){

+ 1 - 1
test/src/tool-md5.cpp

@@ -1,4 +1,4 @@
-#include "tool.hpp"
+#include "aFuntool.h"
 
 int main(int argc, char **argv) {
     if (argc != 3)

+ 1 - 1
test/src/tool-mem.cpp

@@ -1,4 +1,4 @@
-#include "tool.hpp"
+#include "aFuntool.h"
 
 int main() {
     int *p = calloc(1, int);

+ 1 - 1
test/src/tool-regex.cpp

@@ -1,6 +1,6 @@
 #include <cstdio>
 #include <iostream>
-#include "tool.hpp"
+#include "aFuntool.h"
 
 int main() {
     Regex *rg = new Regex("Hello嘿.*d");

+ 1 - 1
test/src/tool-utf.cpp

@@ -1,4 +1,4 @@
-#include "tool.hpp"
+#include "aFuntool.h"
 #include <clocale>
 using namespace aFuntool;