You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2020/05/28 11:48:23 UTC

[royale-asjs] branch develop updated (0e04280 -> 89ae550)

This is an automated email from the ASF dual-hosted git repository.

gregdove pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git.


    from 0e04280  jewel: default css was not updated for BinaryImage
     new db0995e  AMF improvements: Coverage for ignoring custom namespaces and also cases where Transient fields are still deserialized. They are only skipped during local serialization.
     new 20dd957  Fix for SimpleBinding not working sometimes when starting with 'this' + small tidyup in SimpleBinding.
     new 26d4b9c  Quick fix for many Containers (Container-derived mxml components) missing binding support in ported Flex code.
     new 4d9d3e3  Add flexibility for developer to control databinding support in mx.controls.Button-based mxml subclasses. Keeps original behavior, but allows users to explicitly avoid it.
     new 89ae550  Add DynamicEvent to MXRoyale small tidy-up (de-dupe) in MXRoyaleClasses

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/royale/binding/DataBindingBase.as   |   3 +-
 .../org/apache/royale/binding/SimpleBinding.as     |  10 +-
 .../MXRoyale/src/main/royale/MXRoyaleClasses.as    |   7 +-
 .../MXRoyale/src/main/royale/mx/controls/Button.as |  24 ++-
 .../MXRoyale/src/main/royale/mx/core/Container.as  |   2 +-
 .../mx/events/{IOErrorEvent.as => DynamicEvent.as} | 220 ++++++++++-----------
 .../royale/net/remoting/amf/AMFBinaryData.as       |  41 ++--
 .../network/AMFBinaryDataTesterTest.as             | 109 +++++++++-
 .../flexUnitTests/network/support/TestClass6.as    |   0
 .../flexUnitTests/network/support/TestClass7a.as   |   0
 .../flexUnitTests/network/support/TestClass7b.as   |   2 +-
 .../flexUnitTests/network/support/testnamespace.as |   0
 12 files changed, 277 insertions(+), 141 deletions(-)
 copy frameworks/projects/MXRoyale/src/main/royale/mx/events/{IOErrorEvent.as => DynamicEvent.as} (52%)
 copy {manualtests/UnitTests/src/main => frameworks/projects/Network/src/test}/royale/flexUnitTests/network/support/TestClass6.as (100%)
 copy {manualtests/UnitTests/src/main => frameworks/projects/Network/src/test}/royale/flexUnitTests/network/support/TestClass7a.as (100%)
 copy {manualtests/UnitTests/src/main => frameworks/projects/Network/src/test}/royale/flexUnitTests/network/support/TestClass7b.as (97%)
 copy {manualtests/UnitTests/src/main => frameworks/projects/Network/src/test}/royale/flexUnitTests/network/support/testnamespace.as (100%)


[royale-asjs] 04/05: Add flexibility for developer to control databinding support in mx.controls.Button-based mxml subclasses. Keeps original behavior, but allows users to explicitly avoid it.

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 4d9d3e3e8d4e5527806b63a5b8bf493af6934d43
Author: greg-dove <gr...@gmail.com>
AuthorDate: Thu May 28 23:06:18 2020 +1200

    Add flexibility for developer to control databinding support in mx.controls.Button-based mxml subclasses.
    Keeps original behavior, but allows users to explicitly avoid it.
---
 .../MXRoyale/src/main/royale/mx/controls/Button.as | 24 +++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Button.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Button.as
index 2df612c..840dd4f 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Button.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/Button.as
@@ -34,6 +34,7 @@ import mx.core.UIComponent;
 import mx.events.FlexEvent;
 
 import org.apache.royale.binding.ItemRendererDataBinding;
+import org.apache.royale.binding.DataBindingBase;
 import org.apache.royale.core.ITextModel;
 import org.apache.royale.events.Event;
 import org.apache.royale.events.IEventDispatcher;
