Browse Source

feat: 对象id使用std::string

SongZihuan 3 years ago
parent
commit
97902dd125

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

@@ -9,6 +9,7 @@
 
 #ifndef AFUN_OBJ_API_H
 #define AFUN_OBJ_API_H
+#include <iostream>
 #include "env.hpp"
 #include "object.hpp"
 #include "var.hpp"
@@ -37,7 +38,7 @@ typedef struct af_FuncBody *callFuncBody(af_CallFuncInfo *info, af_Environment *
  * API第三个参数: 通常为void *data [仅与data有关的函数会直接传入该值]
  */
 
-#define BASE_ARG const char *id, af_Object *obj /* 基础参数 */
+#define BASE_ARG const std::string &id, af_Object *obj /* 基础参数 */
 
 /*** Object void *data 管理 ***/
 typedef size_t obj_getDataSize(BASE_ARG);  // 获取data的大小

+ 3 - 2
include/core/object.hpp

@@ -1,5 +1,6 @@
 #ifndef AFUN_OBJECT
 #define AFUN_OBJECT
+#include <iostream>
 #include "aFunCoreExport.h"
 #include "tool.hpp"
 
@@ -16,7 +17,7 @@ DEFINE_DLC_SYMBOL(objectAPIFunc);
 #include "var.hpp"
 
 /* 对象创建 */
-AFUN_CORE_EXPORT af_Object * makeObject(const char *id, bool free_api, af_ObjectAPI *api, bool allow_inherit,
+AFUN_CORE_EXPORT af_Object * makeObject(const std::string &id, bool free_api, af_ObjectAPI *api, bool allow_inherit,
                                         af_Object *belong, bool free_inherit, af_Inherit *inherit,
                                         af_Environment *env);
 
@@ -44,7 +45,7 @@ AFUN_CORE_EXPORT af_Inherit **pushInherit(af_Inherit **base, af_Inherit *new_ih)
 AFUN_CORE_EXPORT void *getObjectData(af_Object *obj);
 AFUN_CORE_EXPORT af_Object *getBelongObject(af_Object *object);
 AFUN_CORE_EXPORT af_Object *findObjectAttributes(char *name, af_Object *visitor, af_Object *obj, af_Environment *env);
-AFUN_CORE_EXPORT const char *getObjectID(af_Object *obj);
+AFUN_CORE_EXPORT const std::string &getObjectID(af_Object *obj);
 AFUN_CORE_EXPORT af_ObjectAPI *getObjectAPI(af_Object *obj);
 AFUN_CORE_EXPORT af_Inherit *getObjectInherit(af_Object *obj);
 AFUN_CORE_EXPORT af_VarSpace *getObjectVarSpace(af_Object *obj);

+ 2 - 1
include/runtime/runtime.hpp

@@ -1,5 +1,6 @@
 #ifndef AFUN_RUNTIME_HPP
 #define AFUN_RUNTIME_HPP
+#include <iostream>
 
 typedef struct APIFuncList APIFuncList;
 struct APIFuncList {
@@ -17,7 +18,7 @@ struct InheritDefineList {
 
 typedef struct ObjectDefineList ObjectDefineList;
 struct ObjectDefineList {
-    const char *id;
+    const std::string &id;
 
     bool free_api;
     af_ObjectAPI *api;

+ 1 - 1
src/core/__object.hpp

@@ -34,7 +34,7 @@ struct af_ObjectAPI {
 };
 
 struct af_ObjectData {
-    char *id;  // 对象类型标识符(一个字符串)
+    std::string id;  // 对象类型标识符(一个字符串)
 
     void *data;
     size_t size;  // 标记data的大小

+ 1 - 1
src/core/gc.cpp

@@ -315,7 +315,7 @@ static pgc_Analyzed reachableObjectData(struct af_ObjectData *od, pgc_Analyzed p
 
     auto func = (obj_getGcList *)findAPI("obj_getGcList", od->api);
     if (func != nullptr) {
-        af_GcList *gl = func(od->id, od->base, od->data);
+        af_GcList *gl = func(od->id.c_str(), od->base, od->data);
         for (af_GcList *tmp = gl; tmp != nullptr; tmp = tmp->next) {
             if (tmp->data == nullptr)
                 continue;

+ 10 - 10
src/core/global_obj.cpp

@@ -6,7 +6,7 @@ struct GlobalObjectData {
     af_VarSpace *share;
 };
 
-static const char *global_id = "global-object";
+static const std::string global_id = "global-object";
 
 static void initGOD(af_Object *obj, GlobalObjectData *data, af_Environment *env) {
     data->share = makeVarSpace(obj, 3, 2, 0, env);
@@ -17,23 +17,23 @@ static void freeGOD(GlobalObjectData *god, af_Object  *obj, af_Environment *env)
     god->share = nullptr;
 }
 
-static size_t getSize(char *id, af_Object *obj) {  // NOLINT 必备参数
+static size_t getSize(const std::string &id, af_Object *obj) {  // NOLINT 必备参数
     /* 不需要检查 id */
     return sizeof(GlobalObjectData);
 }
 
-static void initData(char *id, af_Object *obj, GlobalObjectData *data, af_Environment *env) {
-    if (EQ_STR(id, global_id))
+static void initData(const std::string &id, af_Object *obj, GlobalObjectData *data, af_Environment *env) {
+    if (id == global_id)
         initGOD(obj, data, env);
 }
 
-static void freeData(char *id, af_Object *obj, GlobalObjectData *data, af_Environment *env) {
-    if (EQ_STR(id, global_id))
+static void freeData(const std::string &id, af_Object *obj, GlobalObjectData *data, af_Environment *env) {
+    if (id == global_id)
         freeGOD(data, obj, env);
 }
 
-static af_GcList *getGcList(char *id, af_Object *obj, GlobalObjectData *data) {  // NOLINT 必备参数
-    if (!EQ_STR(id, global_id))
+static af_GcList *getGcList(const std::string &id, af_Object *obj, GlobalObjectData *data) {  // NOLINT 必备参数
+    if (id != global_id)
         return nullptr;
 
     if (data->share != nullptr)
@@ -42,8 +42,8 @@ static af_GcList *getGcList(char *id, af_Object *obj, GlobalObjectData *data) {
 }
 
 
-static af_VarSpace *getShareVS(char *id, af_Object *obj) {
-    if (!EQ_STR(id, global_id))
+static af_VarSpace *getShareVS(const std::string &id, af_Object *obj) {
+    if (id != global_id)
         return nullptr;
     return ((GlobalObjectData *)getObjectData(obj))->share;
 }

+ 6 - 12
src/core/object.cpp

@@ -13,12 +13,7 @@ static af_ObjectAPINode *findObjectDataAPINode(const char *api_name, af_ObjectDa
 static int addAPIToObjectData(DLC_SYMBOL(objectAPIFunc) func, const char *api_name, af_ObjectData *od);
 
 
-/*
- * 函数名: 创建一个object
- * 目标: 生成Object和ObjectData, 并且添加到gc链表中
- * 若处于初始化模式, 则belong, inherit等可以设置为nullptr, 由后期统一填上
- */
-af_Object *makeObject(const char *id, bool free_api, af_ObjectAPI *api, bool allow_inherit, af_Object *belong,
+af_Object *makeObject(const std::string &id, bool free_api, af_ObjectAPI *api, bool allow_inherit, af_Object *belong,
                       bool free_inherit, af_Inherit *inherit, af_Environment *env){
     enum af_CoreStatus status = getCoreStatus(env);
 
@@ -53,7 +48,7 @@ af_Object *makeObject(const char *id, bool free_api, af_ObjectAPI *api, bool all
     obj->belong = nullptr;
     od->base = obj;
     obj->data = od;
-    od->id = strCopy(id == nullptr ? "Unknown" : id);
+    od->id = id;
 
     od->api = api;
     od->free_api = free_api;
@@ -123,7 +118,6 @@ void freeObjectData(af_ObjectData *od, af_Environment *env) {
             func(od->id, od->base, od->data, env);
     }
 
-    free(od->id);
     free(od->data);
     if (od->free_api)
         freeObjectAPI(od->api);
@@ -254,8 +248,8 @@ af_ObjectAPI *makeObjectAPI() {
 }
 
 void freeObjectAPI(af_ObjectAPI *api) {
-    for (int i = 0; i < API_HASHTABLE_SIZE; i++)
-        freeAllObjectAPINode(api->node[i]);
+    for (auto & i : api->node)
+        freeAllObjectAPINode(i);
     pthread_rwlock_destroy(&api->lock);
     free(api);
 }
@@ -441,13 +435,13 @@ af_Object *findObjectAttributesByObjectData(const char *name, af_Object *visitor
     return nullptr;
 }
 
-const char *getObjectID(af_Object *obj) {
+const std::string &getObjectID(af_Object *obj) {
     pthread_rwlock_rdlock(&obj->lock);
     af_ObjectData *data = obj->data;
     pthread_rwlock_unlock(&obj->lock);
 
     pthread_rwlock_rdlock(&data->lock);
-    char *id = data->id;
+    const std::string &id = data->id;
     pthread_rwlock_unlock(&data->lock);
 
     return id;

+ 1 - 1
src/core/run.cpp

@@ -194,7 +194,7 @@ static bool codeElement(af_Code *code, af_Environment *env) {
 
     if (code->prefix != getPrefix(E_QUOTE, env)) {
         af_ObjectAPI *api = getObjectAPI(obj);
-        const char *id = getObjectID(obj);
+        const std::string &id = getObjectID(obj);
         if ((is_obj = (obj_isObjFunc *)findAPI("obj_isObjFunc", api)) != nullptr && is_obj(id, obj)) {
             bool res = pushVariableActivity(code, obj, env);  // 对象函数
             gc_delObjectReference(obj, env);

+ 11 - 11
src/runtime/base/quit.cpp

@@ -1,33 +1,33 @@
 #include "__base.hpp"
 
-#define func_id "quit-func"
+static const std::string func_id = "quit-func";
 
 typedef struct QuitFunc QuitFunc;
 struct QuitFunc {
     af_VarList *func_var_list;
 };
 
-static size_t funcGetSize(char *id, af_Object *obj) {
+static size_t funcGetSize(const std::string &id, af_Object *obj) {
     return sizeof(QuitFunc);
 }
 
-static void funcInit(char *id, af_Object *obj, QuitFunc *data, af_Environment *env) {
-    if (!EQ_STR(id, func_id))
+static void funcInit(const std::string &id, af_Object *obj, QuitFunc *data, af_Environment *env) {
+    if (id != func_id)
         return;
     data->func_var_list = copyVarSpaceList(getRunVarSpaceList(env));
 }
 
-static bool funcArgCodeList(char *id, af_Object *obj, af_ArgCodeList **acl, af_Code *code, void **mark, af_Environment *env) {
+static bool funcArgCodeList(const std::string &id, af_Object *obj, af_ArgCodeList **acl, af_Code *code, void **mark, af_Environment *env) {
     *acl = nullptr;
     return true;
 }
 
-static bool funcArgList(char *id, af_Object *obj, af_ArgList **al, af_ArgCodeList *acl, void *mark, af_Environment *env) {
+static bool funcArgList(const std::string &id, af_Object *obj, af_ArgList **al, af_ArgCodeList *acl, void *mark, af_Environment *env) {
     *al = nullptr;
     return true;
 }
 
-static bool funcVarList(char *id, af_Object *obj, af_VarList **vsl, void *mark, af_Environment *env) {
+static bool funcVarList(const std::string &id, af_Object *obj, af_VarList **vsl, void *mark, af_Environment *env) {
     auto sf = (QuitFunc *)getObjectData(obj);
     *vsl = sf->func_var_list;
     return true;
@@ -39,7 +39,7 @@ static af_FuncBody *funcBody(af_CallFuncInfo *cfi, af_Environment *env) {
     return nullptr;
 }
 
-static bool funcGetInfo(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
+static bool funcGetInfo(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, false, false, false);
     DLC_SYMBOL(callFuncBody) func = MAKE_SYMBOL(funcBody, callFuncBody);
     makeCFuncBodyToFuncInfo(func, nullptr, *fi);
@@ -47,8 +47,8 @@ static bool funcGetInfo(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *cod
     return true;
 }
 
-static void funcDestruct(char *id, af_Object *obj, QuitFunc *data, af_Environment *env) {
-    if (EQ_STR(id, func_id))
+static void funcDestruct(const std::string &id, af_Object *obj, QuitFunc *data, af_Environment *env) {
+    if (id == func_id)
         freeAllVarSpaceList(data->func_var_list);
 }
 
@@ -67,7 +67,7 @@ void makeQuitFunc(af_Object *visitor, af_VarSpace *vs, af_Environment *env) {
     static ObjectDefineList obj_def[] = {
             {.id=func_id, .free_api=true, .api_list=api_list, .allow_inherit=false,
                     .var_name="quit", .p_self=3, .p_posterity=3, .p_external=3},
-            {.id=nullptr}
+            {.id=""}
     };
 
     makeObjectFromList(obj_def, visitor, vs, env);

+ 19 - 19
src/runtime/base/str_obj.cpp

@@ -1,6 +1,6 @@
 #include "__base.hpp"
 
-#define string_func_id "string-maker"
+static const std::string string_func_id = "string-maker";
 typedef struct ObjectStrFunc ObjectStrFunc;
 struct ObjectStrFunc {
     af_ObjectAPI *api;
@@ -8,34 +8,34 @@ struct ObjectStrFunc {
     af_VarList *func_var_list;
 };
 
-static size_t strGetSize(char *id, af_Object *obj) {
+static size_t strGetSize(const std::string &id, af_Object *obj) {
     return sizeof(ObjectString);
 }
 
-static void strInit(char *id, af_Object *obj, ObjectString *data, af_Environment *env) {
-    if (EQ_STR(id, string_id))
+static void strInit(const std::string &id, af_Object *obj, ObjectString *data, af_Environment *env) {
+    if (id == string_id)
         data->str = nullptr;
 }
 
-static void strDestruct(char *id, af_Object *obj, ObjectString *data, af_Environment *env) {
-    if (EQ_STR(id, string_id)) {
+static void strDestruct(const std::string &id, af_Object *obj, ObjectString *data, af_Environment *env) {
+    if (id == string_id) {
         free(data->str);
     }
 }
 
-static void strLiteral(char *id, af_Object *obj, ObjectString *data, char *str, af_Environment *env) {
-    if (!EQ_STR(id, string_id) || data->str != nullptr)
+static void strLiteral(const std::string &id, af_Object *obj, ObjectString *data, char *str, af_Environment *env) {
+    if (id != string_id || data->str != nullptr)
         return;
     writeTrackLog(aFunCoreLogger, "strLiteral str = %s, %d", str, strlen(str));
     data->str = NEW_STR(STR_LEN(str) - 2);  // 取出两个引号
     memcpy(data->str, str + 1, (STR_LEN(str) - 2) * sizeof(char));
 }
 
-static size_t strFuncGetSize(char *id, af_Object *obj) {
+static size_t strFuncGetSize(const std::string &id, af_Object *obj) {
     return sizeof(ObjectStrFunc);
 }
 
-static void strFuncInit(char *id, af_Object *obj, ObjectStrFunc *data, af_Environment *env) {
+static void strFuncInit(const std::string &id, af_Object *obj, ObjectStrFunc *data, af_Environment *env) {
     static const APIFuncList api_list[] = {
             {.name="obj_getDataSize", .func=(void *)strGetSize, .dlc=nullptr},
             {.name="obj_initData", .func=(void *)strInit, .dlc=nullptr},
@@ -44,7 +44,7 @@ static void strFuncInit(char *id, af_Object *obj, ObjectStrFunc *data, af_Enviro
             {.name=nullptr}
     };
 
-    if (!EQ_STR(id, string_func_id))
+    if (id != string_func_id)
         return;
     data->func_var_list = copyVarSpaceList(getRunVarSpaceList(env));
     data->share_vs = makeVarSpace(obj, 3, 2, 0, env);
@@ -52,17 +52,17 @@ static void strFuncInit(char *id, af_Object *obj, ObjectStrFunc *data, af_Enviro
     gc_delVarSpaceReference(data->share_vs, env);
 }
 
-static bool strFuncArgCodeList(char *id, af_Object *obj, af_ArgCodeList **acl, af_Code *code, void **mark, af_Environment *env) {
+static bool strFuncArgCodeList(const std::string &id, af_Object *obj, af_ArgCodeList **acl, af_Code *code, void **mark, af_Environment *env) {
     *acl = nullptr;
     return true;
 }
 
-static bool strFuncArgList(char *id, af_Object *obj, af_ArgList **al, af_ArgCodeList *acl, void *mark, af_Environment *env) {
+static bool strFuncArgList(const std::string &id, af_Object *obj, af_ArgList **al, af_ArgCodeList *acl, void *mark, af_Environment *env) {
     *al = nullptr;
     return true;
 }
 
-static bool strFuncVarList(char *id, af_Object *obj, af_VarList **vsl, void *mark, af_Environment *env) {
+static bool strFuncVarList(const std::string &id, af_Object *obj, af_VarList **vsl, void *mark, af_Environment *env) {
     auto sf = (ObjectStrFunc *)getObjectData(obj);
     *vsl = sf->func_var_list;
     return true;
@@ -76,7 +76,7 @@ static af_FuncBody *strFuncBody(af_CallFuncInfo *cfi, af_Environment *env) {
     return nullptr;
 }
 
-static bool strFuncGetInfo(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
+static bool strFuncGetInfo(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, false, false, false);
     DLC_SYMBOL(callFuncBody) func = MAKE_SYMBOL(strFuncBody, callFuncBody);
     makeCFuncBodyToFuncInfo(func, nullptr, *fi);
@@ -84,14 +84,14 @@ static bool strFuncGetInfo(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *
     return true;
 }
 
-static af_GcList *strFuncGetGc(char *id, af_Object *obj, ObjectStrFunc *data) {
+static af_GcList *strFuncGetGc(const std::string &id, af_Object *obj, ObjectStrFunc *data) {
     af_GcList *gl = pushGcList(glt_vsl, data->func_var_list, nullptr);
     gl = pushGcList(glt_vs, data->share_vs, gl);
     return gl;
 }
 
-static void strFuncDestruct(char *id, af_Object *obj, ObjectStrFunc *data, af_Environment *env) {
-    if (EQ_STR(id, string_func_id)) {
+static void strFuncDestruct(const std::string &id, af_Object *obj, ObjectStrFunc *data, af_Environment *env) {
+    if (id == string_func_id) {
         freeObjectAPI(data->api);
         freeAllVarSpaceList(data->func_var_list);
     }
@@ -113,7 +113,7 @@ void makeStrFunc(af_Object *visitor, af_VarSpace *vs, af_Environment *env) {
     static ObjectDefineList obj_def[] = {
             {.id=string_func_id, .free_api=true, .api_list=api_list, .allow_inherit=true,
                     .var_name="str", .p_self=3, .p_posterity=3, .p_external=3},
-            {.id=nullptr}
+            {.id=""}
     };
 
     makeObjectFromList(obj_def, visitor, vs, env);

+ 9 - 9
src/runtime/cycle_obj.cpp

@@ -1,15 +1,15 @@
 #include "aFunlang.hpp"
 #include "__cycle_obj.hpp"
 
-size_t getSizec_Cycle(char *id, af_Object *obj) {
+size_t getSizec_Cycle(const std::string &id, af_Object *obj) {
     return sizeof(af_VarList *);
 }
 
-void initDatac_Cycle(char *id, af_Object *obj, af_VarList **data, af_Environment *env) {
+void initDatac_Cycle(const std::string &id, af_Object *obj, af_VarList **data, af_Environment *env) {
     *data = pushProtectVarList(nullptr, env);
 }
 
-void freeDatac_Cycle(char *id, af_Object *obj, af_VarList **data, af_Environment *env) {
+void freeDatac_Cycle(const std::string &id, af_Object *obj, af_VarList **data, af_Environment *env) {
     freeAllVarSpaceList(*data);
 }
 
@@ -26,7 +26,7 @@ af_FuncBody *func_Cycle(af_CallFuncInfo *cfi, af_Environment *env) {  // 测试
     return nullptr;
 }
 
-bool getInfoc_Cycle(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, CycleMark *mark, af_Environment *env) {
+bool getInfoc_Cycle(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, CycleMark *mark, af_Environment *env) {
     mark->fi = makeFuncInfo(normal_scope, not_embedded, false, false, false);
     *fi = mark->fi;
 
@@ -37,28 +37,28 @@ bool getInfoc_Cycle(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, C
     return true;
 }
 
-bool getAclc_Cycle(char *id, af_Object *obj, af_ArgCodeList **acl, af_Code *code, CycleMark **mark, af_Environment *env) {
+bool getAclc_Cycle(const std::string &id, af_Object *obj, af_ArgCodeList **acl, af_Code *code, CycleMark **mark, af_Environment *env) {
     *acl = nullptr;
     *mark = calloc(1, CycleMark);
     return true;
 }
 
-bool getVslc_Cycle(char *id, af_Object *obj, af_VarList **vsl, CycleMark *mark, af_Environment *env) {
+bool getVslc_Cycle(const std::string &id, af_Object *obj, af_VarList **vsl, CycleMark *mark, af_Environment *env) {
     *vsl = *(af_VarList **)getObjectData(obj);
     return true;
 }
 
-af_GcList *getGcListc_Cycle(char *id, af_Object *obj, void *data) {
+af_GcList *getGcListc_Cycle(const std::string &id, af_Object *obj, void *data) {
     af_GcList *gl = pushGcList(glt_vsl, *(af_VarList **)data, nullptr);
     return gl;
 }
 
-bool getAlc_Cycle(char *id, af_Object *obj, af_ArgList **al, af_ArgCodeList *acl, CycleMark *mark, af_Environment *env) {
+bool getAlc_Cycle(const std::string &id, af_Object *obj, af_ArgList **al, af_ArgCodeList *acl, CycleMark *mark, af_Environment *env) {
     *al = nullptr;
     return true;
 }
 
-void freeMarkc_Cycle(char *id, af_Object *obj, CycleMark *mark) {
+void freeMarkc_Cycle(const std::string &id, af_Object *obj, CycleMark *mark) {
     free(mark);
 }
 

+ 1 - 1
src/runtime/runtime.cpp

@@ -70,7 +70,7 @@ af_ObjectAPI *makeAPIFromList(const APIFuncList api_list[]) {
  * 必须保证 VarSpace 有被 gc 引用
  */
 void makeObjectFromList(const ObjectDefineList obj_def[], af_Object *visitor, af_VarSpace *vs, af_Environment *env) {
-    for (const ObjectDefineList *od = obj_def; od->id != nullptr; od++) {
+    for (const ObjectDefineList *od = obj_def; od->id.size() != 0; od++) {
         af_ObjectAPI *api = od->api;
         if (api == nullptr)
             api = makeAPIFromList(od->api_list);

+ 29 - 29
test/src/run_code.cpp

@@ -1,40 +1,40 @@
 #include <cstdio>
 #include "aFun.hpp"
 
-size_t getSize(char *id, af_Object *obj) {
+size_t getSize(const std::string &id, af_Object *obj) {
     return sizeof(int *);
 }
 
-void initData(char *id, af_Object *obj, int **data, af_Environment *env) {
+void initData(const std::string &id, af_Object *obj, int **data, af_Environment *env) {
     *data = calloc(1, int);
     **data = 100;
 }
 
-void freeData(char *id, af_Object *obj, int **data, af_Environment *env) {
+void freeData(const std::string &id, af_Object *obj, int **data, af_Environment *env) {
     printf("freeData(): **data = %d\n", **data);
     free(*data);
 }
 
-af_VarSpace *getShareVS(char *id, af_Object *obj) {
+af_VarSpace *getShareVS(const std::string &id, af_Object *obj) {
     return *(af_VarSpace **)getObjectData(obj);
 }
 
 
-size_t getSize_Normal(char *id, af_Object *obj) {
+size_t getSize_Normal(const std::string &id, af_Object *obj) {
     return sizeof(af_VarList *);
 }
 
-void initData_Normal(char *id, af_Object *obj, af_VarList **data, af_Environment *env) {
+void initData_Normal(const std::string &id, af_Object *obj, af_VarList **data, af_Environment *env) {
     *data = pushProtectVarList(nullptr, env);
     printf("initData_Normal(): VarSpace %p\n", *data);
 }
 
-void freeData_Normal(char *id, af_Object *obj, af_VarList **data, af_Environment *env) {
+void freeData_Normal(const std::string &id, af_Object *obj, af_VarList **data, af_Environment *env) {
     printf("freeData_Normal(): vsl = %p\n", *data);
     freeAllVarSpaceList(*data);
 }
 
-void literalSet_Data(char *id, af_Object *obj, void *data, char *str, af_Environment *env) {
+void literalSet_Data(const std::string &id, af_Object *obj, void *data, char *str, af_Environment *env) {
     printf("literalSet_Data(): str = %s\n", str);
 }
 
@@ -55,7 +55,7 @@ af_FuncBody *testFunc_Normal(af_CallFuncInfo *cfi, af_Environment *env) {  // 
     return nullptr;
 }
 
-bool getInfo_Normal(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
+bool getInfo_Normal(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, false, true, true);
     makeCodeFuncBodyToFuncInfo(makeElementCode("test", NUL, 0, "Unknown"), true, nullptr, *fi);
 
@@ -65,29 +65,29 @@ bool getInfo_Normal(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, v
     return true;
 }
 
-bool getAcl_Normal(char *id, af_Object *obj, af_ArgCodeList **acl, af_Code *code, int **mark, af_Environment *env) {
+bool getAcl_Normal(const std::string &id, af_Object *obj, af_ArgCodeList **acl, af_Code *code, int **mark, af_Environment *env) {
     *acl = makeArgCodeList(makeElementCode("object", NUL, 0, "Unknown"), 0, true, false);
     *mark = calloc(1, int);
     **mark = 100;
     return true;
 }
 
-bool getVsl_Normal(char *id, af_Object *obj, af_VarList **vsl, void *mark, af_Environment *env) {
+bool getVsl_Normal(const std::string &id, af_Object *obj, af_VarList **vsl, void *mark, af_Environment *env) {
     *vsl = *(af_VarList **)getObjectData(obj);
     return true;
 }
 
-af_GcList *getGcList_Normal(char *id, af_Object *obj, void *data) {
+af_GcList *getGcList_Normal(const std::string &id, af_Object *obj, void *data) {
     af_GcList *gl = pushGcList(glt_vsl, *(af_VarList **)data, nullptr);
     return gl;
 }
 
-bool getAl_Normal(char *id, af_Object *obj, af_ArgList **al, af_ArgCodeList *acl, void *mark, af_Environment *env) {
+bool getAl_Normal(const std::string &id, af_Object *obj, af_ArgList **al, af_ArgCodeList *acl, void *mark, af_Environment *env) {
     *al = makeArgListFromArgCodeList("test",acl, env);
     return true;
 }
 
-void freeMark_Normal(char *id, af_Object *obj, int *mark) {
+void freeMark_Normal(const std::string &id, af_Object *obj, int *mark) {
     printf("freeMark_Normal(): mark = %d\n", *mark);
     free(mark);
 }
@@ -142,7 +142,7 @@ af_FuncBody *testFuncMacro(af_CallFuncInfo *cfi, af_Environment *env) {  // 测
     return nullptr;
 }
 
-bool getInfo_Macro(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
+bool getInfo_Macro(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, true, true, true);
     makeCodeFuncBodyToFuncInfo(makeElementCode("test", NUL, 0, "Unknown"), true, nullptr, *fi);
     DLC_SYMBOL(callFuncBody) func = MAKE_SYMBOL(testFuncMacro, callFuncBody);
@@ -151,7 +151,7 @@ bool getInfo_Macro(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, vo
     return true;
 }
 
-bool getInfo_Tail(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
+bool getInfo_Tail(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, false, true, true);
     makeCodeFuncBodyToFuncInfo(makeElementCode("data3", NUL, 0, "Unknown"), true, nullptr, *fi);
     return true;
@@ -174,7 +174,7 @@ af_FuncBody *testFunc_Obj(af_CallFuncInfo *cfi, af_Environment *env) {  // 测
     return nullptr;
 }
 
-bool getInfo_Obj(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
+bool getInfo_Obj(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, false, true, true);
     DLC_SYMBOL(callFuncBody) func = MAKE_SYMBOL(testFunc_Obj, callFuncBody);
     makeCFuncBodyToFuncInfo(func, nullptr, *fi);
@@ -182,24 +182,24 @@ bool getInfo_Obj(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void
     return true;
 }
 
-bool isObjTrue(char *id, af_Object *obj) {
+bool isObjTrue(const std::string &id, af_Object *obj) {
     return true;
 }
 
-size_t getSize3(char *id, af_Object *obj) {
+size_t getSize3(const std::string &id, af_Object *obj) {
     return sizeof(af_VarSpace *);
 }
 
-void initData3(char *id, af_Object *obj, af_VarSpace **data, af_Environment *env) {
+void initData3(const std::string &id, af_Object *obj, af_VarSpace **data, af_Environment *env) {
     *data = makeVarSpace(obj, 3, 2, 0, env);
     gc_delVarSpaceReference(*data, env);
 }
 
-void freeData3(char *id, af_Object *obj, af_VarSpace **data, af_Environment *env) {
+void freeData3(const std::string &id, af_Object *obj, af_VarSpace **data, af_Environment *env) {
     printf("freeData(): *data = %p\n", *data);
 }
 
-af_GcList *getGcList3(char *id, af_Object *obj, void *data) {
+af_GcList *getGcList3(const std::string &id, af_Object *obj, void *data) {
     af_GcList *gl = pushGcList(glt_vs, *(af_VarSpace **)data, nullptr);
     return gl;
 }
@@ -218,7 +218,7 @@ af_FuncBody *testFunc_Dynamic(af_CallFuncInfo *cfi, af_Environment *env) {  // 
     return fb;
 }
 
-bool getInfo_Dynamic(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
+bool getInfo_Dynamic(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, false, true, true);
     DLC_SYMBOL(callFuncBody) func1 = MAKE_SYMBOL(testFunc_Dynamic, callFuncBody);
     makeCFuncBodyToFuncInfo(func1, nullptr, *fi);
@@ -246,7 +246,7 @@ af_FuncBody *testFunc_GcDestruct_c(af_CallFuncInfo *cfi, af_Environment *env) {
     return nullptr;
 }
 
-bool getInfo_GcDestruct_2(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
+bool getInfo_GcDestruct_2(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, false, true, true);
     DLC_SYMBOL(callFuncBody) func = MAKE_SYMBOL(testFunc_GcDestruct_c, callFuncBody);
     makeCFuncBodyToFuncInfo(func, nullptr, *fi);
@@ -295,7 +295,7 @@ af_FuncBody *testFunc_GcDestruct_a(af_CallFuncInfo *cfi, af_Environment *env) {
     return nullptr;
 }
 
-bool getInfo_GcDestruct(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
+bool getInfo_GcDestruct(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, false, true, true);
     DLC_SYMBOL(callFuncBody) func1 = MAKE_SYMBOL(testFunc_GcDestruct_a, callFuncBody);
     makeCFuncBodyToFuncInfo(func1, nullptr, *fi);
@@ -349,7 +349,7 @@ af_FuncBody *testFunc_Gc(af_CallFuncInfo *cfi, af_Environment *env) {  // 测试
     return nullptr;
 }
 
-bool getInfo_Gc(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
+bool getInfo_Gc(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, false, true, true);
     DLC_SYMBOL(callFuncBody) func = MAKE_SYMBOL(testFunc_Gc, callFuncBody);
     makeCFuncBodyToFuncInfo(func, nullptr, *fi);
@@ -358,19 +358,19 @@ bool getInfo_Gc(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void
     return true;
 }
 
-bool getInfo_NotVar(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
+bool getInfo_NotVar(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, true, true, true);
     makeCodeFuncBodyToFuncInfo(makeElementCode("no-var", NUL, 1, "func9.info.aun"), true, nullptr, *fi);
     return true;
 }
 
-bool getInfo_Import(char *id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
+bool getInfo_Import(const std::string &id, af_Object *obj, af_FuncInfo **fi, af_Code *code, void *mark, af_Environment *env) {
     *fi = makeFuncInfo(normal_scope, not_embedded, false, true, true);
     makeImportFuncBodyToFuncInfo(makeElementCode("global", NUL, 1, "func9.info.aun"), true, nullptr, *fi);
     return true;
 }
 
-bool isInfixTrue(char *id, af_Object *obj) {
+bool isInfixTrue(const std::string &id, af_Object *obj) {
     return true;
 }