/*
 * This file was automatically generated.  Do not edit.
 */

#include <cairo-perl.h>

cairo_antialias_t
cairo_antialias_from_sv (SV * antialias)
{
	char * str = SvPV_nolen (antialias);

		if (strncmp (str, "default", 8) == 0)
		return CAIRO_ANTIALIAS_DEFAULT;
	else if (strncmp (str, "none", 5) == 0)
		return CAIRO_ANTIALIAS_NONE;
	else if (strncmp (str, "gray", 5) == 0)
		return CAIRO_ANTIALIAS_GRAY;
	else if (strncmp (str, "subpixel", 9) == 0)
		return CAIRO_ANTIALIAS_SUBPIXEL;

	croak ("`%s' is not a valid cairo_antialias_t value; valid values are: default, none, gray, subpixel", str);

	return 0;
}

SV *
cairo_antialias_to_sv (cairo_antialias_t val)
{
		if (val == CAIRO_ANTIALIAS_DEFAULT)
		return newSVpv ("default", 0);
	else if (val == CAIRO_ANTIALIAS_NONE)
		return newSVpv ("none", 0);
	else if (val == CAIRO_ANTIALIAS_GRAY)
		return newSVpv ("gray", 0);
	else if (val == CAIRO_ANTIALIAS_SUBPIXEL)
		return newSVpv ("subpixel", 0);

	warn ("unknown cairo_antialias_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_content_t
cairo_content_from_sv (SV * content)
{
	char * str = SvPV_nolen (content);

		if (strncmp (str, "color", 6) == 0)
		return CAIRO_CONTENT_COLOR;
	else if (strncmp (str, "alpha", 6) == 0)
		return CAIRO_CONTENT_ALPHA;
	else if (strncmp (str, "color-alpha", 12) == 0)
		return CAIRO_CONTENT_COLOR_ALPHA;

	croak ("`%s' is not a valid cairo_content_t value; valid values are: color, alpha, color-alpha", str);

	return 0;
}

SV *
cairo_content_to_sv (cairo_content_t val)
{
		if (val == CAIRO_CONTENT_COLOR)
		return newSVpv ("color", 0);
	else if (val == CAIRO_CONTENT_ALPHA)
		return newSVpv ("alpha", 0);
	else if (val == CAIRO_CONTENT_COLOR_ALPHA)
		return newSVpv ("color-alpha", 0);

	warn ("unknown cairo_content_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_extend_t
cairo_extend_from_sv (SV * extend)
{
	char * str = SvPV_nolen (extend);

		if (strncmp (str, "none", 5) == 0)
		return CAIRO_EXTEND_NONE;
	else if (strncmp (str, "repeat", 7) == 0)
		return CAIRO_EXTEND_REPEAT;
	else if (strncmp (str, "reflect", 8) == 0)
		return CAIRO_EXTEND_REFLECT;
	else if (strncmp (str, "pad", 4) == 0)
		return CAIRO_EXTEND_PAD;

	croak ("`%s' is not a valid cairo_extend_t value; valid values are: none, repeat, reflect, pad", str);

	return 0;
}

SV *
cairo_extend_to_sv (cairo_extend_t val)
{
		if (val == CAIRO_EXTEND_NONE)
		return newSVpv ("none", 0);
	else if (val == CAIRO_EXTEND_REPEAT)
		return newSVpv ("repeat", 0);
	else if (val == CAIRO_EXTEND_REFLECT)
		return newSVpv ("reflect", 0);
	else if (val == CAIRO_EXTEND_PAD)
		return newSVpv ("pad", 0);

	warn ("unknown cairo_extend_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_fill_rule_t
cairo_fill_rule_from_sv (SV * fill_rule)
{
	char * str = SvPV_nolen (fill_rule);

		if (strncmp (str, "winding", 8) == 0)
		return CAIRO_FILL_RULE_WINDING;
	else if (strncmp (str, "even-odd", 9) == 0)
		return CAIRO_FILL_RULE_EVEN_ODD;

	croak ("`%s' is not a valid cairo_fill_rule_t value; valid values are: winding, even-odd", str);

	return 0;
}

SV *
cairo_fill_rule_to_sv (cairo_fill_rule_t val)
{
		if (val == CAIRO_FILL_RULE_WINDING)
		return newSVpv ("winding", 0);
	else if (val == CAIRO_FILL_RULE_EVEN_ODD)
		return newSVpv ("even-odd", 0);

	warn ("unknown cairo_fill_rule_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_filter_t
cairo_filter_from_sv (SV * filter)
{
	char * str = SvPV_nolen (filter);

		if (strncmp (str, "fast", 5) == 0)
		return CAIRO_FILTER_FAST;
	else if (strncmp (str, "good", 5) == 0)
		return CAIRO_FILTER_GOOD;
	else if (strncmp (str, "best", 5) == 0)
		return CAIRO_FILTER_BEST;
	else if (strncmp (str, "nearest", 8) == 0)
		return CAIRO_FILTER_NEAREST;
	else if (strncmp (str, "bilinear", 9) == 0)
		return CAIRO_FILTER_BILINEAR;
	else if (strncmp (str, "gaussian", 9) == 0)
		return CAIRO_FILTER_GAUSSIAN;

	croak ("`%s' is not a valid cairo_filter_t value; valid values are: fast, good, best, nearest, bilinear, gaussian", str);

	return 0;
}

SV *
cairo_filter_to_sv (cairo_filter_t val)
{
		if (val == CAIRO_FILTER_FAST)
		return newSVpv ("fast", 0);
	else if (val == CAIRO_FILTER_GOOD)
		return newSVpv ("good", 0);
	else if (val == CAIRO_FILTER_BEST)
		return newSVpv ("best", 0);
	else if (val == CAIRO_FILTER_NEAREST)
		return newSVpv ("nearest", 0);
	else if (val == CAIRO_FILTER_BILINEAR)
		return newSVpv ("bilinear", 0);
	else if (val == CAIRO_FILTER_GAUSSIAN)
		return newSVpv ("gaussian", 0);

	warn ("unknown cairo_filter_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_font_slant_t
cairo_font_slant_from_sv (SV * font_slant)
{
	char * str = SvPV_nolen (font_slant);

		if (strncmp (str, "normal", 7) == 0)
		return CAIRO_FONT_SLANT_NORMAL;
	else if (strncmp (str, "italic", 7) == 0)
		return CAIRO_FONT_SLANT_ITALIC;
	else if (strncmp (str, "oblique", 8) == 0)
		return CAIRO_FONT_SLANT_OBLIQUE;

	croak ("`%s' is not a valid cairo_font_slant_t value; valid values are: normal, italic, oblique", str);

	return 0;
}

SV *
cairo_font_slant_to_sv (cairo_font_slant_t val)
{
		if (val == CAIRO_FONT_SLANT_NORMAL)
		return newSVpv ("normal", 0);
	else if (val == CAIRO_FONT_SLANT_ITALIC)
		return newSVpv ("italic", 0);
	else if (val == CAIRO_FONT_SLANT_OBLIQUE)
		return newSVpv ("oblique", 0);

	warn ("unknown cairo_font_slant_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_font_type_t
cairo_font_type_from_sv (SV * font_type)
{
	char * str = SvPV_nolen (font_type);

		if (strncmp (str, "toy", 4) == 0)
		return CAIRO_FONT_TYPE_TOY;
	else if (strncmp (str, "ft", 3) == 0)
		return CAIRO_FONT_TYPE_FT;
	else if (strncmp (str, "win32", 6) == 0)
		return CAIRO_FONT_TYPE_WIN32;
	else if (strncmp (str, "atsui", 6) == 0)
		return CAIRO_FONT_TYPE_ATSUI;
	else if (strncmp (str, "quartz", 7) == 0)
		return CAIRO_FONT_TYPE_QUARTZ;
	else if (strncmp (str, "user", 5) == 0)
		return CAIRO_FONT_TYPE_USER;

	croak ("`%s' is not a valid cairo_font_type_t value; valid values are: toy, ft, win32, atsui, quartz, user", str);

	return 0;
}

SV *
cairo_font_type_to_sv (cairo_font_type_t val)
{
		if (val == CAIRO_FONT_TYPE_TOY)
		return newSVpv ("toy", 0);
	else if (val == CAIRO_FONT_TYPE_FT)
		return newSVpv ("ft", 0);
	else if (val == CAIRO_FONT_TYPE_WIN32)
		return newSVpv ("win32", 0);
	else if (val == CAIRO_FONT_TYPE_ATSUI)
		return newSVpv ("atsui", 0);
	else if (val == CAIRO_FONT_TYPE_QUARTZ)
		return newSVpv ("quartz", 0);
	else if (val == CAIRO_FONT_TYPE_USER)
		return newSVpv ("user", 0);

	warn ("unknown cairo_font_type_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_font_weight_t
cairo_font_weight_from_sv (SV * font_weight)
{
	char * str = SvPV_nolen (font_weight);

		if (strncmp (str, "normal", 7) == 0)
		return CAIRO_FONT_WEIGHT_NORMAL;
	else if (strncmp (str, "bold", 5) == 0)
		return CAIRO_FONT_WEIGHT_BOLD;

	croak ("`%s' is not a valid cairo_font_weight_t value; valid values are: normal, bold", str);

	return 0;
}

SV *
cairo_font_weight_to_sv (cairo_font_weight_t val)
{
		if (val == CAIRO_FONT_WEIGHT_NORMAL)
		return newSVpv ("normal", 0);
	else if (val == CAIRO_FONT_WEIGHT_BOLD)
		return newSVpv ("bold", 0);

	warn ("unknown cairo_font_weight_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_format_t
cairo_format_from_sv (SV * format)
{
	char * str = SvPV_nolen (format);

		if (strncmp (str, "argb32", 7) == 0)
		return CAIRO_FORMAT_ARGB32;
	else if (strncmp (str, "rgb24", 6) == 0)
		return CAIRO_FORMAT_RGB24;
	else if (strncmp (str, "a8", 3) == 0)
		return CAIRO_FORMAT_A8;
	else if (strncmp (str, "a1", 3) == 0)
		return CAIRO_FORMAT_A1;
	else if (strncmp (str, "rgb16-565", 10) == 0)
		return CAIRO_FORMAT_RGB16_565;

	croak ("`%s' is not a valid cairo_format_t value; valid values are: argb32, rgb24, a8, a1, rgb16-565", str);

	return 0;
}

SV *
cairo_format_to_sv (cairo_format_t val)
{
		if (val == CAIRO_FORMAT_ARGB32)
		return newSVpv ("argb32", 0);
	else if (val == CAIRO_FORMAT_RGB24)
		return newSVpv ("rgb24", 0);
	else if (val == CAIRO_FORMAT_A8)
		return newSVpv ("a8", 0);
	else if (val == CAIRO_FORMAT_A1)
		return newSVpv ("a1", 0);
	else if (val == CAIRO_FORMAT_RGB16_565)
		return newSVpv ("rgb16-565", 0);

	warn ("unknown cairo_format_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_hint_metrics_t
cairo_hint_metrics_from_sv (SV * hint_metrics)
{
	char * str = SvPV_nolen (hint_metrics);

		if (strncmp (str, "default", 8) == 0)
		return CAIRO_HINT_METRICS_DEFAULT;
	else if (strncmp (str, "off", 4) == 0)
		return CAIRO_HINT_METRICS_OFF;
	else if (strncmp (str, "on", 3) == 0)
		return CAIRO_HINT_METRICS_ON;

	croak ("`%s' is not a valid cairo_hint_metrics_t value; valid values are: default, off, on", str);

	return 0;
}

SV *
cairo_hint_metrics_to_sv (cairo_hint_metrics_t val)
{
		if (val == CAIRO_HINT_METRICS_DEFAULT)
		return newSVpv ("default", 0);
	else if (val == CAIRO_HINT_METRICS_OFF)
		return newSVpv ("off", 0);
	else if (val == CAIRO_HINT_METRICS_ON)
		return newSVpv ("on", 0);

	warn ("unknown cairo_hint_metrics_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_hint_style_t
cairo_hint_style_from_sv (SV * hint_style)
{
	char * str = SvPV_nolen (hint_style);

		if (strncmp (str, "default", 8) == 0)
		return CAIRO_HINT_STYLE_DEFAULT;
	else if (strncmp (str, "none", 5) == 0)
		return CAIRO_HINT_STYLE_NONE;
	else if (strncmp (str, "slight", 7) == 0)
		return CAIRO_HINT_STYLE_SLIGHT;
	else if (strncmp (str, "medium", 7) == 0)
		return CAIRO_HINT_STYLE_MEDIUM;
	else if (strncmp (str, "full", 5) == 0)
		return CAIRO_HINT_STYLE_FULL;

	croak ("`%s' is not a valid cairo_hint_style_t value; valid values are: default, none, slight, medium, full", str);

	return 0;
}

SV *
cairo_hint_style_to_sv (cairo_hint_style_t val)
{
		if (val == CAIRO_HINT_STYLE_DEFAULT)
		return newSVpv ("default", 0);
	else if (val == CAIRO_HINT_STYLE_NONE)
		return newSVpv ("none", 0);
	else if (val == CAIRO_HINT_STYLE_SLIGHT)
		return newSVpv ("slight", 0);
	else if (val == CAIRO_HINT_STYLE_MEDIUM)
		return newSVpv ("medium", 0);
	else if (val == CAIRO_HINT_STYLE_FULL)
		return newSVpv ("full", 0);

	warn ("unknown cairo_hint_style_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_line_cap_t
cairo_line_cap_from_sv (SV * line_cap)
{
	char * str = SvPV_nolen (line_cap);

		if (strncmp (str, "butt", 5) == 0)
		return CAIRO_LINE_CAP_BUTT;
	else if (strncmp (str, "round", 6) == 0)
		return CAIRO_LINE_CAP_ROUND;
	else if (strncmp (str, "square", 7) == 0)
		return CAIRO_LINE_CAP_SQUARE;

	croak ("`%s' is not a valid cairo_line_cap_t value; valid values are: butt, round, square", str);

	return 0;
}

SV *
cairo_line_cap_to_sv (cairo_line_cap_t val)
{
		if (val == CAIRO_LINE_CAP_BUTT)
		return newSVpv ("butt", 0);
	else if (val == CAIRO_LINE_CAP_ROUND)
		return newSVpv ("round", 0);
	else if (val == CAIRO_LINE_CAP_SQUARE)
		return newSVpv ("square", 0);

	warn ("unknown cairo_line_cap_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_line_join_t
cairo_line_join_from_sv (SV * line_join)
{
	char * str = SvPV_nolen (line_join);

		if (strncmp (str, "miter", 6) == 0)
		return CAIRO_LINE_JOIN_MITER;
	else if (strncmp (str, "round", 6) == 0)
		return CAIRO_LINE_JOIN_ROUND;
	else if (strncmp (str, "bevel", 6) == 0)
		return CAIRO_LINE_JOIN_BEVEL;

	croak ("`%s' is not a valid cairo_line_join_t value; valid values are: miter, round, bevel", str);

	return 0;
}

SV *
cairo_line_join_to_sv (cairo_line_join_t val)
{
		if (val == CAIRO_LINE_JOIN_MITER)
		return newSVpv ("miter", 0);
	else if (val == CAIRO_LINE_JOIN_ROUND)
		return newSVpv ("round", 0);
	else if (val == CAIRO_LINE_JOIN_BEVEL)
		return newSVpv ("bevel", 0);

	warn ("unknown cairo_line_join_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_operator_t
cairo_operator_from_sv (SV * operator)
{
	char * str = SvPV_nolen (operator);

		if (strncmp (str, "clear", 6) == 0)
		return CAIRO_OPERATOR_CLEAR;
	else if (strncmp (str, "source", 7) == 0)
		return CAIRO_OPERATOR_SOURCE;
	else if (strncmp (str, "over", 5) == 0)
		return CAIRO_OPERATOR_OVER;
	else if (strncmp (str, "in", 3) == 0)
		return CAIRO_OPERATOR_IN;
	else if (strncmp (str, "out", 4) == 0)
		return CAIRO_OPERATOR_OUT;
	else if (strncmp (str, "atop", 5) == 0)
		return CAIRO_OPERATOR_ATOP;
	else if (strncmp (str, "dest", 5) == 0)
		return CAIRO_OPERATOR_DEST;
	else if (strncmp (str, "dest-over", 10) == 0)
		return CAIRO_OPERATOR_DEST_OVER;
	else if (strncmp (str, "dest-in", 8) == 0)
		return CAIRO_OPERATOR_DEST_IN;
	else if (strncmp (str, "dest-out", 9) == 0)
		return CAIRO_OPERATOR_DEST_OUT;
	else if (strncmp (str, "dest-atop", 10) == 0)
		return CAIRO_OPERATOR_DEST_ATOP;
	else if (strncmp (str, "xor", 4) == 0)
		return CAIRO_OPERATOR_XOR;
	else if (strncmp (str, "add", 4) == 0)
		return CAIRO_OPERATOR_ADD;
	else if (strncmp (str, "saturate", 9) == 0)
		return CAIRO_OPERATOR_SATURATE;
	else if (strncmp (str, "multiply", 9) == 0)
		return CAIRO_OPERATOR_MULTIPLY;
	else if (strncmp (str, "screen", 7) == 0)
		return CAIRO_OPERATOR_SCREEN;
	else if (strncmp (str, "overlay", 8) == 0)
		return CAIRO_OPERATOR_OVERLAY;
	else if (strncmp (str, "darken", 7) == 0)
		return CAIRO_OPERATOR_DARKEN;
	else if (strncmp (str, "lighten", 8) == 0)
		return CAIRO_OPERATOR_LIGHTEN;
	else if (strncmp (str, "color-dodge", 12) == 0)
		return CAIRO_OPERATOR_COLOR_DODGE;
	else if (strncmp (str, "color-burn", 11) == 0)
		return CAIRO_OPERATOR_COLOR_BURN;
	else if (strncmp (str, "hard-light", 11) == 0)
		return CAIRO_OPERATOR_HARD_LIGHT;
	else if (strncmp (str, "soft-light", 11) == 0)
		return CAIRO_OPERATOR_SOFT_LIGHT;
	else if (strncmp (str, "difference", 11) == 0)
		return CAIRO_OPERATOR_DIFFERENCE;
	else if (strncmp (str, "exclusion", 10) == 0)
		return CAIRO_OPERATOR_EXCLUSION;
	else if (strncmp (str, "hsl-hue", 8) == 0)
		return CAIRO_OPERATOR_HSL_HUE;
	else if (strncmp (str, "hsl-saturation", 15) == 0)
		return CAIRO_OPERATOR_HSL_SATURATION;
	else if (strncmp (str, "hsl-color", 10) == 0)
		return CAIRO_OPERATOR_HSL_COLOR;
	else if (strncmp (str, "hsl-luminosity", 15) == 0)
		return CAIRO_OPERATOR_HSL_LUMINOSITY;

	croak ("`%s' is not a valid cairo_operator_t value; valid values are: clear, source, over, in, out, atop, dest, dest-over, dest-in, dest-out, dest-atop, xor, add, saturate, multiply, screen, overlay, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, exclusion, hsl-hue, hsl-saturation, hsl-color, hsl-luminosity", str);

	return 0;
}

SV *
cairo_operator_to_sv (cairo_operator_t val)
{
		if (val == CAIRO_OPERATOR_CLEAR)
		return newSVpv ("clear", 0);
	else if (val == CAIRO_OPERATOR_SOURCE)
		return newSVpv ("source", 0);
	else if (val == CAIRO_OPERATOR_OVER)
		return newSVpv ("over", 0);
	else if (val == CAIRO_OPERATOR_IN)
		return newSVpv ("in", 0);
	else if (val == CAIRO_OPERATOR_OUT)
		return newSVpv ("out", 0);
	else if (val == CAIRO_OPERATOR_ATOP)
		return newSVpv ("atop", 0);
	else if (val == CAIRO_OPERATOR_DEST)
		return newSVpv ("dest", 0);
	else if (val == CAIRO_OPERATOR_DEST_OVER)
		return newSVpv ("dest-over", 0);
	else if (val == CAIRO_OPERATOR_DEST_IN)
		return newSVpv ("dest-in", 0);
	else if (val == CAIRO_OPERATOR_DEST_OUT)
		return newSVpv ("dest-out", 0);
	else if (val == CAIRO_OPERATOR_DEST_ATOP)
		return newSVpv ("dest-atop", 0);
	else if (val == CAIRO_OPERATOR_XOR)
		return newSVpv ("xor", 0);
	else if (val == CAIRO_OPERATOR_ADD)
		return newSVpv ("add", 0);
	else if (val == CAIRO_OPERATOR_SATURATE)
		return newSVpv ("saturate", 0);
	else if (val == CAIRO_OPERATOR_MULTIPLY)
		return newSVpv ("multiply", 0);
	else if (val == CAIRO_OPERATOR_SCREEN)
		return newSVpv ("screen", 0);
	else if (val == CAIRO_OPERATOR_OVERLAY)
		return newSVpv ("overlay", 0);
	else if (val == CAIRO_OPERATOR_DARKEN)
		return newSVpv ("darken", 0);
	else if (val == CAIRO_OPERATOR_LIGHTEN)
		return newSVpv ("lighten", 0);
	else if (val == CAIRO_OPERATOR_COLOR_DODGE)
		return newSVpv ("color-dodge", 0);
	else if (val == CAIRO_OPERATOR_COLOR_BURN)
		return newSVpv ("color-burn", 0);
	else if (val == CAIRO_OPERATOR_HARD_LIGHT)
		return newSVpv ("hard-light", 0);
	else if (val == CAIRO_OPERATOR_SOFT_LIGHT)
		return newSVpv ("soft-light", 0);
	else if (val == CAIRO_OPERATOR_DIFFERENCE)
		return newSVpv ("difference", 0);
	else if (val == CAIRO_OPERATOR_EXCLUSION)
		return newSVpv ("exclusion", 0);
	else if (val == CAIRO_OPERATOR_HSL_HUE)
		return newSVpv ("hsl-hue", 0);
	else if (val == CAIRO_OPERATOR_HSL_SATURATION)
		return newSVpv ("hsl-saturation", 0);
	else if (val == CAIRO_OPERATOR_HSL_COLOR)
		return newSVpv ("hsl-color", 0);
	else if (val == CAIRO_OPERATOR_HSL_LUMINOSITY)
		return newSVpv ("hsl-luminosity", 0);

	warn ("unknown cairo_operator_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_path_data_type_t
cairo_path_data_type_from_sv (SV * path_data_type)
{
	char * str = SvPV_nolen (path_data_type);

		if (strncmp (str, "move-to", 8) == 0)
		return CAIRO_PATH_MOVE_TO;
	else if (strncmp (str, "line-to", 8) == 0)
		return CAIRO_PATH_LINE_TO;
	else if (strncmp (str, "curve-to", 9) == 0)
		return CAIRO_PATH_CURVE_TO;
	else if (strncmp (str, "close-path", 11) == 0)
		return CAIRO_PATH_CLOSE_PATH;

	croak ("`%s' is not a valid cairo_path_data_type_t value; valid values are: move-to, line-to, curve-to, close-path", str);

	return 0;
}

SV *
cairo_path_data_type_to_sv (cairo_path_data_type_t val)
{
		if (val == CAIRO_PATH_MOVE_TO)
		return newSVpv ("move-to", 0);
	else if (val == CAIRO_PATH_LINE_TO)
		return newSVpv ("line-to", 0);
	else if (val == CAIRO_PATH_CURVE_TO)
		return newSVpv ("curve-to", 0);
	else if (val == CAIRO_PATH_CLOSE_PATH)
		return newSVpv ("close-path", 0);

	warn ("unknown cairo_path_data_type_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_pattern_type_t
cairo_pattern_type_from_sv (SV * pattern_type)
{
	char * str = SvPV_nolen (pattern_type);

		if (strncmp (str, "solid", 6) == 0)
		return CAIRO_PATTERN_TYPE_SOLID;
	else if (strncmp (str, "surface", 8) == 0)
		return CAIRO_PATTERN_TYPE_SURFACE;
	else if (strncmp (str, "linear", 7) == 0)
		return CAIRO_PATTERN_TYPE_LINEAR;
	else if (strncmp (str, "radial", 7) == 0)
		return CAIRO_PATTERN_TYPE_RADIAL;

	croak ("`%s' is not a valid cairo_pattern_type_t value; valid values are: solid, surface, linear, radial", str);

	return 0;
}

SV *
cairo_pattern_type_to_sv (cairo_pattern_type_t val)
{
		if (val == CAIRO_PATTERN_TYPE_SOLID)
		return newSVpv ("solid", 0);
	else if (val == CAIRO_PATTERN_TYPE_SURFACE)
		return newSVpv ("surface", 0);
	else if (val == CAIRO_PATTERN_TYPE_LINEAR)
		return newSVpv ("linear", 0);
	else if (val == CAIRO_PATTERN_TYPE_RADIAL)
		return newSVpv ("radial", 0);

	warn ("unknown cairo_pattern_type_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_pdf_metadata_t
cairo_pdf_metadata_from_sv (SV * pdf_metadata)
{
	char * str = SvPV_nolen (pdf_metadata);

		if (strncmp (str, "title", 6) == 0)
		return CAIRO_PDF_METADATA_TITLE;
	else if (strncmp (str, "author", 7) == 0)
		return CAIRO_PDF_METADATA_AUTHOR;
	else if (strncmp (str, "subject", 8) == 0)
		return CAIRO_PDF_METADATA_SUBJECT;
	else if (strncmp (str, "keywords", 9) == 0)
		return CAIRO_PDF_METADATA_KEYWORDS;
	else if (strncmp (str, "creator", 8) == 0)
		return CAIRO_PDF_METADATA_CREATOR;
	else if (strncmp (str, "create-date", 12) == 0)
		return CAIRO_PDF_METADATA_CREATE_DATE;
	else if (strncmp (str, "mod-date", 9) == 0)
		return CAIRO_PDF_METADATA_MOD_DATE;

	croak ("`%s' is not a valid cairo_pdf_metadata_t value; valid values are: title, author, subject, keywords, creator, create-date, mod-date", str);

	return 0;
}

SV *
cairo_pdf_metadata_to_sv (cairo_pdf_metadata_t val)
{
		if (val == CAIRO_PDF_METADATA_TITLE)
		return newSVpv ("title", 0);
	else if (val == CAIRO_PDF_METADATA_AUTHOR)
		return newSVpv ("author", 0);
	else if (val == CAIRO_PDF_METADATA_SUBJECT)
		return newSVpv ("subject", 0);
	else if (val == CAIRO_PDF_METADATA_KEYWORDS)
		return newSVpv ("keywords", 0);
	else if (val == CAIRO_PDF_METADATA_CREATOR)
		return newSVpv ("creator", 0);
	else if (val == CAIRO_PDF_METADATA_CREATE_DATE)
		return newSVpv ("create-date", 0);
	else if (val == CAIRO_PDF_METADATA_MOD_DATE)
		return newSVpv ("mod-date", 0);

	warn ("unknown cairo_pdf_metadata_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_pdf_version_t
cairo_pdf_version_from_sv (SV * pdf_version)
{
	char * str = SvPV_nolen (pdf_version);

		if (strncmp (str, "1-4", 4) == 0)
		return CAIRO_PDF_VERSION_1_4;
	else if (strncmp (str, "1-5", 4) == 0)
		return CAIRO_PDF_VERSION_1_5;

	croak ("`%s' is not a valid cairo_pdf_version_t value; valid values are: 1-4, 1-5", str);

	return 0;
}

SV *
cairo_pdf_version_to_sv (cairo_pdf_version_t val)
{
		if (val == CAIRO_PDF_VERSION_1_4)
		return newSVpv ("1-4", 0);
	else if (val == CAIRO_PDF_VERSION_1_5)
		return newSVpv ("1-5", 0);

	warn ("unknown cairo_pdf_version_t value %d encountered", val);
	return &PL_sv_undef;
}

#ifdef CAIRO_HAS_PS_SURFACE

cairo_ps_level_t
cairo_ps_level_from_sv (SV * ps_level)
{
	char * str = SvPV_nolen (ps_level);

		if (strncmp (str, "2", 2) == 0)
		return CAIRO_PS_LEVEL_2;
	else if (strncmp (str, "3", 2) == 0)
		return CAIRO_PS_LEVEL_3;

	croak ("`%s' is not a valid cairo_ps_level_t value; valid values are: 2, 3", str);

	return 0;
}

SV *
cairo_ps_level_to_sv (cairo_ps_level_t val)
{
		if (val == CAIRO_PS_LEVEL_2)
		return newSVpv ("2", 0);
	else if (val == CAIRO_PS_LEVEL_3)
		return newSVpv ("3", 0);

	warn ("unknown cairo_ps_level_t value %d encountered", val);
	return &PL_sv_undef;
}

#endif /* #ifdef CAIRO_HAS_PS_SURFACE */
cairo_region_overlap_t
cairo_region_overlap_from_sv (SV * region_overlap)
{
	char * str = SvPV_nolen (region_overlap);

		if (strncmp (str, "in", 3) == 0)
		return CAIRO_REGION_OVERLAP_IN;
	else if (strncmp (str, "out", 4) == 0)
		return CAIRO_REGION_OVERLAP_OUT;
	else if (strncmp (str, "part", 5) == 0)
		return CAIRO_REGION_OVERLAP_PART;

	croak ("`%s' is not a valid cairo_region_overlap_t value; valid values are: in, out, part", str);

	return 0;
}

SV *
cairo_region_overlap_to_sv (cairo_region_overlap_t val)
{
		if (val == CAIRO_REGION_OVERLAP_IN)
		return newSVpv ("in", 0);
	else if (val == CAIRO_REGION_OVERLAP_OUT)
		return newSVpv ("out", 0);
	else if (val == CAIRO_REGION_OVERLAP_PART)
		return newSVpv ("part", 0);

	warn ("unknown cairo_region_overlap_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_status_t
cairo_status_from_sv (SV * status)
{
	char * str = SvPV_nolen (status);

		if (strncmp (str, "success", 8) == 0)
		return CAIRO_STATUS_SUCCESS;
	else if (strncmp (str, "no-memory", 10) == 0)
		return CAIRO_STATUS_NO_MEMORY;
	else if (strncmp (str, "invalid-restore", 16) == 0)
		return CAIRO_STATUS_INVALID_RESTORE;
	else if (strncmp (str, "invalid-pop-group", 18) == 0)
		return CAIRO_STATUS_INVALID_POP_GROUP;
	else if (strncmp (str, "no-current-point", 17) == 0)
		return CAIRO_STATUS_NO_CURRENT_POINT;
	else if (strncmp (str, "invalid-matrix", 15) == 0)
		return CAIRO_STATUS_INVALID_MATRIX;
	else if (strncmp (str, "invalid-status", 15) == 0)
		return CAIRO_STATUS_INVALID_STATUS;
	else if (strncmp (str, "null-pointer", 13) == 0)
		return CAIRO_STATUS_NULL_POINTER;
	else if (strncmp (str, "invalid-string", 15) == 0)
		return CAIRO_STATUS_INVALID_STRING;
	else if (strncmp (str, "invalid-path-data", 18) == 0)
		return CAIRO_STATUS_INVALID_PATH_DATA;
	else if (strncmp (str, "read-error", 11) == 0)
		return CAIRO_STATUS_READ_ERROR;
	else if (strncmp (str, "write-error", 12) == 0)
		return CAIRO_STATUS_WRITE_ERROR;
	else if (strncmp (str, "surface-finished", 17) == 0)
		return CAIRO_STATUS_SURFACE_FINISHED;
	else if (strncmp (str, "surface-type-mismatch", 22) == 0)
		return CAIRO_STATUS_SURFACE_TYPE_MISMATCH;
	else if (strncmp (str, "pattern-type-mismatch", 22) == 0)
		return CAIRO_STATUS_PATTERN_TYPE_MISMATCH;
	else if (strncmp (str, "invalid-content", 16) == 0)
		return CAIRO_STATUS_INVALID_CONTENT;
	else if (strncmp (str, "invalid-format", 15) == 0)
		return CAIRO_STATUS_INVALID_FORMAT;
	else if (strncmp (str, "invalid-visual", 15) == 0)
		return CAIRO_STATUS_INVALID_VISUAL;
	else if (strncmp (str, "file-not-found", 15) == 0)
		return CAIRO_STATUS_FILE_NOT_FOUND;
	else if (strncmp (str, "invalid-dash", 13) == 0)
		return CAIRO_STATUS_INVALID_DASH;
	else if (strncmp (str, "invalid-dsc-comment", 20) == 0)
		return CAIRO_STATUS_INVALID_DSC_COMMENT;
	else if (strncmp (str, "invalid-index", 14) == 0)
		return CAIRO_STATUS_INVALID_INDEX;
	else if (strncmp (str, "clip-not-representable", 23) == 0)
		return CAIRO_STATUS_CLIP_NOT_REPRESENTABLE;
	else if (strncmp (str, "temp-file-error", 16) == 0)
		return CAIRO_STATUS_TEMP_FILE_ERROR;
	else if (strncmp (str, "invalid-stride", 15) == 0)
		return CAIRO_STATUS_INVALID_STRIDE;
	else if (strncmp (str, "font-type-mismatch", 19) == 0)
		return CAIRO_STATUS_FONT_TYPE_MISMATCH;
	else if (strncmp (str, "user-font-immutable", 20) == 0)
		return CAIRO_STATUS_USER_FONT_IMMUTABLE;
	else if (strncmp (str, "user-font-error", 16) == 0)
		return CAIRO_STATUS_USER_FONT_ERROR;
	else if (strncmp (str, "negative-count", 15) == 0)
		return CAIRO_STATUS_NEGATIVE_COUNT;
	else if (strncmp (str, "invalid-clusters", 17) == 0)
		return CAIRO_STATUS_INVALID_CLUSTERS;
	else if (strncmp (str, "invalid-slant", 14) == 0)
		return CAIRO_STATUS_INVALID_SLANT;
	else if (strncmp (str, "invalid-weight", 15) == 0)
		return CAIRO_STATUS_INVALID_WEIGHT;
	else if (strncmp (str, "invalid-size", 13) == 0)
		return CAIRO_STATUS_INVALID_SIZE;
	else if (strncmp (str, "user-font-not-implemented", 26) == 0)
		return CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED;
	else if (strncmp (str, "device-type-mismatch", 21) == 0)
		return CAIRO_STATUS_DEVICE_TYPE_MISMATCH;
	else if (strncmp (str, "device-error", 13) == 0)
		return CAIRO_STATUS_DEVICE_ERROR;
	else if (strncmp (str, "invalid-mesh-construction", 26) == 0)
		return CAIRO_STATUS_INVALID_MESH_CONSTRUCTION;
	else if (strncmp (str, "device-finished", 16) == 0)
		return CAIRO_STATUS_DEVICE_FINISHED;
	else if (strncmp (str, "jbig2-global-missing", 21) == 0)
		return CAIRO_STATUS_JBIG2_GLOBAL_MISSING;
	else if (strncmp (str, "png-error", 10) == 0)
		return CAIRO_STATUS_PNG_ERROR;
	else if (strncmp (str, "freetype-error", 15) == 0)
		return CAIRO_STATUS_FREETYPE_ERROR;
	else if (strncmp (str, "win32-gdi-error", 16) == 0)
		return CAIRO_STATUS_WIN32_GDI_ERROR;
	else if (strncmp (str, "tag-error", 10) == 0)
		return CAIRO_STATUS_TAG_ERROR;

	croak ("`%s' is not a valid cairo_status_t value; valid values are: success, no-memory, invalid-restore, invalid-pop-group, no-current-point, invalid-matrix, invalid-status, null-pointer, invalid-string, invalid-path-data, read-error, write-error, surface-finished, surface-type-mismatch, pattern-type-mismatch, invalid-content, invalid-format, invalid-visual, file-not-found, invalid-dash, invalid-dsc-comment, invalid-index, clip-not-representable, temp-file-error, invalid-stride, font-type-mismatch, user-font-immutable, user-font-error, negative-count, invalid-clusters, invalid-slant, invalid-weight, invalid-size, user-font-not-implemented, device-type-mismatch, device-error, invalid-mesh-construction, device-finished, jbig2-global-missing, png-error, freetype-error, win32-gdi-error, tag-error", str);

	return 0;
}

SV *
cairo_status_to_sv (cairo_status_t val)
{
		if (val == CAIRO_STATUS_SUCCESS)
		return newSVpv ("success", 0);
	else if (val == CAIRO_STATUS_NO_MEMORY)
		return newSVpv ("no-memory", 0);
	else if (val == CAIRO_STATUS_INVALID_RESTORE)
		return newSVpv ("invalid-restore", 0);
	else if (val == CAIRO_STATUS_INVALID_POP_GROUP)
		return newSVpv ("invalid-pop-group", 0);
	else if (val == CAIRO_STATUS_NO_CURRENT_POINT)
		return newSVpv ("no-current-point", 0);
	else if (val == CAIRO_STATUS_INVALID_MATRIX)
		return newSVpv ("invalid-matrix", 0);
	else if (val == CAIRO_STATUS_INVALID_STATUS)
		return newSVpv ("invalid-status", 0);
	else if (val == CAIRO_STATUS_NULL_POINTER)
		return newSVpv ("null-pointer", 0);
	else if (val == CAIRO_STATUS_INVALID_STRING)
		return newSVpv ("invalid-string", 0);
	else if (val == CAIRO_STATUS_INVALID_PATH_DATA)
		return newSVpv ("invalid-path-data", 0);
	else if (val == CAIRO_STATUS_READ_ERROR)
		return newSVpv ("read-error", 0);
	else if (val == CAIRO_STATUS_WRITE_ERROR)
		return newSVpv ("write-error", 0);
	else if (val == CAIRO_STATUS_SURFACE_FINISHED)
		return newSVpv ("surface-finished", 0);
	else if (val == CAIRO_STATUS_SURFACE_TYPE_MISMATCH)
		return newSVpv ("surface-type-mismatch", 0);
	else if (val == CAIRO_STATUS_PATTERN_TYPE_MISMATCH)
		return newSVpv ("pattern-type-mismatch", 0);
	else if (val == CAIRO_STATUS_INVALID_CONTENT)
		return newSVpv ("invalid-content", 0);
	else if (val == CAIRO_STATUS_INVALID_FORMAT)
		return newSVpv ("invalid-format", 0);
	else if (val == CAIRO_STATUS_INVALID_VISUAL)
		return newSVpv ("invalid-visual", 0);
	else if (val == CAIRO_STATUS_FILE_NOT_FOUND)
		return newSVpv ("file-not-found", 0);
	else if (val == CAIRO_STATUS_INVALID_DASH)
		return newSVpv ("invalid-dash", 0);
	else if (val == CAIRO_STATUS_INVALID_DSC_COMMENT)
		return newSVpv ("invalid-dsc-comment", 0);
	else if (val == CAIRO_STATUS_INVALID_INDEX)
		return newSVpv ("invalid-index", 0);
	else if (val == CAIRO_STATUS_CLIP_NOT_REPRESENTABLE)
		return newSVpv ("clip-not-representable", 0);
	else if (val == CAIRO_STATUS_TEMP_FILE_ERROR)
		return newSVpv ("temp-file-error", 0);
	else if (val == CAIRO_STATUS_INVALID_STRIDE)
		return newSVpv ("invalid-stride", 0);
	else if (val == CAIRO_STATUS_FONT_TYPE_MISMATCH)
		return newSVpv ("font-type-mismatch", 0);
	else if (val == CAIRO_STATUS_USER_FONT_IMMUTABLE)
		return newSVpv ("user-font-immutable", 0);
	else if (val == CAIRO_STATUS_USER_FONT_ERROR)
		return newSVpv ("user-font-error", 0);
	else if (val == CAIRO_STATUS_NEGATIVE_COUNT)
		return newSVpv ("negative-count", 0);
	else if (val == CAIRO_STATUS_INVALID_CLUSTERS)
		return newSVpv ("invalid-clusters", 0);
	else if (val == CAIRO_STATUS_INVALID_SLANT)
		return newSVpv ("invalid-slant", 0);
	else if (val == CAIRO_STATUS_INVALID_WEIGHT)
		return newSVpv ("invalid-weight", 0);
	else if (val == CAIRO_STATUS_INVALID_SIZE)
		return newSVpv ("invalid-size", 0);
	else if (val == CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED)
		return newSVpv ("user-font-not-implemented", 0);
	else if (val == CAIRO_STATUS_DEVICE_TYPE_MISMATCH)
		return newSVpv ("device-type-mismatch", 0);
	else if (val == CAIRO_STATUS_DEVICE_ERROR)
		return newSVpv ("device-error", 0);
	else if (val == CAIRO_STATUS_INVALID_MESH_CONSTRUCTION)
		return newSVpv ("invalid-mesh-construction", 0);
	else if (val == CAIRO_STATUS_DEVICE_FINISHED)
		return newSVpv ("device-finished", 0);
	else if (val == CAIRO_STATUS_JBIG2_GLOBAL_MISSING)
		return newSVpv ("jbig2-global-missing", 0);
	else if (val == CAIRO_STATUS_PNG_ERROR)
		return newSVpv ("png-error", 0);
	else if (val == CAIRO_STATUS_FREETYPE_ERROR)
		return newSVpv ("freetype-error", 0);
	else if (val == CAIRO_STATUS_WIN32_GDI_ERROR)
		return newSVpv ("win32-gdi-error", 0);
	else if (val == CAIRO_STATUS_TAG_ERROR)
		return newSVpv ("tag-error", 0);

	warn ("unknown cairo_status_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_subpixel_order_t
cairo_subpixel_order_from_sv (SV * subpixel_order)
{
	char * str = SvPV_nolen (subpixel_order);

		if (strncmp (str, "default", 8) == 0)
		return CAIRO_SUBPIXEL_ORDER_DEFAULT;
	else if (strncmp (str, "rgb", 4) == 0)
		return CAIRO_SUBPIXEL_ORDER_RGB;
	else if (strncmp (str, "bgr", 4) == 0)
		return CAIRO_SUBPIXEL_ORDER_BGR;
	else if (strncmp (str, "vrgb", 5) == 0)
		return CAIRO_SUBPIXEL_ORDER_VRGB;
	else if (strncmp (str, "vbgr", 5) == 0)
		return CAIRO_SUBPIXEL_ORDER_VBGR;

	croak ("`%s' is not a valid cairo_subpixel_order_t value; valid values are: default, rgb, bgr, vrgb, vbgr", str);

	return 0;
}

SV *
cairo_subpixel_order_to_sv (cairo_subpixel_order_t val)
{
		if (val == CAIRO_SUBPIXEL_ORDER_DEFAULT)
		return newSVpv ("default", 0);
	else if (val == CAIRO_SUBPIXEL_ORDER_RGB)
		return newSVpv ("rgb", 0);
	else if (val == CAIRO_SUBPIXEL_ORDER_BGR)
		return newSVpv ("bgr", 0);
	else if (val == CAIRO_SUBPIXEL_ORDER_VRGB)
		return newSVpv ("vrgb", 0);
	else if (val == CAIRO_SUBPIXEL_ORDER_VBGR)
		return newSVpv ("vbgr", 0);

	warn ("unknown cairo_subpixel_order_t value %d encountered", val);
	return &PL_sv_undef;
}

cairo_surface_type_t
cairo_surface_type_from_sv (SV * surface_type)
{
	char * str = SvPV_nolen (surface_type);

		if (strncmp (str, "image", 6) == 0)
		return CAIRO_SURFACE_TYPE_IMAGE;
	else if (strncmp (str, "pdf", 4) == 0)
		return CAIRO_SURFACE_TYPE_PDF;
	else if (strncmp (str, "ps", 3) == 0)
		return CAIRO_SURFACE_TYPE_PS;
	else if (strncmp (str, "xlib", 5) == 0)
		return CAIRO_SURFACE_TYPE_XLIB;
	else if (strncmp (str, "xcb", 4) == 0)
		return CAIRO_SURFACE_TYPE_XCB;
	else if (strncmp (str, "glitz", 6) == 0)
		return CAIRO_SURFACE_TYPE_GLITZ;
	else if (strncmp (str, "quartz", 7) == 0)
		return CAIRO_SURFACE_TYPE_QUARTZ;
	else if (strncmp (str, "win32", 6) == 0)
		return CAIRO_SURFACE_TYPE_WIN32;
	else if (strncmp (str, "beos", 5) == 0)
		return CAIRO_SURFACE_TYPE_BEOS;
	else if (strncmp (str, "directfb", 9) == 0)
		return CAIRO_SURFACE_TYPE_DIRECTFB;
	else if (strncmp (str, "svg", 4) == 0)
		return CAIRO_SURFACE_TYPE_SVG;
	else if (strncmp (str, "os2", 4) == 0)
		return CAIRO_SURFACE_TYPE_OS2;
	else if (strncmp (str, "win32-printing", 15) == 0)
		return CAIRO_SURFACE_TYPE_WIN32_PRINTING;
	else if (strncmp (str, "quartz-image", 13) == 0)
		return CAIRO_SURFACE_TYPE_QUARTZ_IMAGE;
	else if (strncmp (str, "script", 7) == 0)
		return CAIRO_SURFACE_TYPE_SCRIPT;
	else if (strncmp (str, "qt", 3) == 0)
		return CAIRO_SURFACE_TYPE_QT;
	else if (strncmp (str, "recording", 10) == 0)
		return CAIRO_SURFACE_TYPE_RECORDING;
	else if (strncmp (str, "vg", 3) == 0)
		return CAIRO_SURFACE_TYPE_VG;
	else if (strncmp (str, "gl", 3) == 0)
		return CAIRO_SURFACE_TYPE_GL;
	else if (strncmp (str, "drm", 4) == 0)
		return CAIRO_SURFACE_TYPE_DRM;
	else if (strncmp (str, "tee", 4) == 0)
		return CAIRO_SURFACE_TYPE_TEE;
	else if (strncmp (str, "xml", 4) == 0)
		return CAIRO_SURFACE_TYPE_XML;
	else if (strncmp (str, "skia", 5) == 0)
		return CAIRO_SURFACE_TYPE_SKIA;
	else if (strncmp (str, "subsurface", 11) == 0)
		return CAIRO_SURFACE_TYPE_SUBSURFACE;

	croak ("`%s' is not a valid cairo_surface_type_t value; valid values are: image, pdf, ps, xlib, xcb, glitz, quartz, win32, beos, directfb, svg, os2, win32-printing, quartz-image, script, qt, recording, vg, gl, drm, tee, xml, skia, subsurface", str);

	return 0;
}

SV *
cairo_surface_type_to_sv (cairo_surface_type_t val)
{
		if (val == CAIRO_SURFACE_TYPE_IMAGE)
		return newSVpv ("image", 0);
	else if (val == CAIRO_SURFACE_TYPE_PDF)
		return newSVpv ("pdf", 0);
	else if (val == CAIRO_SURFACE_TYPE_PS)
		return newSVpv ("ps", 0);
	else if (val == CAIRO_SURFACE_TYPE_XLIB)
		return newSVpv ("xlib", 0);
	else if (val == CAIRO_SURFACE_TYPE_XCB)
		return newSVpv ("xcb", 0);
	else if (val == CAIRO_SURFACE_TYPE_GLITZ)
		return newSVpv ("glitz", 0);
	else if (val == CAIRO_SURFACE_TYPE_QUARTZ)
		return newSVpv ("quartz", 0);
	else if (val == CAIRO_SURFACE_TYPE_WIN32)
		return newSVpv ("win32", 0);
	else if (val == CAIRO_SURFACE_TYPE_BEOS)
		return newSVpv ("beos", 0);
	else if (val == CAIRO_SURFACE_TYPE_DIRECTFB)
		return newSVpv ("directfb", 0);
	else if (val == CAIRO_SURFACE_TYPE_SVG)
		return newSVpv ("svg", 0);
	else if (val == CAIRO_SURFACE_TYPE_OS2)
		return newSVpv ("os2", 0);
	else if (val == CAIRO_SURFACE_TYPE_WIN32_PRINTING)
		return newSVpv ("win32-printing", 0);
	else if (val == CAIRO_SURFACE_TYPE_QUARTZ_IMAGE)
		return newSVpv ("quartz-image", 0);
	else if (val == CAIRO_SURFACE_TYPE_SCRIPT)
		return newSVpv ("script", 0);
	else if (val == CAIRO_SURFACE_TYPE_QT)
		return newSVpv ("qt", 0);
	else if (val == CAIRO_SURFACE_TYPE_RECORDING)
		return newSVpv ("recording", 0);
	else if (val == CAIRO_SURFACE_TYPE_VG)
		return newSVpv ("vg", 0);
	else if (val == CAIRO_SURFACE_TYPE_GL)
		return newSVpv ("gl", 0);
	else if (val == CAIRO_SURFACE_TYPE_DRM)
		return newSVpv ("drm", 0);
	else if (val == CAIRO_SURFACE_TYPE_TEE)
		return newSVpv ("tee", 0);
	else if (val == CAIRO_SURFACE_TYPE_XML)
		return newSVpv ("xml", 0);
	else if (val == CAIRO_SURFACE_TYPE_SKIA)
		return newSVpv ("skia", 0);
	else if (val == CAIRO_SURFACE_TYPE_SUBSURFACE)
		return newSVpv ("subsurface", 0);

	warn ("unknown cairo_surface_type_t value %d encountered", val);
	return &PL_sv_undef;
}

#ifdef CAIRO_HAS_SVG_SURFACE

cairo_svg_version_t
cairo_svg_version_from_sv (SV * svg_version)
{
	char * str = SvPV_nolen (svg_version);

		if (strncmp (str, "1-1", 4) == 0)
		return CAIRO_SVG_VERSION_1_1;
	else if (strncmp (str, "1-2", 4) == 0)
		return CAIRO_SVG_VERSION_1_2;

	croak ("`%s' is not a valid cairo_svg_version_t value; valid values are: 1-1, 1-2", str);

	return 0;
}

SV *
cairo_svg_version_to_sv (cairo_svg_version_t val)
{
		if (val == CAIRO_SVG_VERSION_1_1)
		return newSVpv ("1-1", 0);
	else if (val == CAIRO_SVG_VERSION_1_2)
		return newSVpv ("1-2", 0);

	warn ("unknown cairo_svg_version_t value %d encountered", val);
	return &PL_sv_undef;
}

#endif /* #ifdef CAIRO_HAS_SVG_SURFACE */
