소스 검색

refactor: 调整文件结构

obj_api.h不包含在object.h中(object.h并不依赖该文件)
如果obj_api.h包含在object.h中则会造成复杂的循环依赖
SongZihuan 3 년 전
부모
커밋
947bdb7696
4개의 변경된 파일14개의 추가작업 그리고 14개의 파일을 삭제
  1. 2 0
      include/core/info/obj_api.h
  2. 0 1
      include/core/object.h
  3. 1 0
      src/core/__object.h
  4. 11 13
      src/main.c

+ 2 - 0
include/core/info/obj_api.h

@@ -3,6 +3,8 @@
  * 目标:
  * 1) 定义一些函数签名
  * 2) 定义Object的函数签名
+ *
+ * 注意: 该文件不包含在object.h中, object.h并不依赖该文件
  */
 
 #ifndef AFUN_OBJ_API_H

+ 0 - 1
include/core/object.h

@@ -12,7 +12,6 @@ typedef struct af_ObjectAPI af_ObjectAPI;
 typedef void objectAPIFunc();
 DEFINE_DLC_SYMBOL(objectAPIFunc);
 
-#include "obj_api.h"
 #include "env.h"
 #include "var.h"
 

+ 1 - 0
src/core/__object.h

@@ -6,6 +6,7 @@
 #ifndef AFUN_OBJECT_H_
 #define AFUN_OBJECT_H_
 #include "tool.h"
+#include "obj_api.h"  // 该文件不包含在object.h中, object.h并不依赖该文件
 
 // 这些typedef可能会被下面include的文件使用
 typedef struct af_ObjectData af_ObjectData;

+ 11 - 13
src/main.c

@@ -3,19 +3,19 @@
 #include "main_run.h"
 #include "main_build.h"
 
-ff_defArg(help, true)
+ff_defArg(help, false)
                 ff_argRule('h', help, not, 'h')
                 ff_argRule('v', version, not, 'v')
-ff_endArg(help, true);
+ff_endArg(help, false);
 
-ff_defArg(run, false)
+ff_defArg(run, true)
                 ff_argRule('e', eval, must, 'e')
                 ff_argRule('f', file, must, 'f')
                 ff_argRule('s', source, must, 's')
                 ff_argRule('b', byte, must, 'b')
                 ff_argRule(NUL, no-afb, not, 'a')
                 ff_argRule(NUL, no-cl, not, 'n')
-ff_endArg(run, false);
+ff_endArg(run, true);
 
 ff_defArg(build, false)
                 ff_argRule('o', out, must, 'o')
@@ -50,10 +50,6 @@ int main(int argc, char **argv) {
         exit_code = mainHelp(ff);
 
     ff_freeFFlags(ff);
-
-    printf("aFunlang exit as: %d\n", exit_code);
-    printf("Enter any key to continue...\n");
-    getc(stdin);
     return exit_code;
 }
 
@@ -102,9 +98,6 @@ static int mainHelp(ff_FFlags *ff) {
         have_opt = true;  // 表示有实际参数
     }
 out:
-    if (ff_getopt_wild(&text, ff))
-        return EXIT_FAILURE;
-
     if (!have_opt) {
         printHelp();
         return EXIT_SUCCESS;
@@ -195,13 +188,17 @@ static int mainBuild(ff_FFlags *ff) {
 
         switch (mark) {
             case 'o':
-                if (path != NULL)
+                if (path != NULL) {
+                    fprintf(stderr, "Parameter conflict.\n");
                     goto error;
+                }
                 out_put = text;
                 break;
             case 'p':
-                if (out_put != NULL)
+                if (out_put != NULL) {
+                    fprintf(stderr, "Parameter conflict.\n");
                     goto error;
+                }
                 path = text;
                 break;
             case 'f':
@@ -248,5 +245,6 @@ out:
     return exit_code;
 
 error:
+    printHelp();
     return EXIT_FAILURE;
 }