PageRenderTime 40ms CodeModel.GetById 25ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/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
  7 * Copyright 2007, Paolo Redaelli, EWLC team
  8 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public License
 11 * as published by the Free Software Foundation; either version 2 of
 12 * the License, or (at your option) any later version.
 13 
 14 * This library is distributed in the hope that it will be useful, but
 15 * WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 22 * 02111-1307, USA.
 23 */
 24   
 25/* Callbacks found in Glib version 2.12.4 */
 26#include <stdio.h>
 27#include "glib-callbacks.h"
 28#include "cecil.h"
 29
 30
 31/* GSourceFunc () */
 32
 33/* gboolean    (*GSourceFunc)                  (gpointer data); */
 34
 35/* Specifies the type of function passed to g_timeout_add(), g_timeout_add_full(), g_idle_add(), and g_idle_add_full(). */
 36/* data : 	data passed to the function, set when the source was created with one of the above functions. */
 37/* Returns : 	it should return FALSE if the source should be removed. */
 38
 39
 40/* GCompareFunc () */
 41
 42/* gint        (*GCompareFunc)                 (gconstpointer a, */
 43/*                                              gconstpointer b); */
 44
 45/* 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. */
 46/* a : 	a value. */
 47/* b : 	a value to compare with. */
 48/* Returns : 	negative value if a < b; zero if a = b; positive value if a > b */
 49
 50/* GCompareDataFunc () */
 51
 52/* gint (*GCompareDataFunc) (gconstpointer a, gconstpointer b,
 53   gpointer user_data); */
 54
 55int EiffelGCompareDataFunc (void *a, void *b, void *user_data) {
 56  /* 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. */
 57  /* a : 	a value. */
 58  /* b : 	a value to compare with. */
 59  /* user_data : 	user data to pass to comparison function. */
 60  /* Returns : 	negative value if a < b; zero if a = b; positive value if a > b.  */
 61  
 62  // Note: debug code commented out
 63  // printf("EiffelGCompareDataFunc (a=%p, b=%p, user_data=%p)\n",a,b,user_data);
 64  /* print(user_data.generator.to_external) translated to C */
 65  // void *generator = G_COMPARE_DATA_CALLBACK_generator(user_data); 
 66  // printf("Generator %p%n",generator);
 67  // char *generator_name = STRING_to_external(generator); 
 68  // printf("Generator name %p%n",generator_name);
 69  // printf("user_data is a %s\n",generator_name);
 70  return G_COMPARE_DATA_CALLBACK_callback(user_data,a,b);
 71};
 72
 73/* GFunc () */
 74
 75/* void        (*GFunc)                        (gpointer data, */
 76/*                                              gpointer user_data); */
 77
 78/* Specifies the type of functions passed to g_list_foreach() and g_slist_foreach(). */
 79/* data : 	the element's data. */
 80/* user_data : 	user data passed to g_list_foreach() or g_slist_foreach(). */
 81
 82
 83/* ModuleCheckInit () */
 84
 85/* const gchar* (*GModuleCheckInit)            (GModule *module); */
 86
 87/* 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. */
 88/* module : 	the GModule corresponding to the module which has just been loaded. */
 89/* Returns : 	NULL on success, or a string describing the initialization error. */
 90/* GModuleUnload () */
 91
 92/* void        (*GModuleUnload)                (GModule *module); */
 93
 94/* 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. */
 95/* module : 	the GModule about to be unloaded. */
 96
 97/* GPrintFunc () */
 98
 99/* void        (*GPrintFunc)                   (const gchar *string); */
