patch-Slim_Utils_Accessor_pm 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. $OpenBSD: patch-Slim_Utils_Accessor_pm,v 1.1 2011/03/02 08:35:14 sthen Exp $
  2. don't rely on Class::XSAccessor internals; taken from newer squeezeboxserver
  3. --- Slim/Utils/Accessor.pm.orig Mon Jan 24 19:59:11 2011
  4. +++ Slim/Utils/Accessor.pm Mon Jan 24 19:59:17 2011
  5. @@ -37,9 +37,13 @@ BEGIN {
  6. $hasXS = 0;
  7. eval {
  8. require Class::XSAccessor::Array;
  9. - die if $Class::XSAccessor::Array::VERSION lt '0.05';
  10. + die if $Class::XSAccessor::Array::VERSION lt '1.05';
  11. $hasXS = 1;
  12. };
  13. +
  14. + if ( $@ ) {
  15. + warn "NOTE: Class::XSAccessor 1.05+ not found, install it for better performance\n";
  16. + }
  17. return $hasXS;
  18. }
  19. @@ -94,8 +98,9 @@ sub mk_accessor {
  20. if ($type eq 'rw') {
  21. if ( hasXS() ) {
  22. - Class::XSAccessor::Array::_generate_accessor(
  23. - $class, $field, $n, 0, 0, 'accessor',
  24. + Class::XSAccessor::Array->import(
  25. + class => $class,
  26. + accessors => { $field, $n }
  27. );
  28. }
  29. else {
  30. @@ -108,8 +113,9 @@ sub mk_accessor {
  31. } elsif ($type eq 'ro') {
  32. if ( hasXS() ) {
  33. - Class::XSAccessor::Array::_generate_accessor(
  34. - $class, $field, $n, 0, 0, 'getter',
  35. + Class::XSAccessor::Array->import(
  36. + class => $class,
  37. + getters => { $field, $n }
  38. );
  39. }
  40. else {
  41. @@ -152,6 +158,15 @@ sub mk_accessor {
  42. return $_[0]->[$n]->{ $_[1] } = $_[2] if @_ == 3;
  43. };
  44. + } elsif ($type eq 'rw_bt') {
  45. +
  46. + $accessor = sub {
  47. + return $_[0]->[$n] if @_ == 1;
  48. + if (@_ == 2) {
  49. + logBacktrace("$class ->$field set to $_[1]");
  50. + return $_[0]->[$n] = $_[1];
  51. + }
  52. + };
  53. }
  54. if ($accessor) {