You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Alex Harui <ah...@adobe.com> on 2013/11/08 01:15:56 UTC

Re: git commit: [flex-asjs] [refs/heads/develop] - An example of how API parity would look. I started at SimpleStateImpl and worked my way up ; -)

I'm good with that, but what if the original implementation was
significantly faster on JS but not on AS?  Would you then allow for a
different implementation?

On 11/7/13 11:27 AM, "erikdebruin@apache.org" <er...@apache.org>
wrote:

>Updated Branches:
>  refs/heads/develop 4b17f61ce -> 9fa2c6f9b
>
>
>An example of how API parity would look. I started at SimpleStateImpl and
>worked my way up ;-)
>
>Also, all these files now comply with the gjslint and JSHint code quality
>requirements.
>
>Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>
>
>
>Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
>Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/9fa2c6f9
>Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/9fa2c6f9
>Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/9fa2c6f9
>
>Branch: refs/heads/develop
>Commit: 9fa2c6f9ba48b7404a873a26ca98658f1aa33e2d
>Parents: 4b17f61
>Author: Erik de Bruin <er...@ixsoftware.nl>
>Authored: Thu Nov 7 20:27:13 2013 +0100
>Committer: Erik de Bruin <er...@ixsoftware.nl>
>Committed: Thu Nov 7 20:27:21 2013 +0100
>
>----------------------------------------------------------------------
> frameworks/js/FlexJS/src/mx/states/AddItems.js  |  35 +++-
> .../js/FlexJS/src/mx/states/SetProperty.js      |  35 +++-
> frameworks/js/FlexJS/src/mx/states/State.js     |   4 +-
> .../src/org/apache/flex/core/IStatesImpl.js     |  38 +++++
> .../FlexJS/src/org/apache/flex/core/IStrand.js  |  55 ++++++
> .../org/apache/flex/core/SimpleStatesImpl.js    | 171 ++++++++++---------
> .../org/apache/flex/events/IEventDispatcher.js  |  25 +++
> 7 files changed, 272 insertions(+), 91 deletions(-)
>----------------------------------------------------------------------
>
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9fa2c6f9/frameworks/
>js/FlexJS/src/mx/states/AddItems.js
>----------------------------------------------------------------------
>diff --git a/frameworks/js/FlexJS/src/mx/states/AddItems.js
>b/frameworks/js/FlexJS/src/mx/states/AddItems.js
>index 6b1a347..3cf63a2 100644
>--- a/frameworks/js/FlexJS/src/mx/states/AddItems.js
>+++ b/frameworks/js/FlexJS/src/mx/states/AddItems.js
>@@ -14,10 +14,13 @@
>
> goog.provide('mx.states.AddItems');
>
>+goog.require('org.apache.flex.core.IDocument');
>+
>
>
> /**
>  * @constructor
>+ * @implements {org.apache.flex.core.IDocument}
>  */
> mx.states.AddItems = function() {
> };
>@@ -25,19 +28,15 @@ mx.states.AddItems = function() {
>
> /**
>  * @param {Object} document The MXML object.
>+ * @param {string=} opt_id The id.
>  */
>-mx.states.AddItems.prototype.setDocument = function(document) {
>+mx.states.AddItems.prototype.setDocument = function(document, opt_id) {
>+  opt_id = typeof opt_id !== 'undefined' ? opt_id : null;
>   this.document = document;
> };
>
>
> /**
>- * @type {string} document The type of override.
>- */
>-mx.states.AddItems.prototype.type = 'AddItems';
>-
>-
>-/**
>  * @expose
>  * @type {Object} document The MXML object.
>  */
>@@ -85,3 +84,25 @@ mx.states.AddItems.prototype.position = null;
>  */
> mx.states.AddItems.prototype.relativeTo = null;
>
>+
>+/**
>+ * @expose
>+ * @param {Object} properties The properties for the new object.
>+ * @return {Object} The new object.
>+ */
>+mx.states.AddItems.prototype.initializeFromObject = function(properties)
>{
>+  var p;
>+
>+  for (p in properties) {
>+    this[p] = properties[p];
>+  }
>+
>+  return this;
>+};
>+
>+
>+/**
>+ * @const
>+ */
>+mx.states.AddItems.prototype.FLEXJS_CLASS_INFO =
>+    { interfaces: [org.apache.flex.core.IDocument] };
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9fa2c6f9/frameworks/
>js/FlexJS/src/mx/states/SetProperty.js
>----------------------------------------------------------------------
>diff --git a/frameworks/js/FlexJS/src/mx/states/SetProperty.js
>b/frameworks/js/FlexJS/src/mx/states/SetProperty.js
>index 371d986..cfc8b53 100644
>--- a/frameworks/js/FlexJS/src/mx/states/SetProperty.js
>+++ b/frameworks/js/FlexJS/src/mx/states/SetProperty.js
>@@ -14,10 +14,13 @@
>
> goog.provide('mx.states.SetProperty');
>
>+goog.require('org.apache.flex.core.IDocument');
>+
>
>
> /**
>  * @constructor
>+ * @implements {org.apache.flex.core.IDocument}
>  */
> mx.states.SetProperty = function() {
> };
>@@ -25,19 +28,15 @@ mx.states.SetProperty = function() {
>
> /**
>  * @param {Object} document The MXML object.
>+ * @param {string=} opt_id The id.
>  */
>-mx.states.SetProperty.prototype.setDocument = function(document) {
>+mx.states.SetProperty.prototype.setDocument = function(document, opt_id)
>{
>+  opt_id = typeof opt_id !== 'undefined' ? opt_id : null;
>   this.document = document;
> };
>
>
> /**
>- * @type {string} document The type of override.
>- */
>-mx.states.SetProperty.prototype.type = 'SetProperty';
>-
>-
>-/**
>  * @expose
>  * @type {Object} document The MXML object.
>  */
>@@ -71,3 +70,25 @@ mx.states.SetProperty.prototype.previousValue = null;
>  */
> mx.states.SetProperty.prototype.value = null;
>
>+
>+/**
>+ * @expose
>+ * @param {Object} properties The properties for the new object.
>+ * @return {Object} The new object.
>+ */
>+mx.states.SetProperty.prototype.initializeFromObject =
>function(properties) {
>+  var p;
>+
>+  for (p in properties) {
>+    this[p] = properties[p];
>+  }
>+
>+  return this;
>+};
>+
>+
>+/**
>+ * @const
>+ */
>+mx.states.SetProperty.prototype.FLEXJS_CLASS_INFO =
>+    { interfaces: [org.apache.flex.core.IDocument] };
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9fa2c6f9/frameworks/
>js/FlexJS/src/mx/states/State.js
>----------------------------------------------------------------------
>diff --git a/frameworks/js/FlexJS/src/mx/states/State.js
>b/frameworks/js/FlexJS/src/mx/states/State.js
>index 29541f9..b325c50 100644
>--- a/frameworks/js/FlexJS/src/mx/states/State.js
>+++ b/frameworks/js/FlexJS/src/mx/states/State.js
>@@ -18,8 +18,10 @@ goog.provide('mx.states.State');
>
> /**
>  * @constructor
>+ * @param {Object=} opt_props The initial properties.
>  */
>-mx.states.State = function() {
>+mx.states.State = function(opt_props) {
>+  opt_props = typeof opt_props !== 'undefined' ? opt_props : null;
> };
>
>
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9fa2c6f9/frameworks/
>js/FlexJS/src/org/apache/flex/core/IStatesImpl.js
>----------------------------------------------------------------------
>diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/IStatesImpl.js
>b/frameworks/js/FlexJS/src/org/apache/flex/core/IStatesImpl.js
>new file mode 100644
>index 0000000..ddb9ebd
>--- /dev/null
>+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/IStatesImpl.js
>@@ -0,0 +1,38 @@
>+/**
>+ * Licensed under the Apache License, Version 2.0 (the "License");
>+ * you may not use this file except in compliance with the License.
>+ * You may obtain a copy of the License at
>+ *
>+ *     http://www.apache.org/licenses/LICENSE-2.0
>+ *
>+ * Unless required by applicable law or agreed to in writing, software
>+ * distributed under the License is distributed on an "AS IS" BASIS,
>+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+ * See the License for the specific language governing permissions and
>+ * limitations under the License.
>+ */
>+
>+goog.provide('org.apache.flex.core.IStatesImpl');
>+
>+goog.require('org.apache.flex.core.IBead');
>+goog.require('org.apache.flex.events.IEventDispatcher');
>+
>+
>+
>+/**
>+ * IStatesImpl
>+ *
>+ * @interface
>+ * @extends {org.apache.flex.core.IBead}
>+ * @extends {org.apache.flex.events.IEventDispatcher}
>+ */
>+org.apache.flex.core.IStatesImpl = function() {
>+};
>+
>+
>+/**
>+ * @const
>+ */
>+org.apache.flex.core.IStatesImpl.prototype.FLEXJS_CLASS_INFO =
>+    { interfaces: [org.apache.flex.core.IBead,
>+                   org.apache.flex.events.IEventDispatcher] };
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9fa2c6f9/frameworks/
>js/FlexJS/src/org/apache/flex/core/IStrand.js
>----------------------------------------------------------------------
>diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/IStrand.js
>b/frameworks/js/FlexJS/src/org/apache/flex/core/IStrand.js
>new file mode 100644
>index 0000000..8356f12
>--- /dev/null
>+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/IStrand.js
>@@ -0,0 +1,55 @@
>+/**
>+ * Licensed under the Apache License, Version 2.0 (the "License");
>+ * you may not use this file except in compliance with the License.
>+ * You may obtain a copy of the License at
>+ *
>+ *     http://www.apache.org/licenses/LICENSE-2.0
>+ *
>+ * Unless required by applicable law or agreed to in writing, software
>+ * distributed under the License is distributed on an "AS IS" BASIS,
>+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+ * See the License for the specific language governing permissions and
>+ * limitations under the License.
>+ */
>+
>+goog.provide('org.apache.flex.core.IStrand');
>+
>+
>+
>+/**
>+ * IStrand
>+ *
>+ * @interface
>+ */
>+org.apache.flex.core.IStrand = function() {
>+};
>+
>+
>+/**
>+ * addBead()
>+ *
>+ * @expose
>+ * @param {org.apache.flex.core.IBead} bead The bead to add.
>+ */
>+org.apache.flex.core.IStrand.prototype.addBead = function(bead) {};
>+
>+
>+/**
>+ * getBeadByType()
>+ *
>+ * @expose
>+ * @param {Object} classOrInterface The type of bead to look for.
>+ * @return {org.apache.flex.core.IBead} The bead.
>+ */
>+org.apache.flex.core.IStrand.prototype.getBeadByType =
>+    function(classOrInterface) {};
>+
>+
>+/**
>+ * removeBead()
>+ *
>+ * @expose
>+ * @param {org.apache.flex.core.IBead} bead The bead to remove.
>+ * @return {org.apache.flex.core.IBead} The bead that was removed.
>+ */
>+org.apache.flex.core.IStrand.prototype.removeBead = function(bead) {};
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9fa2c6f9/frameworks/
>js/FlexJS/src/org/apache/flex/core/SimpleStatesImpl.js
>----------------------------------------------------------------------
>diff --git
>a/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleStatesImpl.js
>b/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleStatesImpl.js
>index e71bc8f..f0fc482 100644
>--- a/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleStatesImpl.js
>+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/SimpleStatesImpl.js
>@@ -14,19 +14,27 @@
>
> goog.provide('org.apache.flex.core.SimpleStatesImpl');
>
>+goog.require('mx.states.AddItems');
>+goog.require('mx.states.SetProperty');
>+goog.require('mx.states.State');
>+goog.require('org.apache.flex.core.IBead');
>+goog.require('org.apache.flex.core.IStatesImpl');
>+goog.require('org.apache.flex.core.IStrand');
> goog.require('org.apache.flex.events.EventDispatcher');
>
>
>
> /**
>  * @constructor
>+ * @implements {org.apache.flex.core.IBead}
>+ * @implements {org.apache.flex.core.IStatesImpl}
>  */
> org.apache.flex.core.SimpleStatesImpl = function() {
>   goog.base(this);
>
>   /**
>    * @private
>-   * @type {Object}
>+   * @type {org.apache.flex.core.IStrand}
>    */
>   this.strand_ = null;
> };
>@@ -36,42 +44,40 @@ goog.inherits(org.apache.flex.core.SimpleStatesImpl,
>
> /**
>  * @expose
>- * @param {Object} value The new host.
>+ * @param {org.apache.flex.core.IStrand} value The new host.
>  */
> org.apache.flex.core.SimpleStatesImpl.prototype.set_strand =
>     function(value) {
>   if (this.strand_ !== value) {
>     this.strand_ = value;
>     this.strand_.addEventListener('currentStateChanged',
>-        goog.bind(this.stateChangeHandler, this));
>+        goog.bind(this.stateChangeHandler_, this));
>   }
> };
>
>
> /**
>- * @protected
>+ * @private
>  * @param {Object} event The event.
>  */
>-org.apache.flex.core.SimpleStatesImpl.prototype.stateChangeHandler =
>+org.apache.flex.core.SimpleStatesImpl.prototype.stateChangeHandler_ =
>     function(event) {
>-  var s, p;
>-  var doc = event.target;
>-  var arr = doc.get_states();
>-  for (p in arr)
>-  {
>+  var arr, doc, p, s;
>+
>+  doc = event.target;
>+  arr = doc.get_states();
>+  for (p in arr) {
>     s = arr[p];
>-    if (s.name == event.oldValue)
>-    {
>-      this.revert(s);
>+    if (s.name === event.oldValue) {
>+      this.revert_(s);
>       break;
>     }
>   }
>-  for (p in arr)
>-  {
>+
>+  for (p in arr) {
>     s = arr[p];
>-    if (s.name == event.newValue)
>-    {
>-      this.applyState(s);
>+    if (s.name === event.newValue) {
>+      this.apply_(s);
>       break;
>     }
>   }
>@@ -79,109 +85,122 @@
>org.apache.flex.core.SimpleStatesImpl.prototype.stateChangeHandler =
>
>
> /**
>- * @protected
>- * @param {Object} s The State to revert.
>+ * @private
>+ * @param {mx.states.State} s The State to revert.
>  */
>-org.apache.flex.core.SimpleStatesImpl.prototype.revert = function(s) {
>-  var p, o;
>-  var arr = s.overrides;
>-  for (p in arr)
>-  {
>+org.apache.flex.core.SimpleStatesImpl.prototype.revert_ = function(s) {
>+  var arr, item, o, p, parent, q, target;
>+
>+  arr = s.overrides;
>+  for (p in arr) {
>     o = arr[p];
>-    if (o.type == 'AddItems')
>-    {
>-      for (var q in o.items)
>-      {
>-        var item = o.items[q];
>-        var parent;
>-        if (typeof(o.document['get_' + o.destination]) == 'function')
>+    if (org.apache.flex.utils.Language.is(o, mx.states.AddItems)) {
>+      for (q in o.items) {
>+        item = o.items[q];
>+
>+        if (typeof(o.document['get_' + o.destination]) === 'function') {
>           parent = o.document['get_' + o.destination]();
>-        else
>+        } else {
>           parent = o.document[o.destination];
>+        }
>+
>         parent.removeElement(item);
>         parent.dispatchEvent(
>             new org.apache.flex.events.Event('childrenAdded'));
>       }
>-    }
>-    else if (o.type == 'SetProperty')
>-    {
>-      var target;
>-      if (typeof(o.document['get_' + o.target]) == 'function')
>+    } else if (org.apache.flex.utils.Language.is(o,
>mx.states.SetProperty)) {
>+      if (typeof(o.document['get_' + o.target]) === 'function') {
>         target = o.document['get_' + o.target]();
>-      else
>+      } else {
>         target = o.document[o.target];
>-      if (typeof(target['set_' + o.name]) == 'function')
>+      }
>+
>+      if (typeof(target['set_' + o.name]) === 'function') {
>         target['set_' + o.name](o.previousValue);
>-      else
>+      } else {
>         target[o.name] = o.previousValue;
>+      }
>     }
>   }
> };
>
>
> /**
>- * @protected
>- * @param {Object} s The State to apply.
>+ * @private
>+ * @param {mx.states.State} s The State to apply.
>  */
>-org.apache.flex.core.SimpleStatesImpl.prototype.applyState = function(s)
>{
>-  var o, p;
>-  var arr = s.overrides;
>-  for (p in arr)
>-  {
>+org.apache.flex.core.SimpleStatesImpl.prototype.apply_ = function(s) {
>+  var arr, child, index, item, o, p, parent, q, target;
>+
>+  arr = s.overrides;
>+  for (p in arr) {
>     o = arr[p];
>-    if (o.type == 'AddItems')
>-    {
>-      if (o.items == null)
>-      {
>+    if (org.apache.flex.utils.Language.is(o, mx.states.AddItems)) {
>+      if (!o.items) {
>         //TODO (aharui).  This array should be deferred
>         //var di = org.apache.flex.utils.MXMLDataInterpreter;
>         //o.items = di.generateMXMLArray(o.document,
>         //                                null, o.itemsDescriptor, true);
>         o.items = o.itemsDescriptor;
>       }
>-      for (var q in o.items)
>-      {
>-        var item = o.items[q];
>-        var parent;
>-        if (typeof(o.document['get_' + o.destination]) == 'function')
>+
>+      for (q in o.items) {
>+        item = o.items[q];
>+
>+        if (typeof(o.document['get_' + o.destination]) === 'function') {
>           parent = o.document['get_' + o.destination]();
>-        else
>+        } else {
>           parent = o.document[o.destination];
>-        if (o.relativeTo != null)
>-        {
>-          var child;
>-          if (typeof(o.document['get_' + o.relativeTo]) == 'function')
>+        }
>+
>+        if (o.relativeTo) {
>+          if (typeof(o.document['get_' + o.relativeTo]) === 'function') {
>             child = o.document['get_' + o.relativeTo]();
>-          else
>+          } else {
>             child = o.document[o.relativeTo];
>-          var index = parent.getElementIndex(child);
>-          if (o.position == 'after')
>+          }
>+
>+          index = parent.getElementIndex(child);
>+          if (o.position === 'after') {
>             index++;
>+          }
>+
>           parent.addElementAt(item, index);
>-        }
>-        else
>-        {
>+        } else {
>           parent.addElement(item);
>         }
>+
>         parent.dispatchEvent(
>             new org.apache.flex.events.Event('childrenAdded'));
>       }
>     }
>-    else if (o.type == 'SetProperty')
>+    else if (org.apache.flex.utils.Language.is(o, mx.states.SetProperty))
>     {
>-      var target;
>-      if (typeof(o.document['get_' + o.target]) == 'function')
>+      if (typeof(o.document['get_' + o.target]) === 'function') {
>         target = o.document['get_' + o.target]();
>-      else
>+      } else {
>         target = o.document[o.target];
>-      if (typeof(target['get_' + o.name]) == 'function')
>+      }
>+
>+      if (typeof(target['get_' + o.name]) === 'function') {
>         o.previousValue = target['get_' + o.name]();
>-      else
>+      } else {
>         o.previousValue = target[o.name];
>-      if (typeof(target['set_' + o.name]) == 'function')
>+      }
>+
>+      if (typeof(target['set_' + o.name]) === 'function') {
>         target['set_' + o.name](o.value);
>-      else
>+      } else {
>         target[o.name] = o.value;
>+      }
>     }
>   }
> };
>+
>+
>+/**
>+ * @const
>+ */
>+org.apache.flex.core.SimpleStatesImpl.prototype.FLEXJS_CLASS_INFO =
>+    { interfaces: [org.apache.flex.core.IBead,
>+                   org.apache.flex.core.IStatesImpl] };
>
>http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9fa2c6f9/frameworks/
>js/FlexJS/src/org/apache/flex/events/IEventDispatcher.js
>----------------------------------------------------------------------
>diff --git
>a/frameworks/js/FlexJS/src/org/apache/flex/events/IEventDispatcher.js
>b/frameworks/js/FlexJS/src/org/apache/flex/events/IEventDispatcher.js
>new file mode 100644
>index 0000000..401e976
>--- /dev/null
>+++ b/frameworks/js/FlexJS/src/org/apache/flex/events/IEventDispatcher.js
>@@ -0,0 +1,25 @@
>+/**
>+ * Licensed under the Apache License, Version 2.0 (the "License");
>+ * you may not use this file except in compliance with the License.
>+ * You may obtain a copy of the License at
>+ *
>+ *     http://www.apache.org/licenses/LICENSE-2.0
>+ *
>+ * Unless required by applicable law or agreed to in writing, software
>+ * distributed under the License is distributed on an "AS IS" BASIS,
>+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
>implied.
>+ * See the License for the specific language governing permissions and
>+ * limitations under the License.
>+ */
>+
>+goog.provide('org.apache.flex.events.IEventDispatcher');
>+
>+
>+
>+/**
>+ * IEventDispatcher
>+ *
>+ * @interface
>+ */
>+org.apache.flex.events.IEventDispatcher = function() {
>+};
>


Re: git commit: [flex-asjs] [refs/heads/develop] - An example of how API parity would look. I started at SimpleStateImpl and worked my way up ; -)

Posted by Alex Harui <ah...@adobe.com>.

On 11/7/13 11:43 PM, "Erik de Bruin" <er...@ixsoftware.nl> wrote:

>>>At this point in the development of the framework, no. Premature
>>>optimization and all thatŠ I'd maybe mark it as a TODO.
>> Why would that be premature optimization?  I guess I'm now confused as
>>to
>> where you want to put the abstraction differences?  Making all
>> Sprite/DisplayObject APIs available on the JS side seems more of a
>>Vanilla
>> plan than a FlexJS plan.
>
>Ok, that's where I think I didn't make myself clear: I think we should
>match the class structure of the FlexJS framework, NOT anything it
>imports from outside that framework. So in my last commit, on
>SimpleStateImpl.js, I didn't create a placeholder for
>'flash.display.DisplayObject'. In short: if it's a class or an
>interface in the AS FlexJS framework, I say we match it in the JS
>framework, for all the reasons I brought up earlier. If not, we try to
>live without it. This is not always possible, since e.g. AS-only
>projects need 'flash.display.Sprite', but in most of those cases we
>can get away with just an empty placeholder class on the JS side.
>
>Agreed?
I think I'm still unclear what you plan to do about Sprite.  Is that
"outside" so there is no placeholder, or are you still creating a
placeholder for it?  And if you think there should be a placeholder, what
APIs does it have?  Maybe I just need a more explicit example so I
understand the advantages of it.

I think there are different kinds of classes in FlexJS.  There are
"top-level" classes like Button that need to have matching API surfaces in
JS.  But then there are classes like DropDownListList.as which we use on
the AS side as part of a DropDownList but there really is no need for it
on the JS side in the DropDownList that does plain text and simply wraps a
<Select> tag.  IOW, there are pieces we can leverage in a browser that we
have to create in AS, and I don't see any advantages to creating empty
placeholder classes for them in JS, and vice versa.

But in general, there are several classes in FlexJS that could use a scrub
now that we have interfaces and can load beads in JS.
SimpleStatesImpl.as/js is a good example so thanks for scrubbing that one,
but I'm still not sure it makes sense to have every .as have a matching
.js file.

I'd rather have a tool that rolls-up or flattens the APIs for a class and
its superclasses and compares them and doesn't care quite so much about
what goes on inside and can ignore some aspects of inheritance and
inherited APIs.  It should certainly be a goal to make what goes on inside
as similar as possible to the other side, but I don't think we should have
a hard rule that it must be the same.

Anyway, I'm shutting down for the night,
-Alex


>
>>>Remember, there is a second compiler (Closure) in the tool chain
>>>which takes care of most of the 'bloat' when it is creating release
>>>code.
>>>All those interfaces and nested classes go away, as they contain no
>>>actual,
>>>executable code pathways.
>> What about methods?  Does it remove unused APIs?  How can you know when
>>an
>> externally loaded "module" won't need that seemingly unused API?
>
>GCC can work with modules, in order to allow for 'on demand' class
>loading. But I think even if you use these modules, you will have to
>recompile the entire project in order for the compiler to know all
>dependencies and relationships between modules. I don't think is
>possible to recompile just one module and having it work with a
>previously compiled 'main' application.
>
>EdB
>
>
>
>-- 
>Ix Multimedia Software
>
>Jan Luykenstraat 27
>3521 VB Utrecht
>
>T. 06-51952295
>I. www.ixsoftware.nl


Re: git commit: [flex-asjs] [refs/heads/develop] - An example of how API parity would look. I started at SimpleStateImpl and worked my way up ; -)

Posted by Erik de Bruin <er...@ixsoftware.nl>.
>>At this point in the development of the framework, no. Premature
>>optimization and all thatŠ I'd maybe mark it as a TODO.
> Why would that be premature optimization?  I guess I'm now confused as to
> where you want to put the abstraction differences?  Making all
> Sprite/DisplayObject APIs available on the JS side seems more of a Vanilla
> plan than a FlexJS plan.

Ok, that's where I think I didn't make myself clear: I think we should
match the class structure of the FlexJS framework, NOT anything it
imports from outside that framework. So in my last commit, on
SimpleStateImpl.js, I didn't create a placeholder for
'flash.display.DisplayObject'. In short: if it's a class or an
interface in the AS FlexJS framework, I say we match it in the JS
framework, for all the reasons I brought up earlier. If not, we try to
live without it. This is not always possible, since e.g. AS-only
projects need 'flash.display.Sprite', but in most of those cases we
can get away with just an empty placeholder class on the JS side.

Agreed?

>>Remember, there is a second compiler (Closure) in the tool chain
>>which takes care of most of the 'bloat' when it is creating release code.
>>All those interfaces and nested classes go away, as they contain no
>>actual,
>>executable code pathways.
> What about methods?  Does it remove unused APIs?  How can you know when an
> externally loaded "module" won't need that seemingly unused API?

GCC can work with modules, in order to allow for 'on demand' class
loading. But I think even if you use these modules, you will have to
recompile the entire project in order for the compiler to know all
dependencies and relationships between modules. I don't think is
possible to recompile just one module and having it work with a
previously compiled 'main' application.

EdB



-- 
Ix Multimedia Software

Jan Luykenstraat 27
3521 VB Utrecht

T. 06-51952295
I. www.ixsoftware.nl

Re: git commit: [flex-asjs] [refs/heads/develop] - An example of how API parity would look. I started at SimpleStateImpl and worked my way up ; -)

Posted by Alex Harui <ah...@adobe.com>.

On 11/7/13 7:04 PM, "Erik de Bruin" <er...@ixsoftware.nl> wrote:

>At this point in the development of the framework, no. Premature
>optimization and all thatŠ I'd maybe mark it as a TODO.
Why would that be premature optimization?  I guess I'm now confused as to
where you want to put the abstraction differences?  Making all
Sprite/DisplayObject APIs available on the JS side seems more of a Vanilla
plan than a FlexJS plan.

>
>Remember, there is a second compiler (Closure) in the tool chain
>which takes care of most of the 'bloat' when it is creating release code.
>All those interfaces and nested classes go away, as they contain no
>actual,
>executable code pathways.
What about methods?  Does it remove unused APIs?  How can you know when an
externally loaded "module" won't need that seemingly unused API?

-Alex


Re: git commit: [flex-asjs] [refs/heads/develop] - An example of how API parity would look. I started at SimpleStateImpl and worked my way up ; -)

Posted by Erik de Bruin <er...@ixsoftware.nl>.
At this point in the development of the framework, no. Premature
optimization and all that… I'd maybe mark it as a TODO.

Remember, there is a second compiler (Closure) in the tool chain
which takes care of most of the 'bloat' when it is creating release code.
All those interfaces and nested classes go away, as they contain no actual,
executable code pathways.

EdB



On Friday, November 8, 2013, Alex Harui wrote:

> I'm good with that, but what if the original implementation was
> significantly faster on JS but not on AS?  Would you then allow for a
> different implementation?
>
> On 11/7/13 11:27 AM, "erikdebruin@apache.org <javascript:;>" <
> erikdebruin@apache.org <javascript:;>>
> wrote:
>
> >Updated Branches:
> >  refs/heads/develop 4b17f61ce -> 9fa2c6f9b
> >
> >
> >An example of how API parity would look. I started at SimpleStateImpl and
> >worked my way up ;-)
> >
> >Also, all these files now comply with the gjslint and JSHint code quality
> >requirements.
> >
> >Signed-off-by: Erik de Bruin <er...@ixsoftware.nl>
> >
> >
> >Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
> >Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/9fa2c6f9
> >Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/9fa2c6f9
> >Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/9fa2c6f9
> >
> >Branch: refs/heads/develop
> >Commit: 9fa2c6f9ba48b7404a873a26ca98658f1aa33e2d
> >Parents: 4b17f61
> >Author: Erik de Bruin <er...@ixsoftware.nl>
> >Authored: Thu Nov 7 20:27:13 2013 +0100
> >Committer: Erik de Bruin <er...@ixsoftware.nl>
> >Committed: Thu Nov 7 20:27:21 2013 +0100
> >
> >----------------------------------------------------------------------
> > frameworks/js/FlexJS/src/mx/states/AddItems.js  |  35 +++-
> > .../js/FlexJS/src/mx/states/SetProperty.js      |  35 +++-
> > frameworks/js/FlexJS/src/mx/states/State.js     |   4 +-
> > .../src/org/apache/flex/core/IStatesImpl.js     |  38 +++++
> > .../FlexJS/src/org/apache/flex/core/IStrand.js  |  55 ++++++
> > .../org/apache/flex/core/SimpleStatesImpl.js    | 171 ++++++++++---------
> > .../org/apache/flex/events/IEventDispatcher.js  |  25 +++
> > 7 files changed, 272 insertions(+), 91 deletions(-)
> >----------------------------------------------------------------------
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/9fa2c6f9/frameworks/
> >js/FlexJS/src/mx/states/AddItems.js
> >----------------------------------------------------------------------
> >diff --git a/frameworks/js/FlexJS/src/mx/states/AddItems.js
> >b/frameworks/js/FlexJS/src/mx/states/AddItems.js
> >index 6b1a347..3cf63a2 100644
> >--- a/frameworks/js/FlexJS/src/mx/states/AddItems.js
> >+++ b/frameworks/js/FlexJS/src/mx/states/AddItems.js
> >@@ -14,10 +14,13 @@
> >
> > goog.provide('mx.states.AddItems');
> >
> >+goog.require('org.apache.flex.core.IDocument');
> >+
> >
> >
> > /**
> >  * @constructor
> >+ * @implements {org.apache.flex.core.IDocument}
> >  */
> > mx.states.AddItems = function() {
> > };
> >@@ -25,19 +28,15 @@ mx.states.AddItems = function() {
> >
> > /**
> >  * @param {Object} document The MXML object.
> >+ * @param {string=} opt_id The id.
> >  */
> >-mx.states.AddItems.prototype.setDocument = function(document) {
> >+mx.states.AddItems.prototype.setDocument = function(document, opt_id) {
> >+  opt_id = typeof opt_id !== 'undefined' ? opt_id : null;
> >   this.document = document;
> > };
> >
> >
> > /**
> >- * @type {string} document The type of override.
> >- */
> >-mx.states.AddItems.prototype.type = 'AddItems';
> >-
> >-
> >-/**
> >  * @expose
> >  * @type {Object} document The MXML object.
> >  */
> >@@ -85,3 +84,25 @@ mx.states.AddItems.prototype.position = null;
> >  */
> > mx.states.AddItems.prototype.relativeTo = null;
> >
> >+
> >+/**
> >+ * @expose
> >+ * @param {Object} properties The properties for the new object.
> >+ * @return {Object} The new object.
> >+ */
> >+mx.states.AddItems.prototype.initializeFromObject = function(properties)
> >{
> >+  var p;
> >



-- 
Ix Multimedia Software

Jan Luykenstraat 27
3521 VB Utrecht

T. 06-51952295
I. www.ixsoftware.nl