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

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

commit 7af3473cbc18c4d3b5375579ed5a0603e3e16e16
Author: Josh Tynjala <[email protected]>
AuthorDate: Tue Mar 5 14:21:41 2024 -0800

    MXMLRoyaleEmitter: fix issue where non-string values in an array could be 
quoted
    
    The quotes would persist after a previous string value, instead of being 
reset
---
 .../codegen/mxml/royale/MXMLRoyaleEmitter.java     |   5 +-
 .../mxml/royale/TestRoyaleMXMLApplication.java     |  16 +++
 .../resources/royale/files/MixedArrayChildren.mxml |  33 +++++
 .../royale/files/MixedArrayChildren_result.js      | 139 +++++++++++++++++++++
 4 files changed, 192 insertions(+), 1 deletion(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
index 2456933d7..46c1b5e9b 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
@@ -3269,9 +3269,12 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
                primitiveDeclarationNodes.add(node);
                return;
        }
-        getCurrentDescriptor("ps").valueNeedsQuotes = true;
+        MXMLDescriptorSpecifier currentDescriptor = getCurrentDescriptor("ps");
+        currentDescriptor.valueNeedsQuotes = true;
 
         emitAttributeValue(node);
+
+        currentDescriptor.valueNeedsQuotes = false;
     }
     
     @Override
diff --git 
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLApplication.java
 
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLApplication.java
index 8a3f1eec9..91e2fc6a0 100644
--- 
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLApplication.java
+++ 
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLApplication.java
@@ -122,6 +122,22 @@ public class TestRoyaleMXMLApplication extends 
RoyaleTestBase
         assertOutWithMetadata(getCodeFromFile(fileName + "_result", true, 
"royale/files"));
     }
 
+    @Test
+    public void testMixedArrayChildren()
+    {
+        String fileName = "MixedArrayChildren";
+
+        IMXMLFileNode node = compileMXML(fileName, true,
+                new File(testAdapter.getUnitTestBaseDir(), 
"royale/files").getPath(), false);
+               assertNotNull(node);
+
+        mxmlBlockWalker.visitFile(node);
+        
+        // writeResultToFile(writer.toString(), fileName);
+
+        assertOutWithMetadata(getCodeFromFile(fileName + "_result", true, 
"royale/files"));
+    }
+
     @Test
     public void testBackslashStringAttribute()
     {
diff --git 
a/compiler-jx/src/test/resources/royale/files/MixedArrayChildren.mxml 
b/compiler-jx/src/test/resources/royale/files/MixedArrayChildren.mxml
new file mode 100644
index 000000000..1f3090020
--- /dev/null
+++ b/compiler-jx/src/test/resources/royale/files/MixedArrayChildren.mxml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+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.
+
+-->
+<basic:Application xmlns:fx="http://ns.adobe.com/mxml/2009";
+                                  
xmlns:basic="library://ns.apache.org/royale/basic">
+       <fx:Declarations>
+               <fx:Object id="obj">
+                       <fx:propertyName>
+                               <fx:Array>
+                                       <fx:Number>123.4</fx:Number>
+                                       <fx:String>hello</fx:String>
+                                       <fx:Boolean>true</fx:Boolean>
+                               </fx:Array>
+                       </fx:propertyName>
+               </fx:Object>
+       </fx:Declarations>
+</basic:Application>
diff --git 
a/compiler-jx/src/test/resources/royale/files/MixedArrayChildren_result.js 
b/compiler-jx/src/test/resources/royale/files/MixedArrayChildren_result.js
new file mode 100644
index 000000000..a02ae3308
--- /dev/null
+++ b/compiler-jx/src/test/resources/royale/files/MixedArrayChildren_result.js
@@ -0,0 +1,139 @@
+/**
+ * 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.
+ */
+/**
+ * Generated by Apache Royale Compiler from MixedArrayChildren.mxml
+ * MixedArrayChildren
+ *
+ * @fileoverview
+ *
+ * @suppress {checkTypes|accessControls}
+ */
+
+goog.provide('MixedArrayChildren');
+
+goog.require('org.apache.royale.core.Application');
+goog.require('Object');
+
+
+
+/**
+ * @constructor
+ * @extends {org.apache.royale.core.Application}
+ */
+MixedArrayChildren = function() {
+  MixedArrayChildren.base(this, 'constructor');
+  
+  /**
+   * @private
+   * @type {Object}
+   */
+  this.obj_;
+  
+  /**
+   * @private
+   * @type {Array}
+   */
+  this.mxmldd;
+  
+  /**
+   * @private
+   * @type {Array}
+   */
+  this.mxmldp;
+};
+goog.inherits(MixedArrayChildren, org.apache.royale.core.Application);
+
+
+
+
+Object.defineProperties(MixedArrayChildren.prototype, /** @lends 
{MixedArrayChildren.prototype} */ {
+  obj: {
+    /** @this {MixedArrayChildren} */
+    get: function() {
+      return this.obj_;
+    },
+    /** @this {MixedArrayChildren} */
+    set: function(value) {
+      if (value != this.obj_) {
+        this.obj_ = value;
+        
this.dispatchEvent(org.apache.royale.events.ValueChangeEvent.createUpdateEvent(this,
 'obj', null, value));
+      }
+    }
+  },
+  'MXMLDescriptor': {
+    /** @this {MixedArrayChildren} */
+    get: function() {
+      if (this.mxmldd == undefined)
+      {
+        /** @type {Array} */
+        var arr = 
MixedArrayChildren.superClass_.get__MXMLDescriptor.apply(this);
+        /** @type {Array} */
+        var mxmldd = [
+          Object,
+          2,
+          'id',
+          true,
+          'obj',
+          'propertyName',
+          true,
+          [123.4,'hello',true],
+          0,
+          0,
+          null
+        ];
+        if (arr)
+          this.mxmldd = arr.concat(mxmldd);
+        else
+          this.mxmldd = mxmldd;
+      }
+      return this.mxmldd;
+    }
+  }
+});
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+MixedArrayChildren.prototype.ROYALE_CLASS_INFO = { names: [{ name: 
'MixedArrayChildren', qName: 'MixedArrayChildren', kind: 'class'  }] };
+
+
+
+/**
+ * Reflection
+ *
+ * @return {Object.<string, Function>}
+ */
+MixedArrayChildren.prototype.ROYALE_REFLECTION_INFO = function () {
+  return {
+    accessors: function () {
+      return {
+        'obj': { type: 'Object', access: 'readwrite', declaredBy: 
'MixedArrayChildren'}
+      };
+    },
+    methods: function () {
+      return {
+        'MixedArrayChildren': { type: '', declaredBy: 'MixedArrayChildren'}
+      };
+    }
+  };
+};
+/**
+ * @const
+ * @type {number}
+ */
+MixedArrayChildren.prototype.ROYALE_COMPILE_FLAGS = 9;
+
+
+

Reply via email to