[perl-Cairo] Add two private helper macros



commit 24729a6605ae267d7fb0ea25bc91a2af11c71e31
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Sun May 16 21:08:16 2010 +0200

    Add two private helper macros
    
    Namely, cairo_perl_sv_is_array_ref and cairo_perl_sv_is_hash_ref.

 Cairo.xs             |    2 +-
 cairo-perl-private.h |    6 ++++++
 2 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/Cairo.xs b/Cairo.xs
index c657714..430bad4 100644
--- a/Cairo.xs
+++ b/Cairo.xs
@@ -199,7 +199,7 @@ SvCairoGlyph (SV *sv)
 	SV **value;
 	cairo_glyph_t *glyph;
 
-	if (!SvOK (sv) || !SvRV (sv) || SvTYPE (SvRV (sv)) != SVt_PVHV)
+	if (!cairo_perl_sv_is_hash_ref (sv))
 		croak ("cairo_glyph_t must be a hash reference");
 
 	hv = (HV *) SvRV (sv);
diff --git a/cairo-perl-private.h b/cairo-perl-private.h
index 38e9599..622d59c 100644
--- a/cairo-perl-private.h
+++ b/cairo-perl-private.h
@@ -33,4 +33,10 @@ const char * cairo_perl_package_table_lookup (void *pointer);
 		croak (Nullch);					\
 	}
 
+#define cairo_perl_sv_is_array_ref(sv) \
+	(SvOK (sv) && SvROK (sv) && SvTYPE (SvRV(sv)) == SVt_PVAV)
+
+#define cairo_perl_sv_is_hash_ref(sv) \
+	(SvOK (sv) && SvROK (sv) && SvTYPE (SvRV(sv)) == SVt_PVHV)
+
 #endif /* _CAIRO_PERL_PRIVATE_H_ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]