forked from AuroraMiddleware/gtk
Handle static inline GtkOrdering function
The introspection scanner does not handle `static inline` functions: they are not in the shared library, so cannot be dlsym() out of it; and the `static` keyword tells g-ir-scanner to skip the function declaration entirely. We can trick the scanner into thinking the gtk_ordering_from_cmpfunc() symbol is a real, public one, by declaring and defining a regular function under the `__GI_SCANNER__` guard; the symbol does not appear when actually building GTK, or any code using GTK, so we don't risk collisions.
This commit is contained in:
parent
90cf6bb686
commit
816383e9ef
@ -548,7 +548,7 @@ typedef enum
|
||||
* These values can be used with a `GCompareFunc`. However,
|
||||
* a `GCompareFunc` is allowed to return any integer values.
|
||||
* For converting such a value to a `GtkOrdering` value, use
|
||||
* [func@Gtk.ordering_from_cmpfunc].
|
||||
* [func@Gtk.Ordering.from_cmpfunc].
|
||||
*/
|
||||
typedef enum {
|
||||
GTK_ORDERING_SMALLER = -1,
|
||||
@ -556,6 +556,14 @@ typedef enum {
|
||||
GTK_ORDERING_LARGER = 1
|
||||
} GtkOrdering;
|
||||
|
||||
/* The GI scanner does not handle static inline functions, because
|
||||
* of the `static` keyword; so we clip this out when parsing the
|
||||
* header, and we replace it with a real function in gtksorter.c
|
||||
* that only exists when parsing the source for introspection.
|
||||
*/
|
||||
#ifdef __GI_SCANNER__
|
||||
GtkOrdering gtk_ordering_from_cmpfunc (int cmpfunc_result);
|
||||
#else
|
||||
/**
|
||||
* gtk_ordering_from_cmpfunc:
|
||||
* @cmpfunc_result: Result of a comparison function
|
||||
@ -570,6 +578,7 @@ gtk_ordering_from_cmpfunc (int cmpfunc_result)
|
||||
{
|
||||
return (GtkOrdering) ((cmpfunc_result > 0) - (cmpfunc_result < 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GtkPageOrientation:
|
||||
|
@ -364,3 +364,24 @@ gtk_sorter_changed_with_keys (GtkSorter *self,
|
||||
|
||||
gtk_sorter_changed (self, change);
|
||||
}
|
||||
|
||||
/* See the comment in gtkenums.h as to why we need to play
|
||||
* games with the introspection scanner for static inline
|
||||
* functions
|
||||
*/
|
||||
#ifdef __GI_SCANNER__
|
||||
/**
|
||||
* gtk_ordering_from_cmpfunc:
|
||||
* @cmpfunc_result: Result of a comparison function
|
||||
*
|
||||
* Converts the result of a `GCompareFunc` like strcmp() to a
|
||||
* `GtkOrdering` value.
|
||||
*
|
||||
* Returns: the corresponding `GtkOrdering`
|
||||
**/
|
||||
GtkOrdering
|
||||
gtk_ordering_from_cmpfunc (int cmpfunc_result)
|
||||
{
|
||||
return (GtkOrdering) ((cmpfunc_result > 0) - (cmpfunc_result < 0));
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user