Current version is 0.07.
Distribution from this site.
CPAN site
NAME
Class::XSAccessor - Generate fast XS accessors without runtime
compilation
SYNOPSIS
package MyClass;
use Class::XSAccessor
getters => {
get_foo => 'foo', # 'foo' is the hash key to access
get_bar => 'bar',
},
setters => {
set_foo => 'foo',
set_bar => 'bar',
};
# The imported methods are implemented in fast XS.
# normal class code here.
DESCRIPTION
The module implements fast XS accessors both for getting at and setting
an objects attribute. The module works only with objects that are
implement as ordinary hashes. Class::XSAccessor::Array implements the
same interface for objects that use arrays as internal representation.
The XS methods were between 1.6 and 2.5 times faster than typical
pure-perl getter and setter implementations in some simple benchmarking.
The lower factor applies to the potentially slightly obscure "sub
set_foo_pp {$_[0]->{foo} = $_[1]}", so if you usually write clear code,
a factor of two speed-up is a good estimate.
The method names may be fully qualified. In the example of the synopsis,
you could have written "MyClass::get_foo" instead of "get_foo".
CAVEATS
Probably wouldn't work if your objects are *tied* hashes. But that's a
strange thing to do anyway.
Scary code exploiting strange XS features.
If you think writing an accessor in XS should be a laughably simple
exercise, then please contemplate how you could instantiate a new XS
accessor for a new hash key that's only known at run-time. Note that
compiling C code at run-time a la Inline::C is a no go.
SEE ALSO
Class::XSAccessor::Array
AutoXS
AUTHOR
Steffen Mueller,
COPYRIGHT AND LICENSE
Copyright (C) 2008 by Steffen Mueller
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.8 or, at your
option, any later version of Perl 5 you may have available.
Revision history for Perl extension Class::XSAccessor.
0.07 Thu Aug 29 14:14 2008
- Documented the "replace" option.
- Added the "chained" option to generate chainable setters
and mutators.
0.06 Thu Aug 28 13:39 2008
- Copy input scalars on setter/mutator calls (RT #38573)
0.05 Sat Jun 21 18:06 2008
- Add read/write accessors. (Chocolateboy)
- By default, return the new value from setters. (Chocolateboy)
- Add predicates, i.e. "has_foo".
0.04 Mon May 3 19:12 2008
- Win32 support.
0.03 Mon May 3 19:12 2008
- Refer to Class::XSAccessor::Array for array based objects.
0.02 Mon Apr 3 17:12 2008
- Mention in the docs that fully qualified method names are
supported.
0.01 Mon Apr 3 17:09 2008
- original version as uploaded to CPAN.
(c) 2002-2008 Steffen Müller; All rights reserved.