/src/wrappers/glib/library/externals/glib-callbacks.c

http://github.com/tybor/Liberty · C · 405 lines · 6 code · 123 blank · 276 comment · 0 complexity · 54e8a7283a82c1f236b12f3ce3e41c13 MD5 · raw file

  1. /* Eiffel callbacks for the Glib library
  2. *
  3. * based on the original Glib:
  4. * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  5. * Copyright (C) 1997-2000 the GLib Team and others
  6. * Copyright 2007, Paolo Redaelli, EWLC team
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public License
  9. * as published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. * This library is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. * You should have received a copy of the GNU Lesser General Public
  16. * License along with this library; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  18. * 02111-1307, USA.
  19. */
  20. /* Callbacks found in Glib version 2.12.4 */
  21. #include <stdio.h>
  22. #include "glib-callbacks.h"
  23. #include "cecil.h"
  24. /* GSourceFunc () */
  25. /* gboolean (*GSourceFunc) (gpointer data); */
  26. /* Specifies the type of function passed to g_timeout_add(), g_timeout_add_full(), g_idle_add(), and g_idle_add_full(). */
  27. /* data : data passed to the function, set when the source was created with one of the above functions. */
  28. /* Returns : it should return FALSE if the source should be removed. */
  29. /* GCompareFunc () */
  30. /* gint (*GCompareFunc) (gconstpointer a, */
  31. /* gconstpointer b); */
  32. /* Specifies the type of a comparison function used to compare two values. The function should return a negative integer if the first value comes before the second, 0 if they are equal, or a positive integer if the first value comes after the second. */
  33. /* a : a value. */
  34. /* b : a value to compare with. */
  35. /* Returns : negative value if a < b; zero if a = b; positive value if a > b */
  36. /* GCompareDataFunc () */
  37. /* gint (*GCompareDataFunc) (gconstpointer a, gconstpointer b,
  38. gpointer user_data); */
  39. int EiffelGCompareDataFunc (void *a, void *b, void *user_data) {
  40. /* Specifies the type of a comparison function used to compare two values. The function should return a negative integer if the first value comes before the second, 0 if they are equal, or a positive integer if the first value comes after the second. */
  41. /* a : a value. */
  42. /* b : a value to compare with. */
  43. /* user_data : user data to pass to comparison function. */
  44. /* Returns : negative value if a < b; zero if a = b; positive value if a > b. */
  45. // Note: debug code commented out
  46. // printf("EiffelGCompareDataFunc (a=%p, b=%p, user_data=%p)\n",a,b,user_data);
  47. /* print(user_data.generator.to_external) translated to C */
  48. // void *generator = G_COMPARE_DATA_CALLBACK_generator(user_data);
  49. // printf("Generator %p%n",generator);
  50. // char *generator_name = STRING_to_external(generator);
  51. // printf("Generator name %p%n",generator_name);
  52. // printf("user_data is a %s\n",generator_name);
  53. return G_COMPARE_DATA_CALLBACK_callback(user_data,a,b);
  54. };
  55. /* GFunc () */
  56. /* void (*GFunc) (gpointer data, */
  57. /* gpointer user_data); */
  58. /* Specifies the type of functions passed to g_list_foreach() and g_slist_foreach(). */
  59. /* data : the element's data. */
  60. /* user_data : user data passed to g_list_foreach() or g_slist_foreach(). */
  61. /* ModuleCheckInit () */
  62. /* const gchar* (*GModuleCheckInit) (GModule *module); */
  63. /* Specifies the type of the module initialization function. If a module contains a function named g_module_check_init() it is called automatically when the module is loaded. It is passed the GModule structure and should return NULL on success or a string describing the initialization error. */
  64. /* module : the GModule corresponding to the module which has just been loaded. */
  65. /* Returns : NULL on success, or a string describing the initialization error. */
  66. /* GModuleUnload () */
  67. /* void (*GModuleUnload) (GModule *module); */
  68. /* Specifies the type of the module function called when it is unloaded. If a module contains a function named g_module_unload() it is called automatically when the module is unloaded. It is passed the GModule structure. */
  69. /* module : the GModule about to be unloaded. */
  70. /* GPrintFunc () */
  71. /* void (*GPrintFunc) (const gchar *string); */
  72. /* Specifies the type of the print handler functions. These are called with the complete formatted string to output. */
  73. /* string : the message to be output. */
  74. /* GLogFunc () */
  75. /* void (*GLogFunc) (const gchar *log_domain, */
  76. /* GLogLevelFlags log_level, */
  77. /* const gchar *message, */
  78. /* gpointer user_data); */
  79. /* Specifies the prototype of log handler functions. */
  80. /* log_domain : the log domain of the message. */
  81. /* log_level : the log level of the message (including the fatal and recursion flags). */
  82. /* message : the message to process. */
  83. /* user_data : user data, set in g_log_set_handler(). */
  84. /* GHookFinalizeFunc () */
  85. /* void (*GHookFinalizeFunc) (GHookList *hook_list, */
  86. /* GHook *hook); */
  87. /* Defines the type of function to be called when a hook in a list of hooks gets finalized. */
  88. /* hook_list : a GHookList. */
  89. /* hook : the hook in hook_list that gets finalized. */
  90. /* GHookFunc () */
  91. /* void (*GHookFunc) (gpointer data); */
  92. /* Defines the type of a hook function that can be invoked by g_hook_list_invoke(). */
  93. /* data : the data field of the GHook is passed to the hook function here. */
  94. /* GHookCheckFunc () */
  95. /* gboolean (*GHookCheckFunc) (gpointer data); */
  96. /* Defines the type of a hook function that can be invoked by g_hook_list_invoke_check(). */
  97. /* data : the data field of the GHook is passed to the hook function here. */
  98. /* Returns : FALSE if the GHook should be destroyed. */
  99. /* GHookMarshaller () */
  100. /* void (*GHookMarshaller) (GHook *hook, */
  101. /* gpointer marshal_data); */
  102. /* Defines the type of function used by g_hook_list_marshal(). */
  103. /* hook : a GHook. */
  104. /* marshal_data : user data. */
  105. /* GHookCheckMarshaller () */
  106. /* gboolean (*GHookCheckMarshaller) (GHook *hook, */
  107. /* gpointer marshal_data); */
  108. /* Defines the type of function used by g_hook_list_marshal_check(). */
  109. /* hook : a GHook. */
  110. /* marshal_data : user data. */
  111. /* Returns : FALSE if hook should be destroyed. */
  112. /* GHookCompareFunc () */
  113. /* gint (*GHookCompareFunc) (GHook *new_hook, */
  114. /* GHook *sibling); */
  115. /* Defines the type of function used to compare GHook elements in g_hook_insert_sorted(). */
  116. /* new_hook : the GHook being inserted. */
  117. /* sibling : the GHook to compare with new_hook. */
  118. /* Returns : a value <= 0 if new_hook should be before sibling. */
  119. /* GHookFindFunc () */
  120. /* gboolean (*GHookFindFunc) (GHook *hook, */
  121. /* gpointer data); */
  122. /* Defines the type of the function passed to g_hook_find(). */
  123. /* hook : a GHook. */
  124. /* data : user data passed to g_hook_find_func(). */
  125. /* Returns : TRUE if the required GHook has been found. */
  126. /* GScannerMsgFunc () */
  127. /* void (*GScannerMsgFunc) (GScanner *scanner, */
  128. /* gchar *message, */
  129. /* gboolean error); */
  130. /* Specifies the type of the message handler function. */
  131. /* scanner : a GScanner. */
  132. /* message : the message. */
  133. /* error : TRUE if the message signals an error, FALSE if it signals a warning. */
  134. /* GCompletionFunc () */
  135. /* gchar* (*GCompletionFunc) (gpointer ); */
  136. /* Specifies the type of the function passed to g_completion_new(). It should return the string corresponding to the given target item. This is used when you use data structures as GCompletion items. */
  137. /* Param1 : the completion item. */
  138. /* Returns : the string corresponding to the item. */
  139. /* GCompletionStrncmpFunc () */
  140. /* gint (*GCompletionStrncmpFunc) (const gchar *s1, */
  141. /* const gchar *s2, */
  142. /* gsize n); */
  143. /* Specifies the type of the function passed to g_completion_set_compare(). This is used when you use strings as GCompletion items. */
  144. /* s1 : string to compare with s2. */
  145. /* s2 : string to compare with s1. */
  146. /* n : maximal number of bytes to compare. */
  147. /* Returns : an integer less than, equal to, or greater than zero if the first n bytes of s1 is found, respectively, to be less than, to match, or to be greater than the first n bytes of s2. */
  148. /* GSpawnChildSetupFunc () */
  149. /* void (*GSpawnChildSetupFunc) (gpointer user_data); */
  150. /* Specifies the type of the setup function passed to g_spawn_async(), g_spawn_sync() and g_spawn_async_with_pipes(). On POSIX platforms it is called in the child after GLib has performed all the setup it plans to perform but before calling exec(). On POSIX actions taken in this function will thus only affect the child, not the parent. */
  151. /* On Windows the function is called in the parent. Its usefulness on Windows is thus questionable. In many cases executing the child setup function in the parent can have ill effects, and you should be very careful when porting software to Windows that uses child setup functions. */
  152. /* user_data : user data to pass to the function. */
  153. /* GOptionArgFunc () */
  154. /* gboolean (*GOptionArgFunc) (const gchar *option_name, */
  155. /* const gchar *value, */
  156. /* gpointer data, */
  157. /* GError **error); */
  158. /* The type of function to be passed as callback for G_OPTION_ARG_CALLBACK options. */
  159. /* option_name : The name of the option being parsed. This will be either a single dash followed by a single letter (for a short name) or two dashes followed by a long option name. */
  160. /* value : The value to be parsed. */
  161. /* data : User data added to the GOptionGroup containing the option when it was created with g_option_group_new() */
  162. /* error : A return location for errors. The error code G_OPTION_ERROR_FAILED is intended to be used for errors in GOptionArgFunc callbacks. */
  163. /* Returns : TRUE if the option was successfully parsed, FALSE if an error occurred, in which case error should be set with g_set_error() */
  164. /* GTranslateFunc () */
  165. /* const gchar* (*GTranslateFunc) (const gchar *str, */
  166. /* gpointer data); */
  167. /* The type of functions which are used to translate user-visible strings, for --help output. */
  168. /* str : the untranslated string */
  169. /* data : user data specified when installing the function, e.g. in g_option_group_set_translate_func() */
  170. /* Returns : a translation of the string for the current locale. The returned string is owned by GLib and must not be freed. */
  171. /* GOptionParseFunc () */
  172. /* gboolean (*GOptionParseFunc) (GOptionContext *context, */
  173. /* GOptionGroup *group, */
  174. /* gpointer data, */
  175. /* GError **error); */
  176. /* The type of function that can be called before and after parsing. */
  177. /* context : The active GOptionContext */
  178. /* group : The group to which the function belongs */
  179. /* data : User data added to the GOptionGroup containing the option when it was created with g_option_group_new() */
  180. /* error : A return location for error details */
  181. /* Returns : TRUE if the function completed successfully, FALSE if an error occurred, in which case error should be set with g_set_error() */
  182. /* GOptionErrorFunc () */
  183. /* void (*GOptionErrorFunc) (GOptionContext *context, */
  184. /* GOptionGroup *group, */
  185. /* gpointer data, */
  186. /* GError **error); */
  187. /* The type of function to be used as callback when a parse error occurs. */
  188. /* context : The active GOptionContext */
  189. /* group : The group to which the function belongs */
  190. /* data : User data added to the GOptionGroup containing the option when it was created with g_option_group_new() */
  191. /* error : The GError containing details about the parse error */
  192. /* GHashFunc () */
  193. /* guint (*GHashFunc) (gconstpointer key); */
  194. /* Specifies the type of the hash function which is passed to g_hash_table_new() when a GHashTable is created. */
  195. /* The function is passed a key and should return a guint hash value. The functions g_direct_hash(), g_int_hash() and g_str_hash() provide hash functions which can be used when the key is a gpointer, gint, and gchar* respectively. */
  196. /* FIXME: Need more here. The hash values should be evenly distributed over a fairly large range? The modulus is taken with the hash table size (a prime number) to find the 'bucket' to place each key into. The function should also be very fast, since it is called for each key lookup. */
  197. /* key : a key. */
  198. /* Returns : the hash value corresponding to the key. */
  199. /* GEqualFunc () */
  200. /* gboolean (*GEqualFunc) (gconstpointer a, */
  201. /* gconstpointer b); */
  202. /* Specifies the type of a function used to test two values for equality. The function should return TRUE if both values are equal and FALSE otherwise. */
  203. /* a : a value. */
  204. /* b : a value to compare with. */
  205. /* Returns : TRUE if a = b; FALSE otherwise. */
  206. /* GHFunc () */
  207. /* void (*GHFunc) (gpointer key, */
  208. /* gpointer value, */
  209. /* gpointer user_data); */
  210. /* Specifies the type of the function passed to g_hash_table_foreach(). It is called with each key/value pair, together with the user_data parameter which is passed to g_hash_table_foreach(). */
  211. /* key : a key. */
  212. /* value : the value corresponding to the key. */
  213. /* user_data : user data passed to g_hash_table_foreach(). */
  214. /* GHRFunc () */
  215. /* gboolean (*GHRFunc) (gpointer key, */
  216. /* gpointer value, */
  217. /* gpointer user_data); */
  218. /* Specifies the type of the function passed to g_hash_table_foreach_remove(). It is called with each key/value pair, together with the user_data parameter passed to g_hash_table_foreach_remove(). It should return TRUE if the key/value pair should be removed from the GHashTable. */
  219. /* key : a key. */
  220. /* value : the value associated with the key. */
  221. /* user_data : user data passed to g_hash_table_remove(). */
  222. /* Returns : TRUE if the key/value pair should be removed from the GHashTable. */
  223. /* GTraverseFunc () */
  224. /* gboolean (*GTraverseFunc) (gpointer key, */
  225. /* gpointer value, */
  226. /* gpointer data); */
  227. /* Specifies the type of function passed to g_tree_traverse(). It is passed the key and value of each node, together with the user_data parameter passed to g_tree_traverse(). If the function returns TRUE, the traversal is stopped. */
  228. /* key : a key of a GTree node. */
  229. /* value : the value corresponding to the key. */
  230. /* data : user data passed to g_tree_traverse(). */
  231. /* Returns : TRUE to stop the traversal. */
  232. /* GCopyFunc () */
  233. /* gpointer (*GCopyFunc) (gconstpointer src, */
  234. /* gpointer data); */
  235. /* A function of this signature is used to copy the node data when doing a deep-copy of a tree. */
  236. /* src : A pointer to the data which should be copied. */
  237. /* data : Additional data. */
  238. /* Returns : A pointer to the copy. */
  239. /* Since 2.4 */
  240. /* GNodeTraverseFunc () */
  241. /* gboolean (*GNodeTraverseFunc) (GNode *node, */
  242. /* gpointer data); */
  243. /* Specifies the type of function passed to g_node_traverse(). The function is called with each of the nodes visited, together with the user data passed to g_node_traverse(). If the function returns TRUE, then the traversal is stopped. */
  244. /* node : a GNode. */
  245. /* data : user data passed to g_node_traverse(). */
  246. /* Returns : TRUE to stop the traversal. */
  247. /* GNodeForeachFunc () */
  248. /* void (*GNodeForeachFunc) (GNode *node, */
  249. /* gpointer data); */
  250. /* Specifies the type of function passed to g_node_children_foreach(). The function is called with each child node, together with the user data passed to g_node_children_foreach(). */
  251. /* node : a GNode. */
  252. /* data : user data passed to g_node_children_foreach(). */
  253. /* GDestroyNotify () */
  254. /* void (*GDestroyNotify) (gpointer data); */
  255. /* Specifies the type of function which is called when a data element is destroyed. It is passed the pointer to the data element and should free any memory and resources allocated for it. */
  256. /* data : the data element. */
  257. /* GDataForeachFunc () */
  258. /* void (*GDataForeachFunc) (GQuark key_id, */
  259. /* gpointer data, */
  260. /* gpointer user_data); */
  261. /* Specifies the type of function passed to g_dataset_foreach(). It is called with each GQuark id and associated data element, together with the user_data parameter supplied to g_dataset_foreach(). */
  262. /* key_id : the GQuark id to identifying the data element. */
  263. /* data : the data element. */
  264. /* user_data : user data passed to g_dataset_foreach(). */
  265. /* GCacheDestroyFunc () */
  266. /* void (*GCacheDestroyFunc) (gpointer value); */
  267. /* Specifies the type of the value_destroy_func and key_destroy_func functions passed to g_cache_new(). The functions are passed a pointer to the GCache key or GCache value and should free any memory and other resources associated with it. */
  268. /* value : the GCache value to destroy. */
  269. /* GCacheDupFunc () */
  270. /* gpointer (*GCacheDupFunc) (gpointer value); */
  271. /* Specifies the type of the key_dup_func function passed to g_cache_new(). The function is passed a key (not a value as the prototype implies) and should return a duplicate of the key. */
  272. /* value : the GCache key to destroy (not a GCache value as it seems). */
  273. /* Returns : a copy of the GCache key. */
  274. /* GCacheDupFunc () */
  275. /* gpointer (*GCacheDupFunc) (gpointer value); */
  276. /* Specifies the type of the key_dup_func function passed to g_cache_new(). The function is passed a key (not a value as the prototype implies) and should return a duplicate of the key. */
  277. /* value : the GCache key to destroy (not a GCache value as it seems). */
  278. /* Returns : a copy of the GCache key. */