Pārlūkot izejas kodu

refactor & fix: 修复部分GCC警告

* 未使用变量
* 未使用函数
* 长度不同的数据进行比较
* 优先级问题
* 初始化列表问题
* 求值但不使用
SongZihuan 3 gadi atpakaļ
vecāks
revīzija
0113ceb6c8
61 mainītis faili ar 411 papildinājumiem un 393 dzēšanām
  1. 14 14
      include/core/code.h
  2. 14 14
      include/core/code.inline.h
  3. 16 16
      include/core/core-activation.h
  4. 15 15
      include/core/core-activation.inline.h
  5. 5 5
      include/core/core-exception.h
  6. 5 5
      include/core/core-exception.inline.h
  7. 2 2
      include/core/core-init.h
  8. 2 2
      include/core/core-init.inline.h
  9. 7 7
      include/core/core-parser.h
  10. 6 6
      include/core/core-parser.inline.h
  11. 2 2
      include/core/env-var.h
  12. 1 1
      include/core/env-var.inline.h
  13. 22 22
      include/core/inter.h
  14. 18 18
      include/core/inter.inline.h
  15. 7 7
      include/core/msg.h
  16. 8 8
      include/core/msg.inline.h
  17. 1 1
      include/core/msg.template.h
  18. 13 13
      include/core/object-value.h
  19. 10 10
      include/core/object-value.inline.h
  20. 11 11
      include/core/object.h
  21. 4 4
      include/core/object.inline.h
  22. 8 8
      include/core/reader.h
  23. 3 3
      include/core/reader.inline.h
  24. 2 2
      include/interface/it-exception.h
  25. 2 2
      include/interface/it-exception.inline.h
  26. 2 2
      include/interface/it-init.h
  27. 2 2
      include/interface/it-init.inline.h
  28. 2 2
      include/interface/it-reader.h
  29. 2 2
      include/interface/it-reader.inline.h
  30. 2 0
      include/tool/aFuntool.h
  31. 2 2
      include/tool/byte.template.h
  32. 12 12
      include/tool/dlc.h
  33. 9 9
      include/tool/dlc.inline.h
  34. 5 3
      include/tool/log.h
  35. 1 1
      include/tool/log.inline.h
  36. 8 0
      include/tool/macro.h
  37. 3 3
      include/tool/mem.template.h
  38. 10 9
      include/tool/path.h
  39. 9 8
      include/tool/tool-exception.h
  40. 8 8
      include/tool/tool-exception.inline.h
  41. 2 1
      include/tool/tool-logger.h
  42. 1 1
      include/tool/tool-logger.inline.h
  43. 5 4
      include/tool/tool-regex.h
  44. 2 2
      include/tool/tool-regex.inline.h
  45. 37 36
      include/tool/tool-stdio.h
  46. 35 35
      include/tool/tool-stdio.inline.h
  47. 3 1
      include/tool/tool-type.h
  48. 1 1
      src/CMakeLists.txt
  49. 2 3
      src/core/activation.cpp
  50. 3 4
      src/core/inter.cpp
  51. 1 1
      src/core/lexical.cpp
  52. 3 2
      src/core/msg.cpp
  53. 2 2
      src/core/object-value.cpp
  54. 4 4
      src/core/object.cpp
  55. 1 1
      src/tool/file.cpp
  56. 2 2
      src/tool/log.cpp
  57. 6 6
      src/tool/md5.cpp
  58. 1 1
      src/tool/regex.cpp
  59. 18 18
      src/tool/stdio.cpp
  60. 4 4
      test/src/run-code.cpp
  61. 3 3
      test/src/tool-utf.cpp

+ 14 - 14
include/core/code.h

