0 Replies Latest reply on Jan 16, 2009 9:35 AM by (Paul_Reilly)

    [svn] 4559: Since before Flex 1.0, data binding has worked by code generating a

    Level 1
      Revision: 4559
      Author:   preilly@adobe.com
      Date:     2009-01-16 09:35:21 -0800 (Fri, 16 Jan 2009)

      Log Message:
      -----------
      Since before Flex 1.0, data binding has worked by code generating a
      throw away function containing all the source expressions.  Currently,
      this function is named _*_bindingExprs().  The source expressions are
      also written into _*_bindingsSetup(), which is actually used at
      runtime to setup all the Binding objects.  The _*_bindingsSetup()
      function is much more complex than _*_bindingExprs(), so
      _*_bindingExprs() has been kept around to make the processing code,
      which currently lives in DataBindingFirstPassEvaluator, less complex.
      This has come with a cost of increased compile time, increased compile
      memory use, and larger SWF's.  At one point, the throw away functions
      were removed before byte code generation, but that no longer seems to
      be the case.

      This change bites the bullet by getting rid of the throw away function
      and updating DataBindingFirstPassEvaluator to use _*_bindingsSetup()
      to gleam the Bindable information needed to generate the watchers in
      *WatcherSetupUtil.  For Repeaters, the source expressions are
      rewritten making life for DataBindingFirstPassEvaluator particularly
      difficult.  For example, with:

       
         
       


      The source expression in _*_bindingExprs() was:

        destination = (r.currentItem.name);

      but in _*_bindingsSetup(), it's:

        var result:* = (r.mx_internal::getItemAt(repeaterIndices[0]).name);

      And it just gets worse for nested Repeaters.  For example, with:

       
         
           
             
           

         

       


      The source expression becomes:

        var result:* = (outer.mx_internal::getItemAt(repeaterIndices[0]).name) + "" + (inner[instanceIndices[0]].mx_internal::getItemAt(repeaterIndices[1]).name) + "" + (innerInner[instanceIndices[0]][instanceIndices[1]].mx_internal::getItemAt(repeaterIndice s[2]).name);

      Picking apart that line in order to build up the correct watchers is
      no picnic.

      tests Passed: checkintests, mxunit databinding

      Needs QA: YES

      Needs DOC: NO

      API Change: NO

      Reviewer: Carol

      Code-level description of changes:

        modules/compiler/src/java/flex2/compiler/as3/binding/PropertyWatcher.java

          Moved bindingExpressions variable and accessors into parent class.

        modules/compiler/src/java/flex2/compiler/as3/binding/RepeaterItemWatcher.java

          Updated to extend Watcher, instead of PropertyWatcher.

        modules/compiler/src/java/flex2/compiler/as3/binding/WatcherSetupUtil.vm

          Removed some code generation as a result of removing the
          RepeaterDataProviderWatcher class.

        modules/compiler/src/java/flex2/compiler/as3/binding/DataBindingFirstPassEvaluator.java

          Renamed insideXmlExpression variable to insideXMLExpression.

          Added insideRepeaterExpression variable.
         
          Replaced insideBindingExpressionsFunction variable and it's uses
          with insideBindingsSetupFunction.

          Removed insideSetExpression.

          Added bindingId variable to replace [Binding] metadata.

          Modified evaluate(Context, CallExpressionNode) to handle
          getItemAt() when inside a Repeater based expression.

          Modified evaluate(Context, FunctionCommonNode) to look for
          _*_bindingSetup() and evaluate only the statements containing the
          data binding source expressions.

          Modified evaluate(Context, GetExpressionNode) to skip expr of type
          ArgumentListNode when inside a Repeater based expression.

          Modified evaluate(Context, IdentifierNode) to skip
          "instanceIndices".

          Modified evaluate(Context, MemberExpressionNode) to look for
          Repeater based expressions and repeaterIndices based expressions
          and handle them differently than a normal MemberExpressionNode.
          Also moved some logic into helper methods like getRef() and
          pushSrcType().  Lastly, removed special non-handling for XMLList.

          Removed evaluate(Context, SetExpressionNode) since it's no longer
          needed.

          Added three Repeater helper methods, isRepeaterBase(),
          isRepeaterIndicesBase(), and setupRepeaterWatchers().

          Removed RepeaterDataProvider handling from the three
          watchExpressionString*() methods.

          Removed UnableToDetectXMLListChanges warning.

        modules/compiler/src/java/flex2/compiler/as3/binding/RepeaterDataProviderWatcher.java

          Removed no longer used class.

        modules/compiler/src/java/flex2/compiler/as3/binding/Watcher.java

          Added bindingExpressions variable and accessors from PropertyWatcher.

        modules/compiler/src/java/flex2/compiler/mxml/rep/MxmlDocument.java

          Removed getAllBindingNamespaceDeclarations(), because it's no
          longer used.

        modules/compiler/src/java/flex2/compiler/mxml/rep/BindingExpression.java

          Added check for null destination to getRepeaterLevel().

          Added getRepeaterId().

          Removed getAllBindingNamespaceDeclarations(), because it's no
          longer used.

        modules/compiler/src/java/flex2/compiler/mxml/gen/ClassDefLib.vm
        modules/compiler/src/java/flex2/compiler/mxml/ImplementationGenerator.java

          Removed _*_bindingExprs() code generation.

        modules/compiler/src/java/flex2/compiler_en.properties

          Removed UnableToDetectXMLListChanges message.

      Modified Paths:
      --------------
          flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/binding/DataBindingFirstPassE valuator.java
          flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/binding/PropertyWatcher.java
          flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/binding/RepeaterItemWatcher.j ava
          flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/binding/Watcher.java
          flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/binding/WatcherSetupUtil.vm
          flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/ImplementationGenerator.java
          flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/gen/ClassDefLib.vm
          flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/BindingExpression.java
          flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/mxml/rep/MxmlDocument.java
          flex/sdk/trunk/modules/compiler/src/java/flex2/compiler_en.properties

      Removed Paths:
      -------------
          flex/sdk/trunk/modules/compiler/src/java/flex2/compiler/as3/binding/RepeaterDataProviderW atcher.java