flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [3/3] git commit: [flex-asjs] [refs/heads/develop] - adjust for changes to databinding codegen changes
Date Thu, 07 Nov 2013 00:54:53 GMT
adjust for changes to databinding codegen changes


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/984c6f87
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/984c6f87
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/984c6f87

Branch: refs/heads/develop
Commit: 984c6f878c19fb50d042dbe1f9e4a50ac51dc285
Parents: 8d222fa
Author: Alex Harui <aharui@apache.org>
Authored: Wed Nov 6 08:06:00 2013 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Wed Nov 6 08:13:21 2013 -0800

----------------------------------------------------------------------
 .../org/apache/flex/binding/GenericBinding.as   | 11 ++--
 .../org/apache/flex/core/ViewBaseDataBinding.as | 15 ++++-
 .../org/apache/flex/binding/GenericBinding.js   | 16 +++--
 .../org/apache/flex/core/ViewBaseDataBinding.js | 69 +++++++++++++-------
 4 files changed, 75 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/984c6f87/frameworks/as/src/org/apache/flex/binding/GenericBinding.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/binding/GenericBinding.as b/frameworks/as/src/org/apache/flex/binding/GenericBinding.as
index b86c0ab..4cb6f5e 100644
--- a/frameworks/as/src/org/apache/flex/binding/GenericBinding.as
+++ b/frameworks/as/src/org/apache/flex/binding/GenericBinding.as
@@ -35,6 +35,7 @@ package org.apache.flex.binding
 
 		public var source:Object;
 		public var destinationData:Object;
+		public var destinationFunction:Function;
 		
 		public function set strand(value:IStrand):void
 		{
@@ -76,7 +77,11 @@ package org.apache.flex.binding
         
         private function applyValue(value:Object):void
         {
-            if (destinationData is Array)
+			if (destinationFunction != null)
+			{
+				destinationFunction.apply(document, [value]);
+			}
+			else if (destinationData is Array)
             {
                 var arr:Array = destinationData as Array;
                 var n:int = arr.length;
@@ -91,10 +96,6 @@ package org.apache.flex.binding
                 }
                 obj[arr[n-1]] = value;                
             }
-            else if (destinationData is Function)
-            {
-                Function(destinationData).apply(document, [value]);
-            }
         }
 		
 		public function setDocument(document:Object, id:String = null):void

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/984c6f87/frameworks/as/src/org/apache/flex/core/ViewBaseDataBinding.as
----------------------------------------------------------------------
diff --git a/frameworks/as/src/org/apache/flex/core/ViewBaseDataBinding.as b/frameworks/as/src/org/apache/flex/core/ViewBaseDataBinding.as
index 91317ad..0bff3a4 100644
--- a/frameworks/as/src/org/apache/flex/core/ViewBaseDataBinding.as
+++ b/frameworks/as/src/org/apache/flex/core/ViewBaseDataBinding.as
@@ -57,6 +57,7 @@ package org.apache.flex.core
             {
                 var binding:Object = {};
                 binding.source = bindingData[index++];
+				binding.destFunc = bindingData[index++];
                 binding.destination = bindingData[index++];
                 bindings.push(binding);
             }
@@ -142,6 +143,7 @@ package org.apache.flex.core
             var gb:GenericBinding = new GenericBinding();
             gb.setDocument(_strand);
             gb.destinationData = binding.destination;
+			gb.destinationFunction = binding.destFunc;
             gb.source = binding.source;
             setupWatchers(gb, index, watchers.watchers, null);
         }
@@ -200,14 +202,25 @@ package org.apache.flex.core
                     {
                         watcherData = { type: "function" };
                         watcherData.functionName = bindingData[index++];
+						watcherData.paramFunction = bindingData[index++];
                         watcherData.eventNames = bindingData[index++];
                         watcherData.bindings = bindingData[index++];
                         break;
                     }
                     case 1:
