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 2021/11/01 03:00:47 UTC

[royale-asjs] branch develop updated (fbf8fcb -> f2d58a5)

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 fbf8fcb  Added non-modal Alert launch support to mx emulation.
     new bd7b6cf  Added missing clear method to BinaryData. Using 'clear' method to reset the internal state does not affect any previously retrieved internal 'data' object which may be referenced externally.
     new f2d58a5  Support request for ability to switch off AMF verbose logging in js (which is present in flash debug output). The easiest way to do this is with a different ClassAliasBead : <js:AMFClassAliasBead verboseLogging="false" />

The 2 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:
 .../royale/org/apache/royale/utils/BinaryData.as   | 27 ++++++++++
 .../royale/flexUnitTests/BinaryDataTesterTest.as   | 16 +++++-
 .../Network/src/main/resources/basic-manifest.xml  |  1 +
 .../apache/royale/net/beads/AMFClassAliasBead.as}  | 62 ++++++++++------------
 .../royale/net/remoting/amf/AMF0AMF3Context.as     |  5 +-
 .../royale/net/remoting/amf/AMFBinaryData.as       |  9 +++-
 .../apache/royale/net/remoting/amf/AMFContext.as   |  2 +-
 7 files changed, 83 insertions(+), 39 deletions(-)
 copy frameworks/projects/{Reflection/src/main/royale/org/apache/royale/reflection/beads/ExtraReflectionDataBead.as => Network/src/main/royale/org/apache/royale/net/beads/AMFClassAliasBead.as} (50%)

[royale-asjs] 01/02: Added missing clear method to BinaryData. Using 'clear' method to reset the internal state does not affect any previously retrieved internal 'data' object which may be referenced externally.

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 bd7b6cfa3f773d13ab49c5d9a7403038e3470792
Author: greg-dove <gr...@gmail.com>
AuthorDate: Mon Nov 1 15:56:45 2021 +1300

    Added missing clear method to BinaryData.
    Using 'clear' method to reset the internal state does not affect any previously retrieved internal 'data' object which may be referenced externally.
---
 .../royale/org/apache/royale/utils/BinaryData.as   | 27 ++++++++++++++++++++++
 .../royale/flexUnitTests/BinaryDataTesterTest.as   | 16 ++++++++++++-
 2 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/BinaryData.as b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/BinaryData.as
index 483bfb1..c7d1f09 100644
--- a/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/BinaryData.as
+++ b/frameworks/projects/Core/src/main/royale/org/apache/royale/utils/BinaryData.as
@@ -211,6 +211,33 @@ public class BinaryData implements IBinaryDataInput, IBinaryDataOutput
     }
 
     /**
+     *  The same as setting the length of the BinaryData to zero,
+     *  but will be more optimized on specific targets.
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.9.9
+     */
+    public function clear():void
+    {
+        COMPILE::JS {
+            ba = new ArrayBuffer(0);
+            _position = 0;
+            _len = 0;
+            _typedArray = null;
+            _dataView = null;
+        }
+        COMPILE::SWF {
+            //not calling ba.clear() here, to keep consistent with js implementation of 'clear' above,
+            //because there is the possibility of external usage of 'ba' via the data getter.
+            //having 'clear' on this instance affecting external references would be inconsistent between targets if we propagated the
+            //clear call to the original ByteArray instance
+            ba = new ByteArray();
+        }
+    }
+
+    /**
 	 *  create a string representation of the binary data
 	 */
 	public function toString():String
diff --git a/frameworks/projects/Core/src/test/royale/flexUnitTests/BinaryDataTesterTest.as b/frameworks/projects/Core/src/test/royale/flexUnitTests/BinaryDataTesterTest.as
index 32c2e29..caadcf7 100644
--- a/frameworks/projects/Core/src/test/royale/flexUnitTests/BinaryDataTesterTest.as
+++ b/frameworks/projects/Core/src/test/royale/flexUnitTests/BinaryDataTesterTest.as
@@ -476,7 +476,6 @@ package flexUnitTests {
             //check bytes to account for precision loss between double and float comparisons
             assertTrue(bytesMatchExpectedData(bbe,[66,173,20,123]), "Error testing post writeFloat/readFloat round-tripping");
 
-
         }
     
     
