runtime.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef AFUN_RUNTIME_H
  2. #define AFUN_RUNTIME_H
  3. typedef struct APIFunc APIFunc;
  4. struct APIFunc {
  5. char *name;
  6. void *func; // objectAPIFunc
  7. DlcHandle *dlc; // func 的 来源
  8. DLC_SYMBOL(objectAPIFunc) func_; // func_和func二选一, func_时dlc无效
  9. bool free_func_; // func_是否需要释放
  10. };
  11. typedef struct InheritDefine InheritDefine;
  12. struct InheritDefine {
  13. af_Object *obj;
  14. };
  15. typedef struct ObjectDefine ObjectDefine;
  16. struct ObjectDefine {
  17. char *id;
  18. bool free_api;
  19. af_ObjectAPI *api;
  20. struct APIFunc *api_list; // api和api_list只能二选一
  21. bool allow_inherit;
  22. af_Object *belong;
  23. af_Inherit *inherit;
  24. char *var_name;
  25. char p_self, p_posterity, p_external;
  26. af_Object **save; // obj保存位置
  27. };
  28. typedef struct LiteralFunc LiteralFunc;
  29. struct LiteralFunc {
  30. char *pattern;
  31. char *func;
  32. bool in_protect;
  33. };
  34. typedef struct TopMsgFunc TopMsgFunc;
  35. struct TopMsgFunc {
  36. char *type;
  37. TopMsgProcessFunc *func;
  38. DlcHandle *dlc; // func 的 来源
  39. DLC_SYMBOL(TopMsgProcessFunc) func_; // func_和func二选一, func_时dlc无效
  40. bool free_func_; // func_是否需要释放
  41. };
  42. AFUN_LANG_EXPORT int runtimeTool(char *name, af_Code **code, af_Object *visitor, af_VarSpace *vs, af_Environment *env);
  43. AFUN_LANG_EXPORT int runtimeToolImport(char *name, af_Object **obj, af_Code **code, af_Environment *env);
  44. AFUN_LANG_EXPORT af_ObjectAPI *makeAPIFromList(const APIFunc api_list[]);
  45. AFUN_LANG_EXPORT void makeObjectFromList(const ObjectDefine obj_def[], af_Object *visitor, af_VarSpace *vs, af_Environment *env);
  46. AFUN_LANG_EXPORT void makeLiteralRegexFromList(const LiteralFunc literal_list[], af_Environment *env);
  47. AFUN_LANG_EXPORT void makeTopMsgProcessFromList(const TopMsgFunc top_msg_list[], af_Environment *env);
  48. AFUN_LANG_EXPORT af_Inherit *makeInheritFromList(const InheritDefine inherit_list[], bool is_reverse);
  49. #endif //AFUN_RUNTIME_H