gnome-perl-introspection r30 - trunk/Glib-Object-Introspection
- From: tsch svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-perl-introspection r30 - trunk/Glib-Object-Introspection
- Date: Sat, 8 Nov 2008 19:47:00 +0000 (UTC)
Author: tsch
Date: Sat Nov 8 19:47:00 2008
New Revision: 30
URL: http://svn.gnome.org/viewvc/gnome-perl-introspection?rev=30&view=rev
Log:
Add Glib::Object::Introspection::invoke and make AUTOLOAD use it. Don't
automatically modify the stack for non-method function calls; that should be up
to the concrete library's wrapper module.
Modified:
trunk/Glib-Object-Introspection/Introspection.pm
Modified: trunk/Glib-Object-Introspection/Introspection.pm
==============================================================================
--- trunk/Glib-Object-Introspection/Introspection.pm (original)
+++ trunk/Glib-Object-Introspection/Introspection.pm Sat Nov 8 19:47:00 2008
@@ -37,40 +37,36 @@
}
sub AUTOLOAD {
- (my $symbol = $AUTOLOAD) =~ s/${PACKAGE}:://;
+ invoke($AUTOLOAD, @_);
+}
+
+sub invoke {
+ my $full_symbol = shift;
+ (my $symbol = $full_symbol) =~ s/${PACKAGE}:://;
# namespace::method
if ($symbol =~ m/(.+)::(.+)/) {
my ($namespace, $method) = ($1, $2);
my $object = $REPOSITORY -> find_by_name($BASENAME, $namespace);
- my $type = $object -> get_type();
- if ($type eq "object" || $type eq "boxed") {
- my $info;
+ if (my $info = $object -> find_method($method)) {
+ return $info -> invoke(@_);
+ }
- if ($info = $object -> find_method($method)) {
- return $info -> get_flags() & "is-constructor"
- ? $info -> invoke(@_[1..$#_])
- : $info -> invoke(@_);
+ elsif (($info) = grep { $_ -> get_name() eq $method }
+ $object -> get_fields()) {
+ if (@_ != 1 && @_ != 2) {
+ croak "Invalid invocation of a field accessor";
}
- elsif (($info) = grep { $_ -> get_name() eq $method }
- $object -> get_fields()) {
- if (@_ != 1 && @_ != 2) {
- croak "Invalid invocation of a field accessor";
- }
-
- return defined $_[1]
- ? $object -> access_field($info, $_[0], $_[1])
- : $object -> access_field($info, $_[0]);
- }
+ return defined $_[1]
+ ? $object -> access_field($info, $_[0], $_[1])
+ : $object -> access_field($info, $_[0]);
+ }
- else {
- croak "Dispatch error: ${PACKAGE}::$symbol doesn't exist";
- }
- } else {
- croak "Unhandled type: $type";
+ else {
+ croak "Dispatch error: ${PACKAGE}::$symbol doesn't exist";
}
}
@@ -78,13 +74,11 @@
else {
my $info = $REPOSITORY -> find_by_name($BASENAME, $symbol);
if ($info) {
- return defined $_[0] && $_[0] eq $PACKAGE
- ? $info -> invoke(@_[1..$#_])
- : $info -> invoke(@_);
+ return $info -> invoke(@_);
}
}
- croak "Invalid invocation: Cannot handle $AUTOLOAD";
+ croak "Invalid invocation: Cannot handle $full_symbol";
}
1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]