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

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


The following commit(s) were added to refs/heads/develop by this push:
     new ba2d331  fix some bugs around fx:Array, fx:Object, fx:Number, etc in 
fx:Declarations.  Should fix apache/royale-asjs#1007 and apache/royale-asjs#999
ba2d331 is described below

commit ba2d331b07b3ed8b6fdc60f529daf9dad5ec38a1
Author: Alex Harui <[email protected]>
AuthorDate: Mon Dec 21 23:21:48 2020 -0800

    fix some bugs around fx:Array, fx:Object, fx:Number, etc in 
fx:Declarations.  Should fix apache/royale-asjs#1007 and apache/royale-asjs#999
---
 .../codegen/mxml/royale/MXMLRoyaleEmitter.java     | 118 +++++
 .../mxml/royale/TestRoyaleMXMLApplication.java     | 560 +++++++++++++++++++++
 2 files changed, 678 insertions(+)

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 820d26a..f211c8f 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
@@ -3052,6 +3052,50 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
     }
 
     @Override
+    public void emitBoolean(IMXMLBooleanNode node)
+    {
+       if (node.getParent().getNodeID() == ASTNodeID.MXMLDeclarationsID)
+       {
+               primitiveDeclarationNodes.add(node);
+               return;
+       }
+       super.emitBoolean(node);
+    }
+    
+    @Override
+    public void emitNumber(IMXMLNumberNode node)
+    {
+       if (node.getParent().getNodeID() == ASTNodeID.MXMLDeclarationsID)
+       {
+               primitiveDeclarationNodes.add(node);
+               return;
+       }
+       super.emitNumber(node);
+    }
+    
+    @Override
+    public void emitInt(IMXMLIntNode node)
+    {
+       if (node.getParent().getNodeID() == ASTNodeID.MXMLDeclarationsID)
+       {
+               primitiveDeclarationNodes.add(node);
+               return;
+       }
+       super.emitInt(node);
+    }
+    
+    @Override
+    public void emitUint(IMXMLUintNode node)
+    {
+       if (node.getParent().getNodeID() == ASTNodeID.MXMLDeclarationsID)
+       {
+               primitiveDeclarationNodes.add(node);
+               return;
+       }
+       super.emitUint(node);
+    }
+    
+    @Override
     public void emitString(IMXMLStringNode node)
     {
        if (node.getParent().getNodeID() == ASTNodeID.MXMLDeclarationsID)
@@ -3566,6 +3610,26 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
                                        }
                            break;
                                }
+                       case MXMLBooleanID:
+                       case MXMLNumberID:
+                       case MXMLIntID:
+                       case MXMLUintID:
+                               {
+                               IMXMLExpressionNode scalarNode = 
(IMXMLExpressionNode)declNode;
+                               varname = scalarNode.getEffectiveID();
+                       writeNewline();
+                       write(ASEmitterTokens.THIS);
+                       write(ASEmitterTokens.MEMBER_ACCESS);
+                       write(varname);
+                       write(ASEmitterTokens.SPACE);
+                       writeToken(ASEmitterTokens.EQUAL);
+                       IMXMLLiteralNode valueNode = 
(IMXMLLiteralNode)(scalarNode.getExpressionNode());
+                       Object value = valueNode.getValue();
+                       write(value.toString());
+                       write(ASEmitterTokens.SEMICOLON);
+                       break;
+                               }
+
                }
        }
     }
@@ -3596,6 +3660,60 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
                else
                        return "''";
        }