+					{
+						watcherData = { type: "static" };
+						watcherData.propertyName = bindingData[index++];
+						watcherData.eventNames = bindingData[index++];
+						watcherData.bindings = bindingData[index++];
+						watcherData.getterFunction = bindingData[index++];
+						watcherData.parentObj = bindingData[index++];
+						watcherMap[watcherData.propertyName] = watcherData;
+						break;
+					}
                     case 2:
                     {
-                        watcherData = { type: type == 1 ? "static" : "property" };
+                        watcherData = { type: "property" };
                         watcherData.propertyName = bindingData[index++];
                         watcherData.eventNames = bindingData[index++];
                         watcherData.bindings = bindingData[index++];

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/984c6f87/frameworks/js/FlexJS/src/org/apache/flex/binding/GenericBinding.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/binding/GenericBinding.js b/frameworks/js/FlexJS/src/org/apache/flex/binding/GenericBinding.js
index 36d293f..28d38fa 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/binding/GenericBinding.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/binding/GenericBinding.js
@@ -32,6 +32,12 @@ org.apache.flex.binding.GenericBinding.prototype.destinationData = null;
 
 /**
  * @expose
+ * @type {function}
+ */
+org.apache.flex.binding.GenericBinding.prototype.destinationFunction = null;
+
+/**
+ * @expose
  * @this {org.apache.flex.binding.GenericBinding}
  * @param {Object} value The strand (owner) of the bead.
  */
@@ -88,7 +94,11 @@ org.apache.flex.binding.GenericBinding.prototype.getValueFromSource =
 org.apache.flex.binding.GenericBinding.prototype.applyValue =
         function(value)
 {
-    if (typeof(this.destinationData) == 'object')
+    if (this.destinationFunction != null)
+    {
+        this.destinationFunction.apply(this.document, [value]);
+    }
+    else if (typeof(this.destinationData) == 'object')
     {
         var arr = this.destinationData;
         var n = arr.length;
@@ -103,10 +113,6 @@ org.apache.flex.binding.GenericBinding.prototype.applyValue =
         }
         obj['set_' + arr[n - 1]](value);
     }
-    else if (typeof(this.destinationData) == 'function')
-    {
-        this.destinationData.apply(this.document, [value]);
-    }
 };
 
 /**

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/984c6f87/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBaseDataBinding.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBaseDataBinding.js b/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBaseDataBinding.js
index a31c156..cc86875 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBaseDataBinding.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/ViewBaseDataBinding.js
@@ -63,6 +63,7 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.set_strand =
 org.apache.flex.core.ViewBaseDataBinding.prototype.initCompleteHandler =
     function(event) {
 
+    var prop;
     var fieldWatcher;
     var sb;
     var bindingData = this.strand_['_bindings'];
@@ -74,6 +75,7 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.initCompleteHandler =
     {
         var binding = {};
         binding.source = bindingData[index++];
+        binding.destFunc = bindingData[index++];
         binding.destination = bindingData[index++];
         bindings.push(binding);
     }
@@ -105,18 +107,20 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.initCompleteHandler
=
                         sb.sourceID = binding.source[0];
                         sb.sourcePropertyName = binding.source[1];
                         sb.setDocument(this.strand_);
-                        destination = this.strand_[
-                                            binding.destination[0]];
-                        if (destination == null &&
-                                typeof(this.strand_['get_' +
-                                    binding.destination[0]] == 'function'))
+                        prop = binding.destination[0];
+                        
+                        if (typeof(this.strand_['get_' +
+                                    prop]) == 'function')
                                 destination = this.strand_[
-                                        'get_' + binding.destination[0]]();
+                                        'get_' + prop]();
+                        else
+                            destination = this.strand_[prop];
+
                         if (destination)
                               destination.addBead(sb);
                         else
                         {
-                            this.deferredBindings[binding.destination[0]] =
+                            this.deferredBindings[prop] =
                                     sb;
                             this.strand_.addEventListener('valueChange',
                                     this.deferredBindingsHandler);
@@ -132,18 +136,19 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.initCompleteHandler
=
                         cb.sourceID = binding.source[0];
                         cb.sourcePropertyName = binding.source[1];
                         cb.setDocument(this.strand_);
-                        destination = this.strand_[
-                                            binding.destination[0]];
-                        if (destination == null &&
-                                typeof(this.strand_['get_' +
-                                    binding.destination[0]] == 'function'))
+                        prop = binding.destination[0];
+                        if (typeof(this.strand_['get_' +
+                                    prop]) == 'function')
                                 destination = this.strand_[
-                                        'get_' + binding.destination[0]]();
+                                        'get_' + prop]();
+                        else
+                            destination = this.strand_[prop];
+
                         if (destination)
                                 destination.addBead(cb);
                         else
                         {
-                            this.deferredBindings[binding.destination[0]] =
+                            this.deferredBindings[prop] =
                                 cb;
                             this.strand_.addEventListener('valueChange',
                                 this.deferredBindingsHandler);
@@ -162,17 +167,19 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.initCompleteHandler
=
                 sb.eventName = fieldWatcher.eventNames;
                 sb.sourcePropertyName = binding.source;
                 sb.setDocument(this.strand_);
-                destination = this.strand_[binding.destination[0]];
-                if (destination == null &&
-                        typeof(this.strand_['get_' +
-                                binding.destination[0]] == 'function'))
+                prop = binding.destination[0];
+                if (typeof(this.strand_['get_' +
+                                prop]) == 'function')
                     destination = this.strand_[
-                                'get_' + binding.destination[0]]();
+                                'get_' + prop]();
+                else
+                    destination = this.strand_[prop];
+
                 if (destination)
                     destination.addBead(sb);
                 else
                 {
-                    this.deferredBindings[binding.destination[0]] = sb;
+                    this.deferredBindings[prop] = sb;
                     this.strand_.addEventListener('valueChange',
                                 this.deferredBindingsHandler);
                 }
@@ -198,6 +205,7 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.makeGenericBinding
=
     var gb = new org.apache.flex.binding.GenericBinding();
     gb.setDocument(this.strand_);
     gb.destinationData = binding.destination;
+    gb.destinationFunction = binding.destFunc;
     gb.source = binding.source;
     this.setupWatchers(gb, index, watchers.watchers, null);
 };
@@ -274,14 +282,25 @@ org.apache.flex.core.ViewBaseDataBinding.prototype.decodeWatcher =
             {
                 watcherData = { type: 'function' };
                 watcherData.functionName = bindingData[index++];
+                watcherData.paramFunction = bindingData[index++];
                 watcherData.eventNames = bindingData[index++];
                 watcherData.bindings = bindingData[index++];
                 break;
             }
             case 1:
+            {
+                watcherData = { type: 'static' };
+                watcherData.propertyName = bindingData[index++];
+                watcherData.eventNames = bindingData[index++];
+                watcherData.bindings = bindingData[index++];
+                watcherData.getterFunction = bindingData[index++];
+                watcherData.parentObj = bindingData[index++];
+                watcherMap[watcherData.propertyName] = watcherData;
+                break;
+            }
             case 2:
             {
-                watcherData = { type: type == 1 ? 'static' : 'property' };
+                watcherData = { type: 'property' };
                 watcherData.propertyName = bindingData[index++];
                 watcherData.eventNames = bindingData[index++];
                 watcherData.bindings = bindingData[index++];
@@ -319,15 +338,15 @@ function(event) {
     var p;
     for (p in this.deferredBindings)
     {
-        if (this.strand_[p] != null)
+        if (typeof(this.strand_['get_' + p]) == 'function')
         {
-            var destination = this.strand_[p];
+            var destination = this.strand_['get_' + p]();
             destination.addBead(this.deferredBindings[p]);
             delete deferredBindings[p];
         }
-        else if (typeof(this.strand_['get_' + p]) == 'function')
+        else if (this.strand_[p] != null)
         {
-            var destination = this.strand_['get_' + p]();
+            var destination = this.strand_[p];
             destination.addBead(this.deferredBindings[p]);
             delete deferredBindings[p];
         }


Mime
View raw message