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


The following commit(s) were added to refs/heads/develop by this push:
     new 0e8029f6a MXMLRoyaleEmitter: followup to children-as-data=false in JS 
to include IMXMLFactoryNode
0e8029f6a is described below

commit 0e8029f6a9d5f78cc0aebb5cb962ebea72bdd489
Author: Josh Tynjala <[email protected]>
AuthorDate: Thu Jul 16 14:34:03 2026 -0700

    MXMLRoyaleEmitter: followup to children-as-data=false in JS to include 
IMXMLFactoryNode
    
    Followup to commit de684f3eb4c65bcaa424e9a5d22d45ced57c7005
---
 .../codegen/mxml/royale/MXMLRoyaleEmitter.java     | 107 +++++++++++++++++++--
 1 file changed, 99 insertions(+), 8 deletions(-)

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 fd9dedb60..022fe73a0 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
@@ -979,6 +979,9 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
                 case MXMLWebServiceID:
                     emitInstanceFactoryMethod((IMXMLInstanceNode) node);
                     break;
+                case MXMLFactoryID:
+                    emitFactoryFactoryMethod((IMXMLFactoryNode) node);
+                    break;
                 case MXMLVectorID:
                     emitVectorFactoryMethod((IMXMLVectorNode) node);
                     break;
@@ -3619,18 +3622,35 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
     @Override
     public void emitFactory(IMXMLFactoryNode node)
     {
-        IASNode cnode = node.getChild(0);
-       ITypeDefinition type = 
((IMXMLClassNode)cnode).getValue(getMXMLWalker().getProject());
-       if (type == null) return;
+        RoyaleJSProject project = 
(RoyaleJSProject)getMXMLWalker().getProject();
 
-        MXMLDescriptorSpecifier ps = getCurrentDescriptor("ps");
-        ps.value = "new " + 
formatQualifiedName("org.apache.royale.core.ClassFactory") + "(";
+        if (project.getTargetSettings().getMxmlChildrenAsData())
+        {
+            IASNode cnode = node.getChild(0);
+            ITypeDefinition type = ((IMXMLClassNode)cnode).getValue(project);
+            if (type == null) return;
+
+            MXMLDescriptorSpecifier ps = getCurrentDescriptor("ps");
+            ps.value = "new " + 
formatQualifiedName("org.apache.royale.core.ClassFactory") + "(";
 
-        if (cnode instanceof IMXMLClassNode)
+            if (cnode instanceof IMXMLClassNode)
+            {
+                ps.value += formatQualifiedName(type.getQualifiedName());
+            }
+            ps.value += ")";
+        }
+        else
         {
-            ps.value += formatQualifiedName(type.getQualifiedName());
+            String methodName = "_" + documentDefinition.getBaseName() + 
"_Factory_" + factoryMethodCounter;
+            factoryMethodCounter++;
+            factoryMethodNames.put(node, methodName);
+
+            IMXMLClassNode classNode = node.getClassNode();
+            if (classNode != null)
+            {
+                getMXMLWalker().walk(classNode);
+            }
         }
-        ps.value += ")";
     }
 
     
//--------------------------------------------------------------------------
@@ -5483,6 +5503,77 @@ public class MXMLRoyaleEmitter extends MXMLEmitter 
implements
         writeNewline(ASEmitterTokens.SEMICOLON);
     }
 
+    private void emitFactoryFactoryMethod(IMXMLFactoryNode node)
+    {
+        RoyaleJSProject project = (RoyaleJSProject) 
getMXMLWalker().getProject();
+        String cname = node.getFileNode().getName();
+        String methodName = factoryMethodNames.get(node);
+        String tempVarName = "factory";
+        IMXMLClassNode classNode = node.getClassNode();
+
+        writeNewline();
+        write(cname);
+        write(ASEmitterTokens.MEMBER_ACCESS);
+        write(JSEmitterTokens.PROTOTYPE);
+        write(ASEmitterTokens.MEMBER_ACCESS);
+        write(methodName);
+        write(ASEmitterTokens.SPACE);
+        writeToken(ASEmitterTokens.EQUAL);
+        write(ASEmitterTokens.FUNCTION);
+        write(ASEmitterTokens.PAREN_OPEN);
+        writeToken(ASEmitterTokens.PAREN_CLOSE);
+        write(ASEmitterTokens.BLOCK_OPEN);
+        indentPush();
+        writeNewline();
+
+        writeToken(ASEmitterTokens.VAR);
+        write(tempVarName);
+        write(ASEmitterTokens.SPACE);
+        writeToken(ASEmitterTokens.EQUAL);
+        writeToken(ASEmitterTokens.NEW);
+        write(formatQualifiedName(project.getClassFactoryClass()));
+        write(ASEmitterTokens.PAREN_OPEN);
+        write(ASEmitterTokens.PAREN_CLOSE);
+        write(ASEmitterTokens.SEMICOLON);
+        writeNewline();
+        write(tempVarName);
+        write(ASEmitterTokens.MEMBER_ACCESS);
+        writeToken("generator");
+        writeToken(ASEmitterTokens.EQUAL);
+        if (classNode != null)
+        {
+            
write(formatQualifiedName(classNode.getValue(project).getQualifiedName()));
+        }
+        else
+        {
+            write(ASEmitterTokens.NULL);
+        }
+        write(ASEmitterTokens.SEMICOLON);
+        writeNewline();
+
+        String effectiveId = node.getEffectiveID();
+        if (effectiveId != null)
+        {
+            write(ASEmitterTokens.THIS);
+            write(ASEmitterTokens.MEMBER_ACCESS);
+            write(node.getEffectiveID());
+            write(ASEmitterTokens.SPACE);
+            writeToken(ASEmitterTokens.EQUAL);
+            write(tempVarName);
+            write(ASEmitterTokens.SEMICOLON);
+            writeNewline();
+        }
+
+        writeToken(ASEmitterTokens.RETURN);
+        write(tempVarName);
+        write(ASEmitterTokens.SEMICOLON);
+
+        indentPop();
+        writeNewline();
+        write(ASEmitterTokens.BLOCK_CLOSE);
+        writeNewline(ASEmitterTokens.SEMICOLON);
+    }
+
     private void emitUIComponentDescriptorForDocument(IMXMLDocumentNode node)
     {
         if (!node.needsDocumentDescriptor())

Reply via email to