+       else if (instanceNode instanceof IMXMLObjectNode)
+       {
+               IMXMLObjectNode objectNode = (IMXMLObjectNode)instanceNode;
+            StringBuilder sb = new StringBuilder();
+            sb.append("{");
+            int m = objectNode.getChildCount();
+               boolean firstOne = true;
+            for (int j = 0; j < m; j++)
+            {
+               if (firstOne)
+                       firstOne = false;
+               else
+                       sb.append(", ");
+                IMXMLPropertySpecifierNode propName = 
(IMXMLPropertySpecifierNode)objectNode.getChild(j);
+                sb.append(propName.getName() + ": ");
+                IMXMLInstanceNode valueNode = propName.getInstanceNode();
+                   sb.append(instanceToString(valueNode));
+            }
+            sb.append("}");
+            return sb.toString();
+       }
+       else if (instanceNode instanceof IMXMLArrayNode)
+       {
+               IMXMLArrayNode arrayNode = (IMXMLArrayNode)instanceNode;
+            StringBuilder sb = new StringBuilder();
+            sb.append("[");
+            int m = arrayNode.getChildCount();
+               boolean firstOne = true;
+            for (int j = 0; j < m; j++)
+            {
+                   IMXMLInstanceNode valueNode = 
(IMXMLInstanceNode)(arrayNode.getChild(j));
+               if (firstOne)
+                       firstOne = false;
+               else
+                       sb.append(", ");
+                   sb.append(instanceToString(valueNode));
+            }
+            sb.append("]");
+            return sb.toString();
+       }
+       else if ((instanceNode instanceof IMXMLIntNode) ||
+                       (instanceNode instanceof IMXMLUintNode) ||
+                       (instanceNode instanceof IMXMLNumberNode) ||
+                       (instanceNode instanceof IMXMLBooleanNode))
+       {
+               IMXMLExpressionNode scalarNode = 
(IMXMLExpressionNode)instanceNode;
+               IASNode vNode = scalarNode.getExpressionNode();
+               if (vNode instanceof IMXMLLiteralNode)
+               {
+                   IMXMLLiteralNode valueNode = (IMXMLLiteralNode)vNode;
+                   Object value = valueNode.getValue();
+                   return value.toString();
+               }
+       }
        return "";
     }
 
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 ea09b72..b88bb01 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
@@ -1260,6 +1260,426 @@ public class TestRoyaleMXMLApplication extends 
RoyaleTestBase
     }
     
     @Test
