[svn:parrot] r48306 - branches/gsoc_instrument/runtime/parrot/library/Instrument
khairul at svn.parrot.org
khairul at svn.parrot.org
Wed Aug 4 05:28:02 UTC 2010
Author: khairul
Date: Wed Aug 4 05:28:02 2010
New Revision: 48306
URL: https://trac.parrot.org/parrot/changeset/48306
Log:
Added disable method of Instrument::Event::Object.
Modified:
branches/gsoc_instrument/runtime/parrot/library/Instrument/EventLibrary.nqp
Modified: branches/gsoc_instrument/runtime/parrot/library/Instrument/EventLibrary.nqp
==============================================================================
--- branches/gsoc_instrument/runtime/parrot/library/Instrument/EventLibrary.nqp Wed Aug 4 04:25:56 2010 (r48305)
+++ branches/gsoc_instrument/runtime/parrot/library/Instrument/EventLibrary.nqp Wed Aug 4 05:28:02 2010 (r48306)
@@ -232,12 +232,7 @@
$!instr_obj.remove_eventhandler($event, self);
}
- CATCH {
- # Ignore the exception.
- # We are trying to disable a hook that wasn't inserted.
- # TODO: Ensure that the exception came from a place that we are expecting.
- # Otherwise rethrow. (How to do that in NQP?)
- }
+ CATCH {}
}
$!is_enabled := 0;
@@ -248,8 +243,6 @@
has $!object;
method _self_init() {
- #$!object := pir::null;
- #$!instrumented_obj := pir::null;
@!vtable_probes := ();
@!method_probes := ();
};
@@ -265,7 +258,7 @@
for @hooks {
$!object.insert_hook($_);
- my $group := ($!object.get_hook_group($_)).shift();
+ my $group := $!object.get_hook_group($_);
my $event := $vtable_prefix ~ $group ~ '::' ~ $_;
$!instr_obj.register_eventhandler($event, self);
@@ -287,6 +280,39 @@
}
}
+ method disable () {
+ if +$!is_enabled {
+ my $event_prefix := 'Object::' ~ $!object.get_address() ~ '::';
+
+ # Register the vtable probes.
+ my $vtable_prefix := $event_prefix ~ 'vtable::';
+ for @!vtable_probes {
+ my @hooks := $!object.get_hook_list($_);
+
+ for @hooks {
+ $!object.remove_hook($_);
+ my $group := $!object.get_hook_group($_);
+
+ my $event := $vtable_prefix ~ $group ~ '::' ~ $_;
+ $!instr_obj.remove_eventhandler($event, self);
+ }
+ }
+
+ # Register the method probes.
+ my $method_prefix := $event_prefix ~ 'method::';
+ for @!method_probes {
+ $!object.remove_method_hook($_);
+
+ my $event := $method_prefix ~ $_;
+ $!instr_obj.remove_eventhandler($event, self);
+ }
+
+ CATCH {}
+
+ $!is_enabled := 0;
+ }
+ }
+
method get_address() {
return $!object.get_address();
}
More information about the parrot-commits
mailing list