[librsvg/rustification] Dispatch creation of new nodes from an array of element names, not a chain of strcmp()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustification] Dispatch creation of new nodes from an array of element names, not a chain of strcmp()
- Date: Thu, 17 Nov 2016 21:36:51 +0000 (UTC)
commit 4b22ec83e3567fde973aafccbf102bb404d2d6f0
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Nov 17 15:27:32 2016 -0600
Dispatch creation of new nodes from an array of element names, not a chain of strcmp()
Also, the rsvg_new_SOME_NODE_TYPE () constructor functions now take the
element name.
This lets us:
* Use bsearch() on the sorted array of element names, instead of an
unordered chain of if (strcmp (...)). We can replace this later with
something better like a trie.
* Port things to Rust more easily, since the constructor functions can
dispatch on their own based on the element name.
* Avoid special cases in the way
rsvg_new_node_component_transfer_function() and
rsvg_new_node_light_source() are called; now they dispatch on their
own based on the element name.
rsvg-base.c | 221 +++++++++++++++++++++++++--------------------------
rsvg-filter.c | 65 ++++++++++------
rsvg-filter.h | 40 +++++-----
rsvg-image.c | 2 +-
rsvg-image.h | 2 +-
rsvg-marker.c | 2 +-
rsvg-marker.h | 2 +-
rsvg-mask.c | 4 +-
rsvg-mask.h | 4 +-
rsvg-paint-server.c | 8 +-
rsvg-paint-server.h | 8 +-
rsvg-shapes.c | 14 ++--
rsvg-shapes.h | 14 ++--
rsvg-structure.c | 12 ++--
rsvg-structure.h | 12 ++--
rsvg-text.c | 6 +-
rsvg-text.h | 6 +-
rust/src/lib.rs | 1 +
18 files changed, 218 insertions(+), 205 deletions(-)
---
diff --git a/rsvg-base.c b/rsvg-base.c
index 0008673..dcebbbc 100644
--- a/rsvg-base.c
+++ b/rsvg-base.c
@@ -247,125 +247,118 @@ node_set_atts (RsvgNode * node, RsvgHandle * ctx, RsvgPropertyBag * atts)
}
}
+typedef RsvgNode *(* CreateNodeFn) (const char *element_name);
+
+typedef struct {
+ const char *element_name;
+ CreateNodeFn create_fn;
+} NodeCreator;
+
+/* Keep these sorted by element_name! */
+static const NodeCreator node_creators[] = {
+ { "a", rsvg_new_group }, /* treat anchors as groups for now */
+ { "circle", rsvg_new_circle },
+ { "clipPath", rsvg_new_clip_path },
+ { "conicalGradient", rsvg_new_radial_gradient },
+ { "defs", rsvg_new_defs },
+ { "ellipse", rsvg_new_ellipse },
+ { "feBlend", rsvg_new_filter_primitive_blend },
+ { "feColorMatrix", rsvg_new_filter_primitive_color_matrix },
+ { "feComponentTransfer", rsvg_new_filter_primitive_component_transfer },
+ { "feComposite", rsvg_new_filter_primitive_composite },
+ { "feConvolveMatrix", rsvg_new_filter_primitive_convolve_matrix },
+ { "feDiffuseLighting", rsvg_new_filter_primitive_diffuse_lighting },
+ { "feDisplacementMap", rsvg_new_filter_primitive_displacement_map },
+ { "feDistantLight", rsvg_new_node_light_source },
+ { "feFlood", rsvg_new_filter_primitive_flood },
+ { "feFuncA", rsvg_new_node_component_transfer_function },
+ { "feFuncB", rsvg_new_node_component_transfer_function },
+ { "feFuncG", rsvg_new_node_component_transfer_function },
+ { "feFuncR", rsvg_new_node_component_transfer_function },
+ { "feGaussianBlur", rsvg_new_filter_primitive_gaussian_blur },
+ { "feImage", rsvg_new_filter_primitive_image },
+ { "feMerge", rsvg_new_filter_primitive_merge },
+ { "feMergeNode", rsvg_new_filter_primitive_merge_node },
+ { "feMorphology", rsvg_new_filter_primitive_erode },
+ { "feOffset", rsvg_new_filter_primitive_offset },
+ { "fePointLight", rsvg_new_node_light_source },
+ { "feSpecularLighting", rsvg_new_filter_primitive_specular_lighting },
+ { "feSpotLight", rsvg_new_node_light_source },
+ { "feTile", rsvg_new_filter_primitive_tile },
+ { "feTurbulence", rsvg_new_filter_primitive_turbulence },
+ { "filter", rsvg_new_filter },
+ { "g", rsvg_new_group },
+ { "image", rsvg_new_image },
+ { "line", rsvg_new_line },
+ { "linearGradient", rsvg_new_linear_gradient },
+ { "marker", rsvg_new_marker },
+ { "mask", rsvg_new_mask },
+ { "multiImage", rsvg_new_switch }, /* hack to make multiImage sort-of work */
+ { "path", rsvg_new_path },
+ { "pattern", rsvg_new_pattern },
+ { "polygon", rsvg_new_polygon },
+ { "polyline", rsvg_new_polyline },
+ { "radialGradient", rsvg_new_radial_gradient },
+ { "rect", rsvg_new_rect },
+ { "stop", rsvg_new_stop },
+ { "subImage", rsvg_new_group },
+ { "subImageRef", rsvg_new_image },
+ { "svg", rsvg_new_svg },
+ { "switch", rsvg_new_switch },
+ { "symbol", rsvg_new_symbol },
+ { "text", rsvg_new_text },
+ { "tref", rsvg_new_tref },
+ { "tspan", rsvg_new_tspan },
+ { "use", rsvg_new_use },
+};
+
+/* hack for bug 401115. whenever we encounter a node we don't understand, push it into a group.
+ * this will allow us to handle things like conditionals properly.
+ */
+static const NodeCreator default_node_creator = { NULL, rsvg_new_group };
+
+/* Used from bsearch() */
+static int
+compare_node_creators_fn (const void *a, const void *b)
+{
+ const NodeCreator *na = a;
+ const NodeCreator *nb = b;
+
+ return strcmp (na->element_name, nb->element_name);
+}
+
+static const NodeCreator *
+get_node_creator_for_element_name (const char *name)
+{
+ NodeCreator key;
+ const NodeCreator *result;
+
+ key.element_name = name;
+ key.create_fn = NULL;
+
+ result = bsearch (&key,
+ node_creators,
+ G_N_ELEMENTS (node_creators),
+ sizeof (NodeCreator),
+ compare_node_creators_fn);
+
+ if (result == NULL)
+ result = &default_node_creator;
+
+ return result;
+}
+
static void
rsvg_standard_element_start (RsvgHandle * ctx, const char *name, RsvgPropertyBag * atts)
{
/*replace this stuff with a hash for fast reading! */
+ const NodeCreator *creator;
RsvgNode *newnode = NULL;
- if (!strcmp (name, "g"))
- newnode = rsvg_new_group ();
- else if (!strcmp (name, "a")) /*treat anchors as groups for now */
- newnode = rsvg_new_group ();
- else if (!strcmp (name, "switch"))
- newnode = rsvg_new_switch ();
- else if (!strcmp (name, "defs"))
- newnode = rsvg_new_defs ();
- else if (!strcmp (name, "use"))
- newnode = rsvg_new_use ();
- else if (!strcmp (name, "path"))
- newnode = rsvg_new_path ();
- else if (!strcmp (name, "line"))
- newnode = rsvg_new_line ();
- else if (!strcmp (name, "rect"))
- newnode = rsvg_new_rect ();
- else if (!strcmp (name, "ellipse"))
- newnode = rsvg_new_ellipse ();
- else if (!strcmp (name, "circle"))
- newnode = rsvg_new_circle ();
- else if (!strcmp (name, "polygon"))
- newnode = rsvg_new_polygon ();
- else if (!strcmp (name, "polyline"))
- newnode = rsvg_new_polyline ();
- else if (!strcmp (name, "symbol"))
- newnode = rsvg_new_symbol ();
- else if (!strcmp (name, "svg"))
- newnode = rsvg_new_svg ();
- else if (!strcmp (name, "mask"))
- newnode = rsvg_new_mask ();
- else if (!strcmp (name, "clipPath"))
- newnode = rsvg_new_clip_path ();
- else if (!strcmp (name, "image"))
- newnode = rsvg_new_image ();
- else if (!strcmp (name, "marker"))
- newnode = rsvg_new_marker ();
- else if (!strcmp (name, "stop"))
- newnode = rsvg_new_stop ();
- else if (!strcmp (name, "pattern"))
- newnode = rsvg_new_pattern ();
- else if (!strcmp (name, "linearGradient"))
- newnode = rsvg_new_linear_gradient ();
- else if (!strcmp (name, "radialGradient"))
- newnode = rsvg_new_radial_gradient ();
- else if (!strcmp (name, "conicalGradient"))
- newnode = rsvg_new_radial_gradient ();
- else if (!strcmp (name, "filter"))
- newnode = rsvg_new_filter ();
- else if (!strcmp (name, "feBlend"))
- newnode = rsvg_new_filter_primitive_blend ();
- else if (!strcmp (name, "feColorMatrix"))
- newnode = rsvg_new_filter_primitive_color_matrix ();
- else if (!strcmp (name, "feComponentTransfer"))
- newnode = rsvg_new_filter_primitive_component_transfer ();
- else if (!strcmp (name, "feComposite"))
- newnode = rsvg_new_filter_primitive_composite ();
- else if (!strcmp (name, "feConvolveMatrix"))
- newnode = rsvg_new_filter_primitive_convolve_matrix ();
- else if (!strcmp (name, "feDiffuseLighting"))
- newnode = rsvg_new_filter_primitive_diffuse_lighting ();
- else if (!strcmp (name, "feDisplacementMap"))
- newnode = rsvg_new_filter_primitive_displacement_map ();
- else if (!strcmp (name, "feFlood"))
- newnode = rsvg_new_filter_primitive_flood ();
- else if (!strcmp (name, "feGaussianBlur"))
- newnode = rsvg_new_filter_primitive_gaussian_blur ();
- else if (!strcmp (name, "feImage"))
- newnode = rsvg_new_filter_primitive_image ();
- else if (!strcmp (name, "feMerge"))
- newnode = rsvg_new_filter_primitive_merge ();
- else if (!strcmp (name, "feMorphology"))
- newnode = rsvg_new_filter_primitive_erode ();
- else if (!strcmp (name, "feOffset"))
- newnode = rsvg_new_filter_primitive_offset ();
- else if (!strcmp (name, "feSpecularLighting"))
- newnode = rsvg_new_filter_primitive_specular_lighting ();
- else if (!strcmp (name, "feTile"))
- newnode = rsvg_new_filter_primitive_tile ();
- else if (!strcmp (name, "feTurbulence"))
- newnode = rsvg_new_filter_primitive_turbulence ();
- else if (!strcmp (name, "feMergeNode"))
- newnode = rsvg_new_filter_primitive_merge_node ();
- else if (!strcmp (name, "feFuncR"))
- newnode = rsvg_new_node_component_transfer_function ('r'); /* See
rsvg_filter_primitive_component_transfer_render() for where these values are used */
- else if (!strcmp (name, "feFuncG"))
- newnode = rsvg_new_node_component_transfer_function ('g');
- else if (!strcmp (name, "feFuncB"))
- newnode = rsvg_new_node_component_transfer_function ('b');
- else if (!strcmp (name, "feFuncA"))
- newnode = rsvg_new_node_component_transfer_function ('a');
- else if (!strcmp (name, "feDistantLight"))
- newnode = rsvg_new_node_light_source ('d');
- else if (!strcmp (name, "feSpotLight"))
- newnode = rsvg_new_node_light_source ('s');
- else if (!strcmp (name, "fePointLight"))
- newnode = rsvg_new_node_light_source ('p');
- /* hack to make multiImage sort-of work */
- else if (!strcmp (name, "multiImage"))
- newnode = rsvg_new_switch ();
- else if (!strcmp (name, "subImageRef"))
- newnode = rsvg_new_image ();
- else if (!strcmp (name, "subImage"))
- newnode = rsvg_new_group ();
- else if (!strcmp (name, "text"))
- newnode = rsvg_new_text ();
- else if (!strcmp (name, "tspan"))
- newnode = rsvg_new_tspan ();
- else if (!strcmp (name, "tref"))
- newnode = rsvg_new_tref ();
- else {
- /* hack for bug 401115. whenever we encounter a node we don't understand, push it into a
group.
- this will allow us to handle things like conditionals properly. */
- newnode = rsvg_new_group ();
- }
+
+ creator = get_node_creator_for_element_name (name);
+ g_assert (creator != NULL && creator->create_fn != NULL);
+
+ newnode = creator->create_fn (name);
if (newnode) {
g_assert (RSVG_NODE_TYPE (newnode) != RSVG_NODE_TYPE_INVALID);
diff --git a/rsvg-filter.c b/rsvg-filter.c
index df706a3..6fed120 100644
--- a/rsvg-filter.c
+++ b/rsvg-filter.c
@@ -813,7 +813,7 @@ rsvg_filter_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
* Creates a blank filter and assigns default values to everything
**/
RsvgNode *
-rsvg_new_filter (void)
+rsvg_new_filter (const char *element_name)
{
RsvgFilter *filter;
@@ -1045,7 +1045,7 @@ rsvg_filter_primitive_blend_set_atts (RsvgNode * node, RsvgHandle * ctx, RsvgPro
}
RsvgNode *
-rsvg_new_filter_primitive_blend (void)
+rsvg_new_filter_primitive_blend (const char *element_name)
{
RsvgFilterPrimitiveBlend *filter;
filter = g_new0 (RsvgFilterPrimitiveBlend, 1);
@@ -1296,7 +1296,7 @@ rsvg_filter_primitive_convolve_matrix_set_atts (RsvgNode * self,
}
RsvgNode *
-rsvg_new_filter_primitive_convolve_matrix (void)
+rsvg_new_filter_primitive_convolve_matrix (const char *element_name)
{
RsvgFilterPrimitiveConvolveMatrix *filter;
filter = g_new0 (RsvgFilterPrimitiveConvolveMatrix, 1);
@@ -1942,7 +1942,7 @@ rsvg_filter_primitive_gaussian_blur_set_atts (RsvgNode * self,
}
RsvgNode *
-rsvg_new_filter_primitive_gaussian_blur (void)
+rsvg_new_filter_primitive_gaussian_blur (const char *element_name)
{
RsvgFilterPrimitiveGaussianBlur *filter;
filter = g_new0 (RsvgFilterPrimitiveGaussianBlur, 1);
@@ -2062,7 +2062,7 @@ rsvg_filter_primitive_offset_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPr
}
RsvgNode *
-rsvg_new_filter_primitive_offset (void)
+rsvg_new_filter_primitive_offset (const char *element_name)
{
RsvgFilterPrimitiveOffset *filter;
filter = g_new0 (RsvgFilterPrimitiveOffset, 1);
@@ -2149,7 +2149,7 @@ rsvg_filter_primitive_merge_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPro
}
RsvgNode *
-rsvg_new_filter_primitive_merge (void)
+rsvg_new_filter_primitive_merge (const char *element_name)
{
RsvgFilterPrimitiveMerge *filter;
filter = g_new0 (RsvgFilterPrimitiveMerge, 1);
@@ -2191,7 +2191,7 @@ rsvg_filter_primitive_merge_node_render (RsvgFilterPrimitive * self, RsvgFilterC
}
RsvgNode *
-rsvg_new_filter_primitive_merge_node (void)
+rsvg_new_filter_primitive_merge_node (const char *element_name)
{
RsvgFilterPrimitive *filter;
filter = g_new (RsvgFilterPrimitive, 1);
@@ -2425,7 +2425,7 @@ rsvg_filter_primitive_color_matrix_set_atts (RsvgNode * self, RsvgHandle * ctx,
}
RsvgNode *
-rsvg_new_filter_primitive_color_matrix (void)
+rsvg_new_filter_primitive_color_matrix (const char *element_name)
{
RsvgFilterPrimitiveColorMatrix *filter;
filter = g_new0 (RsvgFilterPrimitiveColorMatrix, 1);
@@ -2647,7 +2647,7 @@ rsvg_filter_primitive_component_transfer_set_atts (RsvgNode * self, RsvgHandle *
}
RsvgNode *
-rsvg_new_filter_primitive_component_transfer (void)
+rsvg_new_filter_primitive_component_transfer (const char *element_name)
{
RsvgFilterPrimitiveComponentTransfer *filter;
@@ -2716,9 +2716,23 @@ rsvg_component_transfer_function_free (RsvgNode * self)
}
RsvgNode *
-rsvg_new_node_component_transfer_function (char channel)
+rsvg_new_node_component_transfer_function (const char *element_name)
{
RsvgNodeComponentTransferFunc *filter;
+ char channel;
+
+ if (strcmp (element_name, "feFuncR") == 0)
+ channel = 'r';
+ else if (strcmp (element_name, "feFuncG") == 0)
+ channel = 'g';
+ else if (strcmp (element_name, "feFuncB") == 0)
+ channel = 'b';
+ else if (strcmp (element_name, "feFuncA") == 0)
+ channel = 'a';
+ else {
+ g_assert_not_reached ();
+ channel = '\0';
+ }
filter = g_new0 (RsvgNodeComponentTransferFunc, 1);
_rsvg_node_init (&filter->super, RSVG_NODE_TYPE_COMPONENT_TRANFER_FUNCTION);
@@ -2851,7 +2865,7 @@ rsvg_filter_primitive_erode_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPro
}
RsvgNode *
-rsvg_new_filter_primitive_erode (void)
+rsvg_new_filter_primitive_erode (const char *element_name)
{
RsvgFilterPrimitiveErode *filter;
filter = g_new0 (RsvgFilterPrimitiveErode, 1);
@@ -3082,7 +3096,7 @@ rsvg_filter_primitive_composite_set_atts (RsvgNode * self, RsvgHandle * ctx, Rsv
}
RsvgNode *
-rsvg_new_filter_primitive_composite (void)
+rsvg_new_filter_primitive_composite (const char *element_name)
{
RsvgFilterPrimitiveComposite *filter;
filter = g_new0 (RsvgFilterPrimitiveComposite, 1);
@@ -3169,7 +3183,7 @@ rsvg_filter_primitive_flood_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPro
}
RsvgNode *
-rsvg_new_filter_primitive_flood (void)
+rsvg_new_filter_primitive_flood (const char *element_name)
{
RsvgFilterPrimitive *filter;
filter = g_new0 (RsvgFilterPrimitive, 1);
@@ -3352,7 +3366,7 @@ rsvg_filter_primitive_displacement_map_set_atts (RsvgNode * self, RsvgHandle * c
}
RsvgNode *
-rsvg_new_filter_primitive_displacement_map (void)
+rsvg_new_filter_primitive_displacement_map (const char *element_name)
{
RsvgFilterPrimitiveDisplacementMap *filter;
filter = g_new0 (RsvgFilterPrimitiveDisplacementMap, 1);
@@ -3714,7 +3728,7 @@ rsvg_filter_primitive_turbulence_set_atts (RsvgNode * self, RsvgHandle * ctx,
}
RsvgNode *
-rsvg_new_filter_primitive_turbulence (void)
+rsvg_new_filter_primitive_turbulence (const char *element_name)
{
RsvgFilterPrimitiveTurbulence *filter;
filter = g_new0 (RsvgFilterPrimitiveTurbulence, 1);
@@ -3931,7 +3945,7 @@ rsvg_filter_primitive_image_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPro
}
RsvgNode *
-rsvg_new_filter_primitive_image (void)
+rsvg_new_filter_primitive_image (const char *element_name)
{
RsvgFilterPrimitiveImage *filter;
filter = g_new0 (RsvgFilterPrimitiveImage, 1);
@@ -4326,20 +4340,25 @@ rsvg_node_light_source_set_atts (RsvgNode * self,
}
RsvgNode *
-rsvg_new_node_light_source (char type)
+rsvg_new_node_light_source (const char *element_name)
{
RsvgNodeLightSource *data;
+
data = g_new (RsvgNodeLightSource, 1);
_rsvg_node_init (&data->super, RSVG_NODE_TYPE_LIGHT_SOURCE);
data->super.free = _rsvg_node_free;
data->super.set_atts = rsvg_node_light_source_set_atts;
data->specularExponent = 1;
- if (type == 's')
+
+ if (strcmp (element_name, "feDistantLight") == 0)
data->type = SPOTLIGHT;
- else if (type == 'd')
+ else if (strcmp (element_name, "feSpotLight") == 0)
data->type = DISTANTLIGHT;
- else
+ else if (strcmp (element_name, "fePointLight") == 0)
data->type = POINTLIGHT;
+ else
+ g_assert_not_reached ();
+
data->limitingconeAngle = 180;
return &data->super;
}
@@ -4491,7 +4510,7 @@ rsvg_filter_primitive_diffuse_lighting_set_atts (RsvgNode * self, RsvgHandle * c
}
RsvgNode *
-rsvg_new_filter_primitive_diffuse_lighting (void)
+rsvg_new_filter_primitive_diffuse_lighting (const char *element_name)
{
RsvgFilterPrimitiveDiffuseLighting *filter;
filter = g_new0 (RsvgFilterPrimitiveDiffuseLighting, 1);
@@ -4660,7 +4679,7 @@ rsvg_filter_primitive_specular_lighting_set_atts (RsvgNode * self, RsvgHandle *
RsvgNode *
-rsvg_new_filter_primitive_specular_lighting (void)
+rsvg_new_filter_primitive_specular_lighting (const char *element_name)
{
RsvgFilterPrimitiveSpecularLighting *filter;
filter = g_new0 (RsvgFilterPrimitiveSpecularLighting, 1);
@@ -4764,7 +4783,7 @@ rsvg_filter_primitive_tile_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgProp
}
RsvgNode *
-rsvg_new_filter_primitive_tile (void)
+rsvg_new_filter_primitive_tile (const char *element_name)
{
RsvgFilterPrimitiveTile *filter;
filter = g_new0 (RsvgFilterPrimitiveTile, 1);
diff --git a/rsvg-filter.h b/rsvg-filter.h
index da7ffeb..59aab1b 100644
--- a/rsvg-filter.h
+++ b/rsvg-filter.h
@@ -52,45 +52,45 @@ cairo_surface_t *rsvg_filter_render (RsvgFilter *self,
char *channelmap);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter (void);
+RsvgNode *rsvg_new_filter (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_blend (void);
+RsvgNode *rsvg_new_filter_primitive_blend (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_convolve_matrix (void);
+RsvgNode *rsvg_new_filter_primitive_convolve_matrix (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_gaussian_blur (void);
+RsvgNode *rsvg_new_filter_primitive_gaussian_blur (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_offset (void);
+RsvgNode *rsvg_new_filter_primitive_offset (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_merge (void);
+RsvgNode *rsvg_new_filter_primitive_merge (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_merge_node (void);
+RsvgNode *rsvg_new_filter_primitive_merge_node (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_color_matrix (void);
+RsvgNode *rsvg_new_filter_primitive_color_matrix (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_component_transfer (void);
+RsvgNode *rsvg_new_filter_primitive_component_transfer (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_node_component_transfer_function (char channel);
+RsvgNode *rsvg_new_node_component_transfer_function (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_erode (void);
+RsvgNode *rsvg_new_filter_primitive_erode (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_composite (void);
+RsvgNode *rsvg_new_filter_primitive_composite (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_flood (void);
+RsvgNode *rsvg_new_filter_primitive_flood (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_displacement_map (void);
+RsvgNode *rsvg_new_filter_primitive_displacement_map (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_turbulence (void);
+RsvgNode *rsvg_new_filter_primitive_turbulence (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_image (void);
+RsvgNode *rsvg_new_filter_primitive_image (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_diffuse_lighting (void);
+RsvgNode *rsvg_new_filter_primitive_diffuse_lighting (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_node_light_source (char type);
+RsvgNode *rsvg_new_node_light_source (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_specular_lighting (void);
+RsvgNode *rsvg_new_filter_primitive_specular_lighting (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_filter_primitive_tile (void);
+RsvgNode *rsvg_new_filter_primitive_tile (const char *element_name);
G_END_DECLS
diff --git a/rsvg-image.c b/rsvg-image.c
index 9fa3565..d76dd4e 100644
--- a/rsvg-image.c
+++ b/rsvg-image.c
@@ -234,7 +234,7 @@ rsvg_node_image_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
}
RsvgNode *
-rsvg_new_image (void)
+rsvg_new_image (const char *element_name)
{
RsvgNodeImage *image;
image = g_new (RsvgNodeImage, 1);
diff --git a/rsvg-image.h b/rsvg-image.h
index 9f291d0..9cb0f85 100644
--- a/rsvg-image.h
+++ b/rsvg-image.h
@@ -37,7 +37,7 @@
G_BEGIN_DECLS
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_image (void);
+RsvgNode *rsvg_new_image (const char *element_name);
typedef struct _RsvgNodeImage RsvgNodeImage;
diff --git a/rsvg-marker.c b/rsvg-marker.c
index 1b554f0..3116258 100644
--- a/rsvg-marker.c
+++ b/rsvg-marker.c
@@ -91,7 +91,7 @@ rsvg_node_marker_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag *
}
RsvgNode *
-rsvg_new_marker (void)
+rsvg_new_marker (const char *element_name)
{
RsvgMarker *marker;
marker = g_new (RsvgMarker, 1);
diff --git a/rsvg-marker.h b/rsvg-marker.h
index 0071bd6..5c3463c 100644
--- a/rsvg-marker.h
+++ b/rsvg-marker.h
@@ -31,7 +31,7 @@
G_BEGIN_DECLS
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_marker (void);
+RsvgNode *rsvg_new_marker (const char *element_name);
/* In the Rust code */
G_GNUC_INTERNAL
diff --git a/rsvg-mask.c b/rsvg-mask.c
index 16d4923..30ec090 100644
--- a/rsvg-mask.c
+++ b/rsvg-mask.c
@@ -66,7 +66,7 @@ rsvg_mask_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
}
RsvgNode *
-rsvg_new_mask (void)
+rsvg_new_mask (const char *element_name)
{
RsvgMask *mask;
@@ -123,7 +123,7 @@ rsvg_clip_path_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * at
}
RsvgNode *
-rsvg_new_clip_path (void)
+rsvg_new_clip_path (const char *element_name)
{
RsvgClipPath *clip_path;
diff --git a/rsvg-mask.h b/rsvg-mask.h
index bb6e4e2..d15697a 100644
--- a/rsvg-mask.h
+++ b/rsvg-mask.h
@@ -47,7 +47,7 @@ struct _RsvgMask {
};
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_mask (void);
+RsvgNode *rsvg_new_mask (const char *element_name);
typedef struct _RsvgClipPath RsvgClipPath;
@@ -57,7 +57,7 @@ struct _RsvgClipPath {
};
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_clip_path (void);
+RsvgNode *rsvg_new_clip_path (const char *element_name);
G_END_DECLS
#endif
diff --git a/rsvg-paint-server.c b/rsvg-paint-server.c
index abdf022..289bfe9 100644
--- a/rsvg-paint-server.c
+++ b/rsvg-paint-server.c
@@ -224,7 +224,7 @@ rsvg_stop_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
}
RsvgNode *
-rsvg_new_stop (void)
+rsvg_new_stop (const char *element_name)
{
RsvgGradientStop *stop = g_new (RsvgGradientStop, 1);
_rsvg_node_init (&stop->super, RSVG_NODE_TYPE_STOP);
@@ -292,7 +292,7 @@ rsvg_linear_gradient_free (RsvgNode * node)
}
RsvgNode *
-rsvg_new_linear_gradient (void)
+rsvg_new_linear_gradient (const char *element_name)
{
RsvgLinearGradient *grad = NULL;
grad = g_new (RsvgLinearGradient, 1);
@@ -375,7 +375,7 @@ rsvg_radial_gradient_free (RsvgNode * node)
}
RsvgNode *
-rsvg_new_radial_gradient (void)
+rsvg_new_radial_gradient (const char *element_name)
{
RsvgRadialGradient *grad = g_new (RsvgRadialGradient, 1);
@@ -454,7 +454,7 @@ rsvg_pattern_free (RsvgNode * node)
RsvgNode *
-rsvg_new_pattern (void)
+rsvg_new_pattern (const char *element_name)
{
RsvgPattern *pattern = g_new (RsvgPattern, 1);
_rsvg_node_init (&pattern->super, RSVG_NODE_TYPE_PATTERN);
diff --git a/rsvg-paint-server.h b/rsvg-paint-server.h
index 369ad4d..bfc31ae 100644
--- a/rsvg-paint-server.h
+++ b/rsvg-paint-server.h
@@ -138,13 +138,13 @@ G_GNUC_INTERNAL
void rsvg_paint_server_unref (RsvgPaintServer * ps);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_linear_gradient (void);
+RsvgNode *rsvg_new_linear_gradient (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_radial_gradient (void);
+RsvgNode *rsvg_new_radial_gradient (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_stop (void);
+RsvgNode *rsvg_new_stop (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_pattern (void);
+RsvgNode *rsvg_new_pattern (const char *element_name);
G_GNUC_INTERNAL
void rsvg_pattern_fix_fallback (RsvgDrawingCtx * ctx,
RsvgPattern * pattern);
diff --git a/rsvg-shapes.c b/rsvg-shapes.c
index c559fc7..74b4b6c 100644
--- a/rsvg-shapes.c
+++ b/rsvg-shapes.c
@@ -90,7 +90,7 @@ rsvg_node_path_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * at
}
RsvgNode *
-rsvg_new_path (void)
+rsvg_new_path (const char *element_name)
{
RsvgNodePath *path;
path = g_new (RsvgNodePath, 1);
@@ -222,13 +222,13 @@ rsvg_new_any_poly (RsvgNodeType type)
}
RsvgNode *
-rsvg_new_polygon (void)
+rsvg_new_polygon (const char *element_name)
{
return rsvg_new_any_poly (RSVG_NODE_TYPE_POLYGON);
}
RsvgNode *
-rsvg_new_polyline (void)
+rsvg_new_polyline (const char *element_name)
{
return rsvg_new_any_poly (RSVG_NODE_TYPE_POLYLINE);
}
@@ -288,7 +288,7 @@ _rsvg_node_line_draw (RsvgNode * overself, RsvgDrawingCtx * ctx, int dominate)
}
RsvgNode *
-rsvg_new_line (void)
+rsvg_new_line (const char *element_name)
{
RsvgNodeLine *line;
line = g_new (RsvgNodeLine, 1);
@@ -478,7 +478,7 @@ _rsvg_node_rect_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
}
RsvgNode *
-rsvg_new_rect (void)
+rsvg_new_rect (const char *element_name)
{
RsvgNodeRect *rect;
rect = g_new (RsvgNodeRect, 1);
@@ -567,7 +567,7 @@ _rsvg_node_circle_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
}
RsvgNode *
-rsvg_new_circle (void)
+rsvg_new_circle (const char *element_name)
{
RsvgNodeCircle *circle;
circle = g_new (RsvgNodeCircle, 1);
@@ -658,7 +658,7 @@ _rsvg_node_ellipse_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
}
RsvgNode *
-rsvg_new_ellipse (void)
+rsvg_new_ellipse (const char *element_name)
{
RsvgNodeEllipse *ellipse;
ellipse = g_new (RsvgNodeEllipse, 1);
diff --git a/rsvg-shapes.h b/rsvg-shapes.h
index 2559c36..5b0029f 100644
--- a/rsvg-shapes.h
+++ b/rsvg-shapes.h
@@ -37,19 +37,19 @@
G_BEGIN_DECLS
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_path (void);
+RsvgNode *rsvg_new_path (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_polygon (void);
+RsvgNode *rsvg_new_polygon (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_polyline (void);
+RsvgNode *rsvg_new_polyline (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_line (void);
+RsvgNode *rsvg_new_line (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_rect (void);
+RsvgNode *rsvg_new_rect (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_circle (void);
+RsvgNode *rsvg_new_circle (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_ellipse (void);
+RsvgNode *rsvg_new_ellipse (const char *element_name);
G_END_DECLS
diff --git a/rsvg-structure.c b/rsvg-structure.c
index b1d9d64..475eb7e 100644
--- a/rsvg-structure.c
+++ b/rsvg-structure.c
@@ -132,7 +132,7 @@ rsvg_node_group_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
}
RsvgNode *
-rsvg_new_group (void)
+rsvg_new_group (const char *element_name)
{
RsvgNodeGroup *group;
group = g_new (RsvgNodeGroup, 1);
@@ -362,7 +362,7 @@ _rsvg_svg_free (RsvgNode * self)
}
RsvgNode *
-rsvg_new_svg (void)
+rsvg_new_svg (const char *element_name)
{
RsvgNodeSvg *svg;
svg = g_new (RsvgNodeSvg, 1);
@@ -418,7 +418,7 @@ rsvg_node_use_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * att
}
RsvgNode *
-rsvg_new_use (void)
+rsvg_new_use (const char *element_name)
{
RsvgNodeUse *use;
use = g_new (RsvgNodeUse, 1);
@@ -456,7 +456,7 @@ rsvg_node_symbol_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag *
RsvgNode *
-rsvg_new_symbol (void)
+rsvg_new_symbol (const char *element_name)
{
RsvgNodeSymbol *symbol;
symbol = g_new (RsvgNodeSymbol, 1);
@@ -469,7 +469,7 @@ rsvg_new_symbol (void)
}
RsvgNode *
-rsvg_new_defs (void)
+rsvg_new_defs (const char *element_name)
{
RsvgNodeGroup *group;
group = g_new (RsvgNodeGroup, 1);
@@ -504,7 +504,7 @@ _rsvg_node_switch_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
}
RsvgNode *
-rsvg_new_switch (void)
+rsvg_new_switch (const char *element_name)
{
RsvgNodeGroup *group;
group = g_new (RsvgNodeGroup, 1);
diff --git a/rsvg-structure.h b/rsvg-structure.h
index 64a3367..e7a53db 100644
--- a/rsvg-structure.h
+++ b/rsvg-structure.h
@@ -37,17 +37,17 @@
G_BEGIN_DECLS
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_use (void);
+RsvgNode *rsvg_new_use (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_symbol (void);
+RsvgNode *rsvg_new_symbol (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_svg (void);
+RsvgNode *rsvg_new_svg (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_defs (void);
+RsvgNode *rsvg_new_defs (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_group (void);
+RsvgNode *rsvg_new_group (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_switch (void);
+RsvgNode *rsvg_new_switch (const char *element_name);
typedef struct _RsvgNodeGroup RsvgNodeGroup;
typedef struct _RsvgNodeUse RsvgNodeUse;
diff --git a/rsvg-text.c b/rsvg-text.c
index 159bcc1..f7bd7b6 100644
--- a/rsvg-text.c
+++ b/rsvg-text.c
@@ -311,7 +311,7 @@ _rsvg_node_text_draw (RsvgNode * self, RsvgDrawingCtx * ctx, int dominate)
}
RsvgNode *
-rsvg_new_text (void)
+rsvg_new_text (const char *element_name)
{
RsvgNodeText *text;
text = g_new (RsvgNodeText, 1);
@@ -402,7 +402,7 @@ _rsvg_node_tspan_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag *
}
RsvgNode *
-rsvg_new_tspan (void)
+rsvg_new_tspan (const char *element_name)
{
RsvgNodeText *text;
text = g_new0 (RsvgNodeText, 1);
@@ -472,7 +472,7 @@ _rsvg_node_tref_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * a
}
RsvgNode *
-rsvg_new_tref (void)
+rsvg_new_tref (const char *element_name)
{
RsvgNodeTref *text;
text = g_new (RsvgNodeTref, 1);
diff --git a/rsvg-text.h b/rsvg-text.h
index 185f8ba..18e69d8 100644
--- a/rsvg-text.h
+++ b/rsvg-text.h
@@ -33,11 +33,11 @@
G_BEGIN_DECLS
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_text (void);
+RsvgNode *rsvg_new_text (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_tspan (void);
+RsvgNode *rsvg_new_tspan (const char *element_name);
G_GNUC_INTERNAL
-RsvgNode *rsvg_new_tref (void);
+RsvgNode *rsvg_new_tref (const char *element_name);
G_GNUC_INTERNAL
char *rsvg_make_valid_utf8 (const char *str, int len);
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index 17db675..993c814 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -29,6 +29,7 @@ pub use length::{
mod drawing_ctx;
mod length;
mod marker;
+//mod node;
mod path_builder;
mod path_parser;
mod property_bag;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]