@@ -8,7 +8,7 @@ namespace aFuncore {
     public:
         class ByteCode;
 
-        inline explicit Code(aFuntool::FilePath file_);
+        AFUN_INLINE explicit Code(aFuntool::FilePath file_);
         ~Code();
         Code &operator=(const Code &)=delete;
 
@@ -20,8 +20,8 @@ namespace aFuncore {
         void display() const;
 #endif
 
-        [[nodiscard]] inline const aFuntool::FilePath &getFilePath() const;
-        [[nodiscard]] inline ByteCode *getByteCode() const;
+        [[nodiscard]] AFUN_INLINE const aFuntool::FilePath &getFilePath() const;
+        [[nodiscard]] AFUN_INLINE ByteCode *getByteCode() const;
     private:
         ByteCode *code;
         aFuntool::FilePath file;
@@ -59,18 +59,18 @@ namespace aFuncore {
         void display() const;
 #endif
 
-        [[nodiscard]] CodeType getType() const;
-        [[nodiscard]] char getPrefix() const;
+        [[nodiscard]] AFUN_INLINE CodeType getType() const;
+        [[nodiscard]] AFUN_INLINE char getPrefix() const;
 
-        [[nodiscard]] const char *getElement() const;
-        [[nodiscard]] BlockType getBlockType() const;
-        [[nodiscard]] ByteCode *getSon() const;
-        [[nodiscard]] aFuntool::FileLine getFileLine() const;
-        [[nodiscard]] const aFuntool::FilePath &getFilePath() const;
+        [[nodiscard]] AFUN_INLINE const char *getElement() const;
+        [[nodiscard]] AFUN_INLINE BlockType getBlockType() const;
+        [[nodiscard]] AFUN_INLINE ByteCode *getSon() const;
+        [[nodiscard]] AFUN_INLINE aFuntool::FileLine getFileLine() const;
+        [[nodiscard]] AFUN_INLINE const aFuntool::FilePath &getFilePath() const;
 
-        [[nodiscard]] ByteCode *toNext() const;
-        [[nodiscard]] ByteCode *toPrev() const;
-        [[nodiscard]] ByteCode *toFather() const;
+        [[nodiscard]] AFUN_INLINE ByteCode *toNext() const;
+        [[nodiscard]] AFUN_INLINE ByteCode *toPrev() const;
+        [[nodiscard]] AFUN_INLINE ByteCode *toFather() const;
 
     private:
         CodeType type;
@@ -82,7 +82,7 @@ namespace aFuncore {
                 BlockType block_type;
                 ByteCode *son;
             };
-            inline CodeData();
+            AFUN_INLINE CodeData();
         } data;
 
         ByteCode *father = nullptr;

+ 14 - 14
include/core/code.inline.h

@@ -3,65 +3,65 @@
 #include "code.h"
 
 namespace aFuncore {
-    inline Code::Code(aFuntool::FilePath file_) : code{new ByteCode(*this, 0)}, file{std::move(file_)} {
+    Code::Code(aFuntool::FilePath file_) : code{new ByteCode(*this, 0)}, file{std::move(file_)} {
 
     }
 
-    inline Code::ByteCode *Code::getByteCode() const{
+    Code::ByteCode *Code::getByteCode() const{
         return code;
     }
 
-    inline const aFuntool::FilePath &Code::getFilePath() const{
+    const aFuntool::FilePath &Code::getFilePath() const{
         return file;
     }
 
-    inline Code::ByteCode::CodeType Code::ByteCode::getType() const {
+    Code::ByteCode::CodeType Code::ByteCode::getType() const {
         return type;
     }
 
-    inline char Code::ByteCode::getPrefix() const {
+    char Code::ByteCode::getPrefix() const {
         return prefix;
     }
 
-    inline const char *Code::ByteCode::getElement() const {
+    const char *Code::ByteCode::getElement() const {
         if (type != code_element)
             return "";
         return data.element;
     }
 
-    inline Code::ByteCode::BlockType Code::ByteCode::getBlockType() const {
+    Code::ByteCode::BlockType Code::ByteCode::getBlockType() const {
         if (type != code_block)
             return block_p;
         return data.block_type;
     }
 
-    inline Code::ByteCode *Code::ByteCode::getSon() const {
+    Code::ByteCode *Code::ByteCode::getSon() const {
         if (type != code_block)
             return nullptr;
         return data.son;
     }
 
-    inline Code::ByteCode *Code::ByteCode::toNext() const {
+    Code::ByteCode *Code::ByteCode::toNext() const {
         return next;
     }
 
-    inline Code::ByteCode *Code::ByteCode::toPrev() const {
+    Code::ByteCode *Code::ByteCode::toPrev() const {
         return prev;
     }
 
-    inline Code::ByteCode *Code::ByteCode::toFather() const {
+    Code::ByteCode *Code::ByteCode::toFather() const {
         return father;
     }
 
-    inline aFuntool::FileLine Code::ByteCode::getFileLine() const {
+    aFuntool::FileLine Code::ByteCode::getFileLine() const {
         return line;
     }
 
-    inline const aFuntool::FilePath &Code::ByteCode::getFilePath() const{
+    const aFuntool::FilePath &Code::ByteCode::getFilePath() const{
         return belong.getFilePath();
     }
 
-    inline Code::ByteCode::CodeData::CodeData() : element{nullptr} {
+    Code::ByteCode::CodeData::CodeData() : element{nullptr} {
 
     }
 }

+ 16 - 16
include/core/core-activation.h

@@ -19,17 +19,17 @@ namespace aFuncore {
 
         class AFUN_CORE_EXPORT VarList {
         public:
-            inline explicit VarList();
+            AFUN_INLINE explicit VarList();
             virtual ~VarList();
-            VarList(VarList &&new_varlist);
-            VarList &operator=(VarList &&new_varlist);
+            AFUN_INLINE VarList(VarList &&new_varlist);
+            AFUN_INLINE VarList &operator=(VarList &&new_varlist) noexcept;
             VarList(const VarList &) = delete;
             VarList &operator=(const VarList &) = delete;
 
             void clear();
             void connect(VarList &new_varlist);
-            inline void push(VarSpace *varspace_);
-            inline size_t count();
+            AFUN_INLINE void push(VarSpace *varspace_);
+            AFUN_INLINE size_t count();
 
             template <typename Callable,typename...T>
             void forEach(Callable func, T...arg);
@@ -39,7 +39,7 @@ namespace aFuncore {
             virtual bool defineVar(const std::string &name, Var *data);
             virtual bool setVar(const std::string &name, Object *data);
             virtual bool delVar(const std::string &name);
-            [[nodiscard]] inline Object *findObject(const std::string &name);
+            [[nodiscard]] AFUN_INLINE Object *findObject(const std::string &name);
 
         private:
             std::list<VarSpace *> varspace;
@@ -55,12 +55,12 @@ namespace aFuncore {
         virtual void runCode(const Code::ByteCode *code);
         virtual void endRun();
 
-        [[nodiscard]] inline VarList &getVarlist();
-        [[nodiscard]] inline UpMessage &getUpStream();
-        [[nodiscard]] inline DownMessage &getDownStream();
+        [[nodiscard]] AFUN_INLINE VarList &getVarlist();
+        [[nodiscard]] AFUN_INLINE UpMessage &getUpStream();
+        [[nodiscard]] AFUN_INLINE DownMessage &getDownStream();
 
-        [[nodiscard]] inline aFuntool::FileLine getFileLine() const;
-        [[nodiscard]] inline  const aFuntool::FilePath &getFilePath() const;
+        [[nodiscard]] AFUN_INLINE aFuntool::FileLine getFileLine() const;
+        [[nodiscard]] AFUN_INLINE  const aFuntool::FilePath &getFilePath() const;
 
     protected:
         VarList varlist;
@@ -79,10 +79,10 @@ namespace aFuncore {
 
     class AFUN_CORE_EXPORT ExeActivation : public Activation {
     public:
-        inline ExeActivation(const Code &code, Inter &inter_);
-        inline ExeActivation(const Code::ByteCode *code, Inter &inter_);
+        AFUN_INLINE ExeActivation(const Code &code, Inter &inter_);
+        AFUN_INLINE ExeActivation(const Code::ByteCode *code, Inter &inter_);
         ActivationStatus getCode(const Code::ByteCode *&code) override;
-        [[nodiscard]] inline const Code::ByteCode *getStart() const;
+        [[nodiscard]] AFUN_INLINE const Code::ByteCode *getStart() const;
 
     private:
         const Code::ByteCode *start;
@@ -94,7 +94,7 @@ namespace aFuncore {
     public:
         explicit TopActivation(const Code &code, Inter &inter_);
         ~TopActivation() override = default;
-        [[nodiscard]] inline const Code &getBase() const;
+        [[nodiscard]] AFUN_INLINE const Code &getBase() const;
 
     private:
         const Code &base;
@@ -102,7 +102,7 @@ namespace aFuncore {
 
     class AFUN_CORE_EXPORT FuncActivation : public Activation {
     public:
-        explicit inline FuncActivation(const Code::ByteCode *code, Inter &inter_);
+        AFUN_INLINE explicit FuncActivation(const Code::ByteCode *code, Inter &inter_);
         explicit FuncActivation(Function *func, Inter &inter_);
         ~FuncActivation() override;
         ActivationStatus getCode(const Code::ByteCode *&code) override;

+ 15 - 15
include/core/core-activation.inline.h

@@ -4,63 +4,63 @@
 #include "core-activation.h"
 
 namespace aFuncore {
-    inline Activation::VarList &Activation::getVarlist(){
+    Activation::VarList &Activation::getVarlist(){
         return varlist;
     }
 
-    inline UpMessage &Activation::getUpStream() {
+    UpMessage &Activation::getUpStream() {
         return up;
     }
 
-    inline DownMessage &Activation::getDownStream() {
+    DownMessage &Activation::getDownStream() {
         return down;
     }
 
-    inline aFuntool::FileLine Activation::getFileLine() const{
+    aFuntool::FileLine Activation::getFileLine() const{
         return line;
     }
 
-    inline const aFuntool::FilePath &Activation::getFilePath() const{
+    const aFuntool::FilePath &Activation::getFilePath() const{
         return path;
     }
 
-    inline Activation::VarList::VarList() : varspace{} {
+    Activation::VarList::VarList() : varspace{} {
 
     }
 
-    inline Activation::VarList::VarList(VarList &&new_varlist) : varspace{std::move(new_varlist.varspace)} {
+    Activation::VarList::VarList(VarList &&new_varlist) : varspace{std::move(new_varlist.varspace)} {
 
     }
 
-    inline Activation::VarList &Activation::VarList::operator=(VarList &&new_varlist) {
+    Activation::VarList &Activation::VarList::operator=(VarList &&new_varlist)  noexcept {
         clear();
         varspace = std::move(new_varlist.varspace);
         return *this;
     }
 
-    inline void Activation::VarList::push(VarSpace *varspace_) {
+    void Activation::VarList::push(VarSpace *varspace_) {
         varspace_->addReference();
         varspace.push_front(varspace_);
     }
 
-    inline size_t Activation::VarList::count() {
+    size_t Activation::VarList::count() {
         return varspace.size();
     }
 
-    inline Object *Activation::VarList::findObject(const std::string &name) {
+    Object *Activation::VarList::findObject(const std::string &name) {
         Var *var = findVar(name);
         return var ? var->getData() : nullptr;
     }
 
-    inline ExeActivation::ExeActivation(const Code &code, Inter &inter_) : Activation(inter_), start{code.getByteCode()}, next{code.getByteCode()} {
+    ExeActivation::ExeActivation(const Code &code, Inter &inter_) : Activation(inter_), start{code.getByteCode()}, next{code.getByteCode()} {
 
     }
 
-    inline ExeActivation::ExeActivation(const Code::ByteCode *code, Inter &inter_) : Activation(inter_), start{code}, next{code} {
+    ExeActivation::ExeActivation(const Code::ByteCode *code, Inter &inter_) : Activation(inter_), start{code}, next{code} {
 
     }
 
-    inline const Code::ByteCode *ExeActivation::getStart() const{
+    const Code::ByteCode *ExeActivation::getStart() const{
         return start;
     }
 
@@ -68,7 +68,7 @@ namespace aFuncore {
         return base;
     }
 
-    inline FuncActivation::FuncActivation(const Code::ByteCode *code, Inter &inter_) : Activation(inter_), call{code} {
+    FuncActivation::FuncActivation(const Code::ByteCode *code, Inter &inter_) : Activation(inter_), call{code} {
 
     }
 }

+ 5 - 5
include/core/core-exception.h

@@ -5,25 +5,25 @@
 namespace aFuncore {
     class aFuncoreException : public aFuntool::aFunException {
     public:
-        inline explicit aFuncoreException(const std::string &msg);
+        AFUN_INLINE explicit aFuncoreException(const std::string &msg);
     };
 
     class EnvironmentDestructException : public aFuncoreException {
     public:
-        inline EnvironmentDestructException();
+        AFUN_INLINE EnvironmentDestructException();
     };
 
     class RuntimeError : public aFuncoreException {
         std::string type;
     public:
-        inline RuntimeError(const std::string &msg, std::string type);
-        inline const std::string &getType() const;
+        AFUN_INLINE RuntimeError(const std::string &msg, std::string type);
+        AFUN_INLINE const std::string &getType() const;
     };
 
     class ArgumentError : public RuntimeError {
         std::string type;
     public:
-        inline ArgumentError();
+        AFUN_INLINE ArgumentError();
     };
 }
 

+ 5 - 5
include/core/core-exception.inline.h

@@ -5,23 +5,23 @@
 #include "core-exception.h"
 
 namespace aFuncore {
-    inline aFuncoreException::aFuncoreException(const std::string &msg) : aFunException{msg} {
+    aFuncoreException::aFuncoreException(const std::string &msg) : aFunException{msg} {
 
     }
 
-    inline EnvironmentDestructException::EnvironmentDestructException() : aFuncoreException("Environment Destruct Error") {
+    EnvironmentDestructException::EnvironmentDestructException() : aFuncoreException("Environment Destruct Error") {
 
     }
 
-    inline RuntimeError::RuntimeError(const std::string &msg, std::string type_) : aFuncoreException(msg), type{std::move(type_)} {
+    RuntimeError::RuntimeError(const std::string &msg, std::string type_) : aFuncoreException(msg), type{std::move(type_)} {
 
     }
 
-    inline const std::string &RuntimeError::getType() const {
+    const std::string &RuntimeError::getType() const {
         return type;
     }
 
-    inline ArgumentError::ArgumentError() : RuntimeError("Argument mismatch", "ArgumentError") {
+    ArgumentError::ArgumentError() : RuntimeError("Argument mismatch", "ArgumentError") {
 
     }
 }

+ 2 - 2
include/core/core-init.h

@@ -10,7 +10,7 @@ namespace aFuncore {
         aFuntool::Logger &core_logger;
         aFuntool::Logger &sys_logger;
 
-        inline InitInfo(const std::string &base_dir_,
+        AFUN_INLINE InitInfo(const std::string &base_dir_,
                         aFuntool::LogFactory &factor_,
                         aFuntool::Logger &core_logger_,
                         aFuntool::Logger &sys_logger_);
@@ -20,7 +20,7 @@ namespace aFuncore {
     AFUN_CORE_EXPORT extern aFuntool::Logger *aFunCoreLogger;
 
     AFUN_CORE_EXPORT bool aFunCoreInit(InitInfo *info);
-    static void setCoreLogger(aFuntool::Logger *log);
+    AFUN_STATIC void setCoreLogger(aFuntool::Logger *log);
 }
 
 #include "core-init.inline.h"

+ 2 - 2
include/core/core-init.inline.h

@@ -4,7 +4,7 @@
 #include "core-init.h"
 
 namespace aFuncore {
-    inline InitInfo::InitInfo(const std::string &base_dir_,
+    InitInfo::InitInfo(const std::string &base_dir_,
                               aFuntool::LogFactory &factor_,
                               aFuntool::Logger &core_logger_,
                               aFuntool::Logger &sys_logger_) :
@@ -12,7 +12,7 @@ namespace aFuncore {
 
     }
 
-    static void setCoreLogger(aFuntool::Logger *log) {
+    void setCoreLogger(aFuntool::Logger *log) {
         aFunCoreLogger = log;
     }
 }

+ 7 - 7
include/core/core-parser.h

@@ -71,14 +71,14 @@ namespace aFuncore {
             std::string info;
         };
 
-        inline explicit Parser(Reader &reader_);
+        AFUN_INLINE explicit Parser(Reader &reader_);
 
         TokenType getTokenFromLexical(std::string &text);
         bool parserCode(Code &code);
 
-        [[nodiscard]] inline size_t countEvent() const;
-        inline ParserEvent popEvent();
-        [[nodiscard]] inline const ParserEvent &checkEvent() const;
+        [[nodiscard]] AFUN_INLINE size_t countEvent() const;
+        AFUN_INLINE ParserEvent popEvent();
+        [[nodiscard]] AFUN_INLINE const ParserEvent &checkEvent() const;
     private:
         typedef enum DoneStatus {
             DEL_TOKEN = 0,
@@ -119,14 +119,14 @@ namespace aFuncore {
         bool getToken();
         bool goBackToken();
 
-        static const size_t SYNTACTIC_MAX_DEPTH = 218;
+        AFUN_STATIC const size_t SYNTACTIC_MAX_DEPTH = 218;
         Code::ByteCode *codeSelf(Code &code, size_t deep, char prefix);
         Code::ByteCode *codePrefix(Code &code, size_t deep);
         Code::ByteCode *codeList(Code &code, size_t deep);
         Code::ByteCode *codeListEnd(Code &code);
 
-        inline void pushEvent(const ParserEvent &new_event);
-        inline void pushEvent(ParserEvent &&new_event);
+        AFUN_INLINE void pushEvent(const ParserEvent &new_event);
+        AFUN_INLINE void pushEvent(ParserEvent &&new_event);
     };
 
 }

+ 6 - 6
include/core/core-parser.inline.h

@@ -3,7 +3,7 @@
 #include "core-parser.h"
 
 namespace aFuncore {
-    inline Parser::Parser(Reader &reader_)
+    Parser::Parser(Reader &reader_)
         : reader{reader_},
           lexical{lex_begin, TK_PREFIX, 0, 0, false, false},
           syntactic{false, TK_PREFIX, "", false}{
@@ -11,25 +11,25 @@ namespace aFuncore {
         reader.readFirstWord();
     }
 
-    inline Parser::ParserEvent Parser::popEvent() {
+    Parser::ParserEvent Parser::popEvent() {
         ParserEvent pop = event.front();
         event.pop();
         return pop;
     }
 
-    inline size_t Parser::countEvent() const {
+    size_t Parser::countEvent() const {
         return event.size();
     }
 
-    inline void Parser::pushEvent(const ParserEvent &new_event) {
+    void Parser::pushEvent(const ParserEvent &new_event) {
         event.push(new_event);
     }
 
-    inline void Parser::pushEvent(ParserEvent &&new_event) {
+    void Parser::pushEvent(ParserEvent &&new_event) {
         event.push(new_event);
     }
 
-    inline const Parser::ParserEvent &Parser::checkEvent() const {
+    const Parser::ParserEvent &Parser::checkEvent() const {
             return event.front();
     }
 }

+ 2 - 2
include/core/env-var.h

@@ -14,7 +14,7 @@ namespace aFuncore {
         EnvVarSpace(const EnvVarSpace &)=delete;
         EnvVarSpace &operator=(const EnvVarSpace &)=delete;
 
-        [[nodiscard]] inline size_t getCount();
+        [[nodiscard]] AFUN_INLINE size_t getCount();
         bool findString(const std::string &name, std::string &str);
         bool findNumber(const std::string &name, int32_t &num);
 
@@ -25,7 +25,7 @@ namespace aFuncore {
         void addNumber(const std::string &name, int32_t num);
 
     private:
-        static const size_t ENV_VAR_HASH_SIZE = 100;  // 环境变量哈希表大小
+        AFUN_STATIC const size_t ENV_VAR_HASH_SIZE = 100;  // 环境变量哈希表大小
         struct EnvVar {  // 环境变量
             std::string str;
             int32_t num;  // 可以同时记录字符串和数字

+ 1 - 1
include/core/env-var.inline.h

@@ -3,7 +3,7 @@
 #include "env-var.h"
 
 namespace aFuncore {
-    inline size_t EnvVarSpace::getCount() {
+    size_t EnvVarSpace::getCount() {
         std::unique_lock<std::mutex> mutex{lock};
         return var.size();
     }

+ 22 - 22
include/core/inter.h

@@ -28,10 +28,10 @@ namespace aFuncore {
         Environment(Environment &) = delete;
         Environment &operator=(Environment &) = delete;
 
-        inline size_t operator++();
-        inline size_t operator--();
-        inline size_t operator++(int);
-        inline size_t operator--(int);
+        AFUN_INLINE size_t operator++();
+        AFUN_INLINE size_t operator--();
+        AFUN_INLINE size_t operator++(int);
+        AFUN_INLINE size_t operator--(int);
 
     private:
         std::mutex lock;
@@ -64,10 +64,10 @@ namespace aFuncore {
             prefix_exec_first = 1,
         } Prefix;
 
-        static const int PREFIX_COUNT = 2;
-        constexpr static const char *E_PREFIX = "$`'";  /* NOLINT element前缀 */
-        constexpr static const char *B_PREFIX = "$`'%^&<?>";  /* NOLINT block前缀 */
-        constexpr static const char *ALL_PREFIX = "$`'%^&<?>";  /* NOLINT block前缀 */
+        AFUN_STATIC const int PREFIX_COUNT = 2;
+        AFUN_STATIC constexpr const char *E_PREFIX = "$`'";  /* NOLINT element前缀 */
+        AFUN_STATIC constexpr const char *B_PREFIX = "$`'%^&<?>";  /* NOLINT block前缀 */
+        AFUN_STATIC constexpr const char *ALL_PREFIX = "$`'%^&<?>";  /* NOLINT block前缀 */
 
         explicit Inter(Environment &env_);
         Inter(const Inter &base_inter);
@@ -76,18 +76,18 @@ namespace aFuncore {
 
         void enable();
 
-        [[nodiscard]] inline InterStatus getStatus() const;
-        [[nodiscard]] inline bool isInterStop() const;
-        [[nodiscard]] inline bool isInterExit() const;
-        [[nodiscard]] inline Environment &getEnvironment();
-        [[nodiscard]] inline ProtectVarSpace *getProtectVarSpace() const;
-        [[nodiscard]] inline const std::list<Activation *> &getStack() const;
-        [[nodiscard]] inline Activation *getActivation() const;
+        [[nodiscard]] AFUN_INLINE InterStatus getStatus() const;
+        [[nodiscard]] AFUN_INLINE bool isInterStop() const;
+        [[nodiscard]] AFUN_INLINE bool isInterExit() const;
+        [[nodiscard]] AFUN_INLINE Environment &getEnvironment();
+        [[nodiscard]] AFUN_INLINE ProtectVarSpace *getProtectVarSpace() const;
+        [[nodiscard]] AFUN_INLINE const std::list<Activation *> &getStack() const;
+        [[nodiscard]] AFUN_INLINE Activation *getActivation() const;
         [[nodiscard]] bool checkLiteral(const std::string &element) const;
         [[nodiscard]] bool checkLiteral(const std::string &element, std::string &literaler, bool &in_protect) const;
-        [[nodiscard]] inline EnvVarSpace &getEnvVarSpace();
-        [[nodiscard]] inline InterOutMessage &getOutMessageStream();
-        [[nodiscard]] inline InterInMessage &getInMessageStream();
+        [[nodiscard]] AFUN_INLINE EnvVarSpace &getEnvVarSpace();
+        [[nodiscard]] AFUN_INLINE InterOutMessage &getOutMessageStream();
+        [[nodiscard]] AFUN_INLINE InterInMessage &getInMessageStream();
 
         bool pushLiteral(const std::string &pattern, const std::string &literaler, bool in_protect);
 
@@ -95,8 +95,8 @@ namespace aFuncore {
         bool runCode(const Code &code);
         bool runCode(Object *obj);
 
-        inline InterStatus setInterStop();
-        inline InterStatus setInterExit();
+        AFUN_INLINE InterStatus setInterStop();
+        AFUN_INLINE InterStatus setInterExit();
     private:
         InterStatus status;
 
@@ -110,8 +110,8 @@ namespace aFuncore {
 
         std::list<LiteralRegex> literal;
 
-        inline void pushActivation(Activation *new_activation);
-        inline Activation *popActivation();
+        AFUN_INLINE void pushActivation(Activation *new_activation);
+        AFUN_INLINE Activation *popActivation();
     };
 
     struct Inter::LiteralRegex {

+ 18 - 18
include/core/inter.inline.h

@@ -3,16 +3,16 @@
 #include "inter.h"
 
 namespace aFuncore {
-    inline Environment &Inter::getEnvironment() {
+    Environment &Inter::getEnvironment() {
         return env;
     }
 
-    inline void Inter::pushActivation(Activation *new_activation) {
+    void Inter::pushActivation(Activation *new_activation) {
         stack.push_front(new_activation);
         activation = new_activation;
     }
 
-    inline Activation *Inter::popActivation() {
+    Activation *Inter::popActivation() {
         if (activation == nullptr)
             return nullptr;
 
@@ -25,70 +25,70 @@ namespace aFuncore {
         return ret;
     }
 
-    inline Inter::InterStatus Inter::getStatus() const {
+    Inter::InterStatus Inter::getStatus() const {
         return status;
     }
 
-    inline bool Inter::isInterStop() const {
+    bool Inter::isInterStop() const {
         return (status == inter_exit || status == inter_stop);
     }
 
-    inline bool Inter::isInterExit() const {
+    bool Inter::isInterExit() const {
         return (status == inter_exit);
     }
 
-    inline ProtectVarSpace *Inter::getProtectVarSpace() const {
+    ProtectVarSpace *Inter::getProtectVarSpace() const {
         return env.protect;
     }
 
-    inline const std::list<Activation *> &Inter::getStack() const {
+    const std::list<Activation *> &Inter::getStack() const {
         return stack;
     }
 
-    inline Activation *Inter::getActivation() const {
+    Activation *Inter::getActivation() const {
         return activation;
     }
 
-    inline EnvVarSpace &Inter::getEnvVarSpace() {
+    EnvVarSpace &Inter::getEnvVarSpace() {
         return env.envvar;
     }
 
-    inline InterOutMessage &Inter::getOutMessageStream() {
+    InterOutMessage &Inter::getOutMessageStream() {
         return out;
     }
 
-    inline InterInMessage &Inter::getInMessageStream() {
+    InterInMessage &Inter::getInMessageStream() {
         return in;
     }
 
-    inline size_t Environment::operator++(){
+    size_t Environment::operator++(){
         std::unique_lock<std::mutex> mutex{lock};
         return ++reference;
     }
 
-    inline size_t Environment::operator--(){
+    size_t Environment::operator--(){
         std::unique_lock<std::mutex> mutex{lock};
         return --reference;
     }
 
-    inline size_t Environment::operator++(int){
+    size_t Environment::operator++(int){
         std::unique_lock<std::mutex> mutex{lock};
         return reference++;
     }
 
-    inline size_t Environment::operator--(int){
+    size_t Environment::operator--(int){
         std::unique_lock<std::mutex> mutex{lock};
         return reference--;
     }
 
-    inline Inter::InterStatus Inter::setInterStop() {
+    Inter::InterStatus Inter::setInterStop() {
         InterStatus ret = status;
         if (status != inter_exit)
             status = inter_stop;
         return ret;
     }
 
-    inline Inter::InterStatus Inter::setInterExit() {
+    Inter::InterStatus Inter::setInterExit() {
         InterStatus ret = status;
         status = inter_exit;
         return ret;

+ 7 - 7
include/core/msg.h

@@ -9,7 +9,7 @@
 namespace aFuncore {
     class AFUN_CORE_EXPORT Message {
     public:
-        explicit inline Message() = default;
+        AFUN_INLINE explicit Message() = default;
         virtual ~Message() = default;
         Message &operator=(const Message &)=delete;
 
@@ -27,10 +27,10 @@ namespace aFuncore {
     class AFUN_CORE_EXPORT NormalMessage : public TopMessage {
     public:
         explicit NormalMessage(Object *obj_);
-        inline NormalMessage(NormalMessage &&msg) noexcept;
+        AFUN_INLINE NormalMessage(NormalMessage &&msg) noexcept;
         ~NormalMessage() override;
         void topProgress(Inter &inter, Activation &activation) override;
-        inline Object *getObject();
+        AFUN_INLINE Object *getObject();
 
     private:
         Object *obj;
@@ -44,11 +44,11 @@ namespace aFuncore {
         };
 
         explicit ErrorMessage(std::string error_type_, std::string error_info_, Activation *start);
-        inline ErrorMessage(ErrorMessage &&msg) noexcept;
+        AFUN_INLINE ErrorMessage(ErrorMessage &&msg) noexcept;
         void topProgress(Inter &inter_, Activation &activation) override;
-        [[nodiscard]] inline std::string getErrorType() const;
-        [[nodiscard]] inline std::string getErrorInfo() const;
-        [[nodiscard]] inline const std::list<TrackBack> &getTrackBack() const;
+        [[nodiscard]] AFUN_INLINE std::string getErrorType() const;
+        [[nodiscard]] AFUN_INLINE std::string getErrorInfo() const;
+        [[nodiscard]] AFUN_INLINE const std::list<TrackBack> &getTrackBack() const;
 
     private:
         Inter &inter;

+ 8 - 8
include/core/msg.inline.h

@@ -3,29 +3,29 @@
 #include "msg.h"
 
 namespace aFuncore {
-    inline NormalMessage::NormalMessage(NormalMessage &&msg) noexcept : obj {msg.obj}{
+    NormalMessage::NormalMessage(NormalMessage &&msg) noexcept : obj {msg.obj}{
         msg.obj = nullptr;
     }
 
-    inline Object *NormalMessage::getObject() {
+    Object *NormalMessage::getObject() {
         return obj;
     }
 
-    inline ErrorMessage::ErrorMessage(ErrorMessage &&msg) noexcept
-        : error_type{std::move(msg.error_type)}, error_info{std::move(msg.error_info)},
-          trackback{std::move(msg.trackback)}, inter{msg.inter}{
+    ErrorMessage::ErrorMessage(ErrorMessage &&msg) noexcept
+        : inter{msg.inter}, error_type{std::move(msg.error_type)},
+          error_info{std::move(msg.error_info)}, trackback{std::move(msg.trackback)}{
 
     }
 
-    inline std::string ErrorMessage::getErrorType() const {
+    std::string ErrorMessage::getErrorType() const {
         return error_type;
     }
 
-    inline std::string ErrorMessage::getErrorInfo() const {
+    std::string ErrorMessage::getErrorInfo() const {
         return error_info;
     }
 
-    inline const std::list<ErrorMessage::TrackBack> &ErrorMessage::getTrackBack() const {
+    const std::list<ErrorMessage::TrackBack> &ErrorMessage::getTrackBack() const {
         return trackback;
     }
 }

+ 1 - 1
include/core/msg.template.h

@@ -12,7 +12,7 @@ namespace aFuncore {
 
 
     template <typename Callable, typename...T>
-    inline void MessageStream::forEach(Callable func, T...arg) {
+    void MessageStream::forEach(Callable func, T...arg) {
         for (auto &msg : stream)
             func(msg.second, arg...);
     }

+ 13 - 13
include/core/object-value.h

@@ -46,17 +46,17 @@ namespace aFuncore {
         template <typename Callable,typename...T>
         void forEachLock(Callable func, T...arg);
 
-        [[nodiscard]] inline size_t getCount();
+        [[nodiscard]] AFUN_INLINE size_t getCount();
         [[nodiscard]] virtual Var *findVar(const std::string &name);
         virtual VarOperationFlat defineVar(const std::string &name, Object *data);
         virtual VarOperationFlat defineVar(const std::string &name, Var *data);
         virtual VarOperationFlat setVar(const std::string &name, Object *data);
         virtual VarOperationFlat delVar(const std::string &name);
 
-        [[nodiscard]] Object *findObject(const std::string &name);
+        [[nodiscard]] AFUN_INLINE Object *findObject(const std::string &name);
         void linkObject(std::queue<Object *> &queue) override;
 
-        static const size_t VAR_HASH_SIZE = 100;  // 环境变量哈希表大小
+        AFUN_STATIC const size_t VAR_HASH_SIZE = 100;  // 环境变量哈希表大小
 
     private:
         std::unordered_map<std::string, Var *> var;
@@ -64,11 +64,11 @@ namespace aFuncore {
 
     class AFUN_CORE_EXPORT ProtectVarSpace : public VarSpace {
     public:
-        explicit inline ProtectVarSpace(Inter &inter);
-        explicit inline ProtectVarSpace(Environment &env_);
+        AFUN_INLINE explicit ProtectVarSpace(Inter &inter);
+        AFUN_INLINE explicit ProtectVarSpace(Environment &env_);
 
-        [[nodiscard]] inline bool getProtect() const;
-        inline bool setProtect(bool protect);
+        [[nodiscard]] AFUN_INLINE bool getProtect() const;
+        AFUN_INLINE bool setProtect(bool protect);
 
         VarOperationFlat defineVar(const std::string &name, Object *data) override;
         VarOperationFlat defineVar(const std::string &name, Var *data) override;
@@ -103,10 +103,10 @@ namespace aFuncore {
     class Function::CallFunction::ArgCodeList {
     public:
         const Code::ByteCode *code = nullptr;
-        inline explicit ArgCodeList(const Code::ByteCode *code = nullptr);
-        inline ~ArgCodeList();
-        inline Object *setObject(Object *res);
-        inline Object *getObject();
+        AFUN_INLINE explicit ArgCodeList(const Code::ByteCode *code = nullptr);
+        AFUN_INLINE ~ArgCodeList();
+        AFUN_INLINE Object *setObject(Object *res);
+        AFUN_INLINE Object *getObject();
     private:
         Object *ret;
     };
@@ -139,8 +139,8 @@ namespace aFuncore {
         };
 
     public:
-        inline explicit ImportFunction(Inter &inter_);
-        inline explicit ImportFunction(Environment &env_);
+        AFUN_INLINE explicit ImportFunction(Inter &inter_);
+        AFUN_INLINE explicit ImportFunction(Environment &env_);
         ~ImportFunction() override = default;
 
         CallFunction *getCallFunction(const Code::ByteCode *code, Inter &inter) override;

+ 10 - 10
include/core/object-value.inline.h

@@ -3,37 +3,37 @@
 #include "object-value.h"
 
 namespace aFuncore {
-    inline size_t VarSpace::getCount() {
+    size_t VarSpace::getCount() {
         std::unique_lock<std::mutex> mutex{lock};
         return var.size();
     }
 
-    inline Object *VarSpace::findObject(const std::string &name) {
+    Object *VarSpace::findObject(const std::string &name) {
         Var *ret = findVar(name);
         return ret ? ret->getData() : nullptr;
     }
 
-    inline ProtectVarSpace::ProtectVarSpace(Inter &inter) : VarSpace(inter), is_protect{false} {
+    ProtectVarSpace::ProtectVarSpace(Inter &inter) : VarSpace(inter), is_protect{false} {
 
     }
 
-    inline ProtectVarSpace::ProtectVarSpace(Environment &env_) : VarSpace(env_), is_protect{false} {
+    ProtectVarSpace::ProtectVarSpace(Environment &env_) : VarSpace(env_), is_protect{false} {
 
     }
 
-    inline bool ProtectVarSpace::getProtect() const {
+    bool ProtectVarSpace::getProtect() const {
         return is_protect;
     }
 
-    inline bool ProtectVarSpace::setProtect(bool protect) {
+    bool ProtectVarSpace::setProtect(bool protect) {
         bool ret = is_protect; is_protect = protect; return ret;
     }
 
-    inline Function::CallFunction::ArgCodeList::ArgCodeList(const Code::ByteCode *code_) : code{code_}, ret{nullptr} {
+    Function::CallFunction::ArgCodeList::ArgCodeList(const Code::ByteCode *code_) : code{code_}, ret{nullptr} {
 
     }
 
-    inline Function::CallFunction::ArgCodeList::~ArgCodeList() {
+    Function::CallFunction::ArgCodeList::~ArgCodeList() {
         if (ret != nullptr)
             ret->delReference();
     }
@@ -50,11 +50,11 @@ namespace aFuncore {
         return ret;
     }
 
-    inline ImportFunction::ImportFunction(Inter &inter_) : Object("Function", inter_) {
+    ImportFunction::ImportFunction(Inter &inter_) : Object("Function", inter_) {
 
     }
 
-    inline ImportFunction::ImportFunction(Environment &env_) : Object("Function", env_) {
+    ImportFunction::ImportFunction(Environment &env_) : Object("Function", env_) {
 
     }
 };

+ 11 - 11
include/core/object.h

@@ -18,17 +18,17 @@ namespace aFuncore {
         Object(const Object &) = delete;
         Object &operator=(const Object &) = delete;
 
-        inline void addReference();
-        inline void delReference();
-        [[nodiscard]] inline GcCount getReference() const;
-        inline void setClear(bool clear=false);
-
-        static void checkReachable(std::list<Object *> &list);
-        static void setReachable(std::list<Object *> &list, std::queue<Object *> &des, std::queue<Object *> &del);
-        static void destructUnreachable(std::queue<Object *> &des, Inter &gc_inter);
-        static void deleteUnreachable(std::queue<Object *> &del);
-        static void destructAll(std::list<Object *> &list, Inter &gc_inter);
-        static void deleteAll(std::list<Object *> &list);
+        AFUN_INLINE void addReference();
+        AFUN_INLINE void delReference();
+        [[nodiscard]] AFUN_INLINE GcCount getReference() const;
+        AFUN_INLINE void setClear(bool clear=false);
+
+        AFUN_STATIC void checkReachable(std::list<Object *> &list);
+        AFUN_STATIC void setReachable(std::list<Object *> &list, std::queue<Object *> &des, std::queue<Object *> &del);
+        AFUN_STATIC void destructUnreachable(std::queue<Object *> &des, Inter &gc_inter);
+        AFUN_STATIC void deleteUnreachable(std::queue<Object *> &del);
+        AFUN_STATIC void destructAll(std::list<Object *> &list, Inter &gc_inter);
+        AFUN_STATIC void deleteAll(std::list<Object *> &list);
     protected:
         Environment &env;
         const std::string type;  // 标识 Object 的字符串

+ 4 - 4
include/core/object.inline.h

@@ -3,21 +3,21 @@
 #include "object.h"
 
 namespace aFuncore {
-    inline void Object::addReference() {
+    void Object::addReference() {
         std::unique_lock<std::mutex> mutex{lock};
         reference++;
     }
 
-    inline void Object::delReference() {
+    void Object::delReference() {
         std::unique_lock<std::mutex> mutex{lock};
         reference--;
     }
 
-    inline GcCount Object::getReference() const {
+    GcCount Object::getReference() const {
         return reference;
     }
 
-    inline void Object::setClear(bool clear) {
+    void Object::setClear(bool clear) {
         not_clear=!clear;
     }
 }

+ 8 - 8
include/core/reader.h

@@ -12,21 +12,21 @@ namespace aFuncore {
             read_mode_error = 2,
         } ReadMode;
 
-        static const size_t DEFAULT_BUF_SIZE = 1024;
-        static const size_t NEW_BUF_SIZE  = 512;
+        AFUN_STATIC const size_t DEFAULT_BUF_SIZE = 1024;
+        AFUN_STATIC const size_t NEW_BUF_SIZE  = 512;
 
-        explicit inline Reader(aFuntool::FilePath path_, aFuntool::FileLine line_ = 1);
+        AFUN_INLINE explicit Reader(aFuntool::FilePath path_, aFuntool::FileLine line_ = 1);
         Reader(const Reader &) = delete;
         virtual ~Reader();
         Reader &operator=(const Reader &) = delete;
 
         virtual size_t readText(char *dest, size_t len, ReadMode &mode) = 0;
 
-        [[nodiscard]] inline size_t countRead() const;
-        [[nodiscard]] inline bool isEnd() const;
-        [[nodiscard]] inline bool isError() const;
-        [[nodiscard]] inline aFuntool::FileLine getFileLine() const;
-        [[nodiscard]] inline const aFuntool::FilePath &getFilePath() const;
+        [[nodiscard]] AFUN_INLINE size_t countRead() const;
+        [[nodiscard]] AFUN_INLINE bool isEnd() const;
+        [[nodiscard]] AFUN_INLINE bool isError() const;
+        [[nodiscard]] AFUN_INLINE aFuntool::FileLine getFileLine() const;
+        [[nodiscard]] AFUN_INLINE const aFuntool::FilePath &getFilePath() const;
         char *readWord(size_t del_index);
         void readFirstWord();
         char getChar();

+ 3 - 3
include/core/reader.inline.h

@@ -3,9 +3,9 @@
 #include "reader.h"
 
 namespace aFuncore {
-    inline Reader::Reader(aFuntool::FilePath path_, aFuntool::FileLine line_)
-            : path{std::move(path_)}, line{line_}, read_end{false}, read_error{false},
-              buf{aFuntool::safeCalloc<char>(DEFAULT_BUF_SIZE + 1)}, buf_size{DEFAULT_BUF_SIZE}, read{buf} {
+    Reader::Reader(aFuntool::FilePath path_, aFuntool::FileLine line_)
+            : buf{aFuntool::safeCalloc<char>(DEFAULT_BUF_SIZE + 1)}, buf_size{DEFAULT_BUF_SIZE}, read{buf}, read_end{false},
+              read_error{false}, line{line_}, path{std::move(path_)} {
 
     }
 

+ 2 - 2
include/interface/it-exception.h

@@ -5,12 +5,12 @@
 namespace aFunit {
     class aFunitException : public aFuntool::aFunException {
     public:
-        inline explicit aFunitException(const std::string &msg);
+        AFUN_INLINE explicit aFunitException(const std::string &msg);
     };
 
     class readerFileOpenError : public aFunitException {
     public:
-        inline explicit readerFileOpenError(const aFuntool::FilePath &file);
+        AFUN_INLINE explicit readerFileOpenError(const aFuntool::FilePath &file);
     };
 
 }

+ 2 - 2
include/interface/it-exception.inline.h

@@ -4,11 +4,11 @@
 #include "it-exception.h"
 
 namespace aFunit {
-    inline aFunitException::aFunitException(const std::string &msg) : aFunException{msg} {
+    aFunitException::aFunitException(const std::string &msg) : aFunException{msg} {
 
     }
 
-    inline readerFileOpenError::readerFileOpenError(const aFuntool::FilePath &file)
+    readerFileOpenError::readerFileOpenError(const aFuntool::FilePath &file)
         : aFunitException("Reader cannot open file: " + file) {
 
     }

+ 2 - 2
include/interface/it-init.h

@@ -7,7 +7,7 @@ namespace aFunit {
     struct aFunInitInfo : public aFuncore::InitInfo {
         aFuntool::Logger &afun_logger;
 
-        inline aFunInitInfo(const std::string &base_dir_,
+        AFUN_INLINE aFunInitInfo(const std::string &base_dir_,
                             aFuntool::LogFactory &factor_,
                             aFuntool::Logger &afun_logger_,
                             aFuntool::Logger &core_logger_,
@@ -16,7 +16,7 @@ namespace aFunit {
 
     AFUN_LANG_EXPORT extern aFuntool::Logger *aFunLogger;
     AFUN_LANG_EXPORT bool aFunInit(aFunInitInfo *info);
-    static void setAFunLogger(aFuntool::Logger *log);
+    AFUN_STATIC void setAFunLogger(aFuntool::Logger *log);
 }
 
 #include "it-init.inline.h"

+ 2 - 2
include/interface/it-init.inline.h

@@ -4,7 +4,7 @@
 #include "it-init.h"
 
 namespace aFunit {
-    inline aFunInitInfo::aFunInitInfo(const std::string &base_dir_,
+    aFunInitInfo::aFunInitInfo(const std::string &base_dir_,
                                       aFuntool::LogFactory &factor_,
                                       aFuntool::Logger &afun_logger_,
                                       aFuntool::Logger &core_logger_,
@@ -13,7 +13,7 @@ namespace aFunit {
 
     }
 
-    static void setAFunLogger(aFuntool::Logger *log) {
+    void setAFunLogger(aFuntool::Logger *log) {
         aFunLogger = log;
     }
 }

+ 2 - 2
include/interface/it-reader.h

@@ -8,7 +8,7 @@
 namespace aFunit {
     class AFUN_LANG_EXPORT StringReader : public aFuncore::Reader {
     public:
-        inline StringReader(std::string str_, const aFuntool::FilePath &path_);
+        AFUN_INLINE StringReader(std::string str_, const aFuntool::FilePath &path_);
         size_t readText(char *dest, size_t read_len, ReadMode &mode) override;
     private:
         std::string str;
@@ -18,7 +18,7 @@ namespace aFunit {
 
     class AFUN_LANG_EXPORT FileReader : public aFuncore::Reader {
     public:
-        inline explicit FileReader(const aFuntool::FilePath &path_) noexcept(false);
+        AFUN_INLINE explicit FileReader(const aFuntool::FilePath &path_) noexcept(false);
         size_t readText(char *dest, size_t read_len, ReadMode &mode) override;
     private:
         FILE *file;

+ 2 - 2
include/interface/it-reader.inline.h

@@ -4,12 +4,12 @@
 #include "it-exception.h"
 
 namespace aFunit {
-    inline StringReader::StringReader(std::string str_, const aFuntool::FilePath &path_)
+    StringReader::StringReader(std::string str_, const aFuntool::FilePath &path_)
         : Reader{path_, 0}, str{std::move(str_)}, index{0}, len{str.size()} {
 
     }
 
-    inline FileReader::FileReader(const aFuntool::FilePath &path_)
+    FileReader::FileReader(const aFuntool::FilePath &path_)
         : Reader{path_, 0}, file{aFuntool::fileOpen(path_, "rb")}, no_first{false} {
         if (file == nullptr)
             throw readerFileOpenError(path_);

+ 2 - 0
include/tool/aFuntool.h

@@ -7,6 +7,8 @@
 #ifndef AFUN_AFUNTOOL_H
 #define AFUN_AFUNTOOL_H
 
+#include "macro.h"
+
 #include "tool-type.h"
 #include "aFunToolExport.h"
 

+ 2 - 2
include/tool/byte.template.h

@@ -20,7 +20,7 @@ namespace aFuntool {
                 uint8_t b[len];//元素b,占1个字节,b在内存中的地址为a最低字节的地址
             } in{.a = num}, out{};
 
-            for (int i = 0; i < len; i++)
+            for (size_t i = 0; i < len; i++)
                 out.b[len - i] = in.b[i];  // 大小端序转换
             num = out.a;
         }
@@ -46,7 +46,7 @@ namespace aFuntool {
                 uint8_t b[len];//元素b,占1个字节,b在内存中的地址为a最低字节的地址
             } in{.a = *num}, out{};
 
-            for (int i = 0; i < len; i++)
+            for (size_t i = 0; i < len; i++)
                 out.b[len - i] = in.b[i];  // 大小端序转换
             *num = out.a;
         }

+ 12 - 12
include/tool/dlc.h

@@ -2,9 +2,9 @@
 #define AFUN_DLC_H
 #include <iostream>
 #include "aFunToolExport.h"
+#include "macro.h"
 #include "dlfcn.h"  // CMake 处理 dlfcn.h 的位置
 
-
 /* 动态库工具(dlc): 处理动态库的使用 */
 
 /*
@@ -37,12 +37,12 @@ namespace aFuntool {
     class AFUN_TOOL_EXPORT DlcHandle {
     public:
         DlcHandle(const char *file, int mode) noexcept;  // 仅 openLibary 可用
-        inline DlcHandle(const DlcHandle &dlc_handle) noexcept;
-        inline DlcHandle(DlcHandle &&dlc_handle) noexcept;
-        inline ~DlcHandle() noexcept;
-        inline DlcHandle &operator=(const DlcHandle &dlc_handle) noexcept;
+        AFUN_INLINE DlcHandle(const DlcHandle &dlc_handle) noexcept;
+        AFUN_INLINE DlcHandle(DlcHandle &&dlc_handle) noexcept;
+        AFUN_INLINE ~DlcHandle() noexcept;
+        AFUN_INLINE DlcHandle &operator=(const DlcHandle &dlc_handle) noexcept;
 
-        [[nodiscard]] inline bool isOpen() const;
+        [[nodiscard]] AFUN_INLINE bool isOpen() const;
 
         /**
          * 获得动态库中指定名字的符号
@@ -56,11 +56,11 @@ namespace aFuntool {
         /**
          * 关闭动态库句柄
          */
-        inline void close();
-        inline int operator++(int);
-        inline int operator--(int);
+        AFUN_INLINE void close();
+        AFUN_INLINE int operator++(int);
+        AFUN_INLINE int operator--(int);
 
-        static void dlcExit();
+        AFUN_STATIC void dlcExit();
 
         class AFUN_TOOL_EXPORT Handle {
             friend class DlcHandle;
@@ -70,7 +70,7 @@ namespace aFuntool {
             Handle &operator=(const Handle *dlc) = delete;
             ~Handle();
 
-            [[nodiscard]] inline bool isOpen() const;
+            [[nodiscard]] AFUN_INLINE bool isOpen() const;
 
             /**
              * 获得动态库中指定名字的符号
@@ -93,7 +93,7 @@ namespace aFuntool {
 
     private:
         class Handle *handle_;
-        static Handle *dlc;
+        AFUN_STATIC Handle *dlc;
     };
 
 }

+ 9 - 9
include/tool/dlc.inline.h

@@ -9,30 +9,30 @@ namespace aFuntool {
         return handle_ != nullptr ? handle_->getSymbol<SYMBOL>(name) : DlcSymbol<SYMBOL>();
     }
 
-    inline DlcHandle::~DlcHandle() noexcept {
+    DlcHandle::~DlcHandle() noexcept {
         this->close();
     }
 
-    inline bool DlcHandle::isOpen() const {
+    bool DlcHandle::isOpen() const {
         return handle_ != nullptr ? handle_->isOpen() : false;
     }
 
-    inline void DlcHandle::close(){
+    void DlcHandle::close(){
         if (handle_ == nullptr)
             return;
         (*handle_)--;
         handle_ = nullptr;
     }
 
-    inline int DlcHandle::operator++(int){
+    int DlcHandle::operator++(int){
         return (*handle_)++;
     }
 
-    inline int DlcHandle::operator--(int){
+    int DlcHandle::operator--(int){
         return (*handle_)--;
     }
 
-    inline DlcHandle &DlcHandle::operator=(const DlcHandle &dlc_handle) noexcept {
+    DlcHandle &DlcHandle::operator=(const DlcHandle &dlc_handle) noexcept {
         if (&dlc_handle == this)
             return *this;
 
@@ -43,13 +43,13 @@ namespace aFuntool {
         return *this;
     }
 
-    inline DlcHandle::DlcHandle(const DlcHandle &dlc_handle) noexcept {
+    DlcHandle::DlcHandle(const DlcHandle &dlc_handle) noexcept {
         handle_ = dlc_handle.handle_;
         if (handle_ != nullptr)
             (*handle_)++;
     }
 
-    inline DlcHandle::DlcHandle(DlcHandle &&dlc_handle)noexcept {
+    DlcHandle::DlcHandle(DlcHandle &&dlc_handle)noexcept {
         handle_ = dlc_handle.handle_;
         dlc_handle.handle_ = nullptr;
     }
@@ -64,7 +64,7 @@ namespace aFuntool {
         return DlcSymbol<SYMBOL>(symbol, this);
     }
 
-    inline bool DlcHandle::Handle::isOpen() const {
+    bool DlcHandle::Handle::isOpen() const {
         return handle_ != nullptr;
     }
 }

+ 5 - 3
include/tool/log.h

@@ -3,6 +3,8 @@
 
 #include <iostream>
 #include "aFunToolExport.h"
+#include "macro.h"
+
 #include "tool-type.h"
 #include "thread"
 #include "mutex"
@@ -30,7 +32,7 @@ namespace aFuntool {
     class AFUN_TOOL_EXPORT Logger {
         friend class LogFactory;
     public:
-        inline explicit Logger(LogFactory &factor, std::string id, LogLevel level = log_warning, bool exit = true) noexcept;
+        AFUN_INLINE explicit Logger(LogFactory &factor, std::string id, LogLevel level = log_warning, bool exit = true) noexcept;
 
         int writeTrackLog(const char *file, int line, const char *func, const char *format, ...);
         int writeDebugLog(const char *file, int line, const char *func, const char *format, ...);
@@ -40,10 +42,10 @@ namespace aFuntool {
         int writeSendErrorLog(const char *file, int line, const char *func, const char *format, ...) noexcept(false);
         int writeFatalErrorLog(const char *file, int line, const char *func, int exit_code, const char *format, ...) noexcept(false);
     private:
+        LogFactory &factor_;
         const std::string id_;
         LogLevel level_ = log_debug;
         bool exit_ = true;
-        LogFactory &factor_;
     };
 
     class AFUN_TOOL_EXPORT LogFactory {
@@ -59,7 +61,7 @@ namespace aFuntool {
                       const char *ti, time_t t,
                       const char *file, int line, const char *func,
                       const char *info);
-        static void writeConsole(LogLevel level,
+        AFUN_STATIC void writeConsole(LogLevel level,
                                  const char *id, pid_t tid,
                                  const char *ti, time_t t,
                                  const char *file, int line, const char *func,

+ 1 - 1
include/tool/log.inline.h

@@ -3,7 +3,7 @@
 #include "log.h"
 
 namespace aFuntool {
-    inline aFuntool::Logger::Logger(LogFactory &factor, std::string id, LogLevel level, bool exit) noexcept
+    aFuntool::Logger::Logger(LogFactory &factor, std::string id, LogLevel level, bool exit) noexcept
         : factor_{factor}, id_{std::move(id)}, level_{level}, exit_{exit} {
 
     }

+ 8 - 0
include/tool/macro.h

@@ -0,0 +1,8 @@
+#ifndef AFUN_MACRO_H
+#define AFUN_MACRO_H
+
+#define AFUN_STATIC [[maybe_unused]] static
+#define AFUN_INLINE [[maybe_unused]] inline
+#define AFUN_NULL ((void)0)
+
+#endif //AFUN_MACRO_H

+ 3 - 3
include/tool/mem.template.h

@@ -9,10 +9,10 @@
 /* 取代calloc函数 */
 namespace aFuntool {
     template <typename T = void *>
-    static T *safeFree(T *ptr) {if (ptr != nullptr) free((void *)ptr); return nullptr;}
+    T *safeFree(T *ptr) {if (ptr != nullptr) free((void *)ptr); return nullptr;}
 
     template <typename T = void *>
-    static T *safeCalloc(size_t n, size_t size){
+    T *safeCalloc(size_t n, size_t size){
         T *re = (T *)calloc(n, size);
         if (re == nullptr) {
             if (aFunSysLogger)
@@ -24,7 +24,7 @@ namespace aFuntool {
     }
 
     template <typename T = void *>
-    static T *safeCalloc(size_t n = 1){
+    T *safeCalloc(size_t n = 1){
         T *re = (T *)calloc(n, sizeof(T));  // 自动推断类型
         if (re == nullptr) {
             if (aFunSysLogger)

+ 10 - 9
include/tool/path.h

@@ -1,32 +1,33 @@
 #ifndef AFUN_PATH_H
 #define AFUN_PATH_H
+#include "macro.h"
 #include "tool-type.h"
 
 /* 路径工具 */
 #ifdef aFunWIN32_NO_CYGWIN
 
 namespace aFuntool {
-    static const char *SEP = "\\";
-    static const char SEP_CH = '\\';
+    AFUN_STATIC const char *SEP = "\\";
+    AFUN_STATIC const char SEP_CH = '\\';
 }
 
 #else
 
 namespace aFuntool {
-    static const char *SEP = "/";
-    static const char SEP_CH = '/';
+    AFUN_STATIC const char *SEP = "/";
+    AFUN_STATIC const char SEP_CH = '/';
 }
 
 #endif
 
 namespace aFuntool {
-    static const char *SHARED_PREFIX = aFunSharePrefix;
-    static const char *SHARED_SUFFIX = aFunShareSuffix;
+    AFUN_STATIC const char *SHARED_PREFIX = aFunSharePrefix;
+    AFUN_STATIC const char *SHARED_SUFFIX = aFunShareSuffix;
 
-    static const char *STATIC_PREFIX = aFunStaticPrefix;
-    static const char *STATIC_SUFFIX = aFunStaticSuffix;
+    AFUN_STATIC const char *STATIC_PREFIX = aFunStaticPrefix;
+    AFUN_STATIC const char *STATIC_SUFFIX = aFunStaticSuffix;
 
-    static const char *EXE_SUFFIX = aFunExeSuffix;
+    AFUN_STATIC const char *EXE_SUFFIX = aFunExeSuffix;
 }
 
 #endif //AFUN_PATH_H

+ 9 - 8
include/tool/tool-exception.h

@@ -1,42 +1,43 @@
 #ifndef AFUN_TOOL_EXCEPTION_H
 #define AFUN_TOOL_EXCEPTION_H
 #include "aFunToolExport.h"
+#include "macro.h"
 #include "tool-type.h"
 
 namespace aFuntool {
     class AFUN_TOOL_EXPORT aFunException : public std::exception {
         std::string message;
     public:
-        inline explicit aFunException(std::string msg);
+        AFUN_INLINE explicit aFunException(std::string msg);
         virtual const char *what();
-        [[nodiscard]] inline const std::string &getMessage() const;
+        [[nodiscard]] AFUN_INLINE const std::string &getMessage() const;
     };
 
     class aFuntoolException : public aFunException {
     public:
-        inline explicit aFuntoolException(const std::string &msg);
+        AFUN_INLINE explicit aFuntoolException(const std::string &msg);
     };
 
     class FileOpenException : public aFuntoolException {
     public:
-        inline explicit FileOpenException(const FilePath &file);
+        AFUN_INLINE explicit FileOpenException(const FilePath &file);
     };
 
     class RegexException : public aFuntoolException {
     public:
-        inline explicit RegexException(const std::string &msg);
+        AFUN_INLINE explicit RegexException(const std::string &msg);
     };
 
     class LogFatalError : public aFuntoolException {
     public:
-        inline explicit LogFatalError(const char *msg);
+        AFUN_INLINE explicit LogFatalError(const char *msg);
     };
 
     class Exit : public aFuntoolException {
         int exit_code;
     public:
-        inline explicit Exit(int exit_code_);
-        inline int getExitCode() const;
+        AFUN_INLINE explicit Exit(int exit_code_);
+        AFUN_INLINE int getExitCode() const;
     };
 }
 

+ 8 - 8
include/tool/tool-exception.inline.h

@@ -4,35 +4,35 @@
 #include "tool-exception.h"
 
 namespace aFuntool {
-    inline aFunException::aFunException(std::string msg) : message{std::move(msg)} {
+    aFunException::aFunException(std::string msg) : message{std::move(msg)} {
 
     }
 
-    inline const std::string &aFunException::getMessage() const {
+    const std::string &aFunException::getMessage() const {
         return message;
     }
 
-    inline aFuntoolException::aFuntoolException(const std::string &msg) : aFunException{msg} {
+    aFuntoolException::aFuntoolException(const std::string &msg) : aFunException{msg} {
 
     }
 
-    inline FileOpenException::FileOpenException(const FilePath &file) : aFuntoolException("File cannot open: " + file) {
+    FileOpenException::FileOpenException(const FilePath &file) : aFuntoolException("File cannot open: " + file) {
 
     }
 
-    inline RegexException::RegexException(const std::string &msg) : aFuntoolException("Regex error: " + msg) {
+    RegexException::RegexException(const std::string &msg) : aFuntoolException("Regex error: " + msg) {
 
     }
 
-    inline LogFatalError::LogFatalError(const char *msg) : aFuntoolException(msg) {
+    LogFatalError::LogFatalError(const char *msg) : aFuntoolException(msg) {
 
     }
 
-    inline Exit::Exit(int exit_code_) : aFuntoolException("Exit by user"), exit_code{exit_code_} {
+    Exit::Exit(int exit_code_) : aFuntoolException("Exit by user"), exit_code{exit_code_} {
 
     }
 
-    inline int Exit::getExitCode() const {
+    int Exit::getExitCode() const {
         return exit_code;
     }
 }

+ 2 - 1
include/tool/tool-logger.h

@@ -1,12 +1,13 @@
 #ifndef AFUN_TOOL_LOGGER_H
 #define AFUN_TOOL_LOGGER_H
 #include "aFunToolExport.h"
+#include "macro.h"
 
 namespace aFuntool {
     class Logger;
     extern AFUN_TOOL_EXPORT class Logger *aFunSysLogger;
 
-    static void setSysLogger(aFuntool::Logger *log);
+    AFUN_STATIC void setSysLogger(aFuntool::Logger *log);
 }
 
 #include "tool-logger.inline.h"

+ 1 - 1
include/tool/tool-logger.inline.h

@@ -3,7 +3,7 @@
 #include "tool-logger.h"
 
 namespace aFuntool {
-    static void setSysLogger(aFuntool::Logger *log) {
+    void setSysLogger(aFuntool::Logger *log) {
         aFunSysLogger = log;
     }
 }

+ 5 - 4
include/tool/tool-regex.h

@@ -2,16 +2,17 @@
 #define AFUN_TOOL_REGEX
 #define PCRE2_CODE_UNIT_WIDTH 8
 #include "pcre2.h"
+#include "macro.h"
 
 namespace aFuntool {
     class AFUN_TOOL_EXPORT Regex {  // 整个对象都是inline的, 不需要Export符号
-        pcre2_code *re;  // 正则表达式
         std::string pattern;  // 正则表达式的字符串
+        pcre2_code *re;  // 正则表达式
     public:
         explicit Regex(std::string pattern_) noexcept(false);
-        inline Regex(const Regex &regex) noexcept;
-        inline Regex(Regex &&regex) noexcept;
-        inline ~Regex() noexcept;
+        AFUN_INLINE Regex(const Regex &regex) noexcept;
+        AFUN_INLINE Regex(Regex &&regex) noexcept;
+        AFUN_INLINE ~Regex() noexcept;
         Regex &operator=(const Regex &regex)=delete;
         Regex &operator=(Regex &&regex)=delete;
 

+ 2 - 2
include/tool/tool-regex.inline.h

@@ -3,11 +3,11 @@
 #include "tool-regex.h"
 
 namespace aFuntool {
-    inline Regex::Regex(const Regex &regex) noexcept: Regex(regex.pattern) {
+    Regex::Regex(const Regex &regex) noexcept: Regex(regex.pattern) {
 
     }
 
-    inline Regex::Regex(Regex &&regex) noexcept : pattern {std::move(regex.pattern)}, re {regex.re} {
+    Regex::Regex(Regex &&regex) noexcept : pattern {std::move(regex.pattern)}, re {regex.re} {
         regex.re = nullptr;
     }
 

+ 37 - 36
include/tool/tool-stdio.h

@@ -2,15 +2,16 @@
 #define AFUN_STDIO_H
 #include <cstdio>
 #include <cinttypes>
-#include "tool-type.h"
 #include "aFunToolExport.h"
+#include "macro.h"
+#include "tool-type.h"
 
 namespace aFuntool {
     AFUN_TOOL_EXPORT int fgets_stdin(char **dest, int len);
     AFUN_TOOL_EXPORT bool checkStdin();
     AFUN_TOOL_EXPORT bool fclear_stdin();
-    static bool clear_ferror(FILE *file);
-    static bool clear_stdin();
+    AFUN_STATIC bool clear_ferror(FILE *file);
+    AFUN_STATIC bool clear_stdin();
 }
 
 #ifdef aFunWIN32_NO_CYGWIN
@@ -35,33 +36,33 @@ namespace aFuntool {
     AFUN_TOOL_EXPORT int fungetc_stdin(int ch);
 
     AFUN_TOOL_EXPORT int fputs_std_(const char *str, FILE *std);
-    static int fputs_stdout(const char *str);
-    static int fputs_stderr(const char *str);
+    AFUN_STATIC int fputs_stdout(const char *str);
+    AFUN_STATIC int fputs_stderr(const char *str);
 
     AFUN_TOOL_EXPORT size_t vprintf_std_(FILE *std, size_t buf_len, const char *format, va_list ap);
 
-    static size_t vprintf_stderr(size_t buf_len, const char *format, va_list ap);
-    static size_t vprintf_stdout(size_t buf_len, const char *format, va_list ap);
+    AFUN_STATIC size_t vprintf_stderr(size_t buf_len, const char *format, va_list ap);
+    AFUN_STATIC size_t vprintf_stdout(size_t buf_len, const char *format, va_list ap);
 
-    static size_t printf_stdout(size_t buf_len, const char *format, ...);
-    static size_t printf_stderr(size_t buf_len, const char *format, ...);
+    AFUN_STATIC size_t printf_stdout(size_t buf_len, const char *format, ...);
+    AFUN_STATIC size_t printf_stderr(size_t buf_len, const char *format, ...);
 }
 
 #else
 
 namespace aFuntool {
-    static int fgetc_stdin();
-    static int fgets_stdin_(char *buf, int len, FILE *file);
-    static int fungetc_stdin(char ch);
+    AFUN_STATIC int fgetc_stdin();
+    AFUN_STATIC int fgets_stdin_(char *buf, int len, FILE *file);
+    AFUN_STATIC int fungetc_stdin(char ch);
 
-    static int fputs_stdout(const char *str);
-    static int fputs_stderr(const char *str);
+    AFUN_STATIC int fputs_stdout(const char *str);
+    AFUN_STATIC int fputs_stderr(const char *str);
 
-    static int vprintf_stdout(size_t, const char *format, va_list ap);
-    static int vprintf_stderr(size_t, const char *format, va_list ap);
+    AFUN_STATIC int vprintf_stdout(size_t, const char *format, va_list ap);
+    AFUN_STATIC int vprintf_stderr(size_t, const char *format, va_list ap);
 
-    static size_t printf_stdout(size_t, const char *format, ...);
-    static size_t printf_stderr(size_t, const char *format, ...);
+    AFUN_STATIC size_t printf_stdout(size_t, const char *format, ...);
+    AFUN_STATIC size_t printf_stderr(size_t, const char *format, ...);
 }
 
 #endif
@@ -71,24 +72,24 @@ namespace aFuntool {
         typedef size_t PrintFunction(size_t, const char *, ...);
         PrintFunction *func;
     public:
-        inline explicit OutStream(PrintFunction *func_);
-        inline OutStream &operator<<(char a);
-        inline OutStream &operator<<(signed char a);
-        inline OutStream &operator<<(short a);
-        inline OutStream &operator<<(int a);
-        inline OutStream &operator<<(long a);
-        inline OutStream &operator<<(long long a);
-        inline OutStream &operator<<(unsigned char a);
-        inline OutStream &operator<<(unsigned short a);
-        inline OutStream &operator<<(unsigned int a);
-        inline OutStream &operator<<(unsigned long a);
-        inline OutStream &operator<<(unsigned long long a);
-        inline OutStream &operator<<(float a);
-        inline OutStream &operator<<(double a);
-        inline OutStream &operator<<(long double a);
-        inline OutStream &operator<<(const char *a);
-        inline OutStream &operator<<(const std::string &a);
-        inline OutStream &operator<<(const void *a);
+        AFUN_INLINE explicit OutStream(PrintFunction *func_);
+        AFUN_INLINE OutStream &operator<<(char a);
+        AFUN_INLINE OutStream &operator<<(signed char a);
+        AFUN_INLINE OutStream &operator<<(short a);
+        AFUN_INLINE OutStream &operator<<(int a);
+        AFUN_INLINE OutStream &operator<<(long a);
+        AFUN_INLINE OutStream &operator<<(long long a);
+        AFUN_INLINE OutStream &operator<<(unsigned char a);
+        AFUN_INLINE OutStream &operator<<(unsigned short a);
+        AFUN_INLINE OutStream &operator<<(unsigned int a);
+        AFUN_INLINE OutStream &operator<<(unsigned long a);
+        AFUN_INLINE OutStream &operator<<(unsigned long long a);
+        AFUN_INLINE OutStream &operator<<(float a);
+        AFUN_INLINE OutStream &operator<<(double a);
+        AFUN_INLINE OutStream &operator<<(long double a);
+        AFUN_INLINE OutStream &operator<<(const char *a);
+        AFUN_INLINE OutStream &operator<<(const std::string &a);
+        AFUN_INLINE OutStream &operator<<(const void *a);
     };
 
     AFUN_TOOL_EXPORT extern OutStream cout;

+ 35 - 35
include/tool/tool-stdio.inline.h

@@ -4,11 +4,11 @@
 #include "tool-stdio.h"
 
 namespace aFuntool {
-    static bool clear_ferror(FILE *file) {
+    bool clear_ferror(FILE *file) {
         return ferror(file) && (clearerr(file), ferror(file));
     }
 
-    static bool clear_stdin() {
+    bool clear_stdin() {
         return (ferror(stdin) || feof(stdin)) &&
                (clearerr(stdin), (ferror(stdin) || feof(stdin)));
     }
@@ -16,22 +16,22 @@ namespace aFuntool {
 
 #ifdef aFunWIN32_NO_CYGWIN
 namespace aFuntool {
-    static int fputs_stdout(const char *str) {
+    int fputs_stdout(const char *str) {
         return fputs_std_(str, stdout);
     }
 
-    static int fputs_stderr(const char *str) {
+    int fputs_stderr(const char *str) {
         return fputs_std_(str, stderr);
     }
 
-    static size_t vprintf_stderr(size_t buf_len, const char *format, va_list ap) {
+    size_t vprintf_stderr(size_t buf_len, const char *format, va_list ap) {
         return vprintf_std_(stderr, buf_len, format, ap);
     }
-    static size_t vprintf_stdout(size_t buf_len, const char *format, va_list ap) {
+    size_t vprintf_stdout(size_t buf_len, const char *format, va_list ap) {
         return vprintf_std_(stdout, buf_len, format, ap);
     }
 
-    static size_t printf_stdout(size_t buf_len, const char *format, ...) {
+    size_t printf_stdout(size_t buf_len, const char *format, ...) {
         va_list ap;
         va_start(ap, format);
         size_t re = vprintf_std_(stdout, buf_len, format, ap);
@@ -39,7 +39,7 @@ namespace aFuntool {
         return re;
     }
 
-    static size_t printf_stderr(size_t buf_len, const char *format, ...) {
+    size_t printf_stderr(size_t buf_len, const char *format, ...) {
         va_list ap;
         va_start(ap, format);
         size_t re = vprintf_std_(stderr, buf_len, format, ap);
@@ -49,35 +49,35 @@ namespace aFuntool {
 }
 #else
 namespace aFuntool {
-    static int fgetc_stdin(){
+    int fgetc_stdin(){
         return fgetc(stdout);
     }
 
-    static int fgets_stdin_(char *buf, int len, FILE *file){
+    int fgets_stdin_(char *buf, int len, FILE *file){
         return fgets(buf, len, file) != nullptr;
     }
 
-    static int fungetc_stdin(char ch){
+    int fungetc_stdin(char ch){
         return ungetc(ch, stdin);
     }
 
-    static int fputs_stdout(const char *str){
+    int fputs_stdout(const char *str){
         return fputs(str, stdout);
     }
 
-    static int fputs_stderr(const char *str){
+    int fputs_stderr(const char *str){
         return fputs(str, stderr);
     }
 
-    static int vprintf_stdout(size_t, const char *format, va_list ap){
+    int vprintf_stdout(size_t, const char *format, va_list ap){
         return vfprintf(stdout, format, ap);
     }
 
-    static int vprintf_stderr(size_t, const char *format, va_list ap){
+    int vprintf_stderr(size_t, const char *format, va_list ap){
         return vfprintf(stderr, format, ap);
     }
 
-    static size_t printf_stdout(size_t, const char *format, ...) {
+    size_t printf_stdout(size_t, const char *format, ...) {
         va_list ap;
         va_start(ap, format);
         size_t re = vfprintf(stdout, format, ap);
@@ -85,7 +85,7 @@ namespace aFuntool {
         return re;
     }
 
-    static size_t printf_stderr(size_t, const char *format, ...) {
+    size_t printf_stderr(size_t, const char *format, ...) {
         va_list ap;
         va_start(ap, format);
         size_t re = vfprintf(stderr, format, ap);
@@ -97,91 +97,91 @@ namespace aFuntool {
 #endif
 
 namespace aFuntool {
-    inline OutStream::OutStream(PrintFunction *func_) : func {func_} {
+    OutStream::OutStream(PrintFunction *func_) : func {func_} {
 
     }
 
-    inline OutStream &OutStream::operator<<(char a) {
+    OutStream &OutStream::operator<<(char a) {
         func(0, "%c", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(signed char a) {
+    OutStream &OutStream::operator<<(signed char a) {
         func(0, "%c", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(short a) {
+    OutStream &OutStream::operator<<(short a) {
         func(0, "%d", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(int a) {
+    OutStream &OutStream::operator<<(int a) {
         func(0, "%d", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(long a) {
+    OutStream &OutStream::operator<<(long a) {
         func(0, "%ld", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(long long a) {
+    OutStream &OutStream::operator<<(long long a) {
         func(0, "%lld", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(unsigned char a) {
+    OutStream &OutStream::operator<<(unsigned char a) {
         func(0, "%c", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(unsigned short a) {
+    OutStream &OutStream::operator<<(unsigned short a) {
         func(0, "%u", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(unsigned int a) {
+    OutStream &OutStream::operator<<(unsigned int a) {
         func(0, "%u", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(unsigned long a) {
+    OutStream &OutStream::operator<<(unsigned long a) {
         func(0, "%lu", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(unsigned long long a) {
+    OutStream &OutStream::operator<<(unsigned long long a) {
         func(0, "%llu", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(const char *a){
+    OutStream &OutStream::operator<<(const char *a){
         func(0, "%s", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(const std::string &a) {
+    OutStream &OutStream::operator<<(const std::string &a) {
         func(0, "%s", a.c_str());
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(const void *a) {
+    OutStream &OutStream::operator<<(const void *a) {
         func(0, "%p", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(float a) {
+    OutStream &OutStream::operator<<(float a) {
         func(0, "%f", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(double a) {
+    OutStream &OutStream::operator<<(double a) {
         func(0, "%f", a);
         return *this;
     }
 
-    inline OutStream &OutStream::operator<<(long double a) {
+    OutStream &OutStream::operator<<(long double a) {
         func(0, "%lf", a);
         return *this;
     }

+ 3 - 1
include/tool/tool-type.h

@@ -8,10 +8,12 @@
 #include <iostream>
 #include <cinttypes>
 #include <cstdarg>
+#include "macro.h"
+#include "macro.h"
 #include "aFunbase.h"
 
 namespace aFuntool {
-    static const char NUL = 0;
+    AFUN_STATIC const char NUL = 0;
 
     typedef uint32_t FileLine;  // 文件行号
     typedef std::string FilePath;  // 文件路径

+ 1 - 1
src/CMakeLists.txt

@@ -37,7 +37,7 @@ file(GLOB private_h
      ${CMAKE_CURRENT_LIST_DIR}/*.h)
 
 add_executable(aFun-xx "")  # xx表示均为动态链接
-add_executable(aFun-ct "")  # ct表示均静态链接
+add_executable(aFun-ct "" ../include/tool/macro.h)  # ct表示均静态链接
 set(aFunList aFun-xx aFun-ct)
 
 foreach(tgt IN LISTS aFunList)

+ 2 - 3
src/core/activation.cpp

@@ -13,8 +13,7 @@ namespace aFuncore {
      * @param inter_
      */
     Activation::Activation(Inter &inter_)
-            : inter{inter_}, line{0},
-              up{inter_.activation == nullptr ? nullptr : &inter_.activation->up}, down{}{
+            : inter{inter_}, up{inter_.activation == nullptr ? nullptr : &inter_.activation->up}, down{}, line{0} {
         if (inter_.activation != nullptr) {
             varlist.connect(inter_.activation->varlist);
             line = inter_.activation->line;
@@ -239,7 +238,7 @@ namespace aFuncore {
     }
 
     FuncActivation::FuncActivation(Function *func_, Inter &inter_)
-        : Activation(inter_), call{nullptr}, acl_begin{}, acl_end{}, on_tail{false}, status{func_get_func}, func{func_}  {
+        : Activation(inter_), status{func_get_func}, on_tail{false}, call{nullptr}, func{func_}, acl_begin{}, acl_end{}  {
         func->addReference();
     }
 

+ 3 - 4
src/core/inter.cpp

@@ -6,12 +6,12 @@
 
 namespace aFuncore {
     Inter::Inter(Environment &env_)
-            : out{}, in{}, env{env_}, status{inter_init}, activation{nullptr} {
+            : status{inter_init}, env{env_}, activation{nullptr}, out{}, in{} {
         env++;
     }
 
     Inter::Inter(const Inter &base_inter)
-            : out{}, in{}, env{base_inter.env}, status{inter_init}, activation{nullptr}{
+            : status{inter_init}, env{base_inter.env}, activation{nullptr}, out{}, in{}{
         for (auto &i: base_inter.literal)
             literal.push_back(i);
         env++;
@@ -180,8 +180,7 @@ namespace aFuncore {
     }
 
     Environment::Environment(int argc, char **argv)
-        : reference{0}, gc_inter{*(new Inter(*this))},
-          protect{new ProtectVarSpace(*this)}, destruct{false} {
+        : reference{0}, destruct{false}, gc_inter{*(new Inter(*this))}, protect{new ProtectVarSpace(*this)} {
         /* 生成 gc_inter 后, reference == 1 */
 
         envvar.setNumber("sys:gc-runtime", 2);

+ 1 - 1
src/core/lexical.cpp

@@ -406,7 +406,7 @@ namespace aFuncore {
                     bool flat = false;
                     char *p = word + 1;
                     size_t count = 0;
-                    for (NULL; *p != aFuntool::NUL; p++) {
+                    for(AFUN_NULL; *p != aFuntool::NUL; p++) {
                         if (*p == '|' && !flat) {  // 跳过第一个 `|`, 如果是末尾|则自然跳过, 若不是则在遇到第二个`|`时写入数据
                             flat = true; /* count不需要递增 */
                             continue;

+ 3 - 2
src/core/msg.cpp

@@ -9,9 +9,10 @@ namespace aFuncore {
     }
 
     NormalMessage::~NormalMessage(){
-        if (obj != nullptr)
+        if (obj != nullptr) {
             obj->delReference();
             obj = nullptr;
+        }
     }
 
     void NormalMessage::topProgress(Inter &inter, Activation &activation){
@@ -19,7 +20,7 @@ namespace aFuncore {
     }
 
     ErrorMessage::ErrorMessage(std::string error_type_, std::string error_info_, Activation *start)
-        : error_type{std::move(error_type_)}, error_info{std::move(error_info_)}, inter{start->inter}{
+        : inter{start->inter}, error_type{std::move(error_type_)}, error_info{std::move(error_info_)} {
         for (const auto activation : inter.getStack()) {
             if (activation->getFileLine() != 0)
                 trackback.push_front({activation->getFilePath(), activation->getFileLine()});

+ 2 - 2
src/core/object-value.cpp

@@ -5,11 +5,11 @@
 #include "core-activation.h"
 
 namespace aFuncore {
-    Var::Var(Object *data_, Inter &inter) : Object("Var", inter), data{data_}, env{inter.getEnvironment()}{
+    Var::Var(Object *data_, Inter &inter) : Object("Var", inter), env{inter.getEnvironment()}, data{data_}{
 
     }
 
-    Var::Var(Object *data_, Environment &env_) : Object("Var", env_), data{data_}, env{env_}{
+    Var::Var(Object *data_, Environment &env_) : Object("Var", env_), env{env_}, data{data_}{
 
     }
 

+ 4 - 4
src/core/object.cpp

@@ -4,15 +4,15 @@
 
 namespace aFuncore {
     Object::Object(std::string type_, Inter &inter)
-        : not_clear{false}, reference{1}, reachable{false}, done_destruct{false},
-          type{std::move(type_)}, env{inter.getEnvironment()}{
+        : env{inter.getEnvironment()}, type{std::move(type_)}, done_destruct{false}, not_clear{false},
+          reachable{false}, reference{1}{
         std::unique_lock<std::mutex> mutex{env.lock};
         env.gc.push_back(this);
     }
 
     Object::Object(std::string type_, Environment &env_)
-        : not_clear{false}, reference{1}, reachable{false}, done_destruct{false},
-          type{std::move(type_)}, env{env_}{
+        : env{env_}, type{std::move(type_)}, done_destruct{false}, not_clear{false},
+          reachable{false}, reference{1}{
         std::unique_lock<std::mutex> mutex{env.lock};
         env.gc.push_back(this);
     }

+ 1 - 1
src/tool/file.cpp

@@ -47,7 +47,7 @@ namespace aFuntool {
      * @param path 路径 (utf-8)
      * @return
      */
-    static int get_stat(aFun_stat &stat_, const std::string &path_){
+    int get_stat(aFun_stat &stat_, const std::string &path_){
         int re;
 #ifdef aFunWIN32_NO_CYGWIN
         aFun_path *tmp = nullptr;

+ 2 - 2
src/tool/log.cpp

@@ -130,7 +130,7 @@ namespace aFuntool {
 
 
 /* LogLevel和字符串的转换 */
-    static const char *LogLevelName[] = {
+    const char *LogLevelName[] = {
             "TK",  // track 0
             "DE",  // debug 1
             "IN",  // info 2
@@ -140,7 +140,7 @@ namespace aFuntool {
             "FE",  // fatal_error 6
     };
 
-    static const char *LogLevelNameLong[] = {
+    const char *LogLevelNameLong[] = {
             /* 内容输出到终端时使用*/
             "Track",  // track 0
             "Debug",  // debug 1

+ 6 - 6
src/tool/md5.cpp

@@ -19,11 +19,11 @@ namespace aFuntool {
         unsigned char buffer[64];
     };
 
-    static void MD5Transform(unsigned int state[4], unsigned char block[64]);
+    void MD5Transform(unsigned int state[4], unsigned char block[64]);
 
-    static void MD5Encode(unsigned char *output, const unsigned int *input, unsigned int len);
+    void MD5Encode(unsigned char *output, const unsigned int *input, unsigned int len);
 
-    static void MD5Decode(unsigned int *output, const unsigned char *input, unsigned int len);
+    void MD5Decode(unsigned int *output, const unsigned char *input, unsigned int len);
 
     unsigned char PADDING[] = {
             0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -83,7 +83,7 @@ namespace aFuntool {
         safeFree(context);
     }
 
-    static void MD5Encode(unsigned char *output, const unsigned int *input, unsigned int len){
+    void MD5Encode(unsigned char *output, const unsigned int *input, unsigned int len){
         unsigned int i = 0;
         unsigned int j = 0;
 
@@ -97,7 +97,7 @@ namespace aFuntool {
         }
     }
 
-    static void MD5Decode(unsigned int *output, const unsigned char *input, unsigned int len){
+    void MD5Decode(unsigned int *output, const unsigned char *input, unsigned int len){
         for (unsigned int i = 0, j = 0; j < len; i++, j += 4) {
             output[i] = (input[j]) |
                         (input[j + 1] << (unsigned) 8) |
@@ -106,7 +106,7 @@ namespace aFuntool {
         }
     }
 
-    static void MD5Transform(unsigned int state[4], unsigned char block[64]){
+    void MD5Transform(unsigned int state[4], unsigned char block[64]){
         unsigned int a = state[0];
         unsigned int b = state[1];
         unsigned int c = state[2];

+ 1 - 1
src/tool/regex.cpp

@@ -4,7 +4,7 @@
 #include "string"
 
 namespace aFuntool {
-    Regex::Regex(std::string pattern_) noexcept(false): re{nullptr}, pattern{std::move(pattern_)} {
+    Regex::Regex(std::string pattern_) noexcept(false): pattern{std::move(pattern_)}, re{nullptr} {
         int error_code;
         size_t error_offset;
         pcre2_code *ret = pcre2_compile((PCRE2_SPTR) pattern.c_str(), PCRE2_ZERO_TERMINATED, 0, &error_code,

+ 18 - 18
src/tool/stdio.cpp

@@ -31,14 +31,14 @@ namespace aFuntool {
 
 namespace aFuntool {
     const int BUFF_SIZE = 40960;
-    static char buffer[BUFF_SIZE + 1] = "";
-    static size_t index = 0;
-    static size_t next = 0;
-    static size_t end = 0;
+    char buffer[BUFF_SIZE + 1] = "";
+    size_t index = 0;
+    size_t next = 0;
+    size_t end = 0;
     volatile sig_atomic_t ctrl_c = 0;
-    static std::mutex buffer_mutex;  // 只有 export 的函数统一处理该互斥锁
+    std::mutex buffer_mutex;  // 只有 export 的函数统一处理该互斥锁
 
-    static int setCursorPosition(HANDLE std_o, CONSOLE_SCREEN_BUFFER_INFO *info_, SHORT x_){
+    int setCursorPosition(HANDLE std_o, CONSOLE_SCREEN_BUFFER_INFO *info_, SHORT x_){
         CONSOLE_SCREEN_BUFFER_INFO info;
         if (info_ == nullptr) {
             if (!GetConsoleScreenBufferInfo(std_o, &info))
@@ -69,7 +69,7 @@ namespace aFuntool {
         return 1;
     }
 
-    static int nextToEnd(HANDLE std_o){
+    int nextToEnd(HANDLE std_o){
         CONSOLE_SCREEN_BUFFER_INFO info;
         if (!GetConsoleScreenBufferInfo(std_o, &info))
             return 0;
@@ -79,7 +79,7 @@ namespace aFuntool {
         return 1;
     }
 
-    static int moveBuffer(){
+    int moveBuffer(){
         if (index == 0)
             return 0;
         memmove(buffer, buffer + index, BUFF_SIZE - index);
@@ -90,7 +90,7 @@ namespace aFuntool {
         return 1;
     }
 
-    static int backChar(HANDLE std_o){
+    int backChar(HANDLE std_o){
         if (index != next) {  // 删除一个字符
             if (setCursorPosition(std_o, nullptr, -1) == -1)  // 先一定位置在-1
                 return 0;
@@ -114,7 +114,7 @@ namespace aFuntool {
         return 1;
     }
 
-    static int enterChar(HANDLE std_o){
+    int enterChar(HANDLE std_o){
         if (!nextToEnd(std_o))
             return 0;
         buffer[end] = '\n';
@@ -130,7 +130,7 @@ namespace aFuntool {
      * 返回1表示成功
      * 返回0表示失败
      */
-    static int newChar(HANDLE std_i, char ch){
+    int newChar(HANDLE std_i, char ch){
         if (ch == 0)
             return 1;
         if (end == BUFF_SIZE && !moveBuffer())  // 对比 end 而不是 next
@@ -162,16 +162,16 @@ namespace aFuntool {
      * 返回0表示未完成行读取
      * 返回1表示完成行读取
      */
-    static int checkNewInput(HANDLE std_i, HANDLE std_o){
+    int checkNewInput(HANDLE std_i, HANDLE std_o){
         DWORD len = 0;
-        DWORD oldm;
-        if (!GetConsoleMode(std_i, &oldm))
+        DWORD old_mode;
+        if (!GetConsoleMode(std_i, &old_mode))
             return -1;
 
         if (!GetNumberOfConsoleInputEvents(std_i, &len))
             return -1;
 
-        for (int i = 0; i < len; i++) {
+        for (DWORD i = 0; i < len; i++) {
             INPUT_RECORD record;
             DWORD read_len;
             if (!ReadConsoleInputA(std_i, &record, 1, &read_len) || read_len == 0)
@@ -219,7 +219,7 @@ namespace aFuntool {
         return 0;
     }
 
-    static int fcheck_stdin(HANDLE std_i, HANDLE std_o){
+    int fcheck_stdin(HANDLE std_i, HANDLE std_o){
         if (end == index || end == 0 || buffer[end - 1] != '\n')
             return checkNewInput(std_i, std_o);
         return 1;
@@ -396,7 +396,7 @@ namespace aFuntool {
             return ungetc(ch, stdin);
 
         std::unique_lock<std::mutex> ul{buffer_mutex};
-        if (ch == 0 || index == 0 && end == BUFF_SIZE) {
+        if (ch == 0 || (index == 0 && end == BUFF_SIZE)) {
             return 0;
         }
 
@@ -469,7 +469,7 @@ namespace aFuntool {
 #include <fcntl.h>
 
 namespace aFuntool {
-    static std::mutex fcntl_mutex;  // 只有 export 的函数统一处理该互斥锁
+    std::mutex fcntl_mutex;  // 只有 export 的函数统一处理该互斥锁
     
     // 用于Linux平台的IO函数
     // 默认Linux平台均使用utf-8

+ 4 - 4
test/src/run-code.cpp

@@ -4,7 +4,7 @@ using namespace aFunit;
 using namespace aFuncore;
 using namespace aFuntool;
 
-static void progressInterEvent(Inter &inter);
+void progressInterEvent(Inter &inter);
 
 class Func1 : public Function {
     class CallFunc1 : public CallFunction {
@@ -98,7 +98,7 @@ public:
     }
 };
 
-static void printMessage(const std::string &type, Message *msg, Inter &inter) {
+void printMessage(const std::string &type, Message *msg, Inter &inter) {
     if (type == "NORMAL") {
         auto *msg_ = dynamic_cast<NormalMessage *>(msg);
         if (msg_ == nullptr)
@@ -124,7 +124,7 @@ static void printMessage(const std::string &type, Message *msg, Inter &inter) {
     }
 }
 
-static void progressInterEvent(Inter &inter) {
+void progressInterEvent(Inter &inter) {
     std::string type;
     for (auto msg = inter.getOutMessageStream().popFrontMessage(type); msg != nullptr; msg = inter.getOutMessageStream().popFrontMessage(type)) {
         printMessage(type, msg, inter);
@@ -132,7 +132,7 @@ static void progressInterEvent(Inter &inter) {
     }
 }
 
-static void thread_test(Inter &son) {
+void thread_test(Inter &son) {
     auto code = Code("run-code.aun");
     code.getByteCode()->connect(new Code::ByteCode(code, Code::ByteCode::block_p,
                                                    new Code::ByteCode(code, "test-var", 1), 0));

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

@@ -15,15 +15,15 @@ int main(int argc, char **argv) {
     std::wcout << tmp << std::endl;
     std::wcout << tmp2 << std::endl;
 
-    for (int i = 0; i < wcslen(tmp); i++)
+    for (size_t i = 0; i < wcslen(tmp); i++)
         printf("%x ", tmp[i]);
     printf("\n");
 
-    for (int i = 0; i < wcslen(tmp2); i++)
+    for (size_t i = 0; i < wcslen(tmp2); i++)
         printf("%x ", tmp2[i]);
     printf("\n");
 
-    for (int i = 0; i < strlen(tmp3); i++)
+    for (size_t i = 0; i < strlen(tmp3); i++)
         printf("%x ", (unsigned int)tmp3[i]);
     printf("\n");
 #endif