@@ -435,6 +436,25 @@ public class Button extends UIComponent implements IDataRenderer, IListItemRende
 	}
 	
 	private var bindingAdded:Boolean;
+
+	/**
+	 * By default, ItemRendererDataBinding is added on-demand if an instance is used as a Drop-In Renderer
+	 * But Button subclasses need to be able to add whatever binding support makes sense, and avoid the possibility
+	 * of conflicting databinding support. Using this method in subclasses is one way to achieve that.
+
+	 * @param bindingImplClass a class that is a subclass of DataBindingBase
+	 * @param init true if the bindings should be initialized immediately
+	 */
+	protected function addBindingSupport(bindingImplClass:Class, init:Boolean):void{
+		if (!bindingAdded) {
+			if (!getBeadByType(DataBindingBase)) {
+				var bindingImpl:DataBindingBase = new bindingImplClass()
+				addBead(bindingImpl);
+				if (init) bindingImpl.initializeNow(); //no need to use an event in this case
+			}
+			bindingAdded = true;
+		}
+	}
 	
 	
 	/**
@@ -447,10 +467,8 @@ public class Button extends UIComponent implements IDataRenderer, IListItemRende
 
 		if (!bindingAdded)
 		{
-			addBead(new ItemRendererDataBinding());
-			bindingAdded = true;
+			addBindingSupport(ItemRendererDataBinding, true);
 		}
-		dispatchEvent(new Event("initBindings"));
 		
         _data = value;
 


[royale-asjs] 02/05: Fix for SimpleBinding not working sometimes when starting with 'this' + small tidyup in SimpleBinding.

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 20dd957edf8dedeb11e6422b576f5f17b910c825
Author: greg-dove <gr...@gmail.com>
AuthorDate: Thu May 28 23:00:53 2020 +1200

    Fix for SimpleBinding not working sometimes when starting with 'this' + small tidyup in SimpleBinding.
---
 .../main/royale/org/apache/royale/binding/DataBindingBase.as   |  3 ++-
 .../src/main/royale/org/apache/royale/binding/SimpleBinding.as | 10 ++++------
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/frameworks/projects/Binding/src/main/royale/org/apache/royale/binding/DataBindingBase.as b/frameworks/projects/Binding/src/main/royale/org/apache/royale/binding/DataBindingBase.as
index dd45b24..73e3f30 100644
--- a/frameworks/projects/Binding/src/main/royale/org/apache/royale/binding/DataBindingBase.as
+++ b/frameworks/projects/Binding/src/main/royale/org/apache/royale/binding/DataBindingBase.as
@@ -144,7 +144,8 @@ package org.apache.royale.binding
         {
             if (!destinationObject)
             {
-                destinationObject = _strand[bindingObject.destination[0]];
+                if (bindingObject.destination[0] == 'this') destinationObject = _strand
+                else destinationObject = _strand[bindingObject.destination[0]];
             }
 
             var destination:IStrand = destinationObject as IStrand;
diff --git a/frameworks/projects/Binding/src/main/royale/org/apache/royale/binding/SimpleBinding.as b/frameworks/projects/Binding/src/main/royale/org/apache/royale/binding/SimpleBinding.as
index 8d6934d..19884f9 100644
--- a/frameworks/projects/Binding/src/main/royale/org/apache/royale/binding/SimpleBinding.as
+++ b/frameworks/projects/Binding/src/main/royale/org/apache/royale/binding/SimpleBinding.as
@@ -269,13 +269,11 @@ public class SimpleBinding implements IBead, IDocument, IBinding
 			dispatcher.removeEventListener(eventName, changeHandler);
 
 		source = dispatcher = document[sourceID] as IEventDispatcher;
-		if (source)
-		{
+
+		if (dispatcher)
 			dispatcher.addEventListener(eventName, changeHandler);
-			destination[destinationPropertyName] = source[sourcePropertyName];
-		} else {
-			destination[destinationPropertyName] = null;
-		}
+
+		destination[destinationPropertyName] = source ? source[sourcePropertyName] : null;
 	}
 }
 }


[royale-asjs] 05/05: Add DynamicEvent to MXRoyale small tidy-up (de-dupe) in MXRoyaleClasses

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 89ae55083fe1a1bd0119f8f747467fb778ca3699
Author: greg-dove <gr...@gmail.com>
AuthorDate: Thu May 28 23:09:23 2020 +1200

    Add DynamicEvent to MXRoyale
    small tidy-up (de-dupe) in MXRoyaleClasses
---
 .../MXRoyale/src/main/royale/MXRoyaleClasses.as    |   7 +-
 .../src/main/royale/mx/events/DynamicEvent.as      | 109 +++++++++++++++++++++
 2 files changed, 112 insertions(+), 4 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
index ae39815..8ee0f99 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
@@ -29,8 +29,6 @@ internal class MXRoyaleClasses
 {
 	import mx.core.mx_internal; mx_internal;
 	import mx.core.ScrollPolicy; ScrollPolicy;
-	import mx.containers.beads.ApplicationLayout; ApplicationLayout;
-	import mx.containers.beads.BoxLayout; BoxLayout;
 	import mx.controls.beads.ToolTipBead; ToolTipBead;
 	import mx.effects.IEffectInstance; IEffectInstance;
 	import mx.events.EffectEvent; EffectEvent;
@@ -96,7 +94,7 @@ internal class MXRoyaleClasses
 	import mx.effects.EffectInstance; EffectInstance;
 	import mx.effects.effectClasses.CompositeEffectInstance; CompositeEffectInstance;
 	import mx.charts.HitData; HitData;
-	import mx.events.MenuEvent; MenuEvent;
+
 	import mx.events.FlexEvent; FlexEvent;
 	import mx.managers.PopUpManager; PopUpManager; 
 	import mx.core.IVisualElementContainer; IVisualElementContainer;
@@ -191,7 +189,7 @@ internal class MXRoyaleClasses
     import mx.controls.beads.layouts.AdvancedDataGridLayout; AdvancedDataGridLayout;
     import mx.controls.beads.layouts.DataGridLayout; DataGridLayout;
     import mx.controls.beads.layouts.AdvancedDataGridVirtualListVerticalLayout; AdvancedDataGridVirtualListVerticalLayout;
-	import  mx.controls.beads.layouts.DataGridHeaderLayout; DataGridHeaderLayout;
+	import mx.controls.beads.layouts.DataGridHeaderLayout; DataGridHeaderLayout;
 	import mx.controls.listClasses.VirtualListVerticalLayout; VirtualListVerticalLayout;
     import mx.controls.listClasses.ListSingleSelectionMouseController; ListSingleSelectionMouseController;
     import mx.controls.treeClasses.TreeSingleSelectionMouseController; TreeSingleSelectionMouseController;
@@ -242,6 +240,7 @@ internal class MXRoyaleClasses
 	import mx.controls.Menu; Menu;
 	import mx.events.NumericStepperEvent; NumericStepperEvent;
 	import mx.controls.beads.DataProviderChangeNotifier; DataProviderChangeNotifier;
+	import mx.events.DynamicEvent; DynamicEvent;
 	
 	import mx.controls.PopUpButton; PopUpButton;
 	import mx.controls.PopUpMenuButton; PopUpMenuButton;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/events/DynamicEvent.as b/frameworks/projects/MXRoyale/src/main/royale/mx/events/DynamicEvent.as
new file mode 100644
index 0000000..2e69b5c
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/events/DynamicEvent.as
@@ -0,0 +1,109 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+
+package mx.events
+{
+
+import org.apache.royale.events.Event;
+import org.apache.royale.reflection.getDynamicFields;
+/**
+ *  This subclass of Event is dynamic, meaning that you can set
+ *  arbitrary event properties on its instances at runtime.
+ *
+ *  <p>By contrast, Event and its other subclasses are non-dynamic,
+ *  meaning that you can only set properties that are declared
+ *  in those classes.
+ *  When prototyping an application, using a DynamicEvent can be
+ *  easier because you don't have to write an Event subclass
+ *  to declare the properties in advance.
+ *  However, you should eventually eliminate your DynamicEvents
+ *  and write Event subclasses because these are faster and safer.
+ *  A DynamicEvent is so flexible that the compiler can't help you
+ *  catch your error when you set the wrong property or assign it
+ *  a value of an incorrect type.</p>
+ *
+ *  <p>Example:</p>
+ *
+ *  <pre>
+ *  var event:DynamicEvent = new DynamicEvent("credentialsChanged");
+ *  event.name = name;
+ *  event.passsword = password; // misspelling won't be caught!
+ *  dispatchEvent(event);
+ *  </pre>
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+public dynamic class DynamicEvent extends Event
+{
+    //include "../core/Version.as";
+
+	//--------------------------------------------------------------------------
+	//
+	//  Constructor
+	//
+	//--------------------------------------------------------------------------
+
+	/**
+	 *  Constructor.
+	 *
+	 *  @param type The event type; indicates the action that caused the event.
+	 *
+	 *  @param bubbles Specifies whether the event can bubble up
+	 *  the display list hierarchy.
+	 *
+	 *  @param cancelable Specifies whether the behavior
+	 *  associated with the event can be prevented.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 9
+	 *  @playerversion AIR 1.1
+	 *  @productversion Flex 3
+	 */
+	public function DynamicEvent(type:String, bubbles:Boolean = false,
+                                 cancelable:Boolean = false)
+	{
+		super(type, bubbles, cancelable);
+	}
+
+	//--------------------------------------------------------------------------
+	//
+	//  Overridden methods: Event
+	//
+	//--------------------------------------------------------------------------
+
+	/**
+	 *  @private
+	 */
+	override public function cloneEvent():Event
+	{
+		var event:DynamicEvent = new DynamicEvent(type, bubbles, cancelable);
+		//@todo test/verify in general case:
+		for each(var p:String in getDynamicFields(this))
+		{
+			event[p] = this[p];
+		}
+
+		return event;
+	}
+}
+
+}


