1 package Class::MOP::Deprecated;
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::Class::construct_class_instance' => 0.93,
19 'Class::MOP::Class::check_metaclass_compatibility' => 0.93,
20 'Class::MOP::Class::create_meta_instance' => 0.93,
21 'Class::MOP::Class::clone_instance' => 0.93,
22 'Class::MOP::Class::alias_method' => 0.93,
23 'Class::MOP::Class::compute_all_applicable_methods' => 0.93,
24 'Class::MOP::Class::compute_all_applicable_attributes' => 0.93,
26 'Class::MOP::Instance::bless_instance_structure' => 0.93,
28 'Class::MOP::Attribute::process_accessors' => 0.93,
30 'Class::MOP::Method::Accessor::initialize_body' => 0.93,
31 'Class::MOP::Method::Accessor::generate_accessor_method' => 0.93,
32 'Class::MOP::Method::Accessor::generate_reader_method' => 0.93,
33 'Class::MOP::Method::Accessor::generate_writer_method' => 0.93,
34 'Class::MOP::Method::Accessor::generate_predicate_method' => 0.93,
35 'Class::MOP::Method::Accessor::generate_clearer_method' => 0.93,
36 'Class::MOP::Method::Accessor::generate_accessor_method_inline' => 0.93,
37 'Class::MOP::Method::Accessor::generate_reader_method_inline' => 0.93,
38 'Class::MOP::Method::Accessor::generate_writer_method_inline' => 0.93,
39 'Class::MOP::Method::Accessor::generate_clearer_method_inline' => 0.93,
40 'Class::MOP::Method::Accessor::generate_predicate_method_inline' => 0.93,
42 'Class::MOP::Method::Constructor::meta_instance' => 0.93,
43 'Class::MOP::Method::Constructor::attributes' => 0.93,
44 'Class::MOP::Method::Constructor::initialize_body' => 0.93,
45 'Class::MOP::Method::Constructor::generate_constructor_method' => 0.93,
46 'Class::MOP::Method::Constructor::generate_constructor_method_inline' =>
49 # features deprecated after 0.93
56 my ( $class, %args ) = @_;
58 if ( defined( my $compat_version = delete $args{-compatible} ) ) {
59 $Registry{ (caller) } = $compat_version;
63 my $unknowns = join q{ }, keys %args;
64 cluck "Unknown argument(s) for $class->import: $unknowns.\n";
70 my ( $package, undef, undef, $feature ) = caller(1);
73 while ( $package && !defined( $compat_version = $Registry{$package} ) ) {
74 $package =~ s/ :: \w+ \z//xms or last;
77 my $deprecated_at = $DeprecatedAt{$feature}
78 or die "Unregistered deprecated feature: $feature";
80 if ( !defined($compat_version)
81 || $compat_version >= $DeprecatedAt{$feature} ) {
90 Class::MOP::Deprecated::warn(
91 "Class::MOP::HAVE_ISAREV is deprecated and will be removed in a future release. It has always returned 1 anyway."
97 Class::MOP::Deprecated::warn(
98 "Class::MOP::subname is deprecated. Please use Sub::Name directly.");
100 goto \&Sub::Name::subname;
103 sub in_global_destruction {
104 Class::MOP::Deprecated::warn(
105 "Class::MOP::in_global_destruction is deprecated. Please use Devel::GlobalDestruction directly."
107 require Devel::GlobalDestruction;
108 goto \&Devel::GlobalDestruction::in_global_destruction;
120 sub construct_class_instance {
121 Class::MOP::Deprecated::warn(
122 'The construct_class_instance method has been made private.'
123 . " The public version is deprecated and will be removed in a future release.\n"
125 shift->_construct_class_instance(@_);
128 sub check_metaclass_compatibility {
129 Class::MOP::Deprecated::warn(
130 'The check_metaclass_compatibility method has been made private.'
131 . " The public version is deprecated and will be removed in a future release.\n"
133 shift->_check_metaclass_compatibility(@_);
136 sub construct_instance {
137 Class::MOP::Deprecated::warn(
138 'The construct_instance method has been made private.'
139 . " The public version is deprecated and will be removed in a future release.\n"
141 shift->_construct_instance(@_);
144 sub create_meta_instance {
145 Class::MOP::Deprecated::warn(
146 'The create_meta_instance method has been made private.'
147 . " The public version is deprecated and will be removed in a future release.\n"
149 shift->_create_meta_instance(@_);
153 Class::MOP::Deprecated::warn(
154 'The clone_instance method has been made private.'
155 . " The public version is deprecated and will be removed in a future release.\n"
157 shift->_clone_instance(@_);
161 Class::MOP::Deprecated::warn(
162 "The alias_method method is deprecated. Use add_method instead.\n");
164 shift->add_method(@_);
167 sub compute_all_applicable_methods {
168 Class::MOP::Deprecated::warn(
169 'The compute_all_applicable_methods method is deprecated.'
170 . " Use get_all_methods instead.\n" );
175 class => $_->package_name,
176 code => $_, # sigh, overloading
178 } shift->get_all_methods(@_);
181 sub compute_all_applicable_attributes {
182 Class::MOP::Deprecated::warn(
183 'The compute_all_applicable_attributes method has been deprecated.'
184 . " Use get_all_attributes instead.\n" );
186 shift->get_all_attributes(@_);
190 Class::MOP::Instance;
192 sub bless_instance_structure {
193 Class::MOP::Deprecated::warn(
194 'The bless_instance_structure method is deprecated.'
195 . " It will be removed in a future release.\n" );
197 my ( $self, $instance_structure ) = @_;
198 bless $instance_structure, $self->_class_name;
202 Class::MOP::Attribute;
204 sub process_accessors {
205 Class::MOP::Deprecated::warn(
206 'The process_accessors method has been made private.'
207 . " The public version is deprecated and will be removed in a future release.\n"
209 shift->_process_accessors(@_);
213 Class::MOP::Method::Accessor;
215 sub initialize_body {
216 Class::MOP::Deprecated::warn(
217 'The initialize_body method has been made private.'
218 . " The public version is deprecated and will be removed in a future release.\n"
220 shift->_initialize_body;
223 sub generate_accessor_method {
224 Class::MOP::Deprecated::warn(
225 'The generate_accessor_method method has been made private.'
226 . " The public version is deprecated and will be removed in a future release.\n"
228 shift->_generate_accessor_method;
231 sub generate_reader_method {
232 Class::MOP::Deprecated::warn(
233 'The generate_reader_method method has been made private.'
234 . " The public version is deprecated and will be removed in a future release.\n"
236 shift->_generate_reader_method;
239 sub generate_writer_method {
240 Class::MOP::Deprecated::warn(
241 'The generate_writer_method method has been made private.'
242 . " The public version is deprecated and will be removed in a future release.\n"
244 shift->_generate_writer_method;
247 sub generate_predicate_method {
248 Class::MOP::Deprecated::warn(
249 'The generate_predicate_method method has been made private.'
250 . " The public version is deprecated and will be removed in a future release.\n"
252 shift->_generate_predicate_method;
255 sub generate_clearer_method {
256 Class::MOP::Deprecated::warn(
257 'The generate_clearer_method method has been made private.'
258 . " The public version is deprecated and will be removed in a future release.\n"
260 shift->_generate_clearer_method;
263 sub generate_accessor_method_inline {
264 Class::MOP::Deprecated::warn(
265 'The generate_accessor_method_inline method has been made private.'
266 . " The public version is deprecated and will be removed in a future release.\n"
268 shift->_generate_accessor_method_inline;
271 sub generate_reader_method_inline {
272 Class::MOP::Deprecated::warn(
273 'The generate_reader_method_inline method has been made private.'
274 . " The public version is deprecated and will be removed in a future release.\n"
276 shift->_generate_reader_method_inline;
279 sub generate_writer_method_inline {
280 Class::MOP::Deprecated::warn(
281 'The generate_writer_method_inline method has been made private.'
282 . " The public version is deprecated and will be removed in a future release.\n"
284 shift->_generate_writer_method_inline;
287 sub generate_predicate_method_inline {
288 Class::MOP::Deprecated::warn(
289 'The generate_predicate_method_inline method has been made private.'
290 . " The public version is deprecated and will be removed in a future release.\n"
292 shift->_generate_predicate_method_inline;
295 sub generate_clearer_method_inline {
296 Class::MOP::Deprecated::warn(
297 'The generate_clearer_method_inline method has been made private.'
298 . " The public version is deprecated and will be removed in a future release.\n"
300 shift->_generate_clearer_method_inline;
304 Class::MOP::Method::Constructor;
307 Class::MOP::Deprecated::warn(
308 'The meta_instance method has been made private.'
309 . " The public version is deprecated and will be removed in a future release.\n"
311 shift->_meta_instance;
315 Class::MOP::Deprecated::warn(
316 'The attributes method has been made private.'
317 . " The public version is deprecated and will be removed in a future release.\n"
320 return shift->_attributes;
323 sub initialize_body {
324 Class::MOP::Deprecated::warn(
325 'The initialize_body method has been made private.'
326 . " The public version is deprecated and will be removed in a future release.\n"
328 shift->_initialize_body;
331 sub generate_constructor_method {
332 Class::MOP::Deprecated::warn(
333 'The generate_constructor_method method has been made private.'
334 . " The public version is deprecated and will be removed in a future release.\n"
336 shift->_generate_constructor_method;
339 sub generate_constructor_method_inline {
340 Class::MOP::Deprecated::warn(
341 'The generate_constructor_method_inline method has been made private.'
342 . " The public version is deprecated and will be removed in a future release.\n"
344 shift->_generate_constructor_method_inline;
355 Class::MOP::Deprecated - List of deprecated methods
359 use Class::MOP::Deprecated -compatible => $version;
363 This class provides methods that have been deprecated but remain for backward compatibility.
365 If you specify C<< -compatible => $version >>, you can use deprecated features without warnings.
366 Note that this special treatment is package-scoped.
370 =item B<Class::MOP::Deprecated::warn($message)>
372 Checks compatibility for the caller feature, and produces warnings if needed.
374 This function is used in internals.
380 Goro Fuji E<lt>gfuji@cpan.orgE<gt>
382 =head1 COPYRIGHT AND LICENSE
384 Copyright 2006-2009 by Infinity Interactive, Inc.
386 L<http://www.iinteractive.com>
388 This library is free software; you can redistribute it and/or modify
389 it under the same terms as Perl itself.