changeset 315:77df11605d3a

code cleanup
author cin
date Tue, 07 May 2013 02:19:24 +0400
parents 109f28643025
children 608beb8b3c6c
files Lib/IMPL/DOM/Document.pm Lib/IMPL/DOM/Node.pm Lib/IMPL/SQL/Schema/Column.pm Lib/IMPL/SQL/Schema/Constraint.pm Lib/IMPL/SQL/Schema/Diff.pm Lib/IMPL/SQL/Schema/Table.pm Lib/IMPL/SQL/Schema/Traits/Diff.pm Lib/IMPL/Web/Application/ControllerUnit.pm Lib/IMPL/lang.pm
diffstat 9 files changed, 59 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/Lib/IMPL/DOM/Document.pm	Thu May 02 10:43:49 2013 +0400
+++ b/Lib/IMPL/DOM/Document.pm	Tue May 07 02:19:24 2013 +0400
@@ -3,9 +3,14 @@
 use warnings;
 
 use IMPL::lang;
-use parent qw(IMPL::DOM::Node);
-
-__PACKAGE__->PassThroughArgs;
+use IMPL::declare {
+    require => {
+        DOMNode => 'IMPL::DOM::Node'
+    },
+    base => [
+        DOMNode => '@_'
+    ]
+};
 
 sub document {
     return $_[0];
@@ -19,7 +24,7 @@
         $class = undef;
     }
     
-    $class ||= typeof IMPL::DOM::Node;
+    $class ||= DOMNode;
     $refProps ||= {};
     
     delete $refProps->{nodeName};
--- a/Lib/IMPL/DOM/Node.pm	Thu May 02 10:43:49 2013 +0400
+++ b/Lib/IMPL/DOM/Node.pm	Tue May 07 02:19:24 2013 +0400
@@ -2,27 +2,32 @@
 use strict;
 use warnings;
 
-use parent qw(IMPL::Object);
+use Scalar::Util qw(weaken);
 
 use IMPL::lang;
 use IMPL::Object::List;
-use IMPL::Class::Property;
-use Scalar::Util qw(weaken);
 