[royale-asjs] 01/05: AMF improvements: Coverage for ignoring custom namespaces and also cases where Transient fields are still deserialized. They are only skipped during local serialization.

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit db0995ea20121a7e0490627592367473248266f9
Author: greg-dove <gr...@gmail.com>
AuthorDate: Thu May 28 16:36:51 2020 +1200

    AMF improvements: Coverage for ignoring custom namespaces and also cases where Transient fields are still deserialized. They are only skipped during local serialization.
---
 .../royale/net/remoting/amf/AMFBinaryData.as       |  41 +++++---
 .../network/AMFBinaryDataTesterTest.as             | 109 ++++++++++++++++++++-
 .../flexUnitTests/network/support/TestClass6.as    |  72 ++++++++++++++
 .../flexUnitTests/network/support/TestClass7a.as   |  51 ++++++++++
 .../flexUnitTests/network/support/TestClass7b.as   |  49 +++++++++
 .../flexUnitTests/network/support/testnamespace.as |  26 +++++
 6 files changed, 334 insertions(+), 14 deletions(-)

diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFBinaryData.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFBinaryData.as
index 3eb6955..89350f4 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFBinaryData.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFBinaryData.as
@@ -499,6 +499,7 @@ class SerializationContext extends BinaryData  implements IDataInput, IDataOutpu
 		var l:uint;
 		var metas:Array;
 		var exclude:Boolean;
