Commit 7773ae45 authored by Matthias Clasen's avatar Matthias Clasen
Browse files

csstypes: Add annotations and inlines

Inline _gtk_css_change_for_sibling and
_gtk_css_change_for_child, and mark a few
other functions as const or malloc.
parent bec44acd
......@@ -22,68 +22,6 @@
#include "gtkcssnumbervalueprivate.h"
#include "gtkstylecontextprivate.h"
GtkCssChange
_gtk_css_change_for_sibling (GtkCssChange match)
{
#define BASE_STATES ( GTK_CSS_CHANGE_CLASS \
| GTK_CSS_CHANGE_NAME \
| GTK_CSS_CHANGE_ID \
| GTK_CSS_CHANGE_FIRST_CHILD \
| GTK_CSS_CHANGE_LAST_CHILD \
| GTK_CSS_CHANGE_NTH_CHILD \
| GTK_CSS_CHANGE_NTH_LAST_CHILD \
| GTK_CSS_CHANGE_STATE \
| GTK_CSS_CHANGE_HOVER \
| GTK_CSS_CHANGE_DISABLED \
| GTK_CSS_CHANGE_SELECTED \
| GTK_CSS_CHANGE_BACKDROP)
#define KEEP_STATES ( ~(BASE_STATES|GTK_CSS_CHANGE_SOURCE|GTK_CSS_CHANGE_PARENT_STYLE) \
| GTK_CSS_CHANGE_NTH_CHILD \
| GTK_CSS_CHANGE_NTH_LAST_CHILD)
return (match & KEEP_STATES) | ((match & BASE_STATES) << GTK_CSS_CHANGE_SIBLING_SHIFT);
#undef BASE_STATES
#undef KEEP_STATES
}
GtkCssChange
_gtk_css_change_for_child (GtkCssChange match)
{
#define BASE_STATES ( GTK_CSS_CHANGE_CLASS \
| GTK_CSS_CHANGE_NAME \
| GTK_CSS_CHANGE_ID \
| GTK_CSS_CHANGE_FIRST_CHILD \
| GTK_CSS_CHANGE_LAST_CHILD \
| GTK_CSS_CHANGE_NTH_CHILD \
| GTK_CSS_CHANGE_NTH_LAST_CHILD \
| GTK_CSS_CHANGE_STATE \
| GTK_CSS_CHANGE_HOVER \
| GTK_CSS_CHANGE_DISABLED \
| GTK_CSS_CHANGE_BACKDROP \
| GTK_CSS_CHANGE_SELECTED \
| GTK_CSS_CHANGE_SIBLING_CLASS \
| GTK_CSS_CHANGE_SIBLING_NAME \
| GTK_CSS_CHANGE_SIBLING_ID \
| GTK_CSS_CHANGE_SIBLING_FIRST_CHILD \
| GTK_CSS_CHANGE_SIBLING_LAST_CHILD \
| GTK_CSS_CHANGE_SIBLING_NTH_CHILD \
| GTK_CSS_CHANGE_SIBLING_NTH_LAST_CHILD \
| GTK_CSS_CHANGE_SIBLING_STATE \
| GTK_CSS_CHANGE_SIBLING_HOVER \
| GTK_CSS_CHANGE_SIBLING_DISABLED \
| GTK_CSS_CHANGE_SIBLING_BACKDROP \
| GTK_CSS_CHANGE_SIBLING_SELECTED)
#define KEEP_STATES (~(BASE_STATES|GTK_CSS_CHANGE_SOURCE|GTK_CSS_CHANGE_PARENT_STYLE))
return (match & KEEP_STATES) | ((match & BASE_STATES) << GTK_CSS_CHANGE_PARENT_SHIFT);
#undef BASE_STATES
#undef KEEP_STATES
}
void
gtk_css_change_print (GtkCssChange change,
GString *string)
......
......@@ -452,16 +452,75 @@ typedef enum /*< skip >*/ {
GTK_CSS_FONT_VARIANT_EAST_ASIAN_RUBY = 1 << 9
} GtkCssFontVariantEastAsian;
GtkCssChange _gtk_css_change_for_sibling (GtkCssChange match);
GtkCssChange _gtk_css_change_for_child (GtkCssChange match);
static inline GtkCssChange
_gtk_css_change_for_sibling (GtkCssChange match)
{
#define BASE_STATES ( GTK_CSS_CHANGE_CLASS \
| GTK_CSS_CHANGE_NAME \
| GTK_CSS_CHANGE_ID \
| GTK_CSS_CHANGE_FIRST_CHILD \
| GTK_CSS_CHANGE_LAST_CHILD \
| GTK_CSS_CHANGE_NTH_CHILD \
| GTK_CSS_CHANGE_NTH_LAST_CHILD \
| GTK_CSS_CHANGE_STATE \
| GTK_CSS_CHANGE_HOVER \
| GTK_CSS_CHANGE_DISABLED \
| GTK_CSS_CHANGE_SELECTED \
| GTK_CSS_CHANGE_BACKDROP)
#define KEEP_STATES ( ~(BASE_STATES|GTK_CSS_CHANGE_SOURCE|GTK_CSS_CHANGE_PARENT_STYLE) \
| GTK_CSS_CHANGE_NTH_CHILD \
| GTK_CSS_CHANGE_NTH_LAST_CHILD)
return (match & KEEP_STATES) | ((match & BASE_STATES) << GTK_CSS_CHANGE_SIBLING_SHIFT);
#undef BASE_STATES
#undef KEEP_STATES
}
static inline GtkCssChange
_gtk_css_change_for_child (GtkCssChange match)
{
#define BASE_STATES ( GTK_CSS_CHANGE_CLASS \
| GTK_CSS_CHANGE_NAME \
| GTK_CSS_CHANGE_ID \
| GTK_CSS_CHANGE_FIRST_CHILD \
| GTK_CSS_CHANGE_LAST_CHILD \
| GTK_CSS_CHANGE_NTH_CHILD \
| GTK_CSS_CHANGE_NTH_LAST_CHILD \
| GTK_CSS_CHANGE_STATE \
| GTK_CSS_CHANGE_HOVER \
| GTK_CSS_CHANGE_DISABLED \
| GTK_CSS_CHANGE_BACKDROP \
| GTK_CSS_CHANGE_SELECTED \
| GTK_CSS_CHANGE_SIBLING_CLASS \
| GTK_CSS_CHANGE_SIBLING_NAME \
| GTK_CSS_CHANGE_SIBLING_ID \
| GTK_CSS_CHANGE_SIBLING_FIRST_CHILD \
| GTK_CSS_CHANGE_SIBLING_LAST_CHILD \
| GTK_CSS_CHANGE_SIBLING_NTH_CHILD \
| GTK_CSS_CHANGE_SIBLING_NTH_LAST_CHILD \
| GTK_CSS_CHANGE_SIBLING_STATE \
| GTK_CSS_CHANGE_SIBLING_HOVER \
| GTK_CSS_CHANGE_SIBLING_DISABLED \
| GTK_CSS_CHANGE_SIBLING_BACKDROP \
| GTK_CSS_CHANGE_SIBLING_SELECTED)
#define KEEP_STATES (~(BASE_STATES|GTK_CSS_CHANGE_SOURCE|GTK_CSS_CHANGE_PARENT_STYLE))
return (match & KEEP_STATES) | ((match & BASE_STATES) << GTK_CSS_CHANGE_PARENT_SHIFT);
#undef BASE_STATES
#undef KEEP_STATES
}
GtkCssDimension gtk_css_unit_get_dimension (GtkCssUnit unit);
GtkCssDimension gtk_css_unit_get_dimension (GtkCssUnit unit) G_GNUC_CONST;
char * gtk_css_change_to_string (GtkCssChange change);
char * gtk_css_change_to_string (GtkCssChange change) G_GNUC_MALLOC;
void gtk_css_change_print (GtkCssChange change,
GString *string);
const char * gtk_css_pseudoclass_name (GtkStateFlags flags);
const char * gtk_css_pseudoclass_name (GtkStateFlags flags) G_GNUC_CONST;
/* These hash functions are selected so they achieve 2 things:
* 1. collision free among each other
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment