From c5a6ee923bcac678282ff05770b8c0c566f5e3c2 Mon Sep 17 00:00:00 2001 From: Alessandro Vullo <avullo@ebi.ac.uk> Date: Fri, 25 Oct 2013 14:59:59 +0000 Subject: [PATCH] Added support for the Ensembl API C extensions --- modules/Bio/EnsEMBL/Utils/Scalar.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/modules/Bio/EnsEMBL/Utils/Scalar.pm b/modules/Bio/EnsEMBL/Utils/Scalar.pm index 3ed68f9dc4..5594dd6b3a 100644 --- a/modules/Bio/EnsEMBL/Utils/Scalar.pm +++ b/modules/Bio/EnsEMBL/Utils/Scalar.pm @@ -102,6 +102,19 @@ $Revision$ use strict; use warnings; +BEGIN { + + if (eval { require Bio::EnsEMBL::XS; 1 }) { + *check_ref = \&Bio::EnsEMBL::XS::Utils::Scalar::check_ref; + *assert_ref = \&Bio::EnsEMBL::XS::Utils::Scalar::assert_ref; + } else { + *check_ref = \&check_ref_pp; + *assert_ref = \&assert_ref_pp; + } + +} + + use base qw(Exporter); our %EXPORT_TAGS; @@ -126,7 +139,7 @@ use Scalar::Util qw(blessed looks_like_number openhandle); our $ASSERTIONS = 1; -=head2 check_ref() +=head2 check_ref_pp() Arg [1] : The reference to check Arg [2] : The type we expect @@ -144,7 +157,7 @@ our $ASSERTIONS = 1; =cut -sub check_ref { +sub check_ref_pp { my ($ref, $expected) = @_; throw('No expected type given') if ! defined $expected; if(defined $ref) { @@ -159,7 +172,7 @@ sub check_ref { return 0; } -=head2 assert_ref() +=head2 assert_ref_pp() Arg [1] : The reference to check Arg [2] : The type we expect @@ -184,7 +197,7 @@ sub check_ref { =cut -sub assert_ref { +sub assert_ref_pp { my ($ref, $expected, $attribute_name) = @_; return 1 unless $ASSERTIONS; $attribute_name ||= '-Unknown-'; -- GitLab