+    public void testFXNumberDeclaration()
+    {
+        String code = "<basic:Application 
xmlns:fx=\"http://ns.adobe.com/mxml/2009\"; 
xmlns:basic=\"library://ns.apache.org/royale/basic\">"
+                       + "<fx:Declarations><fx:Number 
id=\"foo\">20.19</fx:Number>"
+                + 
"</fx:Declarations><basic:initialView><basic:View><basic:DropDownList 
dataProvider=\"['Hello', 
'World']\"/></basic:View></basic:initialView></basic:Application>";
+
+        IMXMLDocumentNode dnode = (IMXMLDocumentNode) getNode(code,
+                       IMXMLDocumentNode.class, 
RoyaleTestBase.WRAP_LEVEL_NONE);
+
+        
((JSRoyaleEmitter)(mxmlBlockWalker.getASEmitter())).getModel().setCurrentClass(dnode.getDefinition());
+        mxmlBlockWalker.visitDocument(dnode);
+        String appName = dnode.getQualifiedName();
+        String outTemplate = "/**\n" +
+                       " * AppName\n" +
+                       " *\n" +
+                       " * @fileoverview\n" +
+                       " *\n" +
+                       " * @suppress {checkTypes|accessControls}\n" +
+                       " */\n" +
+                       "\n" +
+                       "goog.provide('AppName');\n" +
+                       "\n" +
+                       "goog.require('org.apache.royale.core.Application');\n" 
+
+                       "goog.require('org.apache.royale.core.View');\n" +
+                       
"goog.require('org.apache.royale.html.DropDownList');\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                       "/**\n" +
+                       " * @constructor\n" +
+                       " * @extends {org.apache.royale.core.Application}\n" +
+                       " */\n" +
+                       "AppName = function() {\n" +
+                       "  AppName.base(this, 'constructor');\n" +
+                       "  \n" +
+                       "  this.foo = 20.19;\n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {org.apache.royale.core.View}\n" +
+                       "   */\n" +
+                       "  this.$ID_8_1;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {org.apache.royale.html.DropDownList}\n" +
+                       "   */\n" +
+                       "  this.$ID_8_0;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {Array}\n" +
+                       "   */\n" +
+                       "  this.mxmldd;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {Array}\n" +
+                       "   */\n" +
+                       "  this.mxmldp;\n" +
+                       "\n" +
+                       "  this.generateMXMLAttributes([\n" +
+                       "    1,\n" +
+                       "    'initialView',\n" +
+                       "    false,\n" +
+                               "    [\n" +
+                               "      org.apache.royale.core.View,\n" +
+                               "      1,\n" +
+                               "      '_id',\n" +
+                               "      true,\n" +
+                               "      '$ID_8_1',\n" +
+                               "      0,\n" +
+                               "      0,\n" +
+                               "      [\n" +
+                               "        
org.apache.royale.html.DropDownList,\n" +
+                               "        2,\n" +
+                               "        '_id',\n" +
+                               "        true,\n" +
+                               "        '$ID_8_0',\n" +
+                               "        'dataProvider',\n" +
+                               "        true,\n" +
+                               "        ['Hello','World'],\n" +
+                               "        0,\n" +
+                               "        0,\n" +
+                               "        null\n" +
+                               "      ]\n" +
+                               "    ],\n" +
+                       "    0,\n" +
+                       "    0\n" +
+                       "  ]);\n" +
+                       "  \n" +
+                       "};\n" +
+                       "goog.inherits(AppName, 
org.apache.royale.core.Application);\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                               "\n" +
+                       "/**\n" +
+                       " * @export\n" +
+                       " * @type {number}\n" +
+                       " */\n" +
+                       "AppName.prototype.foo;\n" +
+                               "\n" +
+                       "/**\n" +
+                       " * Metadata\n" +
+                       " *\n" +
+                       " * @type {Object.<string, Array.<Object>>}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_CLASS_INFO = { names: [{ 
name: 'AppName', qName: 'AppName', kind: 'class'  }] };\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                       "/**\n" +
+                       " * Reflection\n" +
+                       " *\n" +
+                       " * @return {Object.<string, Function>}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_REFLECTION_INFO = function () 
{\n" +
+                       "  return {\n" +
+                       "    variables: function () {\n" +
+                       "      return {\n" +
+                       "        'foo': { type: 'Number', get_set: function 
(/** AppName */ inst, /** * */ v) {return v !== undefined ? inst.foo = v : 
inst.foo;}}\n" +
+                       "      };\n" +
+                       "    },\n" +
+                       "    methods: function () {\n" +
+                       "      return {\n" +
+                               "        'AppName': { type: '', declaredBy: 
'AppName'}\n"+
+                       "      };\n" +
+                       "    }\n" +
+                       "  };\n" +
+                       "};\n" + 
+                       "/**\n" +
+                       " * @const\n" +
+                       " * @type {number}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_COMPILE_FLAGS = 9;";
+
+        assertOutMXMLPostProcess(outTemplate.replaceAll("AppName", appName), 
true);
+    }
+    
+    @Test
+    public void testFXBooleanDeclaration()
+    {
+        String code = "<basic:Application 
xmlns:fx=\"http://ns.adobe.com/mxml/2009\"; 
xmlns:basic=\"library://ns.apache.org/royale/basic\">"
+                       + "<fx:Declarations><fx:Boolean 
id=\"foo\">true</fx:Boolean>"
+                + 
"</fx:Declarations><basic:initialView><basic:View><basic:DropDownList 
dataProvider=\"['Hello', 
'World']\"/></basic:View></basic:initialView></basic:Application>";
+
+        IMXMLDocumentNode dnode = (IMXMLDocumentNode) getNode(code,
+                       IMXMLDocumentNode.class, 
RoyaleTestBase.WRAP_LEVEL_NONE);
+
+        
((JSRoyaleEmitter)(mxmlBlockWalker.getASEmitter())).getModel().setCurrentClass(dnode.getDefinition());
+        mxmlBlockWalker.visitDocument(dnode);
+        String appName = dnode.getQualifiedName();
+        String outTemplate = "/**\n" +
+                       " * AppName\n" +
+                       " *\n" +
+                       " * @fileoverview\n" +
+                       " *\n" +
+                       " * @suppress {checkTypes|accessControls}\n" +
+                       " */\n" +
+                       "\n" +
+                       "goog.provide('AppName');\n" +
+                       "\n" +
+                       "goog.require('org.apache.royale.core.Application');\n" 
+
+                       "goog.require('org.apache.royale.core.View');\n" +
+                       
"goog.require('org.apache.royale.html.DropDownList');\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                       "/**\n" +
+                       " * @constructor\n" +
+                       " * @extends {org.apache.royale.core.Application}\n" +
+                       " */\n" +
+                       "AppName = function() {\n" +
+                       "  AppName.base(this, 'constructor');\n" +
+                       "  \n" +
+                       "  this.foo = true;\n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {org.apache.royale.core.View}\n" +
+                       "   */\n" +
+                       "  this.$ID_8_1;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {org.apache.royale.html.DropDownList}\n" +
+                       "   */\n" +
+                       "  this.$ID_8_0;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {Array}\n" +
+                       "   */\n" +
+                       "  this.mxmldd;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {Array}\n" +
+                       "   */\n" +
+                       "  this.mxmldp;\n" +
+                       "\n" +
+                       "  this.generateMXMLAttributes([\n" +
+                       "    1,\n" +
+                       "    'initialView',\n" +
+                       "    false,\n" +
+                               "    [\n" +
+                               "      org.apache.royale.core.View,\n" +
+                               "      1,\n" +
+                               "      '_id',\n" +
+                               "      true,\n" +
+                               "      '$ID_8_1',\n" +
+                               "      0,\n" +
+                               "      0,\n" +
+                               "      [\n" +
+                               "        
org.apache.royale.html.DropDownList,\n" +
+                               "        2,\n" +
+                               "        '_id',\n" +
+                               "        true,\n" +
+                               "        '$ID_8_0',\n" +
+                               "        'dataProvider',\n" +
+                               "        true,\n" +
+                               "        ['Hello','World'],\n" +
+                               "        0,\n" +
+                               "        0,\n" +
+                               "        null\n" +
+                               "      ]\n" +
+                               "    ],\n" +
+                       "    0,\n" +
+                       "    0\n" +
+                       "  ]);\n" +
+                       "  \n" +
+                       "};\n" +
+                       "goog.inherits(AppName, 
org.apache.royale.core.Application);\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                               "\n" +
+                       "/**\n" +
+                       " * @export\n" +
+                       " * @type {boolean}\n" +
+                       " */\n" +
+                       "AppName.prototype.foo;\n" +
+                               "\n" +
+                       "/**\n" +
+                       " * Metadata\n" +
+                       " *\n" +
+                       " * @type {Object.<string, Array.<Object>>}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_CLASS_INFO = { names: [{ 
name: 'AppName', qName: 'AppName', kind: 'class'  }] };\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                       "/**\n" +
+                       " * Reflection\n" +
+                       " *\n" +
+                       " * @return {Object.<string, Function>}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_REFLECTION_INFO = function () 
{\n" +
+                       "  return {\n" +
+                       "    variables: function () {\n" +
+                       "      return {\n" +
+                       "        'foo': { type: 'Boolean', get_set: function 
(/** AppName */ inst, /** * */ v) {return v !== undefined ? inst.foo = v : 
inst.foo;}}\n" +
+                       "      };\n" +
+                       "    },\n" +
+                       "    methods: function () {\n" +
+                       "      return {\n" +
+                               "        'AppName': { type: '', declaredBy: 
'AppName'}\n"+
+                       "      };\n" +
+                       "    }\n" +
+                       "  };\n" +
+                       "};\n" + 
+                       "/**\n" +
+                       " * @const\n" +
+                       " * @type {number}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_COMPILE_FLAGS = 9;";
+
+        assertOutMXMLPostProcess(outTemplate.replaceAll("AppName", appName), 
true);
+    }
+    
+    @Test
+    public void testFXIntDeclaration()
+    {
+        String code = "<basic:Application 
xmlns:fx=\"http://ns.adobe.com/mxml/2009\"; 
xmlns:basic=\"library://ns.apache.org/royale/basic\">"
+                       + "<fx:Declarations><fx:int id=\"foo\">2020</fx:int>"
+                + 
"</fx:Declarations><basic:initialView><basic:View><basic:DropDownList 
dataProvider=\"['Hello', 
'World']\"/></basic:View></basic:initialView></basic:Application>";
+
+        IMXMLDocumentNode dnode = (IMXMLDocumentNode) getNode(code,
+                       IMXMLDocumentNode.class, 
RoyaleTestBase.WRAP_LEVEL_NONE);
+
+        
((JSRoyaleEmitter)(mxmlBlockWalker.getASEmitter())).getModel().setCurrentClass(dnode.getDefinition());
+        mxmlBlockWalker.visitDocument(dnode);
+        String appName = dnode.getQualifiedName();
+        String outTemplate = "/**\n" +
+                       " * AppName\n" +
+                       " *\n" +
+                       " * @fileoverview\n" +
+                       " *\n" +
+                       " * @suppress {checkTypes|accessControls}\n" +
+                       " */\n" +
+                       "\n" +
+                       "goog.provide('AppName');\n" +
+                       "\n" +
+                       "goog.require('org.apache.royale.core.Application');\n" 
+
+                       "goog.require('org.apache.royale.core.View');\n" +
+                       
"goog.require('org.apache.royale.html.DropDownList');\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                       "/**\n" +
+                       " * @constructor\n" +
+                       " * @extends {org.apache.royale.core.Application}\n" +
+                       " */\n" +
+                       "AppName = function() {\n" +
+                       "  AppName.base(this, 'constructor');\n" +
+                       "  \n" +
+                       "  this.foo = 2020;\n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {org.apache.royale.core.View}\n" +
+                       "   */\n" +
+                       "  this.$ID_8_1;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {org.apache.royale.html.DropDownList}\n" +
+                       "   */\n" +
+                       "  this.$ID_8_0;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {Array}\n" +
+                       "   */\n" +
+                       "  this.mxmldd;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {Array}\n" +
+                       "   */\n" +
+                       "  this.mxmldp;\n" +
+                       "\n" +
+                       "  this.generateMXMLAttributes([\n" +
+                       "    1,\n" +
+                       "    'initialView',\n" +
+                       "    false,\n" +
+                               "    [\n" +
+                               "      org.apache.royale.core.View,\n" +
+                               "      1,\n" +
+                               "      '_id',\n" +
+                               "      true,\n" +
+                               "      '$ID_8_1',\n" +
+                               "      0,\n" +
+                               "      0,\n" +
+                               "      [\n" +
+                               "        
org.apache.royale.html.DropDownList,\n" +
+                               "        2,\n" +
+                               "        '_id',\n" +
+                               "        true,\n" +
+                               "        '$ID_8_0',\n" +
+                               "        'dataProvider',\n" +
+                               "        true,\n" +
+                               "        ['Hello','World'],\n" +
+                               "        0,\n" +
+                               "        0,\n" +
+                               "        null\n" +
+                               "      ]\n" +
+                               "    ],\n" +
+                       "    0,\n" +
+                       "    0\n" +
+                       "  ]);\n" +
+                       "  \n" +
+                       "};\n" +
+                       "goog.inherits(AppName, 
org.apache.royale.core.Application);\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                               "\n" +
+                       "/**\n" +
+                       " * @export\n" +
+                       " * @type {number}\n" +
+                       " */\n" +
+                       "AppName.prototype.foo;\n" +
+                               "\n" +
+                       "/**\n" +
+                       " * Metadata\n" +
+                       " *\n" +
+                       " * @type {Object.<string, Array.<Object>>}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_CLASS_INFO = { names: [{ 
name: 'AppName', qName: 'AppName', kind: 'class'  }] };\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                       "/**\n" +
+                       " * Reflection\n" +
+                       " *\n" +
+                       " * @return {Object.<string, Function>}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_REFLECTION_INFO = function () 
{\n" +
+                       "  return {\n" +
+                       "    variables: function () {\n" +
+                       "      return {\n" +
+                       "        'foo': { type: 'int', get_set: function (/** 
AppName */ inst, /** * */ v) {return v !== undefined ? inst.foo = v : 
inst.foo;}}\n" +
+                       "      };\n" +
+                       "    },\n" +
+                       "    methods: function () {\n" +
+                       "      return {\n" +
+                               "        'AppName': { type: '', declaredBy: 
'AppName'}\n"+
+                       "      };\n" +
+                       "    }\n" +
+                       "  };\n" +
+                       "};\n" + 
+                       "/**\n" +
+                       " * @const\n" +
+                       " * @type {number}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_COMPILE_FLAGS = 9;";
+
+        assertOutMXMLPostProcess(outTemplate.replaceAll("AppName", appName), 
true);
+    }
+    
+    @Test
     public void testFXArrayDeclaration()
     {
         String code = "<basic:Application 
xmlns:fx=\"http://ns.adobe.com/mxml/2009\"; 
xmlns:basic=\"library://ns.apache.org/royale/basic\">"
@@ -1400,6 +1820,146 @@ public class TestRoyaleMXMLApplication extends 
RoyaleTestBase
     }
     
     @Test
