diff Lib/IMPL/Class/Property.pm @ 276:8a5da17d7ef9

*IMPL::Class refactoring property definition mechanism (incomplete).
author sergey
date Thu, 31 Jan 2013 17:37:44 +0400
parents 6253872024a4
children 4ddb27ff4a0b
line wrap: on
line diff
--- a/Lib/IMPL/Class/Property.pm	Thu Jan 31 02:18:31 2013 +0400
+++ b/Lib/IMPL/Class/Property.pm	Thu Jan 31 17:37:44 2013 +0400
@@ -1,12 +1,15 @@
 package IMPL::Class::Property;
 use strict;
 use parent qw(Exporter);
+
 BEGIN {
     our @EXPORT = qw(property prop_get prop_set owner_set prop_none prop_all prop_list CreateProperty);
 }
 
-require IMPL::Class::Member;
-require IMPL::Class::PropertyInfo;
+use IMPL::lang qw(:hash);
+use IMPL::Const qw(:prop);
+use Carp qw(carp);
+require IMPL::Class::Memeber;
 
 sub import {
     __PACKAGE__->export_to_level(1,@_);
@@ -20,16 +23,31 @@
 sub prop_all { 3 };
 sub prop_list { 4 };
 
-sub property($$;$) {
-    my ($propName,$mutators,$attributes) = @_;
-    my $Info = new IMPL::Class::PropertyInfo( {name => $propName, mutators => $mutators, class => scalar(caller), attributes => $attributes } );
-    return $Info;
+sub property($$) {
+    my ($propName,$attributes) = @_;
+    
+    $attributes = {
+    	get => $attributes & PROP_GET,
+    	set => $attributes & PROP_SET,
+    	isList => $attributes & PROP_LIST
+    } unless ref $attributes;
+     
+    return hashMerge (
+        $attributes,
+	    {
+	        -implementor => 'ImplementProperty',
+	    	name => $propName,
+	    	class => scalar(caller),
+	    }
+    );
 }
 
 sub CreateProperty {
-    my ($class,$propName,$mutators,$attributes) = @_;
-    my $Info = new IMPL::Class::PropertyInfo( {name => $propName, mutators => $mutators, class => $class, attributes => $attributes} );
-    return $Info;
+    my ($class,$propName,$attributes) = @_;
+    
+    carp "Using create property is deprecated, use ImplementProperty instead";
+    
+    $class->ImplementProperty($propName,$attributes);
 };
 
 1;