Skip Menu |

This queue is for tickets about the Sentinel CPAN distribution.

Report information
The Basics
Id: 118222
Status: patched
Priority: 0/
Queue: Sentinel

People
Owner: Nobody in particular
Requestors: RANDIR [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Callbacks with utf8 names were handled wrong
Use utf8-aware API for callback calls, and use faster PV-only version of it when available: === modified file 'lib/Sentinel.xs' --- lib/Sentinel.xs 2016-09-30 17:14:04 +0000 +++ lib/Sentinel.xs 2016-10-02 00:22:33 +0000 @@ -12,6 +12,10 @@ #define SvREFCNT_inc_simple SvREFCNT_inc #endif +#ifndef G_METHOD_NAMED +#define G_METHOD_NAMED G_METHOD +#endif + #include <string.h> #define streq(a,b) (strcmp((a),(b)) == 0) @@ -41,7 +45,7 @@ if(ctx->obj && SvPOK(ctx->get_cb)) // Calling method by name - count = call_method(SvPV_nolen(ctx->get_cb), G_SCALAR); + count = call_sv(ctx->get_cb, G_SCALAR | G_METHOD_NAMED); else count = call_sv(ctx->get_cb, G_SCALAR); assert(count == 1); @@ -78,7 +82,7 @@ if(ctx->obj && SvPOK(ctx->set_cb)) // Calling method by name - call_method(SvPV_nolen(ctx->set_cb), G_VOID); + call_sv(ctx->set_cb, G_VOID | G_METHOD_NAMED); else call_sv(ctx->set_cb, G_VOID); === modified file 't/11accessor.t' --- t/11accessor.t 2014-05-11 14:11:22 +0000 +++ t/11accessor.t 2016-10-02 00:27:26 +0000 @@ -2,6 +2,7 @@ use strict; use warnings; +use utf8; use Test::More; @@ -13,6 +14,10 @@ sub get_foo { return $_[0]->{foo} } sub set_foo { $_[0]->{foo} = $_[1] } +sub get_у { goto &get_foo } +sub set_у { goto &set_foo } + +package TestObject; sub foo :lvalue { my $self = shift; @@ -21,6 +26,14 @@ set => \&set_foo; } +sub foo_utf8 :lvalue +{ + my $self = shift; + sentinel obj => $self, + get => "get_у", + set => "set_у"; +} + sub foo_named :lvalue { my $self = shift; @@ -56,4 +69,10 @@ is( $obj->get_foo, "Another message", '$obj->get_foo after set via lvalue named' ); +is( $obj->foo_utf8, "Another message", '$obj->foo_utf8 performs method name lookup' ); + +$obj->foo_utf8 = "Yet another message"; + +is( $obj->get_foo, "Yet another message", '$obj->get_foo after set via lvalue utf8' ); + done_testing;
Thanks. Applied, via a slight renaming of the non-ASCII function name to avoid an ASCII homoglyph. (I usually like to use one of the Esperanto characters as they're not even Latin-1 so it tends to shake out the ISO 8859-1 bugs too.) -- Paul Evans