summaryrefslogtreecommitdiff
path: root/fml/lib/IO
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-09-17 11:59:23 +0000
committerfukachan <fukachan>2001-09-17 11:59:23 +0000
commit0cd2f77785298c4f0395354c87abe3183298e7e1 (patch)
tree85c1067eaba3136713ff6760a0e26b27745924b6 /fml/lib/IO
parent90fa90d591dd70ad025828d4d4d833d89eece665 (diff)
downloadfml8-0cd2f77785298c4f0395354c87abe3183298e7e1.tar.gz
fml8-0cd2f77785298c4f0395354c87abe3183298e7e1.tar.bz2
fml8-0cd2f77785298c4f0395354c87abe3183298e7e1.zip
define AUTOLOAD() to hook up md_XXX() functions
XXX For example, md_XXX() should be implemented at XXX IO::Adapter::SQL::toymodel.pm
Diffstat (limited to 'fml/lib/IO')
-rw-r--r--fml/lib/IO/Adapter.pm35
1 files changed, 33 insertions, 2 deletions
diff --git a/fml/lib/IO/Adapter.pm b/fml/lib/IO/Adapter.pm
index cea8fe81..d524866f 100644
--- a/fml/lib/IO/Adapter.pm
+++ b/fml/lib/IO/Adapter.pm
@@ -4,11 +4,11 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: Adapter.pm,v 1.7 2001/08/26 05:52:08 fukachan Exp $
+# $FML: Adapter.pm,v 1.8 2001/09/17 11:28:31 fukachan Exp $
#
package IO::Adapter;
-use vars qw(@ISA @ORIG_ISA $FirstTime);
+use vars qw(@ISA @ORIG_ISA $FirstTime $AUTOLOAD);
use strict;
use Carp;
use IO::Adapter::ErrorStatus qw(error_set error error_clear);
@@ -398,6 +398,10 @@ sub find
}
+=head2 C<DESTROY>
+
+=cut
+
# Descriptions: destructor
# request is forwarded to close() method.
# Arguments: $self $args
@@ -411,6 +415,33 @@ sub DESTROY
}
+
+=head2 C<AUTOLOAD(@varargs)>
+
+=cut
+
+sub AUTOLOAD
+{
+ my ($self, @varargs) = @_;
+
+ return if $AUTOLOAD =~ /DESTROY/;
+
+ my $comname = $AUTOLOAD;
+ $comname =~ s/.*:://;
+
+ # try md_something() for something()
+ my $fp = "md_${comname}";
+
+ if ($self->can($fp)) {
+ $self->$fp(@varargs);
+ }
+ else {
+ croak("${comname}() nor md_${comname}() is not found");
+ croak($@);
+ }
+}
+
+
=head2
=item C<error()>