+    public void testFXArrayOfObjectsDeclaration()
+    {
+        String code = "<basic:Application 
xmlns:fx=\"http://ns.adobe.com/mxml/2009\"; 
xmlns:basic=\"library://ns.apache.org/royale/basic\">"
+                       + "<fx:Declarations><fx:Array id=\"foo\"><fx:Object 
stringProp=\"A String\" intProp=\"2000\" numProp=\"20.19\" 
boolProp=\"true\"/><fx:Object stringProp=\"Another String\" intProp=\"2021\" 
numProp=\"20.21\" boolProp=\"false\"/></fx:Array>"
+                + 
"</fx:Declarations><basic:initialView><basic:View><basic:DropDownList 
dataProvider=\"['Hello', 
'World']\"/></basic:View></basic:initialView></basic:Application>";
+
+        IMXMLDocumentNode dnode = (IMXMLDocumentNode) getNode(code,
+                       IMXMLDocumentNode.class, 
RoyaleTestBase.WRAP_LEVEL_NONE);
+
+        
((JSRoyaleEmitter)(mxmlBlockWalker.getASEmitter())).getModel().setCurrentClass(dnode.getDefinition());
+        mxmlBlockWalker.visitDocument(dnode);
+        String appName = dnode.getQualifiedName();
+        String outTemplate = "/**\n" +
+                       " * AppName\n" +
+                       " *\n" +
+                       " * @fileoverview\n" +
+                       " *\n" +
+                       " * @suppress {checkTypes|accessControls}\n" +
+                       " */\n" +
+                       "\n" +
+                       "goog.provide('AppName');\n" +
+                       "\n" +
+                       "goog.require('org.apache.royale.core.Application');\n" 
+
+                       "goog.require('org.apache.royale.core.View');\n" +
+                       
"goog.require('org.apache.royale.html.DropDownList');\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                       "/**\n" +
+                       " * @constructor\n" +
+                       " * @extends {org.apache.royale.core.Application}\n" +
+                       " */\n" +
+                       "AppName = function() {\n" +
+                       "  AppName.base(this, 'constructor');\n" +
+                       "  \n" +
+                       "  this.foo = [{stringProp: 'A String', intProp: 2000, 
numProp: 20.19, boolProp: true}, {stringProp: 'Another String', intProp: 2021, 
numProp: 20.21, boolProp: false}];\n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {org.apache.royale.core.View}\n" +
+                       "   */\n" +
+                       "  this.$ID_8_3;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {org.apache.royale.html.DropDownList}\n" +
+                       "   */\n" +
+                       "  this.$ID_8_2;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {Array}\n" +
+                       "   */\n" +
+                       "  this.mxmldd;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {Array}\n" +
+                       "   */\n" +
+                       "  this.mxmldp;\n" +
+                       "\n" +
+                       "  this.generateMXMLAttributes([\n" +
+                       "    1,\n" +
+                       "    'initialView',\n" +
+                       "    false,\n" +
+                               "    [\n" +
+                               "      org.apache.royale.core.View,\n" +
+                               "      1,\n" +
+                               "      '_id',\n" +
+                               "      true,\n" +
+                               "      '$ID_8_3',\n" +
+                               "      0,\n" +
+                               "      0,\n" +
+                               "      [\n" +
+                               "        
org.apache.royale.html.DropDownList,\n" +
+                               "        2,\n" +
+                               "        '_id',\n" +
+                               "        true,\n" +
+                               "        '$ID_8_2',\n" +
+                               "        'dataProvider',\n" +
+                               "        true,\n" +
+                               "        ['Hello','World'],\n" +
+                               "        0,\n" +
+                               "        0,\n" +
+                               "        null\n" +
+                               "      ]\n" +
+                               "    ],\n" +
+                       "    0,\n" +
+                       "    0\n" +
+                       "  ]);\n" +
+                       "  \n" +
+                       "};\n" +
+                       "goog.inherits(AppName, 
org.apache.royale.core.Application);\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                               "\n" +
+                       "/**\n" +
+                       " * @export\n" +
+                       " * @type {Array}\n" +
+                       " */\n" +
+                       "AppName.prototype.foo;\n" +
+                               "\n" +
+                       "/**\n" +
+                       " * Metadata\n" +
+                       " *\n" +
+                       " * @type {Object.<string, Array.<Object>>}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_CLASS_INFO = { names: [{ 
name: 'AppName', qName: 'AppName', kind: 'class'  }] };\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                       "/**\n" +
+                       " * Reflection\n" +
+                       " *\n" +
+                       " * @return {Object.<string, Function>}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_REFLECTION_INFO = function () 
{\n" +
+                       "  return {\n" +
+                       "    variables: function () {\n" +
+                       "      return {\n" +
+                       "        'foo': { type: 'Array', get_set: function (/** 
AppName */ inst, /** * */ v) {return v !== undefined ? inst.foo = v : 
inst.foo;}}\n" +
+                       "      };\n" +
+                       "    },\n" +
+                       "    methods: function () {\n" +
+                       "      return {\n" +
+                               "        'AppName': { type: '', declaredBy: 
'AppName'}\n"+
+                       "      };\n" +
+                       "    }\n" +
+                       "  };\n" +
+                       "};\n" + 
+                       "/**\n" +
+                       " * @const\n" +
+                       " * @type {number}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_COMPILE_FLAGS = 9;";
+
+        assertOutMXMLPostProcess(outTemplate.replaceAll("AppName", appName), 
true);
+    }
+    
+    @Test
     public void testFXXMLDeclaration()
     {
         String code = "<basic:Application 
xmlns:fx=\"http://ns.adobe.com/mxml/2009\"; 
xmlns:basic=\"library://ns.apache.org/royale/basic\">"

Reply via email to