|
@@ -48,9 +48,17 @@ af_ObjectAPI *makeAPIFromList(const APIFunc api_list[]) {
|
|
|
af_ObjectAPI *api = makeObjectAPI();
|
|
|
|
|
|
for (const APIFunc *af = api_list; af->name != NULL; af++) {
|
|
|
- DLC_SYMBOL(objectAPIFunc) func = MAKE_SYMBOL(af->func, objectAPIFunc);
|
|
|
- addAPI(func, af->name, api);
|
|
|
- FREE_SYMBOL(func);
|
|
|
+ if (af->func != NULL) {
|
|
|
+ DLC_SYMBOL(objectAPIFunc) func = MAKE_SYMBOL_FROM_HANDLE(af->func, af->dlc, objectAPIFunc);
|
|
|
+ addAPI(func, af->name, api);
|
|
|
+ FREE_SYMBOL(func);
|
|
|
+ continue;
|
|
|
+ } else if (af->func_ == NULL)
|
|
|
+ continue; // 遇到错误
|
|
|
+
|
|
|
+ addAPI(af->func_, af->name, api);
|
|
|
+ if (af->free_func_)
|
|
|
+ FREE_SYMBOL(af->func_);
|
|
|
}
|
|
|
|
|
|
return api;
|
|
@@ -91,8 +99,66 @@ void makeLiteralRegexFromList(const LiteralFunc literal_list[], af_Environment *
|
|
|
*/
|
|
|
void makeTopMsgProcessFromList(const TopMsgFunc top_msg_list[], af_Environment *env) {
|
|
|
for (const TopMsgFunc *tml = top_msg_list; tml->type != NULL; tml++) {
|
|
|
- DLC_SYMBOL(TopMsgProcessFunc) func = MAKE_SYMBOL(tml->func, TopMsgProcessFunc);
|
|
|
- addTopMsgProcess(tml->type, func, env);
|
|
|
- FREE_SYMBOL(func);
|
|
|
+ if (tml->func != NULL) {
|
|
|
+ DLC_SYMBOL(TopMsgProcessFunc) func = MAKE_SYMBOL(tml->func, TopMsgProcessFunc);
|
|
|
+ addTopMsgProcess(tml->type, func, env);
|
|
|
+ FREE_SYMBOL(func);
|
|
|
+ continue;
|
|
|
+ } else if (tml->func_ == NULL)
|
|
|
+ continue; // 遇到错误
|
|
|
+
|
|
|
+ addTopMsgProcess(tml->type, tml->func_, env);
|
|
|
+ if (tml->free_func_)
|
|
|
+ FREE_SYMBOL(tml->func_);
|
|
|
}
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * 函数名: makeInheritFromListReverse
|
|
|
+ * 目标: 以InheritDefine的顺序反向压入Inherit
|
|
|
+ * 注意: pushInherit是反向压入, 因此InheritDefine得正向读取, 最后Inherit反向压入
|
|
|
+ */
|
|
|
+static af_Inherit *makeInheritFromListReverse(const InheritDefine inherit_list[]) {
|
|
|
+ af_Inherit *inherit = NULL;
|
|
|
+ af_Inherit **pinherit = &inherit;
|
|
|
+ for (const InheritDefine *ind = inherit_list; ind->obj != NULL; ind++) {
|
|
|
+ af_Inherit *ih = makeInherit(ind->obj);
|
|
|
+ pinherit = pushInherit(pinherit, ih);
|
|
|
+ }
|
|
|
+
|
|
|
+ return inherit;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * 函数名: makeInheritFromListForward
|
|
|
+ * 目标: 以InheritDefine的顺序压入Inherit
|
|
|
+ * 注意: pushInherit是反向压入, 因此InheritDefine也得反向读取, 最后Inherit正向压入
|
|
|
+ */
|
|
|
+static af_Inherit *makeInheritFromListForward(const InheritDefine inherit_list[]) {
|
|
|
+ af_Inherit *inherit = NULL;
|
|
|
+ af_Inherit **pinherit = &inherit;
|
|
|
+ const InheritDefine *ind = inherit_list;
|
|
|
+
|
|
|
+ /* 找到最后一个元素 */
|
|
|
+ while (ind->obj != NULL)
|
|
|
+ ind++;
|
|
|
+ ind--; // 最后一个元素的前一个元素为最后一个有效元素
|
|
|
+
|
|
|
+ for (NULL; ind != inherit_list; ind++) {
|
|
|
+ af_Inherit *ih = makeInherit(ind->obj);
|
|
|
+ pinherit = pushInherit(pinherit, ih);
|
|
|
+ }
|
|
|
+
|
|
|
+ return inherit;
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * 函数名: makeInheritFromList
|
|
|
+ * 目标: 根据InheritDefine生成新的Inherit
|
|
|
+ */
|
|
|
+af_Inherit *makeInheritFromList(const InheritDefine inherit_list[], bool is_reverse) {
|
|
|
+ if (is_reverse)
|
|
|
+ return makeInheritFromListReverse(inherit_list);
|
|
|
+ else
|
|
|
+ return makeInheritFromListForward(inherit_list);
|
|
|
+}
|