Add pure and const annotations to various functions

This commit is contained in:
Timm Bäder 2020-01-24 13:17:09 +01:00
parent 942a93250a
commit 77e0d360ed
22 changed files with 71 additions and 71 deletions

View File

@ -53,15 +53,15 @@ GDK_AVAILABLE_IN_ALL
void gdk_rgba_free (GdkRGBA *rgba);
GDK_AVAILABLE_IN_ALL
gboolean gdk_rgba_is_clear (const GdkRGBA *rgba);
gboolean gdk_rgba_is_clear (const GdkRGBA *rgba) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gdk_rgba_is_opaque (const GdkRGBA *rgba);
gboolean gdk_rgba_is_opaque (const GdkRGBA *rgba) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
guint gdk_rgba_hash (gconstpointer p);
guint gdk_rgba_hash (gconstpointer p) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gdk_rgba_equal (gconstpointer p1,
gconstpointer p2);
gconstpointer p2) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gdk_rgba_parse (GdkRGBA *rgba,

View File

@ -51,9 +51,9 @@ GdkTexture * gdk_texture_new_from_file (GFile
GError **error);
GDK_AVAILABLE_IN_ALL
int gdk_texture_get_width (GdkTexture *texture);
int gdk_texture_get_width (GdkTexture *texture) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
int gdk_texture_get_height (GdkTexture *texture);
int gdk_texture_get_height (GdkTexture *texture) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
void gdk_texture_download (GdkTexture *texture,

View File

@ -196,7 +196,7 @@ dump_node (GskRenderNode *node,
cairo_surface_destroy (surface);
}
static inline gboolean
static inline gboolean G_GNUC_PURE
node_is_invisible (const GskRenderNode *node)
{
return node->bounds.size.width == 0.0f ||
@ -237,7 +237,7 @@ sort_border_sides (const GdkRGBA *colors,
}
}
static inline gboolean
static inline gboolean G_GNUC_PURE
color_matrix_modifies_alpha (GskRenderNode *node)
{
const graphene_matrix_t *matrix = gsk_color_matrix_node_peek_color_matrix (node);
@ -261,7 +261,7 @@ gsk_rounded_rect_shrink_to_minimum (GskRoundedRect *self)
MAX (self->corner[2].height, self->corner[3].height)) * 2);
}
static inline gboolean
static inline gboolean G_GNUC_PURE
node_supports_transform (GskRenderNode *node)
{
/* Some nodes can't handle non-trivial transforms without being
@ -611,7 +611,7 @@ render_fallback_node (GskGLRenderer *self,
cairo_fill (cr);
cairo_restore (cr);
#if G_ENABLE_DEBUG
#ifdef G_ENABLE_DEBUG
if (GSK_RENDERER_DEBUG_CHECK (GSK_RENDERER (self), FALLBACK))
{
cairo_move_to (cr, 0, 0);

View File

@ -8,7 +8,7 @@ rect_equal (const graphene_rect_t *a,
return memcmp (a, b, sizeof (graphene_rect_t)) == 0;
}
static inline gboolean
static inline gboolean G_GNUC_PURE
rounded_rect_equal (const GskRoundedRect *r1,
const GskRoundedRect *r2)
{
@ -31,7 +31,7 @@ rounded_rect_equal (const GskRoundedRect *r1,
return TRUE;
}
static inline gboolean
static inline gboolean G_GNUC_PURE
rounded_rect_corners_equal (const GskRoundedRect *r1,
const GskRoundedRect *r2)
{

View File

@ -145,9 +145,9 @@ gsk_render_node_get_node_type (GskRenderNode *node)
return node->node_class->node_type;
}
static inline
G_GNUC_PURE static inline
GskRenderNodeType
_gsk_render_node_get_node_type (GskRenderNode *node)
_gsk_render_node_get_node_type (const GskRenderNode *node)
{
return node->node_class->node_type;
}
@ -248,8 +248,8 @@ gsk_render_node_draw (GskRenderNode *node,
* Returns: %TRUE if @node1 and @node2 can be expected to be compared
**/
gboolean
gsk_render_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2)
gsk_render_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2)
{
if (node1 == node2)
return TRUE;

View File

@ -41,8 +41,8 @@ rectangle_init_from_graphene (cairo_rectangle_int_t *cairo,
}
static gboolean
gsk_render_node_can_diff_true (GskRenderNode *node1,
GskRenderNode *node2)
gsk_render_node_can_diff_true (const GskRenderNode *node1,
const GskRenderNode *node2)
{
return TRUE;
}
@ -1707,8 +1707,8 @@ gsk_container_node_draw (GskRenderNode *node,
}
static gboolean
gsk_container_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2)
gsk_container_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2)
{
return TRUE;
}
@ -1726,7 +1726,7 @@ gsk_render_node_add_to_region (GskRenderNode *node,
static int
gsk_container_node_compare_func (gconstpointer elem1, gconstpointer elem2, gpointer data)
{
return gsk_render_node_can_diff ((GskRenderNode *) elem1, (GskRenderNode *) elem2) ? 0 : 1;
return gsk_render_node_can_diff ((const GskRenderNode *) elem1, (const GskRenderNode *) elem2) ? 0 : 1;
}
static void
@ -1918,8 +1918,8 @@ gsk_transform_node_draw (GskRenderNode *node,
}
static gboolean
gsk_transform_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2)
gsk_transform_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2)
{
GskTransformNode *self1 = (GskTransformNode *) node1;
GskTransformNode *self2 = (GskTransformNode *) node2;
@ -2092,8 +2092,8 @@ gsk_debug_node_draw (GskRenderNode *node,
}
static gboolean
gsk_debug_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2)
gsk_debug_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2)
{
GskDebugNode *self1 = (GskDebugNode *) node1;
GskDebugNode *self2 = (GskDebugNode *) node2;

View File

@ -28,8 +28,8 @@ struct _GskRenderNodeClass
void (* finalize) (GskRenderNode *node);
void (* draw) (GskRenderNode *node,
cairo_t *cr);
gboolean (* can_diff) (GskRenderNode *node1,
GskRenderNode *node2);
gboolean (* can_diff) (const GskRenderNode *node1,
const GskRenderNode *node2);
void (* diff) (GskRenderNode *node1,
GskRenderNode *node2,
cairo_region_t *region);
@ -38,8 +38,8 @@ struct _GskRenderNodeClass
GskRenderNode * gsk_render_node_new (const GskRenderNodeClass *node_class,
gsize extra_size);
gboolean gsk_render_node_can_diff (GskRenderNode *node1,
GskRenderNode *node2);
gboolean gsk_render_node_can_diff (const GskRenderNode *node1,
const GskRenderNode *node2) G_GNUC_PURE;
void gsk_render_node_diff (GskRenderNode *node1,
GskRenderNode *node2,
cairo_region_t *region);

View File

@ -98,16 +98,16 @@ GskRoundedRect * gsk_rounded_rect_shrink (GskRoundedRect
float left);
GDK_AVAILABLE_IN_ALL
gboolean gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self);
gboolean gsk_rounded_rect_is_rectilinear (const GskRoundedRect *self) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gsk_rounded_rect_contains_point (const GskRoundedRect *self,
const graphene_point_t *point);
const graphene_point_t *point) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gsk_rounded_rect_contains_rect (const GskRoundedRect *self,
const graphene_rect_t *rect);
const graphene_rect_t *rect) G_GNUC_PURE;
GDK_AVAILABLE_IN_ALL
gboolean gsk_rounded_rect_intersects_rect (const GskRoundedRect *self,
const graphene_rect_t *rect);
const graphene_rect_t *rect) G_GNUC_PURE;
G_END_DECLS