@@ -617,5 +616,20 @@ package flexUnitTests {
             assertEquals( 3.1415927410, ba.readDouble(), "BinaryData readDouble: should be 3.1415927410");
         }
 
+        [Test]
+        public function testClear():void
+        {
+            var ba:BinaryData = new BinaryData();
+            for (var i:int = 0; i < 50; i++) ba.writeByte(i);
+            ba.position = 25;
+            //test that the internal reference is severed to any external extraction of data after clear, this is different to setting 'length' to zero.
+            var olddata:Object = ba.data;
+            ba.clear();
+
+            assertEquals(0, ba.length, "BinaryData length after clear: should be 0");
+            assertEquals(0, ba.position, "BinaryData position after clear: should be 0");
+            assertNotEquals(ba.data, olddata, "BinaryData data accessor after clear: should be new internal instance");
+        }
+
 }
 }

[royale-asjs] 02/02: Support request for ability to switch off AMF verbose logging in js (which is present in flash debug output). The easiest way to do this is with a different ClassAliasBead :

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 f2d58a5f4475fe0e934979cea04d6b9126ad91b1
Author: greg-dove <gr...@gmail.com>
AuthorDate: Mon Nov 1 16:00:24 2021 +1300

    Support request for ability to switch off AMF verbose logging in js (which is present in flash debug output).
    The easiest way to do this is with a different ClassAliasBead : <js:AMFClassAliasBead verboseLogging="false" />
---
 .../Network/src/main/resources/basic-manifest.xml  |  1 +
 .../apache/royale/net/beads/AMFClassAliasBead.as   | 70 ++++++++++++++++++++++
 .../royale/net/remoting/amf/AMF0AMF3Context.as     |  5 +-
 .../royale/net/remoting/amf/AMFBinaryData.as       |  9 ++-
 .../apache/royale/net/remoting/amf/AMFContext.as   |  2 +-
 5 files changed, 82 insertions(+), 5 deletions(-)

diff --git a/frameworks/projects/Network/src/main/resources/basic-manifest.xml b/frameworks/projects/Network/src/main/resources/basic-manifest.xml
index 74197fd..5218ee1 100644
--- a/frameworks/projects/Network/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Network/src/main/resources/basic-manifest.xml
@@ -20,6 +20,7 @@
 
 <componentPackage>
     <component id="AMF0SupportBead" class="org.apache.royale.net.remoting.amf.AMF0SupportBead"/>
