1 package Class::MOP::Deprecated;
7 our $VERSION = '0.92_01';
8 $VERSION = eval $VERSION;
9 our $AUTHORITY = 'cpan:STEVAN';
13 # features deprecated before 0.93
14 'Class::MOP::HAVE_ISAREV' => 0.93,
15 'Class::MOP::subname' => 0.93,
16 'Class::MOP::in_global_destruction' => 0.93,
18 'Class::MOP::Package::get_method_map' => 0.93,
20 'Class::MOP::Class::construct_class_instance' => 0.93,
21 'Class::MOP::Class::check_metaclass_compatibility' => 0.93,
22 'Class::MOP::Class::create_meta_instance' => 0.93,
23 'Class::MOP::Class::clone_instance' => 0.93,
24 'Class::MOP::Class::alias_method' => 0.93,
25 'Class::MOP::Class::compute_all_applicable_methods' => 0.93,
26 'Class::MOP::Class::compute_all_applicable_attributes' => 0.93,
28 'Class::MOP::Instance::bless_instance_structure' => 0.93,
30 'Class::MOP::Attribute::process_accessors' => 0.93,
32 'Class::MOP::Method::Accessor::initialize_body' => 0.93,
33 'Class::MOP::Method::Accessor::generate_accessor_method' => 0.93,
34 'Class::MOP::Method::Accessor::generate_reader_method' => 0.93,
35 'Class::MOP::Method::Accessor::generate_writer_method' => 0.93,
36 'Class::MOP::Method::Accessor::generate_predicate_method' => 0.93,
37 'Class::MOP::Method::Accessor::generate_clearer_method' => 0.93,
38 'Class::MOP::Method::Accessor::generate_accessor_method_inline' => 0.93,
39 'Class::MOP::Method::Accessor::generate_reader_method_inline' => 0.93,
40 'Class::MOP::Method::Accessor::generate_writer_method_inline' => 0.93,
41 'Class::MOP::Method::Accessor::generate_clearer_method_inline' => 0.93,
42 'Class::MOP::Method::Accessor::generate_predicate_method_inline' => 0.93,
44 'Class::MOP::Method::Constructor::meta_instance' => 0.93,
45 'Class::MOP::Method::Constructor::attributes' => 0.93,
46 'Class::MOP::Method::Constructor::initialize_body' => 0.93,
47 'Class::MOP::Method::Constructor::generate_constructor_method' => 0.93,
48 'Class::MOP::Method::Constructor::generate_constructor_method_inline' =>
51 # features deprecated after 0.93
58 my ( $class, %args ) = @_;
60 if ( defined( my $compat_version = delete $args{-compatible} ) ) {
61 $Registry{ (caller) } = $compat_version;
65 my $unknowns = join q{ }, keys %args;
66 cluck "Unknown argument(s) for $class->import: $unknowns.\n";
72 my ( $package, undef, undef, $feature ) = caller(1);
75 while ( $package && !defined( $compat_version = $Registry{$package} ) ) {
76 $package =~ s/ :: \w+ \z//xms or last;
79 my $deprecated_at = $DeprecatedAt{$feature}
80 or die "Unregistered deprecated feature: $feature";
82 if ( !defined($compat_version)
83 || $compat_version >= $DeprecatedAt{$feature} ) {
92 Class::MOP::Deprecated::warn(
93 "Class::MOP::HAVE_ISAREV is deprecated and will be removed in a future release. It has always returned 1 anyway."
99 Class::MOP::Deprecated::warn(
100 "Class::MOP::subname is deprecated. Please use Sub::Name directly.");
102 goto \&Sub::Name::subname;
105 sub in_global_destruction {
106 Class::MOP::Deprecated::warn(
107 "Class::MOP::in_global_destruction is deprecated. Please use Devel::GlobalDestruction directly."
109 require Devel::GlobalDestruction;
110 goto \&Devel::GlobalDestruction::in_global_destruction;
122 sub construct_class_instance {
123 Class::MOP::Deprecated::warn(
124 'The construct_class_instance method has been made private.'
125 . " The public version is deprecated and will be removed in a future release.\n"
127 shift->_construct_class_instance(@_);
130 sub check_metaclass_compatibility {
131 Class::MOP::Deprecated::warn(
132 'The check_metaclass_compatibility method has been made private.'
133 . " The public version is deprecated and will be removed in a future release.\n"
135 shift->_check_metaclass_compatibility(@_);
138 sub construct_instance {
139 Class::MOP::Deprecated::warn(
140 'The construct_instance method has been made private.'
141 . " The public version is deprecated and will be removed in a future release.\n"
143 shift->_construct_instance(@_);
146 sub create_meta_instance {
147 Class::MOP::Deprecated::warn(
148 'The create_meta_instance method has been made private.'
149 . " The public version is deprecated and will be removed in a future release.\n"
151 shift->_create_meta_instance(@_);
155 Class::MOP::Deprecated::warn(
156 'The clone_instance method has been made private.'
157 . " The public version is deprecated and will be removed in a future release.\n"
159 shift->_clone_instance(@_);
163 Class::MOP::Deprecated::warn(
164 "The alias_method method is deprecated. Use add_method instead.\n");
166 shift->add_method(@_);
169 sub compute_all_applicable_methods {
170 Class::MOP::Deprecated::warn(
171 'The compute_all_applicable_methods method is deprecated.'
172 . " Use get_all_methods instead.\n" );
177 class => $_->package_name,
178 code => $_, # sigh, overloading
180 } shift->get_all_methods(@_);
183 sub compute_all_applicable_attributes {
184 Class::MOP::Deprecated::warn(
185 'The compute_all_applicable_attributes method has been deprecated.'
186 . " Use get_all_attributes instead.\n" );
188 shift->get_all_attributes(@_);
192 Class::MOP::Instance;
194 sub bless_instance_structure {
195 Class::MOP::Deprecated::warn(
196 'The bless_instance_structure method is deprecated.'
197 . " It will be removed in a future release.\n" );
199 my ( $self, $instance_structure ) = @_;
200 bless $instance_structure, $self->_class_name;
204 Class::MOP::Attribute;
206 sub process_accessors {
207 Class::MOP::Deprecated::warn(
208 'The process_accessors method has been made private.'
209 . " The public version is deprecated and will be removed in a future release.\n"
211 shift->_process_accessors(@_);
215 Class::MOP::Method::Accessor;
217 sub initialize_body {
218 Class::MOP::Deprecated::warn(
219 'The initialize_body method has been made private.'
220 . " The public version is deprecated and will be removed in a future release.\n"
222 shift->_initialize_body;
225 sub generate_accessor_method {
226 Class::MOP::Deprecated::warn(
227 'The generate_accessor_method method has been made private.'
228 . " The public version is deprecated and will be removed in a future release.\n"
230 shift->_generate_accessor_method;
233 sub generate_reader_method {
234 Class::MOP::Deprecated::warn(
235 'The generate_reader_method method has been made private.'
236 . " The public version is deprecated and will be removed in a future release.\n"
238 shift->_generate_reader_method;
241 sub generate_writer_method {
242 Class::MOP::Deprecated::warn(
243 'The generate_writer_method method has been made private.'
244 . " The public version is deprecated and will be removed in a future release.\n"
246 shift->_generate_writer_method;
249 sub generate_predicate_method {
250 Class::MOP::Deprecated::warn(
251 'The generate_predicate_method method has been made private.'
252 . " The public version is deprecated and will be removed in a future release.\n"
254 shift->_generate_predicate_method;
257 sub generate_clearer_method {
258 Class::MOP::Deprecated::warn(
259 'The generate_clearer_method method has been made private.'
260 . " The public version is deprecated and will be removed in a future release.\n"
262 shift->_generate_clearer_method;
265 sub generate_accessor_method_inline {
266 Class::MOP::Deprecated::warn(
267 'The generate_accessor_method_inline method has been made private.'
268 . " The public version is deprecated and will be removed in a future release.\n"
270 shift->_generate_accessor_method_inline;
273 sub generate_reader_method_inline {
274 Class::MOP::Deprecated::warn(
275 'The generate_reader_method_inline method has been made private.'
276 . " The public version is deprecated and will be removed in a future release.\n"
278 shift->_generate_reader_method_inline;
281 sub generate_writer_method_inline {
282 Class::MOP::Deprecated::warn(
283 'The generate_writer_method_inline method has been made private.'
284 . " The public version is deprecated and will be removed in a future release.\n"
286 shift->_generate_writer_method_inline;
289 sub generate_predicate_method_inline {
290 Class::MOP::Deprecated::warn(
291 'The generate_predicate_method_inline method has been made private.'
292 . " The public version is deprecated and will be removed in a future release.\n"
294 shift->_generate_predicate_method_inline;
297 sub generate_clearer_method_inline {
298 Class::MOP::Deprecated::warn(
299 'The generate_clearer_method_inline method has been made private.'
300 . " The public version is deprecated and will be removed in a future release.\n"
302 shift->_generate_clearer_method_inline;
306 Class::MOP::Method::Constructor;
309 Class::MOP::Deprecated::warn(
310 'The meta_instance method has been made private.'
311 . " The public version is deprecated and will be removed in a future release.\n"
313 shift->_meta_instance;
317 Class::MOP::Deprecated::warn(
318 'The attributes method has been made private.'
319 . " The public version is deprecated and will be removed in a future release.\n"
322 return shift->_attributes;
325 sub initialize_body {
326 Class::MOP::Deprecated::warn(
327 'The initialize_body method has been made private.'
328 . " The public version is deprecated and will be removed in a future release.\n"
330 shift->_initialize_body;
333 sub generate_constructor_method {
334 Class::MOP::Deprecated::warn(
335 'The generate_constructor_method method has been made private.'
336 . " The public version is deprecated and will be removed in a future release.\n"
338 shift->_generate_constructor_method;
341 sub generate_constructor_method_inline {
342 Class::MOP::Deprecated::warn(
343 'The generate_constructor_method_inline method has been made private.'
344 . " The public version is deprecated and will be removed in a future release.\n"
346 shift->_generate_constructor_method_inline;
357 Class::MOP::Deprecated - List of deprecated methods
361 use Class::MOP::Deprecated -compatible => $version;
365 This class provides methods that have been deprecated but remain for backward compatibility.
367 If you specify C<< -compatible => $version >>, you can use deprecated features without warnings.
368 Note that this special treatment is package-scoped.
372 =item B<Class::MOP::Deprecated::warn($message)>
374 Checks compatibility for the caller feature, and produces warnings if needed.
376 This function is used in internals.
382 Goro Fuji E<lt>gfuji@cpan.orgE<gt>
384 =head1 COPYRIGHT AND LICENSE
386 Copyright 2006-2009 by Infinity Interactive, Inc.
388 L<http://www.iinteractive.com>
390 This library is free software; you can redistribute it and/or modify
391 it under the same terms as Perl itself.