🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

296 lines
6.9 KiB

2 years ago
  1. /****************************************************************************
  2. *
  3. * ftlist.h
  4. *
  5. * Generic list support for FreeType (specification).
  6. *
  7. * Copyright (C) 1996-2022 by
  8. * David Turner, Robert Wilhelm, and Werner Lemberg.
  9. *
  10. * This file is part of the FreeType project, and may only be used,
  11. * modified, and distributed under the terms of the FreeType project
  12. * license, LICENSE.TXT. By continuing to use, modify, or distribute
  13. * this file you indicate that you have read the license and
  14. * understand and accept it fully.
  15. *
  16. */
  17. /**************************************************************************
  18. *
  19. * This file implements functions relative to list processing. Its data
  20. * structures are defined in `freetype.h`.
  21. *
  22. */
  23. #ifndef FTLIST_H_
  24. #define FTLIST_H_
  25. #include <freetype/freetype.h>
  26. #ifdef FREETYPE_H
  27. #error "freetype.h of FreeType 1 has been loaded!"
  28. #error "Please fix the directory search order for header files"
  29. #error "so that freetype.h of FreeType 2 is found first."
  30. #endif
  31. FT_BEGIN_HEADER
  32. /**************************************************************************
  33. *
  34. * @section:
  35. * list_processing
  36. *
  37. * @title:
  38. * List Processing
  39. *
  40. * @abstract:
  41. * Simple management of lists.
  42. *
  43. * @description:
  44. * This section contains various definitions related to list processing
  45. * using doubly-linked nodes.
  46. *
  47. * @order:
  48. * FT_List
  49. * FT_ListNode
  50. * FT_ListRec
  51. * FT_ListNodeRec
  52. *
  53. * FT_List_Add
  54. * FT_List_Insert
  55. * FT_List_Find
  56. * FT_List_Remove
  57. * FT_List_Up
  58. * FT_List_Iterate
  59. * FT_List_Iterator
  60. * FT_List_Finalize
  61. * FT_List_Destructor
  62. *
  63. */
  64. /**************************************************************************
  65. *
  66. * @function:
  67. * FT_List_Find
  68. *
  69. * @description:
  70. * Find the list node for a given listed object.
  71. *
  72. * @input:
  73. * list ::
  74. * A pointer to the parent list.
  75. * data ::
  76. * The address of the listed object.
  77. *
  78. * @return:
  79. * List node. `NULL` if it wasn't found.
  80. */
  81. FT_EXPORT( FT_ListNode )
  82. FT_List_Find( FT_List list,
  83. void* data );
  84. /**************************************************************************
  85. *
  86. * @function:
  87. * FT_List_Add
  88. *
  89. * @description:
  90. * Append an element to the end of a list.
  91. *
  92. * @inout:
  93. * list ::
  94. * A pointer to the parent list.
  95. * node ::
  96. * The node to append.
  97. */
  98. FT_EXPORT( void )
  99. FT_List_Add( FT_List list,
  100. FT_ListNode node );
  101. /**************************************************************************
  102. *
  103. * @function:
  104. * FT_List_Insert
  105. *
  106. * @description:
  107. * Insert an element at the head of a list.
  108. *
  109. * @inout:
  110. * list ::
  111. * A pointer to parent list.
  112. * node ::
  113. * The node to insert.
  114. */
  115. FT_EXPORT( void )
  116. FT_List_Insert( FT_List list,
  117. FT_ListNode node );
  118. /**************************************************************************
  119. *
  120. * @function:
  121. * FT_List_Remove
  122. *
  123. * @description:
  124. * Remove a node from a list. This function doesn't check whether the
  125. * node is in the list!
  126. *
  127. * @input:
  128. * node ::
  129. * The node to remove.
  130. *
  131. * @inout:
  132. * list ::
  133. * A pointer to the parent list.
  134. */
  135. FT_EXPORT( void )
  136. FT_List_Remove( FT_List list,
  137. FT_ListNode node );
  138. /**************************************************************************
  139. *
  140. * @function:
  141. * FT_List_Up
  142. *
  143. * @description:
  144. * Move a node to the head/top of a list. Used to maintain LRU lists.
  145. *
  146. * @inout:
  147. * list ::
  148. * A pointer to the parent list.
  149. * node ::
  150. * The node to move.
  151. */
  152. FT_EXPORT( void )
  153. FT_List_Up( FT_List list,
  154. FT_ListNode node );
  155. /**************************************************************************
  156. *
  157. * @functype:
  158. * FT_List_Iterator
  159. *
  160. * @description:
  161. * An FT_List iterator function that is called during a list parse by
  162. * @FT_List_Iterate.
  163. *
  164. * @input:
  165. * node ::
  166. * The current iteration list node.
  167. *
  168. * user ::
  169. * A typeless pointer passed to @FT_List_Iterate. Can be used to point
  170. * to the iteration's state.
  171. */
  172. typedef FT_Error
  173. (*FT_List_Iterator)( FT_ListNode node,
  174. void* user );
  175. /**************************************************************************
  176. *
  177. * @function:
  178. * FT_List_Iterate
  179. *
  180. * @description:
  181. * Parse a list and calls a given iterator function on each element.
  182. * Note that parsing is stopped as soon as one of the iterator calls
  183. * returns a non-zero value.
  184. *
  185. * @input:
  186. * list ::
  187. * A handle to the list.
  188. * iterator ::
  189. * An iterator function, called on each node of the list.
  190. * user ::
  191. * A user-supplied field that is passed as the second argument to the
  192. * iterator.
  193. *
  194. * @return:
  195. * The result (a FreeType error code) of the last iterator call.
  196. */
  197. FT_EXPORT( FT_Error )
  198. FT_List_Iterate( FT_List list,
  199. FT_List_Iterator iterator,
  200. void* user );
  201. /**************************************************************************
  202. *
  203. * @functype:
  204. * FT_List_Destructor
  205. *
  206. * @description:
  207. * An @FT_List iterator function that is called during a list
  208. * finalization by @FT_List_Finalize to destroy all elements in a given
  209. * list.
  210. *
  211. * @input:
  212. * system ::
  213. * The current system object.
  214. *
  215. * data ::
  216. * The current object to destroy.
  217. *
  218. * user ::
  219. * A typeless pointer passed to @FT_List_Iterate. It can be used to
  220. * point to the iteration's state.
  221. */
  222. typedef void
  223. (*FT_List_Destructor)( FT_Memory memory,
  224. void* data,
  225. void* user );
  226. /**************************************************************************
  227. *
  228. * @function:
  229. * FT_List_Finalize
  230. *
  231. * @description:
  232. * Destroy all elements in the list as well as the list itself.
  233. *
  234. * @input:
  235. * list ::
  236. * A handle to the list.
  237. *
  238. * destroy ::
  239. * A list destructor that will be applied to each element of the list.
  240. * Set this to `NULL` if not needed.
  241. *
  242. * memory ::
  243. * The current memory object that handles deallocation.
  244. *
  245. * user ::
  246. * A user-supplied field that is passed as the last argument to the
  247. * destructor.
  248. *
  249. * @note:
  250. * This function expects that all nodes added by @FT_List_Add or
  251. * @FT_List_Insert have been dynamically allocated.
  252. */
  253. FT_EXPORT( void )
  254. FT_List_Finalize( FT_List list,
  255. FT_List_Destructor destroy,
  256. FT_Memory memory,
  257. void* user );
  258. /* */
  259. FT_END_HEADER
  260. #endif /* FTLIST_H_ */
  261. /* END */