-use IMPL::Exception;
-
-BEGIN {
-    public _direct property nodeName => prop_get;
-    public _direct property document => prop_get;
-    public _direct property isComplex => { get => \&_getIsComplex } ;
-    public _direct property nodeValue => prop_all;
-    public _direct property childNodes => { get => \&_getChildNodes }; # prop_list
-    public _direct property parentNode => prop_get | owner_set;
-    public _direct property schema => prop_get | owner_set;
-    public _direct property schemaSource => prop_get | owner_set;
-    private _direct property _propertyMap => prop_all ;
-    
-}
+use IMPL::Exception();
+use IMPL::Const qw(:prop);
+use IMPL::declare {
+    require => {
+        PropertyInfo => '-IMPL::Class::PropertyInfo'
+    },
+    base => [
+        'IMPL::Object' => undef
+    ],
+    props => [
+        nodeName => PROP_RO | PROP_DIRECT,
+        document => PROP_RO | PROP_DIRECT,
+        isComplex => { get => \&_getIsComplex },
+        nodeValue => PROP_RW | PROP_DIRECT,
+        childNodes => { get => \&_getChildNodes, isList => 1, direct => 1 },
+        parentNode => PROP_RO | PROP_DIRECT,
+        schema => PROP_RO | PROP_DIRECT,
+        schemaSource => PROP_RO | PROP_DIRECT,
+        _propertyMap => PROP_RW | PROP_DIRECT
+    ]
+};
 
 our %Axes = (
     parent => \&selectParent,
@@ -388,7 +393,7 @@
 sub listProperties {
     my ($this) = @_;
     
-    my %props = map {$_->name, 1} $this->GetMeta(typeof IMPL::Class::PropertyInfo, sub { $_->attributes->{domProperty}},1);
+    my %props = map {$_->name, 1} $this->GetMeta(PropertyInfo, sub { $_->attributes->{domProperty}},1);
     
     return (keys %props,keys %{$this->{$_propertyMap}});
 }
--- a/Lib/IMPL/SQL/Schema/Column.pm	Thu May 02 10:43:49 2013 +0400
+++ b/Lib/IMPL/SQL/Schema/Column.pm	Tue May 07 02:19:24 2013 +0400
@@ -5,6 +5,9 @@
 use IMPL::Exception();
 use IMPL::Const qw(:prop);
 use IMPL::declare {
+    require => {
+        SchemaType => '-IMPL::SQL::Schema::Type'
+    },
     base => [
         'IMPL::Object' => undef,
         'IMPL::Object::Autofill' => '@_'
@@ -26,7 +29,7 @@
     
     $this->{$isNullable} ||= 0; # if not exists $this->{$isNullable};
     
-    is( $this->{$type}, typeof IMPL::SQL::Schema::Type) or
+    is( $this->{$type}, SchemaType) or
         die new IMPL::InvalidArgumentException('a type is required for the column',$this->{$name});
 }
 
--- a/Lib/IMPL/SQL/Schema/Constraint.pm	Thu May 02 10:43:49 2013 +0400
+++ b/Lib/IMPL/SQL/Schema/Constraint.pm	Tue May 07 02:19:24 2013 +0400
@@ -81,7 +81,7 @@
 sub RegisterAlias {
     my ($self,$alias) = @_;
     
-    $aliases{$alias} = $self->typeof;
+    $aliases{$alias} = typeof($self);
 }
 
 1;
--- a/Lib/IMPL/SQL/Schema/Diff.pm	Thu May 02 10:43:49 2013 +0400
+++ b/Lib/IMPL/SQL/Schema/Diff.pm	Tue May 07 02:19:24 2013 +0400
@@ -1,7 +1,7 @@
 package IMPL::SQL::Schema::Diff;
 use strict;
 use warnings;
-use IMPL::lang qw(:compare :hash is);
+use IMPL::lang qw(:compare :hash is typeof);
 
 use IMPL::SQL::Schema::Traits();
 
@@ -172,7 +172,7 @@
         Index , TraitsIndex
     };
     
-    my $class = $map->{$constraint->typeof} or die Exception->new("Can't map the constraint",$constraint->typeof);
+    my $class = $map->{typeof($constraint)} or die Exception->new("Can't map the constraint",typeof($constraint));
     
     if ($class eq TraitsForeignKey) {
         return $class->new(
--- a/Lib/IMPL/SQL/Schema/Table.pm	Thu May 02 10:43:49 2013 +0400
+++ b/Lib/IMPL/SQL/Schema/Table.pm	Tue May 07 02:19:24 2013 +0400
@@ -154,7 +154,7 @@
     if (@_ == 1) {
         my ($Constraint) = @_;
         
-        die new IMPL::InvalidArgumentException('The invalid parameter') if not is($Constraint,typeof IMPL::SQL::Schema::Constraint);
+        die new IMPL::InvalidArgumentException('The invalid parameter') if not is($Constraint,'IMPL::SQL::Schema::Constraint');
         
         $Constraint->table == $this or die new IMPL::InvalidOperationException('The constaint must belong to the target table');
         
@@ -246,7 +246,7 @@
 sub SameValue {
     my ($this,$other) = @_;
     
-    return 0 unless is $other, typeof $this;
+    return 0 unless is($other, typeof($this));
     
     return 0 unless $this->name eq $other->name;
     return 0 unless $this->ColumnsCount eq $other->ColumnsCount;
--- a/Lib/IMPL/SQL/Schema/Traits/Diff.pm	Thu May 02 10:43:49 2013 +0400
+++ b/Lib/IMPL/SQL/Schema/Traits/Diff.pm	Tue May 07 02:19:24 2013 +0400
@@ -1,13 +1,22 @@
 package IMPL::SQL::Schema::Traits::Diff;
 use strict;
 use warnings;
-use IMPL::lang qw(:compare :hash is);
+use IMPL::lang qw(:compare :hash is typeof);
 
 use IMPL::SQL::Schema();
 use IMPL::SQL::Schema::Traits();
 
+# defining a constant is a good style to enable compile checks
 use constant {
-    schema_t => typeof IMPL::SQL::Schema # defining a constant is a good style to enable compile checks
+    schema_t => 'IMPL::SQL::Schema',
+    ConstraintForeignKey => 'IMPL::SQL::Schema::Constraint::ForeignKey',
+    TraitsForeignKey => 'IMPL::SQL::Schema::Traits::ForeignKey',
+    ConstraintPrimaryKey => 'IMPL::SQL::Schema::Constraint::PrimaryKey',
+    TraitsPrimaryKey => 'IMPL::SQL::Schema::Traits::PrimaryKey',
+    ConstraintUnique => 'IMPL::SQL::Schema::Constraint::Unique',
+    TraitsUnique => 'IMPL::SQL::Schema::Traits::Unique',
+    ConstraintIndex => 'IMPL::SQL::Schema::Constraint::Index',
+    TraitsIndex => 'IMPL::SQL::Schema::Traits::Index'
 };
 
 sub Diff {
@@ -148,13 +157,13 @@
     my ($constraint) = @_;
     
     my $map = {
-        typeof IMPL::SQL::Schema::Constraint::ForeignKey , typeof IMPL::SQL::Schema::Traits::ForeignKey,
-        typeof IMPL::SQL::Schema::Constraint::PrimaryKey , typeof IMPL::SQL::Schema::Traits::PrimaryKey,
-        typeof IMPL::SQL::Schema::Constraint::Unique , typeof IMPL::SQL::Schema::Traits::Unique,
-        typeof IMPL::SQL::Schema::Constraint::Index , typeof IMPL::SQL::Schema::Traits::Index
+        ConstraintForeignKey , TraitsForeignKey,
+        ConstraintPrimaryKey , TraitsPrimaryKey,
+        ConstraintUnique , TraitsUnique,
+        ConstraintIndex , TraitsIndex
     };
     
-    my $class = $map->{$constraint->typeof} or die new IMPL::Exception("Can't map the constraint",$constraint->typeof);
+    my $class = $map->{typeof($constraint)} or die new IMPL::Exception("Can't map the constraint",typeof($constraint));
     
     return $class->new(
         $constraint->name,
--- a/Lib/IMPL/Web/Application/ControllerUnit.pm	Thu May 02 10:43:49 2013 +0400
+++ b/Lib/IMPL/Web/Application/ControllerUnit.pm	Tue May 07 02:19:24 2013 +0400
@@ -28,7 +28,7 @@
     public property formErrors => prop_get | owner_set;
 }
 
-my %publicProps = map {$_->Name , 1} __PACKAGE__->get_meta(typeof IMPL::Class::PropertyInfo);
+my %publicProps = map {$_->Name , 1} __PACKAGE__->GetMeta(typeof IMPL::Class::PropertyInfo);
 
 __PACKAGE__->class_data(CONTROLLER_METHODS,{});
 
--- a/Lib/IMPL/lang.pm	Thu May 02 10:43:49 2013 +0400
+++ b/Lib/IMPL/lang.pm	Tue May 07 02:19:24 2013 +0400
@@ -75,7 +75,7 @@
 }
 
 sub typeof(*) {
-    eval { $_[0]->_typeof } || blessed($_[0]) || ref($_[0]) || $_[0];
+    eval { $_[0]->_typeof } || blessed($_[0]) || ref($_[0]);
 }
 
 sub public($) {