View File

@ -15,7 +15,7 @@ void gsk_rounded_rect_to_float (const GskRounde
float rect[12]);
gboolean gsk_rounded_rect_equal (gconstpointer rect1,
gconstpointer rect2);
gconstpointer rect2) G_GNUC_PURE;
char * gsk_rounded_rect_to_string (const GskRoundedRect *self);

View File

@ -109,16 +109,16 @@ union _GtkCssToken {
void gtk_css_token_clear (GtkCssToken *token);
gboolean gtk_css_token_is_finite (const GtkCssToken *token);
gboolean gtk_css_token_is_finite (const GtkCssToken *token) G_GNUC_PURE;
gboolean gtk_css_token_is_preserved (const GtkCssToken *token,
GtkCssTokenType *out_closing);
GtkCssTokenType *out_closing) G_GNUC_PURE;
#define gtk_css_token_is(token, _type) ((token)->type == (_type))
gboolean gtk_css_token_is_ident (const GtkCssToken *token,
const char *ident);
const char *ident) G_GNUC_PURE;
gboolean gtk_css_token_is_function (const GtkCssToken *token,
const char *ident);
const char *ident) G_GNUC_PURE;
gboolean gtk_css_token_is_delim (const GtkCssToken *token,
gunichar delim);
gunichar delim) G_GNUC_PURE;
void gtk_css_token_print (const GtkCssToken *token,
GString *string);

View File