100
101/* Specifies the type of the print handler functions. These are called with the complete formatted string to output. */
102/* string : 	the message to be output. */
103
104/* GLogFunc () */
105
106/* void        (*GLogFunc)                     (const gchar *log_domain, */
107/*                                              GLogLevelFlags log_level, */
108/*                                              const gchar *message, */
109/*                                              gpointer user_data); */
110
111/* Specifies the prototype of log handler functions. */
112/* log_domain : 	the log domain of the message. */
113/* log_level : 	the log level of the message (including the fatal and recursion flags). */
114/* message : 	the message to process. */
115/* user_data : 	user data, set in g_log_set_handler(). */
116
117/* GHookFinalizeFunc () */
118
119/* void        (*GHookFinalizeFunc)            (GHookList *hook_list, */
120/*                                              GHook *hook); */
121
122/* Defines the type of function to be called when a hook in a list of hooks gets finalized. */
123/* hook_list : 	a GHookList. */
124/* hook : 	the hook in hook_list that gets finalized. */
125
126
127/* GHookFunc () */
128
129/* void        (*GHookFunc)                    (gpointer data); */
130
131/* Defines the type of a hook function that can be invoked by g_hook_list_invoke(). */
132/* data : 	the data field of the GHook is passed to the hook function here. */
133/* GHookCheckFunc () */
134
135/* gboolean    (*GHookCheckFunc)               (gpointer data); */
136
137/* Defines the type of a hook function that can be invoked by g_hook_list_invoke_check(). */
138/* data : 	the data field of the GHook is passed to the hook function here. */
139/* Returns : 	FALSE if the GHook should be destroyed. */
140
141/* GHookMarshaller () */
142
143/* void        (*GHookMarshaller)              (GHook *hook, */
144/*                                              gpointer marshal_data); */
145
146/* Defines the type of function used by g_hook_list_marshal(). */
147/* hook : 	a GHook. */
148/* marshal_data : 	user data. */
149
150/* GHookCheckMarshaller () */
151
152/* gboolean    (*GHookCheckMarshaller)         (GHook *hook, */
153/*                                              gpointer marshal_data); */
154
155/* Defines the type of function used by g_hook_list_marshal_check(). */
156/* hook : 	a GHook. */
157/* marshal_data : 	user data. */
158/* Returns : 	FALSE if hook should be destroyed. */
159
160/* GHookCompareFunc () */
161
162/* gint        (*GHookCompareFunc)             (GHook *new_hook, */
163/*                                              GHook *sibling); */
164
165/* Defines the type of function used to compare GHook elements in g_hook_insert_sorted(). */
166/* new_hook : 	the GHook being inserted. */
167/* sibling : 	the GHook to compare with new_hook. */
168/* Returns : 	a value <= 0 if new_hook should be before sibling. */
169
170/* GHookFindFunc () */
171
172/* gboolean    (*GHookFindFunc)                (GHook *hook, */
173/*                                              gpointer data); */
174
175/* Defines the type of the function passed to g_hook_find(). */
176/* hook : 	a GHook. */
177/* data : 	user data passed to g_hook_find_func(). */
178/* Returns : 	TRUE if the required GHook has been found.  */
179
180/* GScannerMsgFunc () */
181
182/* void        (*GScannerMsgFunc)              (GScanner *scanner, */
183/*                                              gchar *message, */
184/*                                              gboolean error); */
185
186/* Specifies the type of the message handler function. */
187/* scanner : 	a GScanner. */
188/* message : 	the message. */
189/* error : 	TRUE if the message signals an error, FALSE if it signals a warning. */
190
191/* GCompletionFunc () */
192
193/* gchar*      (*GCompletionFunc)              (gpointer ); */
194
195/* 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. */
196/* Param1 : 	the completion item. */
197/* Returns : 	the string corresponding to the item. */
198
199
200/* GCompletionStrncmpFunc () */
201
202/* gint        (*GCompletionStrncmpFunc)       (const gchar *s1, */
203/*                                              const gchar *s2, */
204/*                                              gsize n); */
205
206/* Specifies the type of the function passed to g_completion_set_compare(). This is used when you use strings as GCompletion items. */
207/* s1 : 	string to compare with s2. */
208/* s2 : 	string to compare with s1. */
209/* n : 	maximal number of bytes to compare. */
210/* 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. */
211
212
213/* GSpawnChildSetupFunc () */
214
215/* void        (*GSpawnChildSetupFunc)         (gpointer user_data); */
216
217/* 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. */
218
219/* 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. */
220/* user_data : 	user data to pass to the function.  */
221
222/* GOptionArgFunc () */
223
224/* gboolean    (*GOptionArgFunc)               (const gchar *option_name, */
225/*                                              const gchar *value, */
226/*                                              gpointer data, */
227/*                                              GError **error); */
228
229/* The type of function to be passed as callback for G_OPTION_ARG_CALLBACK options. */
230/* 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. */
231/* value : 	The value to be parsed. */
232/* data : 	User data added to the GOptionGroup containing the option when it was created with g_option_group_new() */
233/* error : 	A return location for errors. The error code G_OPTION_ERROR_FAILED is intended to be used for errors in GOptionArgFunc callbacks. */
234/* Returns : 	TRUE if the option was successfully parsed, FALSE if an error occurred, in which case error should be set with g_set_error() */
235
236/* GTranslateFunc () */
237
238/* const gchar* (*GTranslateFunc)              (const gchar *str, */
239/*                                              gpointer data); */
240
241/* The type of functions which are used to translate user-visible strings, for --help output. */
242/* str : 	the untranslated string */
243/* data : 	user data specified when installing the function, e.g. in g_option_group_set_translate_func() */
244/* Returns : 	a translation of the string for the current locale. The returned string is owned by GLib and must not be freed. */
245
246/* GOptionParseFunc () */
247
248/* gboolean    (*GOptionParseFunc)             (GOptionContext *context, */
249/*                                              GOptionGroup *group, */
250/*                                              gpointer data, */
251/*                                              GError **error); */
252
253/* The type of function that can be called before and after parsing. */
254/* context : 	The active GOptionContext */
255/* group : 	The group to which the function belongs */
256/* data : 	User data added to the GOptionGroup containing the option when it was created with g_option_group_new() */
257/* error : 	A return location for error details */
258/* Returns : 	TRUE if the function completed successfully, FALSE if an error occurred, in which case error should be set with g_set_error() */
259
260/* GOptionErrorFunc () */
261
262/* void        (*GOptionErrorFunc)             (GOptionContext *context, */
263/*                                              GOptionGroup *group, */
264/*                                              gpointer data, */
265/*                                              GError **error); */
266
267/* The type of function to be used as callback when a parse error occurs. */
268/* context : 	The active GOptionContext */
269/* group : 	The group to which the function belongs */
270/* data : 	User data added to the GOptionGroup containing the option when it was created with g_option_group_new() */
271/* error : 	The GError containing details about the parse error */
272
273
274/* GHashFunc () */
275
276/* guint       (*GHashFunc)                    (gconstpointer key); */
277
278/* Specifies the type of the hash function which is passed to g_hash_table_new() when a GHashTable is created. */
279
280/* 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. */
281
282/* 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. */
283/* key : 	a key. */
284/* Returns : 	the hash value corresponding to the key. */
285
286/* GEqualFunc () */
287
288/* gboolean    (*GEqualFunc)                   (gconstpointer a, */
289/*                                              gconstpointer b); */
290
291/* 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. */
292/* a : 	a value. */
293/* b : 	a value to compare with. */
294/* Returns : 	TRUE if a = b; FALSE otherwise. */
295
296
297/* GHFunc () */
298
299/* void        (*GHFunc)                       (gpointer key, */
300/*                                              gpointer value, */
301/*                                              gpointer user_data); */
302
303/* 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(). */
304/* key : 	a key. */
305/* value : 	the value corresponding to the key. */
306/* user_data : 	user data passed to g_hash_table_foreach(). */
307
308/* GHRFunc () */
309
310/* gboolean    (*GHRFunc)                      (gpointer key, */
311/*                                              gpointer value, */
312/*                                              gpointer user_data); */
313
314/* 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. */
315/* key : 	a key. */
316/* value : 	the value associated with the key. */
317/* user_data : 	user data passed to g_hash_table_remove(). */
318/* Returns : 	TRUE if the key/value pair should be removed from the GHashTable. */
319
320/* GTraverseFunc () */
321
322/* gboolean    (*GTraverseFunc)                (gpointer key, */
323/*                                              gpointer value, */
324/*                                              gpointer data); */
325
326/* 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. */
327/* key : 	a key of a GTree node. */
328/* value : 	the value corresponding to the key. */
329/* data : 	user data passed to g_tree_traverse(). */
330/* Returns : 	TRUE to stop the traversal.  */
331
332
333/* GCopyFunc () */
334
335/* gpointer    (*GCopyFunc)                    (gconstpointer src, */
336/*                                              gpointer data); */
337
338/* A function of this signature is used to copy the node data when doing a deep-copy of a tree. */
339/* src : 	A pointer to the data which should be copied. */
340/* data : 	Additional data. */
341/* Returns : 	A pointer to the copy. */
342
343/* Since 2.4 */
344
345/* GNodeTraverseFunc () */
346
347/* gboolean    (*GNodeTraverseFunc)            (GNode *node, */
348/*                                              gpointer data); */
349
350/* 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. */
351/* node : 	a GNode. */
352/* data : 	user data passed to g_node_traverse(). */
353/* Returns : 	TRUE to stop the traversal. */
354
355/* GNodeForeachFunc () */
356
357/* void        (*GNodeForeachFunc)             (GNode *node, */
358/*                                              gpointer data); */
359
360/* 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(). */
361/* node : 	a GNode. */
362/* data : 	user data passed to g_node_children_foreach(). */
363
364/* GDestroyNotify () */
365
366/* void        (*GDestroyNotify)               (gpointer data); */
367
368/* 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. */
369/* data : 	the data element. */
370
371/* GDataForeachFunc () */
372
373/* void        (*GDataForeachFunc)             (GQuark key_id, */
374/*                                              gpointer data, */
375/*                                              gpointer user_data); */
376
377/* 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(). */
378/* key_id : 	the GQuark id to identifying the data element. */
379/* data : 	the data element. */
380/* user_data : 	user data passed to g_dataset_foreach(). */
381
382/* GCacheDestroyFunc () */
383
384/* void        (*GCacheDestroyFunc)            (gpointer value); */
385
386/* 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. */
387/* value : 	the GCache value to destroy. */
388
389
390/* GCacheDupFunc () */
391
392/* gpointer    (*GCacheDupFunc)                (gpointer value); */
393
394/* 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. */
395/* value : 	the GCache key to destroy (not a GCache value as it seems). */
396/* Returns : 	a copy of the GCache key. */
397
398/* GCacheDupFunc () */
399
400/* gpointer    (*GCacheDupFunc)                (gpointer value); */
401
402/* 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. */
403/* value : 	the GCache key to destroy (not a GCache value as it seems). */
404/* Returns : 	a copy of the GCache key.  */
405