+		var transient:Boolean;
 		var fieldName:String;
 		const into:Array = localTraits.props;
 		
@@ -509,9 +510,11 @@ class SerializationContext extends BinaryData  implements IDataInput, IDataOutpu
 			if (fieldName.indexOf('::') != -1) continue;
 			var field:Object = fieldSet[fieldName];
 			exclude = false;
+			transient = false;
+			var alreadyPresent:Boolean = into.indexOf(fieldName) != -1 ;
 			if (asAccessors) {
 				exclude = field.access != 'readwrite';
-				if (exclude && into.indexOf(fieldName) == -1) { //<-- if at some level we already have read-write access, then that wins
+				if (exclude && !alreadyPresent) { //<-- if at some level we already have read-write access, then that wins
 					//check: does it combine to provide 'readwrite' permissions via accessChecks through inheritance chain
 					if (accessChecks[fieldName] && accessChecks[fieldName] != field.access) {
 						//readonly or writeonly overridde at one level and different at another == readwrite
@@ -524,21 +527,18 @@ class SerializationContext extends BinaryData  implements IDataInput, IDataOutpu
 					}
 				}
 			}
-			if (!exclude && excludeTransient && field.metadata != null) {
-				//exclude anything marked as Transient
+			//if a subclass override does not redeclare the field as transient, then it is already considered explicitly 'non-transient'
+			if (!exclude && !alreadyPresent && excludeTransient && field.metadata != null) {
+				//we need to mark Transient fields as special case
 				metas = field.metadata();
 				l = metas.length;
 				while (l--) {
 					if (metas[l].name == 'Transient') {
-						exclude = true;
+						transient = true;
+						Traits.markTransient(fieldName, localTraits);
+						break;
 					}
 				}
-				if (exclude && into.indexOf(fieldName) != -1) {
-					//?possible case where it is marked transient on an ancestor but not in a subclass override
-					//it will not have been excluded when processing the subclass, which occurs first, so remove it now
-					//@todo untested : check this scenario, assume it should be removed
-					into.splice(into.indexOf(fieldName), 1);
-				}
 			}
 			if (!exclude) {
 				//set up null/undefined value lookups for undefined field values (when encoding)
@@ -554,7 +554,10 @@ class SerializationContext extends BinaryData  implements IDataInput, IDataOutpu
 				} else {
 					nullValues[fieldName] = null;
 				}
-				into.push(fieldName);
+				if (alreadyPresent) {
+					into.splice(into.indexOf(fieldName), 1);
+				}
+				if (!transient) into.push(fieldName);
 				if (asAccessors) {
 					localTraits.getterSetters[fieldName] = Traits.createInstanceAccessorGetterSetter(fieldName);
 				} else {
@@ -610,6 +613,9 @@ class SerializationContext extends BinaryData  implements IDataInput, IDataOutpu
 					classInfo = c.constructor.superClass_.ROYALE_CLASS_INFO;
 					c = c.constructor.superClass_;
 				}
+				//sometimes flash native seriazliation double-counts props and outputs some props data twice.
+				//this can happen with overrides (it was noticed with Transient overrides)
+				//it may mean that js amf output can sometimes be more compact, but should always deserialize to the same result.
 				localTraits.count = localTraits.props.length;
 				//not required, but useful when testing:
 				localTraits.props.sort();
@@ -632,7 +638,6 @@ class SerializationContext extends BinaryData  implements IDataInput, IDataOutpu
 			}
 			//not required, but useful when testing:
 			localTraits.props.sort();
-			
 		}
 		return localTraits;
 	}
