diff Lib/IMPL/Class/Property/Base.pm @ 133:a07a66fd8d5c

Added IMPL::Class::MethodInfo IMPL::Class::Property::Base optimizations
author wizard
date Fri, 18 Jun 2010 16:27:28 +0400
parents f017c0d7527c
children 44977efed303
line wrap: on
line diff
--- a/Lib/IMPL/Class/Property/Base.pm	Thu Jun 17 17:35:36 2010 +0400
+++ b/Lib/IMPL/Class/Property/Base.pm	Fri Jun 18 16:27:28 2010 +0400
@@ -37,16 +37,16 @@
 	
 	if (not ref $param) {
 		if ($param & prop_list) {
-			$accessors{get} = ($param & prop_get) ? $self->GenerateGetList(@params) : $accessor_get_no;
-			$accessors{set} = ($param & prop_set) ? $self->GenerateSetList(@params) : $accessor_set_no;
+			$accessors{get} = ($param & prop_get) ? $self->GenerateGetList(@params) : undef;
+			$accessors{set} = ($param & prop_set) ? $self->GenerateSetList(@params) : undef;
 		} else {
-			$accessors{get} = ($param & prop_get) ? $self->GenerateGet(@params) : $accessor_get_no;
-			$accessors{set} = ($param & prop_set) ? $self->GenerateSet(@params) : $accessor_set_no;
+			$accessors{get} = ($param & prop_get) ? $self->GenerateGet(@params) : undef;
+			$accessors{set} = ($param & prop_set) ? $self->GenerateSet(@params) : undef;
 		}
 		$accessors{owner} = (($param & owner_set) == owner_set) ? $owner_check : "";
 	} elsif (UNIVERSAL::isa($param,'HASH')) {
-		$accessors{get} = $param->{get} ? $custom_accessor_get : $accessor_get_no;
-		$accessors{set} = $param->{set} ? $custom_accessor_set : $accessor_set_no;
+		$accessors{get} = $param->{get} ? $custom_accessor_get : undef;
+		$accessors{set} = $param->{set} ? $custom_accessor_set : undef;
 		$accessors{owner} = "";
 	} else {
 		die new IMPL::Exception('The unsupported accessor/mutators supplied',$param);
@@ -77,36 +77,35 @@
 	
 	my $key = $self->MakeFactoryKey($propInfo);
 	
-	my $factory = $factoryCache{$key};
+	my $factoryInfo = $factoryCache{$key};
 	
-	unless ($factory) {
+	unless ($factoryInfo) {
 		my $mutators = $self->GenerateAccessors($propInfo->Mutators);
-		$factory = $self->CreateFactory(
-			$access_code{ $propInfo->Access },
-			$propInfo->Attributes->{validator} ? $validator_code : "",
-			$mutators->{owner},
-			$mutators->{get},
-			$mutators->{set}
-		);
-		$factoryCache{$key} = $factory; 
+		$factoryInfo = {
+			factory => $self->CreateFactory(
+				$access_code{ $propInfo->Access },
+				$propInfo->Attributes->{validator} ? $validator_code : "",
+				$mutators->{owner},
+				$mutators->{get} || $accessor_get_no,
+				$mutators->{set} || $accessor_set_no
+			),
+			mutators => $mutators
+		};
+		$factoryCache{$key} = $factoryInfo; 
 	}
 	
 	{
 		no strict 'refs';
-		*{ $propInfo->Class.'::'.$propInfo->Name } = &$factory($self->RemapFactoryParams($propInfo));
+		*{ $propInfo->Class.'::'.$propInfo->Name } = $factoryInfo->{factory}->($self->RemapFactoryParams($propInfo));
 	}
 	
-	my $mutators = $propInfo->Mutators;
+	my $mutators = $factoryInfo->{mutators};
 	
-	if (ref $mutators) {
-		$propInfo->canGet( $mutators->{get} ? 1 : 0 );
-		$propInfo->canSet( $mutators->{set} ? 1 : 0 );
-		$propInfo->ownerSet(0);
-	} else {
-		$propInfo->canGet( $mutators & prop_get );
-		$propInfo->canSet( $mutators & prop_set );
-		$propInfo->ownerSet( ($mutators & owner_set) == owner_set );
-	}
+	$propInfo->canGet( $mutators->{get} ? 1 : 0 );
+	$propInfo->canSet( $mutators->{set} ? 1 : 0 );
+	$propInfo->ownerSet( $mutators->{owner} );
+	
+	1;
 }
 
 # extract from property info: class, name, get_accessor, set_accessor, validator