parent
1a65c82cfb
commit
cf5f6d8e74
@ -0,0 +1,39 @@
|
||||
From 43bd48014c89331cc0dadad78190890199469e81 Mon Sep 17 00:00:00 2001
|
||||
From: Syohei YOSHIDA <syohex@gmail.com>
|
||||
Date: Wed, 24 Jun 2015 18:02:57 +0900
|
||||
Subject: [PATCH 2/2] Fix test code
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
In original code, mismatching plan error is occurred.
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
t/900_mouse_bugs/017_issue29.t | 9 ++++++---
|
||||
1 file changed, 6 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/t/900_mouse_bugs/017_issue29.t b/t/900_mouse_bugs/017_issue29.t
|
||||
index 14c2900..bc93767 100644
|
||||
--- a/t/900_mouse_bugs/017_issue29.t
|
||||
+++ b/t/900_mouse_bugs/017_issue29.t
|
||||
@@ -3,10 +3,13 @@
|
||||
package main;
|
||||
use strict;
|
||||
use warnings;
|
||||
-use Test::More skip_all => 'See https://github.com/gfx/p5-Mouse/issues/29';
|
||||
-
|
||||
-use Test::Requires qw(threads); # XXX: ithreads is discuraged!
|
||||
+use constant HAS_THREADS => eval{ require threads && require threads::shared };
|
||||
+use Test::More;
|
||||
|
||||
+use if !HAS_THREADS, 'Test::More',
|
||||
+ (skip_all => "This is a test for threads ($@)");
|
||||
+use if $Test::More::VERSION >= 2.00, 'Test::More',
|
||||
+ (skip_all => "Test::Builder2 has bugs about threads");
|
||||
|
||||
{
|
||||
package Foo;
|
||||
--
|
||||
2.1.0
|
||||
|
@ -0,0 +1,195 @@
|
||||
From 40f345f8b69a863069b25c5f3aac22d8f677eb03 Mon Sep 17 00:00:00 2001
|
||||
From: Syohei YOSHIDA <syohex@gmail.com>
|
||||
Date: Wed, 24 Jun 2015 17:34:02 +0900
|
||||
Subject: [PATCH 1/2] Fix thread issue for Perl 5.22.0 or higher
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
||||
---
|
||||
mouse.h | 8 ++++++++
|
||||
xs-src/MouseAccessor.xs | 20 ++++++++++++--------
|
||||
xs-src/MouseTypeConstraints.xs | 17 +++++++++++------
|
||||
3 files changed, 31 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/mouse.h b/mouse.h
|
||||
index b0c53ef..48792a2 100644
|
||||
--- a/mouse.h
|
||||
+++ b/mouse.h
|
||||
@@ -106,6 +106,14 @@ SV* mouse_av_at_safe(pTHX_ AV* const mi, I32 const ix);
|
||||
#define MOUSE_mg_slot(mg) MOUSE_mg_obj(mg)
|
||||
#define MOUSE_mg_xa(mg) ((AV*)MOUSE_mg_ptr(mg))
|
||||
|
||||
+static inline MAGIC *MOUSE_get_magic(CV *cv, MGVTBL *vtbl)
|
||||
+{
|
||||
+#ifndef MULTIPLICITY
|
||||
+ return (MAGIC*)(CvXSUBANY(cv).any_ptr);
|
||||
+#else
|
||||
+ return mg_findext((SV*)cv, PERL_MAGIC_ext, vtbl);
|
||||
+#endif
|
||||
+}
|
||||
|
||||
/* mouse_instance.xs stuff */
|
||||
SV* mouse_instance_create (pTHX_ HV* const stash);
|
||||
diff --git a/xs-src/MouseAccessor.xs b/xs-src/MouseAccessor.xs
|
||||
index daf9cf1..11eb630 100644
|
||||
--- a/xs-src/MouseAccessor.xs
|
||||
+++ b/xs-src/MouseAccessor.xs
|
||||
@@ -122,7 +122,9 @@ mouse_accessor_generate(pTHX_ SV* const attr, XSUBADDR_t const accessor_impl){
|
||||
* although we use MAGIC for gc, we also store mg to
|
||||
* CvXSUBANY for efficiency (gfx)
|
||||
*/
|
||||
+#ifndef MULTIPLICITY
|
||||
CvXSUBANY(xsub).any_ptr = (void*)mg;
|
||||
+#endif
|
||||
|
||||
return xsub;
|
||||
}
|
||||
@@ -262,7 +264,7 @@ XS(XS_Mouse_accessor)
|
||||
{
|
||||
dVAR; dXSARGS;
|
||||
dMOUSE_self;
|
||||
- MAGIC* const mg = (MAGIC*)XSANY.any_ptr;
|
||||
+ MAGIC* const mg = MOUSE_get_magic(cv, &mouse_accessor_vtbl);
|
||||
|
||||
SP -= items; /* PPCODE */
|
||||
PUTBACK;
|
||||
@@ -285,7 +287,7 @@ XS(XS_Mouse_reader)
|
||||
{
|
||||
dVAR; dXSARGS;
|
||||
dMOUSE_self;
|
||||
- MAGIC* const mg = (MAGIC*)XSANY.any_ptr;
|
||||
+ MAGIC* const mg = MOUSE_get_magic(cv, &mouse_accessor_vtbl);
|
||||
|
||||
if (items != 1) {
|
||||
mouse_throw_error(MOUSE_mg_attribute(mg), NULL,
|
||||
@@ -303,7 +305,7 @@ XS(XS_Mouse_writer)
|
||||
{
|
||||
dVAR; dXSARGS;
|
||||
dMOUSE_self;
|
||||
- MAGIC* const mg = (MAGIC*)XSANY.any_ptr;
|
||||
+ MAGIC* const mg = MOUSE_get_magic(cv, &mouse_accessor_vtbl);
|
||||
|
||||
if (items != 2) {
|
||||
mouse_throw_error(MOUSE_mg_attribute(mg), NULL,
|
||||
@@ -351,7 +353,9 @@ mouse_simple_accessor_generate(pTHX_
|
||||
* although we use MAGIC for gc, we also store mg to CvXSUBANY
|
||||
* for efficiency (gfx)
|
||||
*/
|
||||
+#ifndef MULTIPLICITY
|
||||
CvXSUBANY(xsub).any_ptr = (void*)mg;
|
||||
+#endif
|
||||
|
||||
return xsub;
|
||||
}
|
||||
@@ -360,7 +364,7 @@ XS(XS_Mouse_simple_reader)
|
||||
{
|
||||
dVAR; dXSARGS;
|
||||
dMOUSE_self;
|
||||
- MAGIC* const mg = (MAGIC*)XSANY.any_ptr;
|
||||
+ MAGIC* const mg = MOUSE_get_magic(cv, &mouse_accessor_vtbl);
|
||||
SV* value;
|
||||
|
||||
if (items != 1) {
|
||||
@@ -389,7 +393,7 @@ XS(XS_Mouse_simple_writer)
|
||||
{
|
||||
dVAR; dXSARGS;
|
||||
dMOUSE_self;
|
||||
- SV* const slot = MOUSE_mg_slot((MAGIC*)XSANY.any_ptr);
|
||||
+ SV* const slot = MOUSE_mg_slot(MOUSE_get_magic(cv, &mouse_accessor_vtbl));
|
||||
|
||||
if (items != 2) {
|
||||
croak("Expected exactly two argument for a writer of %"SVf,
|
||||
@@ -404,7 +408,7 @@ XS(XS_Mouse_simple_clearer)
|
||||
{
|
||||
dVAR; dXSARGS;
|
||||
dMOUSE_self;
|
||||
- SV* const slot = MOUSE_mg_slot((MAGIC*)XSANY.any_ptr);
|
||||
+ SV* const slot = MOUSE_mg_slot(MOUSE_get_magic(cv, &mouse_accessor_vtbl));
|
||||
SV* value;
|
||||
|
||||
if (items != 1) {
|
||||
@@ -421,7 +425,7 @@ XS(XS_Mouse_simple_predicate)
|
||||
{
|
||||
dVAR; dXSARGS;
|
||||
dMOUSE_self;
|
||||
- SV* const slot = MOUSE_mg_slot((MAGIC*)XSANY.any_ptr);
|
||||
+ SV* const slot = MOUSE_mg_slot(MOUSE_get_magic(cv, &mouse_accessor_vtbl));
|
||||
|
||||
if (items != 1) {
|
||||
croak("Expected exactly one argument for a predicate of %"SVf, slot);
|
||||
@@ -435,7 +439,7 @@ XS(XS_Mouse_simple_predicate)
|
||||
XS(XS_Mouse_inheritable_class_accessor) {
|
||||
dVAR; dXSARGS;
|
||||
dMOUSE_self;
|
||||
- SV* const slot = MOUSE_mg_slot((MAGIC*)XSANY.any_ptr);
|
||||
+ SV* const slot = MOUSE_mg_slot(MOUSE_get_magic(cv, &mouse_accessor_vtbl));
|
||||
SV* value;
|
||||
HV* stash;
|
||||
|
||||
diff --git a/xs-src/MouseTypeConstraints.xs b/xs-src/MouseTypeConstraints.xs
|
||||
index d4b57a0..6d723ee 100644
|
||||
--- a/xs-src/MouseTypeConstraints.xs
|
||||
+++ b/xs-src/MouseTypeConstraints.xs
|
||||
@@ -24,6 +24,8 @@ typedef int (*check_fptr_t)(pTHX_ SV* const data, SV* const sv);
|
||||
static
|
||||
XSPROTO(XS_Mouse_constraint_check);
|
||||
|
||||
+static MGVTBL mouse_util_type_constraints_vtbl; /* not used, only for identity */
|
||||
+
|
||||
/*
|
||||
NOTE: mouse_tc_check() handles GETMAGIC
|
||||
*/
|
||||
@@ -33,9 +35,10 @@ mouse_tc_check(pTHX_ SV* const tc_code, SV* const sv) {
|
||||
assert(SvTYPE(cv) == SVt_PVCV);
|
||||
|
||||
if(CvXSUB(cv) == XS_Mouse_constraint_check){ /* built-in type constraints */
|
||||
- MAGIC* const mg = (MAGIC*)CvXSUBANY(cv).any_ptr;
|
||||
-
|
||||
+ MAGIC* const mg = MOUSE_get_magic(cv, &mouse_util_type_constraints_vtbl);
|
||||
+#ifndef MULTIPLICITY
|
||||
assert(CvXSUBANY(cv).any_ptr != NULL);
|
||||
+#endif
|
||||
assert(mg->mg_ptr != NULL);
|
||||
|
||||
SvGETMAGIC(sv);
|
||||
@@ -498,14 +501,13 @@ mouse_can_methods(pTHX_ AV* const methods, SV* const instance){
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
-static MGVTBL mouse_util_type_constraints_vtbl; /* not used, only for identity */
|
||||
-
|
||||
static CV*
|
||||
mouse_tc_generate(pTHX_ const char* const name, check_fptr_t const fptr, SV* const param) {
|
||||
CV* xsub;
|
||||
+ MAGIC* mg;
|
||||
|
||||
xsub = newXS(name, XS_Mouse_constraint_check, __FILE__);
|
||||
- CvXSUBANY(xsub).any_ptr = sv_magicext(
|
||||
+ mg = sv_magicext(
|
||||
(SV*)xsub,
|
||||
param, /* mg_obj: refcnt will be increased */
|
||||
PERL_MAGIC_ext,
|
||||
@@ -513,6 +515,9 @@ mouse_tc_generate(pTHX_ const char* const name, check_fptr_t const fptr, SV* con
|
||||
(char*)fptr, /* mg_ptr */
|
||||
0 /* mg_len: 0 for static data */
|
||||
);
|
||||
+#ifndef MULTIPLICITY
|
||||
+ CvXSUBANY(xsub).any_ptr = (void*)mg;
|
||||
+#endif
|
||||
|
||||
if(!name){
|
||||
sv_2mortal((SV*)xsub);
|
||||
@@ -569,7 +574,7 @@ static
|
||||
XSPROTO(XS_Mouse_constraint_check) {
|
||||
dVAR;
|
||||
dXSARGS;
|
||||
- MAGIC* const mg = (MAGIC*)XSANY.any_ptr;
|
||||
+ MAGIC* const mg = MOUSE_get_magic(cv, &mouse_util_type_constraints_vtbl);
|
||||
SV* sv;
|
||||
|
||||
if(items < 1){
|
||||
--
|
||||
2.1.0
|
||||
|
Loading…
Reference in new issue