flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [03/31] git commit: [flex-asjs] [refs/heads/develop] - sync up with as version
Date Tue, 09 Dec 2014 05:16:50 GMT
sync up with as version


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

Branch: refs/heads/develop
Commit: bdac9ea237db25f371d62ce35827ab89917e92fb
Parents: f690403
Author: Alex Harui <aharui@apache.org>
Authored: Fri Nov 21 16:46:06 2014 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Mon Dec 8 20:47:40 2014 -0800

----------------------------------------------------------------------
 .../apache/flex/utils/MXMLDataInterpreter.js    | 346 ++++++++++---------
 1 file changed, 176 insertions(+), 170 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/bdac9ea2/frameworks/js/FlexJS/src/org/apache/flex/utils/MXMLDataInterpreter.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/utils/MXMLDataInterpreter.js b/frameworks/js/FlexJS/src/org/apache/flex/utils/MXMLDataInterpreter.js
index 4b9f273..03b873b 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/utils/MXMLDataInterpreter.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/utils/MXMLDataInterpreter.js
@@ -40,7 +40,7 @@ org.apache.flex.utils.MXMLDataInterpreter.prototype.FLEXJS_CLASS_INFO =
  */
 org.apache.flex.utils.MXMLDataInterpreter.generateMXMLObject =
     function(document, data) {
-  var assingComp, Cls, comp, generateMXMLArray, generateMXMLObject, i, id, j, m,
+  var assignComp, Cls, comp, generateMXMLArray, generateMXMLObject, i, id, j, m,
       name, simple, value;
 
   i = 0;
@@ -52,39 +52,50 @@ org.apache.flex.utils.MXMLDataInterpreter.generateMXMLObject =
   generateMXMLObject =
       org.apache.flex.utils.MXMLDataInterpreter.generateMXMLObject;
 
-  m = data[i++]; // num props
-  for (j = 0; j < m; j++) {
-    name = data[i++];
-    simple = data[i++];
-    value = data[i++];
+  if (comp.set_strand)
+    org.apache.flex.utils.MXMLDataInterpreter.initializeStrandBasedObject(document, null,
comp, data, i);
+  else {
+    m = data[i++]; // num props
+    for (j = 0; j < m; j++) {
+      name = data[i++];
+      simple = data[i++];
+      value = data[i++];
 
-    if (simple === null) {
-      value = generateMXMLArray(document, null, value);
-    } else if (simple === false) {
-      value = generateMXMLObject(document, value);
-    }
+      if (simple === null) {
+        value = generateMXMLArray(document, null, value);
+      } else if (simple === false) {
+        value = generateMXMLObject(document, value);
+      }
 
-    assingComp = true;
-    if (name === 'id') {
-      document['set_' + value](comp);
-      id = value;
-    } else if (name === '_id') {
-      document[value] = comp;
-      id = value;
-      assingComp = false;
-    }
+      if (name === 'id') {
+        document['set_' + value](comp);
+        id = value;
+      }
 
-    if (assingComp) {
-      if (typeof comp['set_' + name] === 'function') {
-        comp['set_' + name](value);
-      } else {
-        comp[name] = value;
+      if (name == 'document' && !comp.document) {
+        comp.document = document;
+      }
+      else if (name === '_id') {
+        document[value] = comp;
+        id = value;
+      }
+      else if (name === 'id') {
+        if (typeof(comp['set_id']) === 'function') {
+          comp['set_id'](value);
+        }
+      }
+      else {
+        if (typeof comp['set_' + name] === 'function') {
+          comp['set_' + name](value);
+        } else {
+          comp[name] = value;
+        }
       }
     }
-  }
 
-  if (typeof comp.setDocument === 'function') {
-    comp.setDocument(document, id);
+    if (typeof comp.setDocument === 'function') {
+      comp.setDocument(document, id);
+    }
   }
 
   return comp;
@@ -96,60 +107,64 @@ org.apache.flex.utils.MXMLDataInterpreter.generateMXMLObject =
  * @param {Object} document The MXML object.
  * @param {Object} parent The parent object.
  * @param {Array} data The data array.
- * @param {boolean=} opt_recursive Whether to create objects in children.
  * @return {Array} The generated array.
  */
 org.apache.flex.utils.MXMLDataInterpreter.generateMXMLArray =
-    function(document, parent, data, opt_recursive) {
-  var bead, beadOffset, beads, children, Cls, comp, comps, generateMXMLArray,
-      generateMXMLObject, i, id, j, k, l, m, n, name, self, simple, value, dispatchBeadsAdded;
+    function(document, parent, data) {
+  var comps = [];
 
-  if (opt_recursive === undefined) {
-    opt_recursive = true;
+  var n = data.length;
+  var i = 0;
+  while (i < n) {
+    var cls = data[i++];
+    var comp = new cls();
+
+    i = org.apache.flex.utils.MXMLDataInterpreter.initializeStrandBasedObject(document, parent,
comp, data, i);
+
+    comps.push(comp);
   }
+  return comps;
+};
+
+
+/**
+ * @expose
+ * @param {Object} document The MXML object.
+ * @param {Object} parent The parent object.
+ * @param {Object} comp The component being initialized.
+ * @param {Array} data The data array.
+ * @param {number} i The offset into data.
+ * @return {number} The new offset into the data.
+ */
+org.apache.flex.utils.MXMLDataInterpreter.initializeStrandBasedObject =
+    function(document, parent, comp, data, i) {
+  var bead, beadOffset, beads, children, Cls, generateMXMLArray,
+      generateMXMLObject, id, j, k, l, m, n, name, self, simple, value, dispatchBeadsAdded;
 
   generateMXMLArray =
       org.apache.flex.utils.MXMLDataInterpreter.generateMXMLArray;
   generateMXMLObject =
       org.apache.flex.utils.MXMLDataInterpreter.generateMXMLObject;
 
-  comps = [];
-
-  n = data.length;
-  i = 0;
-  while (i < n) {
-    Cls = data[i++];
-    comp = new Cls();
-
-    id = null;
-    dispatchBeadsAdded = false;
-
-    m = data[i++]; // num props
-    if (m > 0 && data[0] === 'model') {
-      m--;
-      name = data[i++];
-      simple = data[i++];
-      value = data[i++];
+  id = null;
 
-      if (simple === null) {
-        value = generateMXMLArray(document, parent, value, opt_recursive);
-      } else if (simple === false) {
-        value = generateMXMLObject(document, value);
-      }
+  m = data[i++]; // num props
+  if (m > 0 && data[0] === 'model') {
+    m--;
+    name = data[i++];
+    simple = data[i++];
+    value = data[i++];
 
-      if (typeof comp['set_' + name] === 'function') {
-        comp['set_' + name](value);
-      } else {
-        comp[name] = value;
-      }
+    if (simple === null) {
+      value = generateMXMLArray(document, parent, value);
+    } else if (simple === false) {
+      value = generateMXMLObject(document, value);
+    }
 
-      // (erikdebruin) There are no components with the 'get_strand' method...
-      /*
-      if (typeof value.addBead === 'function' &&
-          typeof comp.get_strand === 'function') {
-        comp.addBead(value);
-      }
-      */
+    if (typeof comp['set_' + name] === 'function') {
+      comp['set_' + name](value);
+    } else {
+      comp[name] = value;
     }
 
     beadOffset = i + (m - 1) * 3;
@@ -158,78 +173,76 @@ org.apache.flex.utils.MXMLDataInterpreter.generateMXMLArray =
     } else {
       beadOffset = -1;
     }
+  }
 
-    for (j = 0; j < m; j++) {
-      name = data[i++];
-      simple = data[i++];
-      value = data[i++];
+  for (j = 0; j < m; j++) {
+    name = data[i++];
+    simple = data[i++];
+    value = data[i++];
 
-      if (simple === null) {
-        value = generateMXMLArray(document, null, value, opt_recursive);
-      } else if (simple === false) {
-        value = generateMXMLObject(document, value);
-      }
+    if (simple === null) {
+      value = generateMXMLArray(document, null, value);
+    } else if (simple === false) {
+      value = generateMXMLObject(document, value);
+    }
 
-      if (name === 'id') {
-        id = value;
-      }
+    if (name === 'id') {
+      id = value;
+      document['set_' + value](comp);
+    }
 
-      if (name === 'document' && !comp.document) {
-        comp.document = document;
-      } else if (name === '_id') {
-        id = value; // and don't assign to comp
+    if (name === 'document' && !comp.document) {
+      comp.document = document;
+    } else if (name === '_id') {
+      id = value; // and don't assign to comp
+    } else if (name === 'id') {
+      if (typeof(comp['set_id']) === 'function') {
+        comp['set_id'](value);
+      }
+    } else {
+      if (typeof(comp['set_' + name]) === 'function') {
+        comp['set_' + name](value);
       } else {
-        if (typeof(comp['set_' + name]) === 'function') {
-          comp['set_' + name](value);
-        } else {
-          comp[name] = value;
-        }
+        comp[name] = value;
       }
     }
+  }
 
-    if (beadOffset > -1)
-    {
-      name = data[i++];
-      simple = data[i++];
-      value = data[i++];
+  if (beadOffset > -1)
+  {
+    name = data[i++];
+    simple = data[i++];
+    value = data[i++];
 
-      if (simple === null) {
-        value = generateMXMLArray(document, null, value, opt_recursive);
-      } else if (simple === false) {
-        value = generateMXMLObject(document, value);
+    if (simple === null) {
+      value = generateMXMLArray(document, null, value);
+    } else if (simple === false) {
+      value = generateMXMLObject(document, value);
+    } else {
+      if (typeof(comp['set_' + name]) === 'function') {
+        comp['set_' + name](value);
       } else {
-        if (typeof(comp['set_' + name]) === 'function') {
-          comp['set_' + name](value);
-        } else {
-          comp[name] = value;
-        }
-      }
-
-      beads = value;
-      l = beads.length;
-      for (k = 0; k < l; k++) {
-        bead = beads[k];
-        comp.addBead(bead);
-        dispatchBeadsAdded = true;
+        comp[name] = value;
       }
     }
+  }
 
-    m = data[i++]; // num styles
-    for (j = 0; j < m; j++) {
-      name = data[i++];
-      simple = data[i++];
-      value = data[i++];
+  m = data[i++]; // num styles
+  for (j = 0; j < m; j++) {
+    name = data[i++];
+    simple = data[i++];
+    value = data[i++];
 
-      if (simple === null) {
-        value = generateMXMLArray(document, null, value, opt_recursive);
-      } else if (simple === false) {
-        value = generateMXMLObject(document, value);
-      }
+    if (simple === null) {
+      value = generateMXMLArray(document, null, value);
+    } else if (simple === false) {
+      value = generateMXMLObject(document, value);
+    }
 
-      if (comp.setStyle) {
-        comp.setStyle(name, value);
-      }
+    if (comp.setStyle) {
+      comp.setStyle(name, value);
     }
+  }
 
     /*
     m = data[i++]; // num effects
@@ -246,56 +259,50 @@ org.apache.flex.utils.MXMLDataInterpreter.generateMXMLArray =
     }
     */
 
-    m = data[i++]; // num events
-    for (j = 0; j < m; j++) {
-      name = data[i++];
-      value = data[i++];
-
-      comp.addEventListener(name, goog.bind(value, document));
-    }
-
-    if (parent) {
-      parent.addElement(comp);
-      dispatchBeadsAdded = true;
-    }
+  m = data[i++]; // num events
+  for (j = 0; j < m; j++) {
+    name = data[i++];
+    value = data[i++];
 
-    children = data[i++];
-    if (children) {
-      if (opt_recursive) {
-        self = org.apache.flex.utils.MXMLDataInterpreter;
-        self.generateMXMLInstances(
-            document, comp, children, opt_recursive);
-        if (typeof comp.childrenAdded === 'function')
-          comp.childrenAdded();
-      } else if (comp.setMXMLDescriptor) {
-        comp.setMXMLDescriptor(children);
-      }
-    }
+    comp.addEventListener(name, goog.bind(value, document));
+  }
 
-    if (id) {
-      if (typeof(document['set_' + id]) === 'function') {
-        document['set_' + id](comp);
-      } else {
-        document[id] = comp;
-      }
-    }
+  children = data[i++];
+  if (children && comp["setMXMLDescriptor"]) {
+    comp["setMXMLDescriptor"](document, children);
+  }
+  if (parent && org.apache.flex.utils.Language.is(comp,
+      org.apache.flex.core.IUIBase)) {
+    parent.addElement(comp);
+  }
 
-    if (typeof(comp.setDocument) === 'function') {
-      comp.setDocument(document, id);
+  if (children) {
+    if (!comp["setMXMLDescriptor"]) {
+      self = org.apache.flex.utils.MXMLDataInterpreter;
+      self.generateMXMLInstances(
+            document, comp, children);
+      if (typeof comp.childrenAdded === 'function')
+        comp.childrenAdded();
     }
+  }
 
-    if (goog.isFunction(comp.finalizeElement)) {
-      comp.finalizeElement();
+  if (id) {
+    if (typeof(document['set_' + id]) === 'function') {
+      document['set_' + id](comp);
+    } else {
+      document[id] = comp;
     }
+  }
 
-    comps.push(comp);
+  if (typeof(comp.setDocument) === 'function') {
+    comp.setDocument(document, id);
+  }
 
-    if (dispatchBeadsAdded) {
-      comp.dispatchEvent('beadsAdded');
-    }
+  if (goog.isFunction(comp.finalizeElement)) {
+    comp.finalizeElement();
   }
 
-  return comps;
+  return i;
 };
 
 
@@ -304,13 +311,12 @@ org.apache.flex.utils.MXMLDataInterpreter.generateMXMLArray =
  * @param {Object} document The MXML object.
  * @param {Object} parent The parent object.
  * @param {Array} data The data array.
- * @param {boolean=} opt_recursive Whether to create objects in children.
  */
 org.apache.flex.utils.MXMLDataInterpreter.generateMXMLInstances =
-    function(document, parent, data, opt_recursive) {
+    function(document, parent, data) {
   if (data) {
     org.apache.flex.utils.MXMLDataInterpreter.generateMXMLArray(
-        document, parent, data, opt_recursive);
+        document, parent, data);
   }
 };
 
@@ -351,7 +357,7 @@ org.apache.flex.utils.MXMLDataInterpreter.generateMXMLProperties =
     value = data[i++];
 
     if (simple === null) {
-      value = generateMXMLArray(host, null, value, true);
+      value = generateMXMLArray(host, null, value);
     } else if (simple === false) {
       value = generateMXMLObject(host, value);
     }
@@ -377,7 +383,7 @@ org.apache.flex.utils.MXMLDataInterpreter.generateMXMLProperties =
     value = data[i++];
 
     if (simple === null) {
-      value = generateMXMLArray(host, null, value, true);
+      value = generateMXMLArray(host, null, value);
     } else if (simple === false) {
       value = generateMXMLObject(host, value);
     } else {
@@ -403,7 +409,7 @@ org.apache.flex.utils.MXMLDataInterpreter.generateMXMLProperties =
     value = data[i++];
 
     if (simple === null) {
-      value = generateMXMLArray(host, null, value, true);
+      value = generateMXMLArray(host, null, value);
     } else if (simple === false) {
       value = generateMXMLObject(host, value);
     }


Mime
View raw message