bump version to 0.92_01 and add release date
[gitmo/Class-MOP.git] / lib / Class / MOP / Deprecated.pm
CommitLineData
30229767 1package Class::MOP::Deprecated;
2
3use strict;
4use warnings;
5use Carp qw(cluck);
6
d499b013 7our $VERSION = '0.92_01';
30229767 8$VERSION = eval $VERSION;
9our $AUTHORITY = 'cpan:STEVAN';
10
11my %DeprecatedAt = (
12
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,
17
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,
25
26 'Class::MOP::Instance::bless_instance_structure' => 0.93,
27
28 'Class::MOP::Attribute::process_accessors' => 0.93,
29
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,
41
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' =>
47 0.93,
48
49 # features deprecated after 0.93
50 # ...
51);
52
53my %Registry;
54
55sub import {
56 my ( $class, %args ) = @_;
57
58 if ( defined( my $compat_version = delete $args{-compatible} ) ) {
59 $Registry{ (caller) } = $compat_version;
60 }
61
62 if (%args) {
63 my $unknowns = join q{ }, keys %args;
64 cluck "Unknown argument(s) for $class->import: $unknowns.\n";
65 }
66 return;
67}
68
69sub warn {
70 my ( $package, undef, undef, $feature ) = caller(1);
71
72 my $compat_version;
73 while ( $package && !defined( $compat_version = $Registry{$package} ) ) {
74 $package =~ s/ :: \w+ \z//xms or last;
75 }
76
77 my $deprecated_at = $DeprecatedAt{$feature}
78 or die "Unregistered deprecated feature: $feature";
79
80 if ( !defined($compat_version)
81 || $compat_version >= $DeprecatedAt{$feature} ) {
82 goto &cluck;
83 }
84}
85
86package
87 Class::MOP;
88
89sub HAVE_ISAREV () {
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."
92 );
93 return 1;
94}
95
96sub subname {
97 Class::MOP::Deprecated::warn(
98 "Class::MOP::subname is deprecated. Please use Sub::Name directly.");
99 require Sub::Name;
100 goto \&Sub::Name::subname;
101}
102
103sub in_global_destruction {
104 Class::MOP::Deprecated::warn(
105 "Class::MOP::in_global_destruction is deprecated. Please use Devel::GlobalDestruction directly."
106 );
107 require Devel::GlobalDestruction;
108 goto \&Devel::GlobalDestruction::in_global_destruction;
109}
110
111package
112 Class::MOP::Package;
113
114package
115 Class::MOP::Module;
116
117package
118 Class::MOP::Class;
119
120sub 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"
124 );
125 shift->_construct_class_instance(@_);
126}
127
128sub 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"
132 );
133 shift->_check_metaclass_compatibility(@_);
134}
135
136sub 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"
140 );
141 shift->_construct_instance(@_);
142}
143
144sub 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"
148 );
149 shift->_create_meta_instance(@_);
150}
151
152sub clone_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"
156 );
157 shift->_clone_instance(@_);
158}
159
160sub alias_method {
161 Class::MOP::Deprecated::warn(
162 "The alias_method method is deprecated. Use add_method instead.\n");
163
164 shift->add_method(@_);
165}
166
167sub 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" );
171
172 return map {
173 {
174 name => $_->name,
175 class => $_->package_name,
176 code => $_, # sigh, overloading
177 },
178 } shift->get_all_methods(@_);
179}
180
181sub 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" );
185
186 shift->get_all_attributes(@_);
187}
188
189package
190 Class::MOP::Instance;
191
192sub 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" );
196
197 my ( $self, $instance_structure ) = @_;
198 bless $instance_structure, $self->_class_name;
199}
200
201package
202 Class::MOP::Attribute;
203
204sub 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"
208 );
209 shift->_process_accessors(@_);
210}
211
212package
213 Class::MOP::Method::Accessor;
214
215sub 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"
219 );
220 shift->_initialize_body;
221}
222
223sub 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"
227 );
228 shift->_generate_accessor_method;
229}
230
231sub 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"
235 );
236 shift->_generate_reader_method;
237}
238
239sub 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"
243 );
244 shift->_generate_writer_method;
245}
246
247sub 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"
251 );
252 shift->_generate_predicate_method;
253}
254
255sub 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"
259 );
260 shift->_generate_clearer_method;
261}
262
263sub 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"
267 );
268 shift->_generate_accessor_method_inline;
269}
270
271sub 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"
275 );
276 shift->_generate_reader_method_inline;
277}
278
279sub 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"
283 );
284 shift->_generate_writer_method_inline;
285}
286
287sub 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"
291 );
292 shift->_generate_predicate_method_inline;
293}
294
295sub 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"
299 );
300 shift->_generate_clearer_method_inline;
301}
302
303package
304 Class::MOP::Method::Constructor;
305
306sub meta_instance {
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"
310 );
311 shift->_meta_instance;
312}
313
314sub attributes {
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"
318 );
319
320 return shift->_attributes;
321}
322
323sub 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"
327 );
328 shift->_initialize_body;
329}
330
331sub 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"
335 );
336 shift->_generate_constructor_method;
337}
338
339sub 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"
343 );
344 shift->_generate_constructor_method_inline;
345}
346
3471;
348
349__END__
350
351=pod
352
353=head1 NAME
354
355Class::MOP::Deprecated - List of deprecated methods
356
357=head1 DESCRIPTION
358
359 use Class::MOP::Deprecated -compatible => $version;
360
361=head1 FUNCTIONS
362
363This class provides methods that have been deprecated but remain for backward compatibility.
364
365If you specify C<< -compatible => $version >>, you can use deprecated features without warnings.
366Note that this special treatment is package-scoped.
367
368=over 4
369
370=item B<Class::MOP::Deprecated::warn($message)>
371
372Checks compatibility for the caller feature, and produces warnings if needed.
373
374This function is used in internals.
375
376=back
377
378=head1 AUTHORS
379
380Goro Fuji E<lt>gfuji@cpan.orgE<gt>
381
382=head1 COPYRIGHT AND LICENSE
383
384Copyright 2006-2009 by Infinity Interactive, Inc.
385
386L<http://www.iinteractive.com>
387
388This library is free software; you can redistribute it and/or modify
389it under the same terms as Perl itself.
390
391=cut