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

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

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);
}