@@ -1102,7 +1107,7 @@ class SerializationContext extends BinaryData  implements IDataInput, IDataOutpu
 				for (var i:uint = 0; i < l; i++) {
 					var fieldValue:* = readObject();
 					var prop:String = decodedTraits.props[i];
-					hasProp = localTraits &&  (localTraits.hasProp(prop) || localTraits.isDynamic);
+					hasProp = localTraits &&  (localTraits.hasProp(prop) || localTraits.isDynamic || localTraits.isTransient(prop));
 					if (hasProp) {
 						localTraits.getterSetters[prop].setValue(obj, fieldValue);
 					} else {
@@ -1319,6 +1324,11 @@ class Traits {
 			}
 		};
 	}
+
+	public static function markTransient(fieldName:String, traits:Traits):void{
+		if (!traits.transients) traits.transients={};
+		traits.transients[fieldName] = true;
+	}
 	
 	private static var _emtpy_object:Traits;
 	
@@ -1362,10 +1372,15 @@ class Traits {
 	public var nullValues:Object = {};
 	
 	public var getterSetters:Object = {};
+	public var transients:Object ;
 	
 	public function hasProp(prop:String):Boolean {
 		return props.indexOf(prop) != -1;
 	}
+
+	public function isTransient(prop:String):Boolean {
+		return transients && prop in transients;
+	}
 	
 	public function toString():String {
 		if (goog.DEBUG) {
diff --git a/frameworks/projects/Network/src/test/royale/flexUnitTests/network/AMFBinaryDataTesterTest.as b/frameworks/projects/Network/src/test/royale/flexUnitTests/network/AMFBinaryDataTesterTest.as
index 144d034..1cca14c 100644
--- a/frameworks/projects/Network/src/test/royale/flexUnitTests/network/AMFBinaryDataTesterTest.as
+++ b/frameworks/projects/Network/src/test/royale/flexUnitTests/network/AMFBinaryDataTesterTest.as
@@ -27,7 +27,9 @@ package flexUnitTests.network
     import flexUnitTests.network.support.TestClass3;
     import flexUnitTests.network.support.TestClass4;
     import flexUnitTests.network.support.DynamicTestClass;
-    
+    import flexUnitTests.network.support.TestClass6;
+    import flexUnitTests.network.support.TestClass7a;
+    import flexUnitTests.network.support.TestClass7b;
     import org.apache.royale.test.asserts.*;
     
     import org.apache.royale.net.remoting.amf.AMFBinaryData;
@@ -532,6 +534,111 @@ package flexUnitTests.network
             //javascript toXMLString pretty printing does not match exactly flash...
             assertTrue( xml.toXMLString() === xml2.toXMLString(), "XML round-tripping failed");
         }
+
+
+        [Test]
+        public function testWithCustomNS():void
+        {
+            var ba:AMFBinaryData = new AMFBinaryData();
+            var test:TestClass6 = new TestClass6();
+            ba.writeObject(test);
+            ba.position = 0;
+            assertEquals(ba.length, 50, 'unexpected serialized content with custom namespaces');
+            //cover variation in order
+            const validOptions:Array = [
+                '0a23010b6d79566172156d794163636573736f7206177075626c69634d79566172061f7075626c6963206163636573736f72',
+                '0a2301156d794163636573736f720b6d79566172061f7075626c6963206163636573736f7206177075626c69634d79566172'
+            ];
+
+            assertTrue(validOptions.indexOf(getBytesOut(ba)) != -1, 'unexpected byte content with custom namespace content');
+
+           /* var restored:Object = ba.readObject();
+
+            var json:String = JSON.stringify(restored)*/
+            //order may be different... need json object check here for: {"myAccessor":"public accessor","myVar":"publicMyVar"}
+        }
+
+        [Test]
+        public function testTransientAndBindable():void{
+            var ba:AMFBinaryData = new AMFBinaryData();
+            registerClassAlias('TestClass7a', TestClass7a);
+            registerClassAlias('TestClass7b', TestClass7b);
+            var test1:TestClass7a = new TestClass7a();
+            test1.something = 'whatever';
+            ba.writeObject(test1);
+
+            ba.position = 0;
+
+            var retrieved:Object = ba.readObject();
+
+            assertTrue(retrieved is TestClass7a, 'unexpected deserialization');
+
+            var test2:TestClass7b = new TestClass7b();
+            test1.something = 'whatever';
+            ba.length = 0;
+            ba.writeObject(test2);
+
+            ba.position = 0;
+            retrieved = ba.readObject();
+
+            assertTrue(retrieved is TestClass7b, 'unexpected deserialization');
+
+        }
+
+
+        [Test]
+        public function testTransientDeserialized():void{
+            //if a transient field is already serialized, then we do deserialize it
+            //this means it can be sent from the server (for example) but is not sent to the server
+
+            //to test this we will use TestClass7b (where 'something' is not Transient) which will serialize the 'something' field with an alias that matches
+            //a subsequent deserialization to a TestClass7a instance (where 'something' is Transient);
+            //the expected result will be that the Transient field is still deserialized
+
+            var ba:AMFBinaryData = new AMFBinaryData();
+            registerClassAlias('TestClass7a', TestClass7b);
+            var test1:TestClass7b = new TestClass7b();
+            test1.something = 'something interesting';
+            ba.length = 0;
+            //non-transient inbound:
+            ba.writeObject(test1);
+
+            //The bytes for the above can differ between swf and js. 54 vs. 57 bytes length
+            //It is possible to correct that. But it is the swf output that is serializing the 'something' field twice
+            // (second time is string ref for both field and value, so quite compact, but still unnecessary)
+            //so not trying to match that exactly, because it is redundant data.
+
+            ba.position = 0;
+
+            //read it back as TestClass7a
+            registerClassAlias('TestClass7a', TestClass7a);
+
+            var retrieved:Object = ba.readObject();
+
+
+            assertTrue(retrieved is TestClass7a, 'unexpected deserialization');
+            assertEquals(retrieved.something , 'something interesting', 'unexpected deserialization');
+            assertEquals(retrieved.test , 'test', 'unexpected deserialization');
+
+            //this time round it won't be read out because it is Transient for serialization/inbound:
+            ba.position = 0;
+            ba.length=0;
+            ba.writeObject(retrieved);
+            ba.position = 0;
+            retrieved = ba.readObject();
+            assertTrue(retrieved is TestClass7a, 'unexpected deserialization');
+            assertEquals(retrieved.something , null, 'unexpected deserialization');
+            assertEquals(retrieved.test , 'test', 'unexpected deserialization');
+        }
+
+
+        private function getBytesOut(bytes:AMFBinaryData):String{
+            var out:Array = [];
+            for each(var byte:uint in bytes) {
+                out.push(('0'+byte.toString(16)).substr(-2));
+            }
+            return out.join('');
+        }
         
     }
 }
