--- /dev/null
+#!perl
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+use Tie::Scalar;
+
+{
+ package MyClass;
+ use Mouse;
+
+ has foo => (
+ is => 'rw',
+ isa => 'Int',
+ );
+ has bar => (
+ is => 'rw',
+ isa => 'Maybe[Int]',
+ );
+}
+
+sub ts_init {
+ tie $_[0], 'Tie::StdScalar', $_[1];
+}
+
+ts_init(my $x, 10);
+
+my $o = MyClass->new();
+is(eval{ $o->foo($x) }, 10)
+ or diag("Error: $@");
+
+ts_init($x, 'foo');
+
+eval{
+ $o->bar($x);
+};
+isnt $@, '';
+
+ts_init $x, 42;
+is(eval{ $o->bar($x) }, 42)
+ or diag("Error: $@");
+
typedef int (*check_fptr_t)(pTHX_ SV* const data, SV* const sv);
+/*
+ NOTE: mouse_tc_check() handles GETMAGIC
+*/
int
mouse_tc_check(pTHX_ SV* const tc_code, SV* const sv) {
CV* const cv = (CV*)SvRV(tc_code);
assert(SvTYPE(cv) == SVt_PVCV);
+ SvGETMAGIC(sv);
if(CvXSUB(cv) == XS_Mouse_constraint_check){ /* built-in type constraints */
MAGIC* const mg = (MAGIC*)CvXSUBANY(cv).any_ptr;
I32 i;
for(i = 0; i < len; i++){
SV* const value = *av_fetch(av, i, TRUE);
- SvGETMAGIC(value);
if(!mouse_tc_check(aTHX_ param, value)){
return FALSE;
}
hv_iterinit(hv);
while((he = hv_iternext(hv))){
SV* const value = hv_iterval(hv, he);
- SvGETMAGIC(value);
if(!mouse_tc_check(aTHX_ param, value)){
hv_iterinit(hv); /* reset */
return FALSE;