You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2019/05/02 16:38:15 UTC
[royale-compiler] branch develop updated: handle calling custom
namespace methods. Fixes apache/royale-asjs#419.
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 95a8ca4 handle calling custom namespace methods. Fixes apache/royale-asjs#419.
95a8ca4 is described below
commit 95a8ca4465c627892dcae6e0df266fd8f918b85e
Author: Alex Harui <ah...@apache.org>
AuthorDate: Thu May 2 09:37:59 2019 -0700
handle calling custom namespace methods. Fixes apache/royale-asjs#419.
---
.../internal/codegen/js/jx/FunctionCallEmitter.java | 20 ++++++++++++++++++++
.../codegen/js/royale/TestRoyaleExpressions.java | 10 ++++++++++
2 files changed, 30 insertions(+)
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 570bf9d..1e0bae0 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
@@ -34,10 +34,14 @@ import org.apache.royale.compiler.internal.codegen.js.royale.JSRoyaleEmitterToke
import org.apache.royale.compiler.internal.codegen.js.utils.EmitterUtils;
import org.apache.royale.compiler.internal.definitions.AppliedVectorDefinition;
import org.apache.royale.compiler.internal.definitions.ClassDefinition;
+import org.apache.royale.compiler.internal.definitions.FunctionDefinition;
import org.apache.royale.compiler.internal.definitions.InterfaceDefinition;
+import org.apache.royale.compiler.internal.definitions.NamespaceDefinition;
import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
import org.apache.royale.compiler.internal.tree.as.ContainerNode;
+import org.apache.royale.compiler.internal.tree.as.IdentifierNode;
import org.apache.royale.compiler.internal.tree.as.MemberAccessExpressionNode;
+import org.apache.royale.compiler.internal.tree.as.NamespaceIdentifierNode;
import org.apache.royale.compiler.internal.tree.as.VectorLiteralNode;
import org.apache.royale.compiler.problems.TooFewFunctionParametersProblem;
import org.apache.royale.compiler.problems.TooManyFunctionParametersProblem;
@@ -323,6 +327,22 @@ public class FunctionCallEmitter extends JSSubEmitter implements ISubEmitter<IFu
getEmitter().emitArguments(node.getArgumentsNode());
return;
}
+ else if (nameNode.getNodeID() == ASTNodeID.NamespaceAccessExpressionID && def instanceof FunctionDefinition)
+ {
+ if (fjs.isCustomNamespace((FunctionDefinition)def))
+ {
+ write(ASEmitterTokens.THIS);
+ NamespaceIdentifierNode nin = (NamespaceIdentifierNode)nameNode.getChild(0);
+ NamespaceDefinition nsDef = (NamespaceDefinition)nin.resolve(getProject());
+ IdentifierNode idNode = (IdentifierNode)nameNode.getChild(1);
+ String propName = idNode.getName();
+ fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names
+ String s = nsDef.getURI();
+ write(JSRoyaleEmitter.formatNamespacedProperty(s, propName, true));
+ getEmitter().emitArguments(node.getArgumentsNode());
+ return;
+ }
+ }
}
else if (nameNode.getNodeID() == ASTNodeID.MemberAccessExpressionID && ((JSRoyaleEmitter)getEmitter()).isProxy(((MemberAccessExpressionNode)nameNode).getLeftOperandNode()) && def == null)
{
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
index 24a0101..0b32b4a 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
@@ -1314,6 +1314,16 @@ public class TestRoyaleExpressions extends TestGoogExpressions
}
@Test
+ public void testFunctionCallCustomNamespace()
+ {
+ IFunctionNode node = (IFunctionNode) getNode(
+ "import custom.custom_namespace; public class B {custom_namespace function b() { custom_namespace::b(); }}",
+ IFunctionNode.class, WRAP_LEVEL_PACKAGE, true);
+ asBlockWalker.visitFunction(node);
+ assertOut("/**\n * @export\n */\nfoo.bar.B.prototype.http_$$ns_apache_org$2017$custom$namespace__b = function() {\n this.http_$$ns_apache_org$2017$custom$namespace__b();\n}");
+ }
+
+ @Test
public void testFunctionMemberFullyQualified()
{
IFunctionNode node = (IFunctionNode) getNode(