+    <component id="AMFClassAliasBead" class="org.apache.royale.net.beads.AMFClassAliasBead"/>
     <component id="SimpleRemoteObject" class="org.apache.royale.net.SimpleRemoteObject"/>
     <component id="RemoteObject" class="org.apache.royale.net.RemoteObject"/>
     <component id="CompressedRemoteObject" class="org.apache.royale.net.CompressedRemoteObject"/>
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/beads/AMFClassAliasBead.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/beads/AMFClassAliasBead.as
new file mode 100644
index 0000000..b9d8fbf
--- /dev/null
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/beads/AMFClassAliasBead.as
@@ -0,0 +1,70 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 org.apache.royale.net.beads
+{
+
+    COMPILE::JS
+    {
+        import org.apache.royale.net.remoting.amf.AMFBinaryData;
+    }
+
+    import org.apache.royale.reflection.beads.ClassAliasBead;
+    
+    /**
+     *  The AMFClassAliasBead class is an extension of the reflection
+     *  ClassAliasBead and is useful where aliasing is for AMF serialization/deserialization support.
+     *  It offers a simple option to reduce logging noise in JSRoyale debug builds by setting
+     *  verboseLogging to false (it is true by default for debug builds).
+     *  AMF Verbose logging is never present in JSRoyale release builds.
+     * 
+     *  @langversion 3.0
+     *  @playerversion Flash 10.2
+     *  @playerversion AIR 2.6
+     *  @productversion Royale 0.9.9
+     */
+	public class AMFClassAliasBead extends ClassAliasBead
+	{
+
+
+        /**
+         *  Whether or not AMF Verbose logging should be enabled in JSRoyale debug builds.
+         *  AMF Verbose logging is never present in JSRoyale release builds.
+         *
+         *  @default true
+         *
+         *  @langversion 3.0
+         *  @playerversion Flash 10.2
+         *  @playerversion AIR 2.6
+         *  @productversion Royale 0.9.9
+         */
+        public function set verboseLogging(value:Boolean):void{
+            COMPILE::JS{
+                AMFBinaryData.verboseLogging = value;
+            }
+        }
+        public function get verboseLogging():Boolean{
+            COMPILE::JS{
+                return AMFBinaryData.verboseLogging;
+            }
+            COMPILE::SWF{
+                return false;
+            }
+        }
+    }
+}
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMF0AMF3Context.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMF0AMF3Context.as
index 85989c0..3d8f425 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMF0AMF3Context.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMF0AMF3Context.as
@@ -448,9 +448,8 @@ package org.apache.royale.net.remoting.amf {
 					} else if (localTraits.isDynamic) {
 						obj[key] = fieldValue;
 					} else {
-						//@todo
-						trace('unknown field ', key)
-						if (goog.DEBUG) {
+						//@todo add debug-only logging for error checks (e.g. ReferenceError: Error #1074: Illegal write to read-only property)
+						if (goog.DEBUG && AMFBinaryData.verboseLogging) {
 							trace('ReferenceError: Error #1056: Cannot create property ' + key + ' on ' + localTraits.qName);
 						}
 					}
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 4413204..84388ab 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
@@ -46,6 +46,13 @@ package org.apache.royale.net.remoting.amf {
 	 */
 	public class AMFBinaryData extends BinaryData implements IDataInput, IDataOutput {
 
+		/**
+		 * For swf target this is not available, but for js (and possible other future targets)
+		 * setting it to false will avoid verbose logging in debug builds, that may slow down execution if logging is excessive.
+		 */
+		COMPILE::JS
+		public static var verboseLogging:Boolean = goog.DEBUG;
+
 		COMPILE::JS
 		private static var _propertyWriter:IDynamicPropertyWriter;
 		COMPILE::JS
@@ -184,7 +191,7 @@ package org.apache.royale.net.remoting.amf {
 			var value:* = _serializationContext.readObjectExternal();
 			var err:Error = _serializationContext.getError();
 			if (err) {
-				if (goog.DEBUG){
+				if (goog.DEBUG && AMFBinaryData.verboseLogging){
 					console.log('%c[AMFBinaryData.readObject] - Deserialization Error :'+ err.message,'color:red');
 				}
 				throw new Error(err.message);
diff --git a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFContext.as b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFContext.as
index f383a42..6ee0a22 100644
--- a/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFContext.as
+++ b/frameworks/projects/Network/src/main/royale/org/apache/royale/net/remoting/amf/AMFContext.as
@@ -1034,7 +1034,7 @@ internal class AMFContext extends BinaryData implements IDataInput, IDataOutput,
 							obj[prop] = fieldValue;
 						} else {
 							//@todo add debug-only logging for error checks (e.g. ReferenceError: Error #1074: Illegal write to read-only property)
-							if (goog.DEBUG) {
+							if (goog.DEBUG && AMFBinaryData.verboseLogging) {
 								trace('ReferenceError: Error #1056: Cannot create property ' + prop + ' on ' + localTraits.qName);
 							}
 						}