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

#include <cairo-perl.h>
#include <cairo-perl-private.h>

static cairo_pdf_outline_flags_t
cairo_pdf_outline_flags_from_sv_part (const char *str)
{
		if (strncmp (str, "open", 5) == 0) {
		return CAIRO_PDF_OUTLINE_FLAG_OPEN;
	}
	else if (strncmp (str, "bold", 5) == 0) {
		return CAIRO_PDF_OUTLINE_FLAG_BOLD;
	}
	else if (strncmp (str, "italic", 7) == 0) {
		return CAIRO_PDF_OUTLINE_FLAG_ITALIC;
	}

	croak ("`%s' is not a valid cairo_pdf_outline_flags_t value; valid values are: open, bold, italic", str);
	return 0;
}

cairo_pdf_outline_flags_t
cairo_pdf_outline_flags_from_sv (SV * pdf_outline_flags)
{
	if (cairo_perl_sv_is_array_ref (pdf_outline_flags)) {
		AV *vals = (AV *) SvRV (pdf_outline_flags);
		cairo_pdf_outline_flags_t value = 0;
		int i;
		for (i=0; i<=av_len(vals); i++)
			value |= cairo_pdf_outline_flags_from_sv_part (
					SvPV_nolen (*av_fetch (vals, i, 0)));
		return value;
	}
	if (SvPOK (pdf_outline_flags))
		return cairo_pdf_outline_flags_from_sv_part (SvPV_nolen (pdf_outline_flags));
	croak ("`%s' is not a valid cairo_pdf_outline_flags_t value, expecting a string scalar "
	       "or an arrayref of strings",
	       SvPV_nolen (pdf_outline_flags));
	return 0;
}

SV *
cairo_pdf_outline_flags_to_sv (cairo_pdf_outline_flags_t val)
{
	AV *flags = newAV ();
		if ((val & CAIRO_PDF_OUTLINE_FLAG_OPEN) == CAIRO_PDF_OUTLINE_FLAG_OPEN) {
		val -= CAIRO_PDF_OUTLINE_FLAG_OPEN;
		av_push (flags, newSVpv ("open", 0));
	}
	if ((val & CAIRO_PDF_OUTLINE_FLAG_BOLD) == CAIRO_PDF_OUTLINE_FLAG_BOLD) {
		val -= CAIRO_PDF_OUTLINE_FLAG_BOLD;
		av_push (flags, newSVpv ("bold", 0));
	}
	if ((val & CAIRO_PDF_OUTLINE_FLAG_ITALIC) == CAIRO_PDF_OUTLINE_FLAG_ITALIC) {
		val -= CAIRO_PDF_OUTLINE_FLAG_ITALIC;
		av_push (flags, newSVpv ("italic", 0));
	}

	return newRV_noinc ((SV *) flags);
}

static cairo_text_cluster_flags_t
cairo_text_cluster_flags_from_sv_part (const char *str)
{
		if (strncmp (str, "backward", 9) == 0) {
		return CAIRO_TEXT_CLUSTER_FLAG_BACKWARD;
	}

	croak ("`%s' is not a valid cairo_text_cluster_flags_t value; valid values are: backward", str);
	return 0;
}

cairo_text_cluster_flags_t
cairo_text_cluster_flags_from_sv (SV * text_cluster_flags)
{
	if (cairo_perl_sv_is_array_ref (text_cluster_flags)) {
		AV *vals = (AV *) SvRV (text_cluster_flags);
		cairo_text_cluster_flags_t value = 0;
		int i;
		for (i=0; i<=av_len(vals); i++)
			value |= cairo_text_cluster_flags_from_sv_part (
					SvPV_nolen (*av_fetch (vals, i, 0)));
		return value;
	}
	if (SvPOK (text_cluster_flags))
		return cairo_text_cluster_flags_from_sv_part (SvPV_nolen (text_cluster_flags));
	croak ("`%s' is not a valid cairo_text_cluster_flags_t value, expecting a string scalar "
	       "or an arrayref of strings",
	       SvPV_nolen (text_cluster_flags));
	return 0;
}

SV *
cairo_text_cluster_flags_to_sv (cairo_text_cluster_flags_t val)
{
	AV *flags = newAV ();
		if ((val & CAIRO_TEXT_CLUSTER_FLAG_BACKWARD) == CAIRO_TEXT_CLUSTER_FLAG_BACKWARD) {
		val -= CAIRO_TEXT_CLUSTER_FLAG_BACKWARD;
		av_push (flags, newSVpv ("backward", 0));
	}

	return newRV_noinc ((SV *) flags);
}