diff --git a/frameworks/projects/Network/src/test/royale/flexUnitTests/network/support/TestClass6.as b/frameworks/projects/Network/src/test/royale/flexUnitTests/network/support/TestClass6.as
new file mode 100644
index 0000000..42a1e3c
--- /dev/null
+++ b/frameworks/projects/Network/src/test/royale/flexUnitTests/network/support/TestClass6.as
@@ -0,0 +1,72 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests.network.support
+{
+   
+    import flexUnitTests.network.support.testnamespace;
+    
+    /**
+     * @royalesuppresspublicvarwarning
+     */
+    public class TestClass6
+    {
+        //Note: do not change this test class unless you change the related tests to
+        //support any changes that might appear when testing reflection into it
+        
+        public function TestClass6()
+        {
+        
+        }
+        
+        
+        public var myVar:String = 'publicMyVar';
+        
+        testnamespace var myVar:String = 'testnamespaceMyVar';
+        
+        public function myMethod():String{
+            return 'public myMethod';
+        }
+    
+        testnamespace function myMethod():String{
+            return 'testnamespace myMethod';
+        }
+    
+        private var _v:String = 'public accessor';
+        public function get myAccessor():String{
+            return _v;
+        }
+    
+        public function set myAccessor(value:String):void{
+            _v = value;
+        }
+        
+        private var _v2:String = 'testnamespace accessor';
+        testnamespace function get myAccessor():String{
+            return _v2;
+        }
+    
+        testnamespace function set myAccessor(value:String):void{
+            _v2 = value;
+        }
+        
+        
+    }
+    
+    
+}
diff --git a/frameworks/projects/Network/src/test/royale/flexUnitTests/network/support/TestClass7a.as b/frameworks/projects/Network/src/test/royale/flexUnitTests/network/support/TestClass7a.as
new file mode 100644
index 0000000..db6ec8b
--- /dev/null
+++ b/frameworks/projects/Network/src/test/royale/flexUnitTests/network/support/TestClass7a.as
@@ -0,0 +1,51 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests.network.support
+{
+   
+    import flexUnitTests.network.support.testnamespace;
+    
+    /**
+     * @royalesuppresspublicvarwarning
+     */
+    public class TestClass7a
+    {
+        //Note: do not change this test class unless you change the related tests to
+        //support any changes that might appear when testing reflection into it
+        
+        public function TestClass7a()
+        {
+        
+        }
+
+        public var test:String = 'test';
+        
+        protected var _something:String;
+        [Transient]
+        public function get something():String{
+            return _something;
+        }
+        public function set something(value:String):void{
+            _something = value;
+        }
+        
+    }
+    
+    
+}
diff --git a/frameworks/projects/Network/src/test/royale/flexUnitTests/network/support/TestClass7b.as b/frameworks/projects/Network/src/test/royale/flexUnitTests/network/support/TestClass7b.as
new file mode 100644
index 0000000..39b5f7d
--- /dev/null
+++ b/frameworks/projects/Network/src/test/royale/flexUnitTests/network/support/TestClass7b.as
@@ -0,0 +1,49 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests.network.support
+{
+   
+    import flexUnitTests.network.support.testnamespace;
+    
+    /**
+     * @royalesuppresspublicvarwarning
+     */
+    public class TestClass7b extends TestClass7a
+    {
+        //Note: do not change this test class unless you change the related tests to
+        //support any changes that might appear when testing reflection into it
+        
+        public function TestClass7b()
+        {
+        
+        }
+        
+
+        [Bindable]
+        override public function get something():String{
+            return _something;
+        }
+        override public function set something(value:String):void{
+            _something = value;
+        }
+        
+    }
+    
+    
+}
diff --git a/frameworks/projects/Network/src/test/royale/flexUnitTests/network/support/testnamespace.as b/frameworks/projects/Network/src/test/royale/flexUnitTests/network/support/testnamespace.as
new file mode 100644
index 0000000..3a552b8
--- /dev/null
+++ b/frameworks/projects/Network/src/test/royale/flexUnitTests/network/support/testnamespace.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You 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.
+//
+////////////////////////////////////////////////////////////////////////////////
+package flexUnitTests.network.support
+{
+    
+    
+
+    public namespace testnamespace = 'http://testnamespace.com/network';
+   
+}


[royale-asjs] 03/05: Quick fix for many Containers (Container-derived mxml components) missing binding support in ported Flex code.

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

gregdove pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 26d4b9cf7c1968160278754a01bd612946ddf41d
Author: greg-dove <gr...@gmail.com>
AuthorDate: Thu May 28 23:03:43 2020 +1200

    Quick fix for many Containers (Container-derived mxml components) missing binding support in ported Flex code.
---
 frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as
index b8b875f..bc50368 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/Container.as
@@ -825,7 +825,7 @@ public class Container extends UIComponent
     {
         super.createChildren();
         
-        if (getBeadByType(DataBindingBase) == null && mxmlDocument == this)
+        if (getBeadByType(DataBindingBase) == null && '_bindings' in this /*mxmlDocument == this*/)
             addBead(new ContainerDataBinding());
 
         dispatchEvent(new Event("initBindings"));