@ -299,7 +299,7 @@ gtk_css_value_array_transition (GtkCssValue *start,
}
static gboolean
gtk_css_value_array_is_dynamic (GtkCssValue *value)
gtk_css_value_array_is_dynamic (const GtkCssValue *value)
{
guint i;

View File

@ -34,7 +34,7 @@ GtkCssValue * _gtk_css_array_value_parse (GtkCssParser *
GtkCssValue * _gtk_css_array_value_get_nth (GtkCssValue *value,
guint i);
guint _gtk_css_array_value_get_n_values (const GtkCssValue *value);
guint _gtk_css_array_value_get_n_values (const GtkCssValue *value) G_GNUC_PURE;
G_END_DECLS

View File

@ -24,18 +24,18 @@
G_BEGIN_DECLS
GtkCssValue * gtk_css_color_value_new_transparent (void);
GtkCssValue * gtk_css_color_value_new_white (void);
GtkCssValue * _gtk_css_color_value_new_literal (const GdkRGBA *color);
GtkCssValue * _gtk_css_color_value_new_name (const gchar *name);
GtkCssValue * gtk_css_color_value_new_transparent (void) G_GNUC_PURE;
GtkCssValue * gtk_css_color_value_new_white (void) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_literal (const GdkRGBA *color) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_name (const gchar *name) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_shade (GtkCssValue *color,
gdouble factor);
gdouble factor) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_alpha (GtkCssValue *color,
gdouble factor);
gdouble factor) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_mix (GtkCssValue *color1,
GtkCssValue *color2,
gdouble factor);
GtkCssValue * _gtk_css_color_value_new_current_color (void);
gdouble factor) G_GNUC_PURE;
GtkCssValue * _gtk_css_color_value_new_current_color (void) G_GNUC_PURE;
gboolean gtk_css_color_value_can_parse (GtkCssParser *parser);
GtkCssValue * _gtk_css_color_value_parse (GtkCssParser *parser);
@ -44,7 +44,7 @@ GtkCssValue * _gtk_css_color_value_resolve (GtkCssValue *color
GtkStyleProvider *provider,
GtkCssValue *current,
GSList *cycle_list);
const GdkRGBA * gtk_css_color_value_get_rgba (const GtkCssValue *color);
const GdkRGBA * gtk_css_color_value_get_rgba (const GtkCssValue *color) G_GNUC_CONST;
G_END_DECLS

View File

@ -30,9 +30,9 @@ GtkCssValue * _gtk_css_corner_value_new (GtkCssValue *x,
GtkCssValue * _gtk_css_corner_value_parse (GtkCssParser *parser);
double _gtk_css_corner_value_get_x (const GtkCssValue *corner,
double one_hundred_percent);
double one_hundred_percent) G_GNUC_PURE;
double _gtk_css_corner_value_get_y (const GtkCssValue *corner,
double one_hundred_percent);
double one_hundred_percent) G_GNUC_PURE;
G_END_DECLS

View File

