From: gfx Date: Sun, 15 Nov 2009 05:15:33 +0000 (+0900) Subject: Add $ignore_triggers option to _initialize_object() X-Git-Tag: 0.40_06~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d4712779eb600de46ed09b09afd193d3def11786;p=gitmo%2FMouse.git Add $ignore_triggers option to _initialize_object() --- diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index eb0aadc..75fd5af 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -167,7 +167,7 @@ sub new_object { } sub _initialize_object{ - my($self, $object, $args) = @_; + my($self, $object, $args, $ignore_triggers) = @_; my @triggers_queue; @@ -208,9 +208,11 @@ sub _initialize_object{ } } - foreach my $trigger_and_value(@triggers_queue){ - my($trigger, $value) = @{$trigger_and_value}; - $trigger->($object, $value); + if(!$ignore_triggers){ + foreach my $trigger_and_value(@triggers_queue){ + my($trigger, $value) = @{$trigger_and_value}; + $trigger->($object, $value); + } } if($self->is_anon_class){ diff --git a/xs-src/Mouse.xs b/xs-src/Mouse.xs index 3e654c4..ee14df3 100644 --- a/xs-src/Mouse.xs +++ b/xs-src/Mouse.xs @@ -229,10 +229,15 @@ mouse_build_args(aTHX_ SV* metaclass, SV* const klass, I32 const start, I32 cons } void -mouse_class_initialize_object(pTHX_ SV* const meta, SV* const object, HV* const args, bool const invoke_triggers) { - AV* const xc = mouse_get_xc(aTHX_ meta); - - // TODO +mouse_class_initialize_object(pTHX_ SV* const meta, SV* const object, HV* const args, bool const ignore_triggers) { + AV* const xc = mouse_get_xc(aTHX_ meta); + AV* const attrs = MOUSE_xc_attrall(xc); + I32 const len = AvFILLp(attrs) + 1; + I32 i; + AV* const triggers_queue = (invoke_triggers ? newAV_mortal() : NULL); + for(i = 0; i < len; i++){ + AV* const = mouse_get_xa(aTHX_ AvARRAY(attrs)[i]); + } } MODULE = Mouse PACKAGE = Mouse @@ -374,16 +379,17 @@ CODE: { HV* const args = mouse_build_args(aTHX_ meta, NULL, 1, items, ax); AV* const xc = mouse_get_xc(aTHX_ meta); + RETVAL = mouse_instance_create(aTHX_ MOUSE_xc_stash(xc)); - mouse_class_initialize_object(aTHX_ meta, RETVAL, args, TRUE); + mouse_class_initialize_object(aTHX_ meta, RETVAL, args, FALSE); } void -_initialize_object_(SV* meta, SV* object, HV* args, bool invoke_triggers = TRUE) +_initialize_object_(SV* meta, SV* object, HV* args, bool ignore_triggers = FALSE) CODE: { - mouse_class_initialize_object(aTHX_ meta, object, args, invoke_triggers); + mouse_class_initialize_object(aTHX_ meta, object, args, ignore_triggers); } MODULE = Mouse PACKAGE = Mouse::Meta::Role