You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2019/08/30 23:20:36 UTC
[royale-compiler] branch develop updated: Support for '*' ANY
namespace,
and also some other unusual possibilities when using AS3 language namespaces
in e4x.
This is an automated email from the ASF dual-hosted git repository.
gregdove 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 4499026 Support for '*' ANY namespace, and also some other unusual possibilities when using AS3 language namespaces in e4x.
4499026 is described below
commit 4499026c52896c0f65b4def93c0f6f306c6a6e12
Author: greg-dove <gr...@gmail.com>
AuthorDate: Sat Aug 31 11:16:53 2019 +1200
Support for '*' ANY namespace, and also some other unusual possibilities when using AS3 language namespaces in e4x.
---
.../codegen/js/jx/MemberAccessEmitter.java | 46 +++++++++++++++++++---
1 file changed, 40 insertions(+), 6 deletions(-)
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/MemberAccessEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
index 28a60cf..d6e5ccb 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/MemberAccessEmitter.java
@@ -21,8 +21,11 @@ package org.apache.royale.compiler.internal.codegen.js.jx;
import org.apache.royale.compiler.codegen.ISubEmitter;
import org.apache.royale.compiler.codegen.js.IJSEmitter;
+import org.apache.royale.compiler.constants.IASKeywordConstants;
import org.apache.royale.compiler.constants.IASLanguageConstants;
+import org.apache.royale.compiler.constants.INamespaceConstants;
import org.apache.royale.compiler.definitions.IDefinition;
+import org.apache.royale.compiler.definitions.INamespaceDefinition;
import org.apache.royale.compiler.definitions.IPackageDefinition;
import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
import org.apache.royale.compiler.internal.codegen.js.JSEmitterTokens;
@@ -104,13 +107,44 @@ public class MemberAccessEmitter extends JSSubEmitter implements
String closeMethodCall = "')";
String s = "";
if (rightNode instanceof INamespaceAccessExpressionNode) {
- //use a QName to support the namespace access
- write("new QName(");
NamespaceIdentifierNode namespaceIdentifierNode = (NamespaceIdentifierNode) ((INamespaceAccessExpressionNode) rightNode).getLeftOperandNode();
- s = fjs.stringifyNode(namespaceIdentifierNode);
- write(s + ", '");
- rightNode = ((INamespaceAccessExpressionNode) rightNode).getRightOperandNode();
- closeMethodCall = "'))";
+ IDefinition nsDef = namespaceIdentifierNode.resolve(getProject());
+ if (nsDef instanceof INamespaceDefinition
+ && ((INamespaceDefinition)nsDef).getNamespaceClassification().equals(INamespaceDefinition.NamespaceClassification.LANGUAGE)) {
+ //deal with built-ins
+ String name = ((NamespaceIdentifierNode) ((INamespaceAccessExpressionNode) rightNode).getLeftOperandNode()).getName();
+ if (name.equals(INamespaceConstants.ANY)) {
+ //let the internal support within 'QName' class deal with it
+ write("new QName('*', '");
+ //only stringify the right node at the next step (it is the localName part)
+ rightNode = ((INamespaceAccessExpressionNode) rightNode).getRightOperandNode();
+ closeMethodCall = "'))";
+ } else if (name.equals(IASKeywordConstants.PUBLIC)
+ || name.equals(IASKeywordConstants.PROTECTED)) {
+ //@todo check this, but both public and protected appear to have the effect of skipping the namespace part in swf, so just use default namespace
+ write("/* as3 " + name + " */ '");
+ //skip the namespace to just output the name
+ rightNode = ((INamespaceAccessExpressionNode) rightNode).getRightOperandNode();
+ } else {
+ //this is an unlikely condition, but do something that should give same results as swf...
+ //private, internal namespaces used in an XML context (I don't think this makes sense)
+ //@todo check this, but it seems like it should never match anything in a valid XML query
+ write("new QName('");
+ //provide an 'unlikely' 'uri':
+ write("_as3Lang_" + fjs.stringifyNode(namespaceIdentifierNode));
+ write(s + "', '");
+ //only stringify the right node at the next step (it is the localName part)
+ rightNode = ((INamespaceAccessExpressionNode) rightNode).getRightOperandNode();
+ closeMethodCall = "'))";
+ }
+ } else {
+ write("new QName(");
+ s = fjs.stringifyNode(namespaceIdentifierNode);
+ write(s + ", '");
+ //only stringify the right node at the next step (it is the localName part)
+ rightNode = ((INamespaceAccessExpressionNode) rightNode).getRightOperandNode();
+ closeMethodCall = "'))";
+ }
} else write("'"); //normal string name for child
s = fjs.stringifyNode(rightNode);