gc.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef AFUN_GC
  2. #define AFUN_GC
  3. #include "aFunCoreExport.h"
  4. #include "object.h"
  5. #include "var.h"
  6. typedef struct af_GcList af_GcList;
  7. typedef struct gc_DestructList gc_DestructList;
  8. enum af_GcListType {
  9. glt_obj = 1,
  10. glt_vs,
  11. glt_var,
  12. glt_vsl,
  13. };
  14. /* gc 引用计数管理函数 */
  15. #define gc_addReference(obj) ((_Generic((obj), \
  16. af_Object *:gc_addObjectReference, \
  17. af_Var *: gc_addVarReference, \
  18. af_VarSpace *: gc_addVarSpaceReference))(obj))
  19. #define gc_delReference(obj) ((_Generic((obj), \
  20. af_Object *: gc_delObjectReference, \
  21. af_Var *: gc_delVarReference, \
  22. af_VarSpace *: gc_delVarSpaceReference))(obj))
  23. /* gc_DestructList 释放函数*/
  24. AFUN_CORE_EXPORT void freeAllDestructList(gc_DestructList *dl);
  25. /* GcList 操作函数 */
  26. AFUN_CORE_EXPORT af_GcList *pushGcList(enum af_GcListType type, void *data, af_GcList *base);
  27. /* gc 对象新增函数 */
  28. AFUN_CORE_EXPORT void gc_addObject(af_Object *obj, af_Environment *env);
  29. AFUN_CORE_EXPORT void gc_addVar(af_Var *obj, af_Environment *env);
  30. AFUN_CORE_EXPORT void gc_addVarSpace(af_VarSpace *obj, af_Environment *env);
  31. /* gc Reference 管理函数 */
  32. AFUN_CORE_EXPORT void gc_addObjectReference(af_Object *obj);
  33. AFUN_CORE_EXPORT void gc_addVarReference(af_Var *obj);
  34. AFUN_CORE_EXPORT void gc_addVarSpaceReference(af_VarSpace *obj);
  35. AFUN_CORE_EXPORT void gc_delObjectReference(af_Object *obj);
  36. AFUN_CORE_EXPORT void gc_delVarReference(af_Var *obj);
  37. AFUN_CORE_EXPORT void gc_delVarSpaceReference(af_VarSpace *obj);
  38. /* gc 运行时函数 */
  39. AFUN_CORE_EXPORT void resetGC(af_Environment *env);
  40. #endif //AFUN_GC