[librsvg/rustification] Use a new rsvg_node_type() function throughout instead of an RSVG_NODE_TYPE() macro



commit a49f8d38acc51e094a6dc24efd6ff12f6db6871e
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Nov 22 16:20:00 2016 -0600

    Use a new rsvg_node_type() function throughout instead of an RSVG_NODE_TYPE() macro

 rsvg-base.c         |   20 +++++++++++++-------
 rsvg-cairo-draw.c   |    8 ++++----
 rsvg-filter.c       |   10 +++++-----
 rsvg-paint-server.c |   24 ++++++++++++------------
 rsvg-private.h      |    3 ++-
 rsvg-shapes.c       |    2 +-
 rsvg-structure.c    |    2 +-
 rsvg-text.c         |    4 ++--
 8 files changed, 40 insertions(+), 33 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 186550f..2d1b379 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -388,7 +388,7 @@ node_set_atts (RsvgNode * node, RsvgHandle * ctx, const NodeCreator *creator, Rs
          * attributes until the end, when rsvg_end_element() calls
          * _rsvg_node_svg_apply_atts()
          */
-        if (RSVG_NODE_TYPE (node) != RSVG_NODE_TYPE_SVG) {
+        if (rsvg_node_type (node) != RSVG_NODE_TYPE_SVG) {
             id = rsvg_property_bag_lookup (atts, "id");
 
             if (creator->supports_class_attribute)
@@ -414,7 +414,7 @@ rsvg_standard_element_start (RsvgHandle * ctx, const char *name, RsvgPropertyBag
     newnode = creator->create_fn (name);
 
     if (newnode) {
-        g_assert (RSVG_NODE_TYPE (newnode) != RSVG_NODE_TYPE_INVALID);
+        g_assert (rsvg_node_type (newnode) != RSVG_NODE_TYPE_INVALID);
 
         push_element_name (ctx, name);
 
@@ -423,7 +423,7 @@ rsvg_standard_element_start (RsvgHandle * ctx, const char *name, RsvgPropertyBag
 
         if (ctx->priv->currentnode) {
             rsvg_node_add_child (ctx->priv->currentnode, newnode);
-        } else if (RSVG_NODE_TYPE (newnode) == RSVG_NODE_TYPE_SVG) {
+        } else if (rsvg_node_type (newnode) == RSVG_NODE_TYPE_SVG) {
             ctx->priv->treebase = newnode;
         }
 
@@ -433,6 +433,12 @@ rsvg_standard_element_start (RsvgHandle * ctx, const char *name, RsvgPropertyBag
     }
 }
 
+RsvgNodeType
+rsvg_node_type (RsvgNode *node)
+{
+    return node->type;
+}
+
 RsvgState *
 rsvg_node_get_state (RsvgNode *node)
 {
@@ -911,9 +917,9 @@ find_last_chars_node (RsvgNode *node, gpointer data)
 
     dest = data;
 
-    if (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_CHARS) {
+    if (rsvg_node_type (node) == RSVG_NODE_TYPE_CHARS) {
         *dest = node;
-    } else if (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_TSPAN) {
+    } else if (rsvg_node_type (node) == RSVG_NODE_TYPE_TSPAN) {
         *dest = NULL;
     }
 
@@ -929,7 +935,7 @@ rsvg_characters_impl (RsvgHandle * ctx, const xmlChar * ch, int len)
         return;
 
     if (ctx->priv->currentnode) {
-        RsvgNodeType type = RSVG_NODE_TYPE (ctx->priv->currentnode);
+        RsvgNodeType type = rsvg_node_type (ctx->priv->currentnode);
         if (type == RSVG_NODE_TYPE_TSPAN || type == RSVG_NODE_TYPE_TEXT) {
             /* find the last CHARS node in the text or tspan node, so that we
                can coalesce the text, and thus avoid screwing up the Pango layouts */
@@ -2264,7 +2270,7 @@ rsvg_acquire_node_of_type (RsvgDrawingCtx * ctx, const char *url, RsvgNodeType t
     RsvgNode *node;
 
     node = rsvg_acquire_node (ctx, url);
-    if (node == NULL || RSVG_NODE_TYPE (node) != type) {
+    if (node == NULL || rsvg_node_type (node) != type) {
         rsvg_release_node (ctx, node);
         return NULL;
     }
diff --git a/rsvg-cairo-draw.c b/rsvg-cairo-draw.c
index e4995a1..a8f685e 100644
--- a/rsvg-cairo-draw.c
+++ b/rsvg-cairo-draw.c
@@ -63,7 +63,7 @@ add_color_stops_for_gradient (cairo_pattern_t * pattern,
 
     for (i = 0; i < stops->len; i++) {
         node = (RsvgNode *) g_ptr_array_index (stops, i);
-        if (RSVG_NODE_TYPE (node) != RSVG_NODE_TYPE_STOP)
+        if (rsvg_node_type (node) != RSVG_NODE_TYPE_STOP)
             continue;
 
         stop = (RsvgGradientStop *) node;
@@ -428,11 +428,11 @@ _set_source_rsvg_paint_server (RsvgDrawingCtx * ctx,
         node = rsvg_acquire_node (ctx, ps->core.iri);
         if (node == NULL)
             break;
-        else if (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_LINEAR_GRADIENT)
+        else if (rsvg_node_type (node) == RSVG_NODE_TYPE_LINEAR_GRADIENT)
             _set_source_rsvg_linear_gradient (ctx, (RsvgLinearGradient *) node, opacity, bbox);
-        else if (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_RADIAL_GRADIENT)
+        else if (rsvg_node_type (node) == RSVG_NODE_TYPE_RADIAL_GRADIENT)
             _set_source_rsvg_radial_gradient (ctx, (RsvgRadialGradient *) node, opacity, bbox);
-        else if (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_PATTERN)
+        else if (rsvg_node_type (node) == RSVG_NODE_TYPE_PATTERN)
             _set_source_rsvg_pattern (ctx, (RsvgPattern *) node, opacity, bbox);
 
         rsvg_release_node (ctx, node);
diff --git a/rsvg-filter.c b/rsvg-filter.c
index d0d8010..3d7b4c6 100644
--- a/rsvg-filter.c
+++ b/rsvg-filter.c
@@ -539,7 +539,7 @@ rsvg_filter_context_free (RsvgFilterContext * ctx)
 static gboolean
 node_is_filter_primitive (RsvgNode *node)
 {
-    RsvgNodeType type = RSVG_NODE_TYPE (node);
+    RsvgNodeType type = rsvg_node_type (node);
 
     return type > RSVG_NODE_TYPE_FILTER_PRIMITIVE_FIRST && type < RSVG_NODE_TYPE_FILTER_PRIMITIVE_LAST;
 }
@@ -2115,7 +2115,7 @@ rsvg_filter_primitive_merge_render (RsvgFilterPrimitive * self, RsvgFilterContex
     for (i = 0; i < upself->super.super.children->len; i++) {
         RsvgFilterPrimitive *mn;
         mn = g_ptr_array_index (upself->super.super.children, i);
-        if (RSVG_NODE_TYPE (&mn->super) != RSVG_NODE_TYPE_FILTER_PRIMITIVE_MERGE_NODE)
+        if (rsvg_node_type (&mn->super) != RSVG_NODE_TYPE_FILTER_PRIMITIVE_MERGE_NODE)
             continue;
         in = rsvg_filter_get_in (mn->in, ctx);
         if (in == NULL)
@@ -2566,7 +2566,7 @@ rsvg_filter_primitive_component_transfer_render (RsvgFilterPrimitive *
             RsvgNode *child_node;
 
             child_node = (RsvgNode *) g_ptr_array_index (self->super.children, i);
-            if (RSVG_NODE_TYPE (child_node) == RSVG_NODE_TYPE_COMPONENT_TRANFER_FUNCTION) {
+            if (rsvg_node_type (child_node) == RSVG_NODE_TYPE_COMPONENT_TRANFER_FUNCTION) {
                 RsvgNodeComponentTransferFunc *temp = (RsvgNodeComponentTransferFunc *) child_node;
 
                 if (temp->channel == channel) {
@@ -4406,7 +4406,7 @@ rsvg_filter_primitive_diffuse_lighting_render (RsvgFilterPrimitive * self, RsvgF
         RsvgNode *temp;
 
         temp = g_ptr_array_index (self->super.children, i);
-        if (RSVG_NODE_TYPE (temp) == RSVG_NODE_TYPE_LIGHT_SOURCE) {
+        if (rsvg_node_type (temp) == RSVG_NODE_TYPE_LIGHT_SOURCE) {
             source = (RsvgNodeLightSource *) temp;
         }
     }
@@ -4569,7 +4569,7 @@ rsvg_filter_primitive_specular_lighting_render (RsvgFilterPrimitive * self, Rsvg
     for (i = 0; i < self->super.children->len; i++) {
         RsvgNode *temp;
         temp = g_ptr_array_index (self->super.children, i);
-        if (RSVG_NODE_TYPE (temp) == RSVG_NODE_TYPE_LIGHT_SOURCE) {
+        if (rsvg_node_type (temp) == RSVG_NODE_TYPE_LIGHT_SOURCE) {
             source = (RsvgNodeLightSource *) temp;
         }
     }
diff --git a/rsvg-paint-server.c b/rsvg-paint-server.c
index e5477c9..4af5fa0 100644
--- a/rsvg-paint-server.c
+++ b/rsvg-paint-server.c
@@ -474,7 +474,7 @@ hasstop (GPtrArray * lookin)
     unsigned int i;
     for (i = 0; i < lookin->len; i++) {
         RsvgNode *node = g_ptr_array_index (lookin, i);
-        if (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_STOP)
+        if (rsvg_node_type (node) == RSVG_NODE_TYPE_STOP)
             return 1;
     }
     return 0;
@@ -515,10 +515,10 @@ resolve_fallbacks (RsvgDrawingCtx *ctx,
 static const char *
 gradient_get_fallback (RsvgNode *node)
 {
-    if (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_LINEAR_GRADIENT) {
+    if (rsvg_node_type (node) == RSVG_NODE_TYPE_LINEAR_GRADIENT) {
         RsvgLinearGradient *g = (RsvgLinearGradient *) node;
         return g->fallback;
-    } else if (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_RADIAL_GRADIENT) {
+    } else if (rsvg_node_type (node) == RSVG_NODE_TYPE_RADIAL_GRADIENT) {
         RsvgRadialGradient *g = (RsvgRadialGradient *) node;
         return g->fallback;
     } else
@@ -530,10 +530,10 @@ linear_gradient_apply_fallback (RsvgNode *node, RsvgNode *fallback_node)
 {
     RsvgLinearGradient *grad;
 
-    g_assert (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_LINEAR_GRADIENT);
+    g_assert (rsvg_node_type (node) == RSVG_NODE_TYPE_LINEAR_GRADIENT);
     grad = (RsvgLinearGradient *) node;
 
-    if (RSVG_NODE_TYPE (fallback_node) == RSVG_NODE_TYPE_LINEAR_GRADIENT) {
+    if (rsvg_node_type (fallback_node) == RSVG_NODE_TYPE_LINEAR_GRADIENT) {
         RsvgLinearGradient *fallback = (RsvgLinearGradient *) fallback_node;
 
         if (!grad->hasx1 && fallback->hasx1) {
@@ -567,7 +567,7 @@ linear_gradient_apply_fallback (RsvgNode *node, RsvgNode *fallback_node)
         if (!hasstop (grad->super.children) && hasstop (fallback->super.children)) {
             grad->super.children = fallback->super.children;
         }
-    } else if (RSVG_NODE_TYPE (fallback_node) == RSVG_NODE_TYPE_RADIAL_GRADIENT) {
+    } else if (rsvg_node_type (fallback_node) == RSVG_NODE_TYPE_RADIAL_GRADIENT) {
         RsvgRadialGradient *fallback = (RsvgRadialGradient *) fallback_node;
 
         if (!grad->hastransform && fallback->hastransform) {
@@ -603,10 +603,10 @@ radial_gradient_apply_fallback (RsvgNode *node, RsvgNode *fallback_node)
 {
     RsvgRadialGradient *grad;
 
-    g_assert (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_RADIAL_GRADIENT);
+    g_assert (rsvg_node_type (node) == RSVG_NODE_TYPE_RADIAL_GRADIENT);
     grad = (RsvgRadialGradient *) node;
 
-    if (RSVG_NODE_TYPE (fallback_node) == RSVG_NODE_TYPE_RADIAL_GRADIENT) {
+    if (rsvg_node_type (fallback_node) == RSVG_NODE_TYPE_RADIAL_GRADIENT) {
         RsvgRadialGradient *fallback = (RsvgRadialGradient *) fallback_node;
 
         if (!grad->hascx && fallback->hascx) {
@@ -644,7 +644,7 @@ radial_gradient_apply_fallback (RsvgNode *node, RsvgNode *fallback_node)
         if (!hasstop (grad->super.children) && hasstop (fallback->super.children)) {
             grad->super.children = fallback->super.children;
         }
-    } else if (RSVG_NODE_TYPE (fallback_node) == RSVG_NODE_TYPE_LINEAR_GRADIENT) {
+    } else if (rsvg_node_type (fallback_node) == RSVG_NODE_TYPE_LINEAR_GRADIENT) {
         RsvgLinearGradient *fallback = (RsvgLinearGradient *) fallback_node;
 
         if (!grad->hastransform && fallback->hastransform) {
@@ -678,7 +678,7 @@ rsvg_radial_gradient_fix_fallback (RsvgDrawingCtx *ctx, RsvgRadialGradient * gra
 static const char *
 pattern_get_fallback (RsvgNode *node)
 {
-    if (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_PATTERN) {
+    if (rsvg_node_type (node) == RSVG_NODE_TYPE_PATTERN) {
         RsvgPattern *pattern = (RsvgPattern *) node;
 
         return pattern->fallback;
@@ -692,9 +692,9 @@ pattern_apply_fallback (RsvgNode *pattern_node, RsvgNode *fallback_node)
     RsvgPattern *pattern;
     RsvgPattern *fallback;
 
-    g_assert (RSVG_NODE_TYPE (pattern_node) == RSVG_NODE_TYPE_PATTERN);
+    g_assert (rsvg_node_type (pattern_node) == RSVG_NODE_TYPE_PATTERN);
 
-    if (RSVG_NODE_TYPE (fallback_node) != RSVG_NODE_TYPE_PATTERN)
+    if (rsvg_node_type (fallback_node) != RSVG_NODE_TYPE_PATTERN)
         return;
 
     pattern = (RsvgPattern *) pattern_node;
diff --git a/rsvg-private.h b/rsvg-private.h
index 313433b..a833311 100644
--- a/rsvg-private.h
+++ b/rsvg-private.h
@@ -338,7 +338,8 @@ struct _RsvgNode {
     void (*set_atts) (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag *);
 };
 
-#define RSVG_NODE_TYPE(node)                ((node)->type)
+G_GNUC_INTERNAL
+RsvgNodeType rsvg_node_type (RsvgNode *node);
 
 G_GNUC_INTERNAL
 RsvgState *rsvg_node_get_state (RsvgNode *node);
diff --git a/rsvg-shapes.c b/rsvg-shapes.c
index 9e69726..277625a 100644
--- a/rsvg-shapes.c
+++ b/rsvg-shapes.c
@@ -120,7 +120,7 @@ _rsvg_node_poly_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
         if (poly->builder)
             rsvg_path_builder_destroy (poly->builder);
         poly->builder = _rsvg_node_poly_create_builder (value,
-                                                        RSVG_NODE_TYPE (self) == RSVG_NODE_TYPE_POLYGON);
+                                                        rsvg_node_type (self) == RSVG_NODE_TYPE_POLYGON);
     }
 }
 
diff --git a/rsvg-structure.c b/rsvg-structure.c
index a3f5b80..049a181 100644
--- a/rsvg-structure.c
+++ b/rsvg-structure.c
@@ -189,7 +189,7 @@ rsvg_node_use_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
     }
 
     state = rsvg_current_state (ctx);
-    if (RSVG_NODE_TYPE (child) != RSVG_NODE_TYPE_SYMBOL) {
+    if (rsvg_node_type (child) != RSVG_NODE_TYPE_SYMBOL) {
         cairo_matrix_init_translate (&affine, x, y);
         cairo_matrix_multiply (&state->affine, &affine, &state->affine);
 
diff --git a/rsvg-text.c b/rsvg-text.c
index 79b0c9a..dc4e2f5 100644
--- a/rsvg-text.c
+++ b/rsvg-text.c
@@ -183,7 +183,7 @@ static gboolean
 draw_text_child (RsvgNode *node, gpointer data)
 {
     DrawTextClosure *closure;
-    RsvgNodeType type = RSVG_NODE_TYPE (node);
+    RsvgNodeType type = rsvg_node_type (node);
 
     closure = data;
 
@@ -276,7 +276,7 @@ static gboolean
 compute_child_length (RsvgNode *node, gpointer data)
 {
     ChildrenLengthClosure *closure;
-    RsvgNodeType type = RSVG_NODE_TYPE (node);
+    RsvgNodeType type = rsvg_node_type (node);
     gboolean done;
 
     closure = data;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]