/src/wrappers/glib/library/utilities/glib_hook_functions.e

http://github.com/tybor/Liberty · Specman e · 685 lines · 2 code · 218 blank · 465 comment · 0 complexity · 759d3dbdd49b0a6650ee87eeddac5102 MD5 · raw file

  1. deferred class GLIB_HOOK_FUNCTIONS
  2. -- Hook Functions
  3. -- Hook Functions -- support for manipulating lists of hook functions.
  4. -- Synopsis
  5. -- #include <glib.h>
  6. -- GHookList;
  7. -- void (*GHookFinalizeFunc) (GHookList *hook_list,
  8. -- GHook *hook);
  9. -- GHook;
  10. -- void (*GHookFunc) (gpointer data);
  11. -- gboolean (*GHookCheckFunc) (gpointer data);
  12. -- void g_hook_list_init (GHookList *hook_list,
  13. -- guint hook_size);
  14. -- void g_hook_list_invoke (GHookList *hook_list,
  15. -- gboolean may_recurse);
  16. -- void g_hook_list_invoke_check (GHookList *hook_list,
  17. -- gboolean may_recurse);
  18. -- void g_hook_list_marshal (GHookList *hook_list,
  19. -- gboolean may_recurse,
  20. -- GHookMarshaller marshaller,
  21. -- gpointer marshal_data);
  22. -- void (*GHookMarshaller) (GHook *hook,
  23. -- gpointer marshal_data);
  24. -- void g_hook_list_marshal_check (GHookList *hook_list,
  25. -- gboolean may_recurse,
  26. -- GHookCheckMarshaller marshaller,
  27. -- gpointer marshal_data);
  28. -- gboolean (*GHookCheckMarshaller) (GHook *hook,
  29. -- gpointer marshal_data);
  30. -- void g_hook_list_clear (GHookList *hook_list);
  31. -- GHook* g_hook_alloc (GHookList *hook_list);
  32. -- #define g_hook_append ( hook_list, hook )
  33. -- void g_hook_prepend (GHookList *hook_list,
  34. -- GHook *hook);
  35. -- void g_hook_insert_before (GHookList *hook_list,
  36. -- GHook *sibling,
  37. -- GHook *hook);
  38. -- void g_hook_insert_sorted (GHookList *hook_list,
  39. -- GHook *hook,
  40. -- GHookCompareFunc func);
  41. -- gint (*GHookCompareFunc) (GHook *new_hook,
  42. -- GHook *sibling);
  43. -- gint g_hook_compare_ids (GHook *new_hook,
  44. -- GHook *sibling);
  45. -- GHook* g_hook_get (GHookList *hook_list,
  46. -- gulong hook_id);
  47. -- GHook* g_hook_find (GHookList *hook_list,
  48. -- gboolean need_valids,
  49. -- GHookFindFunc func,
  50. -- gpointer data);
  51. -- gboolean (*GHookFindFunc) (GHook *hook,
  52. -- gpointer data);
  53. -- GHook* g_hook_find_data (GHookList *hook_list,
  54. -- gboolean need_valids,
  55. -- gpointer data);
  56. -- GHook* g_hook_find_func (GHookList *hook_list,
  57. -- gboolean need_valids,
  58. -- gpointer func);
  59. -- GHook* g_hook_find_func_data (GHookList *hook_list,
  60. -- gboolean need_valids,
  61. -- gpointer func,
  62. -- gpointer data);
  63. -- GHook* g_hook_first_valid (GHookList *hook_list,
  64. -- gboolean may_be_in_call);
  65. -- GHook* g_hook_next_valid (GHookList *hook_list,
  66. -- GHook *hook,
  67. -- gboolean may_be_in_call);
  68. -- enum GHookFlagMask;
  69. -- #define G_HOOK_FLAGS (hook)
  70. -- #define G_HOOK_FLAG_USER_SHIFT
  71. -- #define G_HOOK (hook)
  72. -- #define G_HOOK_IS_VALID (hook)
  73. -- #define G_HOOK_ACTIVE (hook)
  74. -- #define G_HOOK_IN_CALL (hook)
  75. -- #define G_HOOK_IS_UNLINKED (hook)
  76. -- GHook* g_hook_ref (GHookList *hook_list,
  77. -- GHook *hook);
  78. -- void g_hook_unref (GHookList *hook_list,
  79. -- GHook *hook);
  80. -- void g_hook_free (GHookList *hook_list,
  81. -- GHook *hook);
  82. -- gboolean g_hook_destroy (GHookList *hook_list,
  83. -- gulong hook_id);
  84. -- void g_hook_destroy_link (GHookList *hook_list,
  85. -- GHook *hook);
  86. -- Description
  87. -- The GHookList, GHook and their related functions provide support for lists of
  88. -- hook functions. Functions can be added and removed from the lists, and the list
  89. -- of hook functions can be invoked.
  90. -- Details
  91. -- GHookList
  92. -- typedef struct {
  93. -- gulong seq_id;
  94. -- guint hook_size : 16;
  95. -- guint is_setup : 1;
  96. -- GHook *hooks;
  97. -- gpointer dummy3;
  98. -- GHookFinalizeFunc finalize_hook;
  99. -- gpointer dummy[2];
  100. -- } GHookList;
  101. -- The GHookList struct represents a list of hook functions.
  102. -- gulong seq_id; the next free GHook id.
  103. -- guint hook_size : 16; the size of the GHookList elements, in bytes.
  104. -- guint is_setup : 1; 1 if the GHookList has been initialized.
  105. -- GHook *hooks; the first GHook element in the list.
  106. -- gpointer dummy3;
  107. -- GHookFinalizeFunc finalize_hook; the function to call to finalize a GHook
  108. -- element. The default behaviour is to call the
  109. -- hooks destroy function.
  110. -- gpointer dummy[2];
  111. -- ---------------------------------------------------------------------------------
  112. -- GHookFinalizeFunc ()
  113. -- void (*GHookFinalizeFunc) (GHookList *hook_list,
  114. -- GHook *hook);
  115. -- Defines the type of function to be called when a hook in a list of hooks gets
  116. -- finalized.
  117. -- hook_list : a GHookList.
  118. -- hook : the hook in hook_list that gets finalized.
  119. -- ---------------------------------------------------------------------------------
  120. -- GHook
  121. -- typedef struct {
  122. -- gpointer data;
  123. -- GHook *next;
  124. -- GHook *prev;
  125. -- guint ref_count;
  126. -- gulong hook_id;
  127. -- guint flags;
  128. -- gpointer func;
  129. -- GDestroyNotify destroy;
  130. -- } GHook;
  131. -- The GHook struct represents a single hook function in a GHookList.
  132. -- gpointer data; data which is passed to func when this hook is invoked.
  133. -- GHook *next; pointer to the next hook in the list.
  134. -- GHook *prev; pointer to the previous hook in the list.
  135. -- guint ref_count; the reference count of this hook.
  136. -- gulong hook_id; the id of this hook, which is unique within its list.
  137. -- guint flags; flags which are set for this hook. See GHookFlagMask for
  138. -- predefined flags.
  139. -- gpointer func; the function to call when this hook is invoked. The
  140. -- possible signatures for this function are GHookFunc and
  141. -- GHookCheckFunc.
  142. -- GDestroyNotify destroy; the default finalize_hook function of a GHookList calls
  143. -- this member of the hook that is being finalized.
  144. -- ---------------------------------------------------------------------------------
  145. -- GHookFunc ()
  146. -- void (*GHookFunc) (gpointer data);
  147. -- Defines the type of a hook function that can be invoked by g_hook_list_invoke().
  148. -- data : the data field of the GHook is passed to the hook function here.
  149. -- ---------------------------------------------------------------------------------
  150. -- GHookCheckFunc ()
  151. -- gboolean (*GHookCheckFunc) (gpointer data);
  152. -- Defines the type of a hook function that can be invoked by
  153. -- g_hook_list_invoke_check().
  154. -- data : the data field of the GHook is passed to the hook function here.
  155. -- Returns : FALSE if the GHook should be destroyed.
  156. -- ---------------------------------------------------------------------------------
  157. -- g_hook_list_init ()
  158. -- void g_hook_list_init (GHookList *hook_list,
  159. -- guint hook_size);
  160. -- Initializes a GHookList. This must be called before the GHookList is used.
  161. -- hook_list : a GHookList.
  162. -- hook_size : the size of each element in the GHookList, typically sizeof (GHook).
  163. -- ---------------------------------------------------------------------------------
  164. -- g_hook_list_invoke ()
  165. -- void g_hook_list_invoke (GHookList *hook_list,
  166. -- gboolean may_recurse);
  167. -- Calls all of the GHook functions in a GHookList.
  168. -- hook_list : a GHookList.
  169. -- may_recurse : TRUE if functions which are already running (e.g. in another
  170. -- thread) can be called. If set to FALSE, these are skipped.
  171. -- ---------------------------------------------------------------------------------
  172. -- g_hook_list_invoke_check ()
  173. -- void g_hook_list_invoke_check (GHookList *hook_list,
  174. -- gboolean may_recurse);
  175. -- Calls all of the GHook functions in a GHookList. Any function which returns TRUE
  176. -- is removed from the GHookList.
  177. -- hook_list : a GHookList.
  178. -- may_recurse : TRUE if functions which are already running (e.g. in another
  179. -- thread) can be called. If set to FALSE, these are skipped.
  180. -- ---------------------------------------------------------------------------------
  181. -- g_hook_list_marshal ()
  182. -- void g_hook_list_marshal (GHookList *hook_list,
  183. -- gboolean may_recurse,
  184. -- GHookMarshaller marshaller,
  185. -- gpointer marshal_data);
  186. -- Calls a function on each valid GHook.
  187. -- hook_list : a GHookList.
  188. -- may_recurse : TRUE if hooks which are currently running (e.g. in another thread)
  189. -- are considered valid. If set to FALSE, these are skipped.
  190. -- marshaller : the function to call for each GHook.
  191. -- marshal_data : data to pass to marshaller.
  192. -- ---------------------------------------------------------------------------------
  193. -- GHookMarshaller ()
  194. -- void (*GHookMarshaller) (GHook *hook,
  195. -- gpointer marshal_data);
  196. -- Defines the type of function used by g_hook_list_marshal().
  197. -- hook : a GHook.
  198. -- marshal_data : user data.
  199. -- ---------------------------------------------------------------------------------
  200. -- g_hook_list_marshal_check ()
  201. -- void g_hook_list_marshal_check (GHookList *hook_list,
  202. -- gboolean may_recurse,
  203. -- GHookCheckMarshaller marshaller,
  204. -- gpointer marshal_data);
  205. -- Calls a function on each valid GHook and destroys it if the function returns
  206. -- FALSE.
  207. -- hook_list : a GHookList.
  208. -- may_recurse : TRUE if hooks which are currently running (e.g. in another thread)
  209. -- are considered valid. If set to FALSE, these are skipped.
  210. -- marshaller : the function to call for each GHook.
  211. -- marshal_data : data to pass to marshaller.
  212. -- ---------------------------------------------------------------------------------
  213. -- GHookCheckMarshaller ()
  214. -- gboolean (*GHookCheckMarshaller) (GHook *hook,
  215. -- gpointer marshal_data);
  216. -- Defines the type of function used by g_hook_list_marshal_check().
  217. -- hook : a GHook.
  218. -- marshal_data : user data.
  219. -- Returns : FALSE if hook should be destroyed.
  220. -- ---------------------------------------------------------------------------------
  221. -- g_hook_list_clear ()
  222. -- void g_hook_list_clear (GHookList *hook_list);
  223. -- Removes all the GHook elements from a GHookList.
  224. -- hook_list : a GHookList.
  225. -- ---------------------------------------------------------------------------------
  226. -- g_hook_alloc ()
  227. -- GHook* g_hook_alloc (GHookList *hook_list);
  228. -- Allocates space for a GHook and initializes it.
  229. -- hook_list : a GHookList.
  230. -- Returns : a new GHook.
  231. -- ---------------------------------------------------------------------------------
  232. -- g_hook_append()
  233. -- #define g_hook_append( hook_list, hook )
  234. -- Appends a GHook onto the end of a GHookList.
  235. -- hook_list : a GHookList.
  236. -- hook : the GHook to add to the end of hook_list.
  237. -- ---------------------------------------------------------------------------------
  238. -- g_hook_prepend ()
  239. -- void g_hook_prepend (GHookList *hook_list,
  240. -- GHook *hook);
  241. -- Prepends a GHook on the start of a GHookList.
  242. -- hook_list : a GHookList.
  243. -- hook : the GHook to add to the start of hook_list.
  244. -- ---------------------------------------------------------------------------------
  245. -- g_hook_insert_before ()
  246. -- void g_hook_insert_before (GHookList *hook_list,
  247. -- GHook *sibling,
  248. -- GHook *hook);
  249. -- Inserts a GHook into a GHookList, before a given GHook.
  250. -- hook_list : a GHookList.
  251. -- sibling : the GHook to insert the new GHook before.
  252. -- hook : the GHook to insert.
  253. -- ---------------------------------------------------------------------------------
  254. -- g_hook_insert_sorted ()
  255. -- void g_hook_insert_sorted (GHookList *hook_list,
  256. -- GHook *hook,
  257. -- GHookCompareFunc func);
  258. -- Inserts a GHook into a GHookList, sorted by the given function.
  259. -- hook_list : a GHookList.
  260. -- hook : the GHook to insert.
  261. -- func : the comparison function used to sort the GHook elements.
  262. -- ---------------------------------------------------------------------------------
  263. -- GHookCompareFunc ()
  264. -- gint (*GHookCompareFunc) (GHook *new_hook,
  265. -- GHook *sibling);
  266. -- Defines the type of function used to compare GHook elements in
  267. -- g_hook_insert_sorted().
  268. -- new_hook : the GHook being inserted.
  269. -- sibling : the GHook to compare with new_hook.
  270. -- Returns : a value <= 0 if new_hook should be before sibling.
  271. -- ---------------------------------------------------------------------------------
  272. -- g_hook_compare_ids ()
  273. -- gint g_hook_compare_ids (GHook *new_hook,
  274. -- GHook *sibling);
  275. -- Compares the ids of two GHook elements, returning a negative value if the second
  276. -- id is greater than the first.
  277. -- new_hook : a GHook.
  278. -- sibling : a GHook to compare with new_hook.
  279. -- Returns : a value <= 0 if the id of sibling is >= the id of new_hook.
  280. -- ---------------------------------------------------------------------------------
  281. -- g_hook_get ()
  282. -- GHook* g_hook_get (GHookList *hook_list,
  283. -- gulong hook_id);
  284. -- Returns the GHook with the given id, or NULL if it is not found.
  285. -- hook_list : a GHookList.
  286. -- hook_id : a hook id.
  287. -- Returns : the GHook with the given id, or NULL if it is not found.
  288. -- ---------------------------------------------------------------------------------
  289. -- g_hook_find ()
  290. -- GHook* g_hook_find (GHookList *hook_list,
  291. -- gboolean need_valids,
  292. -- GHookFindFunc func,
  293. -- gpointer data);
  294. -- Finds a GHook in a GHookList using the given function to test for a match.
  295. -- hook_list : a GHookList.
  296. -- need_valids : TRUE if GHook elements which have been destroyed should be skipped.
  297. -- func : the function to call for each GHook, which should return TRUE when
  298. -- the GHook has been found.
  299. -- data : the data to pass to func.
  300. -- Returns : the found GHook or NULL if no matching GHook is found.
  301. -- ---------------------------------------------------------------------------------
  302. -- GHookFindFunc ()
  303. -- gboolean (*GHookFindFunc) (GHook *hook,
  304. -- gpointer data);
  305. -- Defines the type of the function passed to g_hook_find().
  306. -- hook : a GHook.
  307. -- data : user data passed to g_hook_find_func().
  308. -- Returns : TRUE if the required GHook has been found.
  309. -- ---------------------------------------------------------------------------------
  310. -- g_hook_find_data ()
  311. -- GHook* g_hook_find_data (GHookList *hook_list,
  312. -- gboolean need_valids,
  313. -- gpointer data);
  314. -- Finds a GHook in a GHookList with the given data.
  315. -- hook_list : a GHookList.
  316. -- need_valids : TRUE if GHook elements which have been destroyed should be skipped.
  317. -- data : the data to find.
  318. -- Returns : the GHook with the given data or NULL if no matching GHook is
  319. -- found.
  320. -- ---------------------------------------------------------------------------------
  321. -- g_hook_find_func ()
  322. -- GHook* g_hook_find_func (GHookList *hook_list,
  323. -- gboolean need_valids,
  324. -- gpointer func);
  325. -- Finds a GHook in a GHookList with the given function.
  326. -- hook_list : a GHookList.
  327. -- need_valids : TRUE if GHook elements which have been destroyed should be skipped.
  328. -- func : the function to find.
  329. -- Returns : the GHook with the given func or NULL if no matching GHook is
  330. -- found.
  331. -- ---------------------------------------------------------------------------------
  332. -- g_hook_find_func_data ()
  333. -- GHook* g_hook_find_func_data (GHookList *hook_list,
  334. -- gboolean need_valids,
  335. -- gpointer func,
  336. -- gpointer data);
  337. -- Finds a GHook in a GHookList with the given function and data.
  338. -- hook_list : a GHookList.
  339. -- need_valids : TRUE if GHook elements which have been destroyed should be skipped.
  340. -- func : the function to find.
  341. -- data : the data to find.
  342. -- Returns : the GHook with the given func and data or NULL if no matching GHook
  343. -- is found.
  344. -- ---------------------------------------------------------------------------------
  345. -- g_hook_first_valid ()
  346. -- GHook* g_hook_first_valid (GHookList *hook_list,
  347. -- gboolean may_be_in_call);
  348. -- Returns the first GHook in a GHookList which has not been destroyed. The
  349. -- reference count for the GHook is incremented, so you must call g_hook_unref() to
  350. -- restore it when no longer needed. (Or call g_hook_next_valid() if you are
  351. -- stepping through the GHookList.)
  352. -- hook_list : a GHookList.
  353. -- may_be_in_call : TRUE if hooks which are currently running (e.g. in another
  354. -- thread) are considered valid. If set to FALSE, these are
  355. -- skipped.
  356. -- Returns : the first valid GHook, or NULL if none are valid.
  357. -- ---------------------------------------------------------------------------------
  358. -- g_hook_next_valid ()
  359. -- GHook* g_hook_next_valid (GHookList *hook_list,
  360. -- GHook *hook,
  361. -- gboolean may_be_in_call);
  362. -- Returns the next GHook in a GHookList which has not been destroyed. The reference
  363. -- count for the GHook is incremented, so you must call g_hook_unref() to restore it
  364. -- when no longer needed. (Or continue to call g_hook_next_valid() until NULL is
  365. -- returned.)
  366. -- hook_list : a GHookList.
  367. -- hook : the current GHook.
  368. -- may_be_in_call : TRUE if hooks which are currently running (e.g. in another
  369. -- thread) are considered valid. If set to FALSE, these are
  370. -- skipped.
  371. -- Returns : the next valid GHook, or NULL if none are valid.
  372. -- ---------------------------------------------------------------------------------
  373. -- enum GHookFlagMask
  374. -- typedef enum
  375. -- {
  376. -- G_HOOK_FLAG_ACTIVE = 1 << 0,
  377. -- G_HOOK_FLAG_IN_CALL = 1 << 1,
  378. -- G_HOOK_FLAG_MASK = 0x0f
  379. -- } GHookFlagMask;
  380. -- Flags used internally in the GHook implementation.
  381. -- G_HOOK_FLAG_ACTIVE set if the hook has not been destroyed.
  382. -- G_HOOK_FLAG_IN_CALL set if the hook is currently being run.
  383. -- G_HOOK_FLAG_MASK A mask covering all bits reserved for hook flags; see
  384. -- G_HOOK_FLAGS_USER_SHIFT
  385. -- ---------------------------------------------------------------------------------
  386. -- G_HOOK_FLAGS()
  387. -- #define G_HOOK_FLAGS(hook) (G_HOOK (hook)->flags)
  388. -- Returns the flags of a hook.
  389. -- hook : a GHook.
  390. -- ---------------------------------------------------------------------------------
  391. -- G_HOOK_FLAG_USER_SHIFT
  392. -- #define G_HOOK_FLAG_USER_SHIFT (4)
  393. -- The position of the first bit which is not reserved for internal use be the GHook
  394. -- implementation, i.e. 1 << G_HOOK_FLAG_USER_SHIFT is the first bit which can be
  395. -- used for application-defined flags.
  396. -- ---------------------------------------------------------------------------------
  397. -- G_HOOK()
  398. -- #define G_HOOK(hook) ((GHook*) (hook))
  399. -- Casts a pointer to a GHook*.
  400. -- hook : a pointer.
  401. -- ---------------------------------------------------------------------------------
  402. -- G_HOOK_IS_VALID()
  403. -- #define G_HOOK_IS_VALID(hook)
  404. -- Returns TRUE if the GHook is valid, i.e. it is in a GHookList, it is active and
  405. -- it has not been destroyed.
  406. -- hook : a GHook.
  407. -- Returns : TRUE if the GHook is valid.
  408. -- ---------------------------------------------------------------------------------
  409. -- G_HOOK_ACTIVE()
  410. -- #define G_HOOK_ACTIVE(hook)
  411. -- Returns TRUE if the GHook is active, which is normally TRUE until the GHook is
  412. -- destroyed.
  413. -- hook : a GHook.
  414. -- Returns : TRUE if the GHook is active.
  415. -- ---------------------------------------------------------------------------------
  416. -- G_HOOK_IN_CALL()
  417. -- #define G_HOOK_IN_CALL(hook)
  418. -- Returns TRUE if the GHook function is currently executing.
  419. -- hook : a GHook.
  420. -- Returns : TRUE if the GHook function is currently executing.
  421. -- ---------------------------------------------------------------------------------
  422. -- G_HOOK_IS_UNLINKED()
  423. -- #define G_HOOK_IS_UNLINKED(hook)
  424. -- Returns TRUE if the GHook is not in a GHookList.
  425. -- hook : a GHook.
  426. -- Returns : TRUE if the GHook is not in a GHookList.
  427. -- ---------------------------------------------------------------------------------
  428. -- g_hook_ref ()
  429. -- GHook* g_hook_ref (GHookList *hook_list,
  430. -- GHook *hook);
  431. -- Increments the reference count for a GHook.
  432. -- hook_list : a GHookList.
  433. -- hook : the GHook to increment the reference count of.
  434. -- Returns : the hook that was passed in (since 2.6)
  435. -- ---------------------------------------------------------------------------------
  436. -- g_hook_unref ()
  437. -- void g_hook_unref (GHookList *hook_list,
  438. -- GHook *hook);
  439. -- Decrements the reference count of a GHook. If the reference count falls to 0, the
  440. -- GHook is removed from the GHookList and g_hook_free() is called to free it.
  441. -- hook_list : a GHookList.
  442. -- hook : the GHook to unref.
  443. -- ---------------------------------------------------------------------------------
  444. -- g_hook_free ()
  445. -- void g_hook_free (GHookList *hook_list,
  446. -- GHook *hook);
  447. -- Calls the GHookList hook_free function if it exists, and frees the memory
  448. -- allocated for the GHook.
  449. -- hook_list : a GHookList.
  450. -- hook : the GHook to free.
  451. -- ---------------------------------------------------------------------------------
  452. -- g_hook_destroy ()
  453. -- gboolean g_hook_destroy (GHookList *hook_list,
  454. -- gulong hook_id);
  455. -- Destroys a GHook, given its ID.
  456. -- hook_list : a GHookList.
  457. -- hook_id : a hook ID.
  458. -- Returns : TRUE if the GHook was found in the GHookList and destroyed.
  459. -- ---------------------------------------------------------------------------------
  460. -- g_hook_destroy_link ()
  461. -- void g_hook_destroy_link (GHookList *hook_list,
  462. -- GHook *hook);
  463. -- Removes one GHook from a GHookList, marking it inactive and calling
  464. -- g_hook_unref() on it.
  465. -- hook_list : a GHookList.
  466. -- hook : the GHook to remove.
  467. end -- class GLIB_HOOK_FUNCTIONS