1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- $OpenBSD: patch-Slim_Utils_Accessor_pm,v 1.1 2011/03/02 08:35:14 sthen Exp $
- don't rely on Class::XSAccessor internals; taken from newer squeezeboxserver
- --- Slim/Utils/Accessor.pm.orig Mon Jan 24 19:59:11 2011
- +++ Slim/Utils/Accessor.pm Mon Jan 24 19:59:17 2011
- @@ -37,9 +37,13 @@ BEGIN {
- $hasXS = 0;
- eval {
- require Class::XSAccessor::Array;
- - die if $Class::XSAccessor::Array::VERSION lt '0.05';
- + die if $Class::XSAccessor::Array::VERSION lt '1.05';
- $hasXS = 1;
- };
- +
- + if ( $@ ) {
- + warn "NOTE: Class::XSAccessor 1.05+ not found, install it for better performance\n";
- + }
-
- return $hasXS;
- }
- @@ -94,8 +98,9 @@ sub mk_accessor {
- if ($type eq 'rw') {
-
- if ( hasXS() ) {
- - Class::XSAccessor::Array::_generate_accessor(
- - $class, $field, $n, 0, 0, 'accessor',
- + Class::XSAccessor::Array->import(
- + class => $class,
- + accessors => { $field, $n }
- );
- }
- else {
- @@ -108,8 +113,9 @@ sub mk_accessor {
- } elsif ($type eq 'ro') {
-
- if ( hasXS() ) {
- - Class::XSAccessor::Array::_generate_accessor(
- - $class, $field, $n, 0, 0, 'getter',
- + Class::XSAccessor::Array->import(
- + class => $class,
- + getters => { $field, $n }
- );
- }
- else {
- @@ -152,6 +158,15 @@ sub mk_accessor {
- return $_[0]->[$n]->{ $_[1] } = $_[2] if @_ == 3;
- };
-
- + } elsif ($type eq 'rw_bt') {
- +
- + $accessor = sub {
- + return $_[0]->[$n] if @_ == 1;
- + if (@_ == 2) {
- + logBacktrace("$class ->$field set to $_[1]");
- + return $_[0]->[$n] = $_[1];
- + }
- + };
- }
-
- if ($accessor) {
|