@ -97,9 +97,9 @@ GType _gtk_css_image_get_type (void) G_GNUC_CONST;
gboolean _gtk_css_image_can_parse (GtkCssParser *parser);
GtkCssImage * _gtk_css_image_new_parse (GtkCssParser *parser);
int _gtk_css_image_get_width (GtkCssImage *image);
int _gtk_css_image_get_height (GtkCssImage *image);
double _gtk_css_image_get_aspect_ratio (GtkCssImage *image);
int _gtk_css_image_get_width (GtkCssImage *image) G_GNUC_PURE;
int _gtk_css_image_get_height (GtkCssImage *image) G_GNUC_PURE;
double _gtk_css_image_get_aspect_ratio (GtkCssImage *image) G_GNUC_PURE;
GtkCssImage * _gtk_css_image_compute (GtkCssImage *image,
guint property_id,
@ -107,7 +107,7 @@ GtkCssImage * _gtk_css_image_compute (GtkCssImage *
GtkCssStyle *style,
GtkCssStyle *parent_style);
gboolean _gtk_css_image_equal (GtkCssImage *image1,
GtkCssImage *image2);
GtkCssImage *image2) G_GNUC_PURE;
GtkCssImage * _gtk_css_image_transition (GtkCssImage *start,
GtkCssImage *end,
guint property_id,
@ -121,8 +121,8 @@ void gtk_css_image_snapshot (GtkCssImage *
GtkSnapshot *snapshot,
double width,
double height);
gboolean gtk_css_image_is_invalid (GtkCssImage *image);
gboolean gtk_css_image_is_dynamic (GtkCssImage *image);
gboolean gtk_css_image_is_invalid (GtkCssImage *image) G_GNUC_PURE;
gboolean gtk_css_image_is_dynamic (GtkCssImage *image) G_GNUC_PURE;
GtkCssImage * gtk_css_image_get_dynamic_image (GtkCssImage *image,
gint64 monotonic_time);
void _gtk_css_image_print (GtkCssImage *image,
@ -141,7 +141,7 @@ cairo_surface_t *
cairo_surface_t *target,
int surface_width,
int surface_height);
gboolean gtk_css_image_is_computed (GtkCssImage *image);
gboolean gtk_css_image_is_computed (GtkCssImage *image) G_GNUC_PURE;
G_END_DECLS

View File

@ -82,7 +82,7 @@ gtk_css_value_image_transition (GtkCssValue *start,
}
static gboolean
gtk_css_value_image_is_dynamic (GtkCssValue *value)
gtk_css_value_image_is_dynamic (const GtkCssValue *value)
{
GtkCssImage *image = _gtk_css_image_value_get_image (value);

View File

@ -41,7 +41,7 @@ GtkCssKeyframes * _gtk_css_keyframes_compute (GtkCssKeyframes
GtkCssStyle *style,
GtkCssStyle *parent_style);
guint _gtk_css_keyframes_get_n_properties (GtkCssKeyframes *keyframes);
guint _gtk_css_keyframes_get_n_properties (GtkCssKeyframes *keyframes) G_GNUC_PURE;
guint _gtk_css_keyframes_get_property_id (GtkCssKeyframes *keyframes,
guint id);
GtkCssValue * _gtk_css_keyframes_get_value (GtkCssKeyframes *keyframes,

View File

@ -46,8 +46,8 @@ void gtk_css_shadow_value_snapshot_inset (const GtkCssValue
GtkSnapshot *snapshot,
const GskRoundedRect *padding_box);
gboolean gtk_css_shadow_value_is_clear (const GtkCssValue *shadow);
gboolean gtk_css_shadow_value_is_none (const GtkCssValue *shadow);
gboolean gtk_css_shadow_value_is_clear (const GtkCssValue *shadow) G_GNUC_PURE;
gboolean gtk_css_shadow_value_is_none (const GtkCssValue *shadow) G_GNUC_PURE;
gboolean gtk_css_shadow_value_push_snapshot (const GtkCssValue *value,
GtkSnapshot *snapshot);

View File

@ -67,7 +67,7 @@ GType _gtk_css_shorthand_property_get_type (void) G
GtkCssStyleProperty * _gtk_css_shorthand_property_get_subproperty (GtkCssShorthandProperty *shorthand,
guint property);
guint _gtk_css_shorthand_property_get_n_subproperties (GtkCssShorthandProperty *shorthand);
guint _gtk_css_shorthand_property_get_n_subproperties (GtkCssShorthandProperty *shorthand) G_GNUC_CONST;
G_END_DECLS

View File

@ -64,7 +64,7 @@ GType _gtk_css_style_property_get_type (void) G_GNUC_CO
void _gtk_css_style_property_init_properties (void);
guint _gtk_css_style_property_get_n_properties(void);
guint _gtk_css_style_property_get_n_properties(void) G_GNUC_CONST;
GtkCssStyleProperty * _gtk_css_style_property_lookup_by_id (guint id);
gboolean _gtk_css_style_property_is_inherit (GtkCssStyleProperty *property);

View File

@ -329,7 +329,7 @@ _gtk_css_value_print (const GtkCssValue *value,
* Returns %TRUE if the value is dynamic
*/
gboolean
gtk_css_value_is_dynamic (GtkCssValue *value)
gtk_css_value_is_dynamic (const GtkCssValue *value)
{
gtk_internal_return_val_if_fail (value != NULL, FALSE);

View File

@ -55,7 +55,7 @@ struct _GtkCssValueClass {
GtkCssValue *end,
guint property_id,
double progress);
gboolean (* is_dynamic) (GtkCssValue *value);
gboolean (* is_dynamic) (const GtkCssValue *value);
GtkCssValue * (* get_dynamic_value) (GtkCssValue *value,
gint64 monotonic_time);
void (* print) (const GtkCssValue *value,
@ -77,16 +77,16 @@ GtkCssValue *_gtk_css_value_compute (GtkCssValue
guint property_id,
GtkStyleProvider *provider,
GtkCssStyle *style,
GtkCssStyle *parent_style);
GtkCssStyle *parent_style) G_GNUC_PURE;
gboolean _gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2);
const GtkCssValue *value2) G_GNUC_PURE;
gboolean _gtk_css_value_equal0 (const GtkCssValue *value1,
const GtkCssValue *value2);
const GtkCssValue *value2) G_GNUC_PURE;
GtkCssValue *_gtk_css_value_transition (GtkCssValue *start,
GtkCssValue *end,
guint property_id,
double progress);
gboolean gtk_css_value_is_dynamic (GtkCssValue *value);
gboolean gtk_css_value_is_dynamic (const GtkCssValue *value) G_GNUC_PURE;
GtkCssValue * gtk_css_value_get_dynamic_value (GtkCssValue *value,
gint64 monotonic_time);