From 61fc779eac194f9dfdfea45be35014d6112ccd83 Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Sat, 13 Feb 2010 21:37:18 +0100 Subject: [PATCH] [CpmlPrimitive] Using the class name in cpml_primitive_dump() Removed the hardcoded switch and used the name field defined by the primitive types themselves. --- cpml/cpml-arc.c | 2 +- cpml/cpml-curve.c | 2 +- cpml/cpml-line.c | 2 +- cpml/cpml-primitive.c | 36 +++++++++--------------------------- 4 files changed, 12 insertions(+), 30 deletions(-) diff --git a/cpml/cpml-arc.c b/cpml/cpml-arc.c index 7fd4ab2e..29fc6a08 100644 --- a/cpml/cpml-arc.c +++ b/cpml/cpml-arc.c @@ -129,7 +129,7 @@ _cpml_arc_get_class(void) if (p_class == NULL) { static _CpmlPrimitiveClass class_data = { - "arc", 3, + "arc to", 3, get_length, put_extents, put_pair_at, diff --git a/cpml/cpml-curve.c b/cpml/cpml-curve.c index 9b366e2f..76c2dd5e 100644 --- a/cpml/cpml-curve.c +++ b/cpml/cpml-curve.c @@ -211,7 +211,7 @@ _cpml_curve_get_class(void) if (p_class == NULL) { static _CpmlPrimitiveClass class_data = { - "curve", 4, + "curve to", 4, NULL, put_extents, NULL, diff --git a/cpml/cpml-line.c b/cpml/cpml-line.c index d989acb4..655b6558 100644 --- a/cpml/cpml-line.c +++ b/cpml/cpml-line.c @@ -99,7 +99,7 @@ _cpml_line_get_class(void) if (p_class == NULL) { static _CpmlPrimitiveClass class_data = { - "line", 2, + "line to", 2, get_length, put_extents, put_pair_at, diff --git a/cpml/cpml-primitive.c b/cpml/cpml-primitive.c index 33443061..5d1a0b4c 100644 --- a/cpml/cpml-primitive.c +++ b/cpml/cpml-primitive.c @@ -616,46 +616,28 @@ cpml_primitive_dump(const CpmlPrimitive *primitive, cairo_bool_t org_also) { const cairo_path_data_t *data; int type; + const _CpmlPrimitiveClass *class_data; size_t n, n_points; data = primitive->data; type = data->header.type; - n_points = cpml_primitive_get_n_points(primitive); - if (n_points == 0) { - printf("Unhandled primitive type (%d)\n", type); + class_data = get_class_from_type(type); + + if (class_data == NULL) { + printf("Unknown primitive type (%d)\n", type); return; } - /* Dump the origin movement, if requested */ + /* Dump the origin, if requested */ if (org_also) { - printf("Move to "); + printf("move to "); dump_cairo_point(primitive->org); printf("\n"); } - switch (type) { - - case CPML_LINE: - printf("Line to "); - break; - - case CPML_ARC: - printf("Arc to "); - break; - - case CPML_CURVE: - printf("Curve to "); - break; - - case CPML_CLOSE: - printf("Path close"); - break; - - default: - printf("Unknown primitive (type = %d)", type); - break; - } + printf("%s ", class_data->name); + n_points = cpml_primitive_get_n_points(primitive); for (n = 1; n < n_points; ++n) dump_cairo_point(cpml_primitive_get_point(primitive, n)); -- 2.11.4.GIT