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 7097ac045051639bda1bc72761b8fe94494ea743 Author: Josh Tynjala <[email protected]> AuthorDate: Wed Feb 5 13:55:41 2020 -0800 JSGoogConfiguration: added mxml-reflect-object-property option to enable/disable goog.reflect.objectProperty() in JS output --- .../mxml/royale/MXMLDescriptorSpecifier.java | 29 +++++++++++++++------- .../codegen/mxml/royale/MXMLRoyaleEmitter.java | 6 +++-- .../driver/js/goog/JSGoogConfiguration.java | 19 ++++++++++++++ 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLDescriptorSpecifier.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLDescriptorSpecifier.java index eecca50..048cb93 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLDescriptorSpecifier.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLDescriptorSpecifier.java @@ -118,6 +118,8 @@ public class MXMLDescriptorSpecifier extends MXMLNodeSpecifier public MXMLDescriptorSpecifier parent; + public boolean useGoogReflectObjectProperty = false; + //-------------------------------------------------------------------------- // // Methods @@ -154,15 +156,24 @@ public class MXMLDescriptorSpecifier extends MXMLNodeSpecifier { if (isProperty) { - write(JSGoogEmitterTokens.GOOG_REFLECT_OBJECTPROPERTY); - write(ASEmitterTokens.PAREN_OPEN); - write(ASEmitterTokens.SINGLE_QUOTE); - write(name); - write(ASEmitterTokens.SINGLE_QUOTE); - write(ASEmitterTokens.COMMA); - write(ASEmitterTokens.SPACE); - write(ASEmitterTokens.THIS); - write(ASEmitterTokens.PAREN_CLOSE); + if(useGoogReflectObjectProperty) + { + write(JSGoogEmitterTokens.GOOG_REFLECT_OBJECTPROPERTY); + write(ASEmitterTokens.PAREN_OPEN); + write(ASEmitterTokens.SINGLE_QUOTE); + write(name); + write(ASEmitterTokens.SINGLE_QUOTE); + write(ASEmitterTokens.COMMA); + write(ASEmitterTokens.SPACE); + write(ASEmitterTokens.THIS); + write(ASEmitterTokens.PAREN_CLOSE); + } + else + { + write(ASEmitterTokens.SINGLE_QUOTE); + write(name); + write(ASEmitterTokens.SINGLE_QUOTE); + } } else { 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 32ab604..ffbd25b 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 @@ -38,7 +38,6 @@ import org.apache.commons.lang.StringEscapeUtils; import org.apache.royale.abc.ABCConstants; import org.apache.royale.abc.instructionlist.InstructionList; import org.apache.royale.abc.semantics.Instruction; -import org.apache.royale.abc.semantics.MethodInfo; import org.apache.royale.abc.semantics.Name; import org.apache.royale.abc.semantics.Namespace; import org.apache.royale.abc.semantics.OneOperandInstruction; @@ -2114,7 +2113,7 @@ public class MXMLRoyaleEmitter extends MXMLEmitter implements if (instanceId != null) { indentPush(); - writeNewline("/** @export */"); + writeNewline("/** @export */"); writeNewline(instanceId + ": {"); writeNewline("/** @this {" + formattedCName + "} */"); indentPush(); @@ -2844,6 +2843,8 @@ public class MXMLRoyaleEmitter extends MXMLEmitter implements if (isStateDependent(node, null)) return; + + RoyaleJSProject project = (RoyaleJSProject)getMXMLWalker().getProject(); IDefinition cdef = node.getDefinition(); @@ -2853,6 +2854,7 @@ public class MXMLRoyaleEmitter extends MXMLEmitter implements MXMLDescriptorSpecifier currentPropertySpecifier = new MXMLDescriptorSpecifier(); currentPropertySpecifier.isProperty = true; + currentPropertySpecifier.useGoogReflectObjectProperty = project.config.getMxmlReflectObjectProperty(); currentPropertySpecifier.name = cdef != null ? cdef.getQualifiedName() : node.getName(); currentPropertySpecifier.parent = currentInstance; diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java index 9942bd0..d06475c 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/driver/js/goog/JSGoogConfiguration.java @@ -446,6 +446,25 @@ public class JSGoogConfiguration extends JSConfiguration exportProtectedSymbols = value; } + // + // 'mxml-reflect-object-property' + // + + private boolean mxmlReflectObjectProperty = true; + + public boolean getMxmlReflectObjectProperty() + { + return mxmlReflectObjectProperty; + } + + @Config + @Mapping("mxml-reflect-object-property") + public void setMxmlReflectObjectProperty(ConfigurationValue cv, boolean value) + throws ConfigurationException + { + mxmlReflectObjectProperty = value; + } + // // 'warn-public-vars'
