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 3f764ab90ea4773beab7dd4a234d1037d2711240
Author: Josh Tynjala <[email protected]>
AuthorDate: Wed Jan 14 15:47:50 2026 -0800

    JSConfiguration: js-vector-emulation-literal-function to allow calling a 
function to create a Vector literal instead of the constructor
    
    A custom Vector implementation that closely follows Flash's implementation 
would accept length and fixed values in the constructor. However, the vector 
emulation class was expected to overload the constructor to accept an array for 
the first parameter too. That may not be possible, so a custom function to 
create a vector and populate it for a vector literal offers more flexibility.
---
 .../royale/compiler/clients/JSConfiguration.java   | 22 +++++++++++++++++++++-
 .../codegen/js/jx/FunctionCallEmitter.java         |  9 ++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/JSConfiguration.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/JSConfiguration.java
index fa58d9901..c4fc0539c 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/clients/JSConfiguration.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/clients/JSConfiguration.java
@@ -495,7 +495,7 @@ public class JSConfiguration extends Configuration
     }
 
     /**
-     * The class to use instead of default Vector implementation for handling 
Vector.
+     * The class to use instead of default Vector implementation.
      */
     @Config(advanced = true)
     public void setJsVectorEmulationClass(ConfigurationValue cv, String b)
@@ -523,6 +523,26 @@ public class JSConfiguration extends Configuration
     {
        jsVectorEmulationElementTypes = b;
     }
+
+    //
+    // 'js-vector-emulation-literal-function' option
+    //
+
+    private String jsVectorEmulationLiteralFunction = null;
+
+    public String getJsVectorEmulationLiteralFunction()
+    {
+        return jsVectorEmulationLiteralFunction;
+    }
+
+    /**
+     * The function to use instead of default Vector literal implementation.
+     */
+    @Config(advanced = true)
+    public void setJsVectorEmulationLiteralFunction(ConfigurationValue cv, 
String b)
+    {
+       jsVectorEmulationLiteralFunction = b;
+    }
     
     
     //
diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
index 79f87bcf0..a4210d385 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
@@ -139,6 +139,7 @@ public class FunctionCallEmitter extends JSSubEmitter 
implements ISubEmitter<IFu
                 {
                     VectorLiteralNode vectorLiteralNode = (VectorLiteralNode) 
node.getChild(1);
                     String vectorEmulationClass = null;
+                    String vectorEmulationLiteralFunction = null;
                     boolean vectorEmulationElementTypes = true;
                     if (project instanceof RoyaleJSProject)
                     {
@@ -146,6 +147,7 @@ public class FunctionCallEmitter extends JSSubEmitter 
implements ISubEmitter<IFu
                         if (royaleProject.config != null)
                         {
                             vectorEmulationClass = 
royaleProject.config.getJsVectorEmulationClass();
+                            vectorEmulationLiteralFunction = 
royaleProject.config.getJsVectorEmulationLiteralFunction();
                             vectorEmulationElementTypes = 
royaleProject.config.getJsVectorEmulationElementTypes();
                         }
                     }
@@ -153,7 +155,12 @@ public class FunctionCallEmitter extends JSSubEmitter 
implements ISubEmitter<IFu
                     String elementClassName;
                     IDefinition elementClass = 
(((AppliedVectorDefinition)def).resolveElementType(getWalker().getProject()));
                     elementClassName = 
getEmitter().formatQualifiedName(elementClass.getQualifiedName());
-                    if (vectorEmulationClass != null)
+                    if (vectorEmulationLiteralFunction != null)
+                    {
+                        write(vectorEmulationLiteralFunction);
+                        write(ASEmitterTokens.PAREN_OPEN);
+                    }
+                    else if (vectorEmulationClass != null)
                     {
                         if 
(!vectorEmulationClass.equals(IASLanguageConstants.Array))
                         {

Reply via email to