You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2020/12/23 21:46:52 UTC

[royale-compiler] branch develop updated: FieldEmitteR: uses Object.defineProperties() instead of Object.defineProperty() for fields with complex initializers because it plays nicer with Closure renaming (closes #169) (closes apache/royale-asjs#408) (closes apache/royale-asjs#831) (references matrix3d/spriteflexjs#21)

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 472c934  FieldEmitteR: uses Object.defineProperties() instead of Object.defineProperty() for fields with complex initializers because it plays nicer with Closure renaming (closes #169) (closes apache/royale-asjs#408) (closes apache/royale-asjs#831) (references matrix3d/spriteflexjs#21)
472c934 is described below

commit 472c934fd34423d79b37c328324ba3c42f28065a
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Wed Dec 23 13:38:48 2020 -0800

    FieldEmitteR: uses Object.defineProperties() instead of Object.defineProperty() for fields with complex initializers because it plays nicer with Closure renaming (closes #169) (closes apache/royale-asjs#408) (closes apache/royale-asjs#831) (references matrix3d/spriteflexjs#21)
---
 .../compiler/internal/codegen/js/jx/FieldEmitter.java  | 18 +++++++++---------
 .../codegen/mxml/royale/TestRoyaleMXMLScript.java      |  6 +++---
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FieldEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FieldEmitter.java
index 7e81916..6a056bb 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FieldEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FieldEmitter.java
@@ -183,18 +183,18 @@ public class FieldEmitter extends JSSubEmitter implements
                 writeNewline(ASEmitterTokens.SEMICOLON);
                 write(IASLanguageConstants.Object);
                 write(ASEmitterTokens.MEMBER_ACCESS);
-                write(JSEmitterTokens.DEFINE_PROPERTY);
+                write(JSEmitterTokens.DEFINE_PROPERTIES);
                 write(ASEmitterTokens.PAREN_OPEN);
                 write(className);
                 writeToken(ASEmitterTokens.COMMA);
-                write(ASEmitterTokens.SINGLE_QUOTE);
+                writeToken(ASEmitterTokens.BLOCK_OPEN);
 	            writeFieldName(node, fjs);
-                write(ASEmitterTokens.SINGLE_QUOTE);
-                writeToken(ASEmitterTokens.COMMA);
+                writeToken(ASEmitterTokens.COLON);
                 if (node.isConst())
                 	write("{ value: value, writable: false }");
                 else
-                	write("{ value: value, writable: true }");
+                    write("{ value: value, writable: true }");
+                write(ASEmitterTokens.BLOCK_CLOSE);
                 write(ASEmitterTokens.PAREN_CLOSE);
                 writeNewline(ASEmitterTokens.SEMICOLON);
                 writeToken(ASEmitterTokens.RETURN);
@@ -217,15 +217,15 @@ public class FieldEmitter extends JSSubEmitter implements
 	                writeNewline(ASEmitterTokens.BLOCK_OPEN, true);
 	                write(IASLanguageConstants.Object);
 	                write(ASEmitterTokens.MEMBER_ACCESS);
-	                write(JSEmitterTokens.DEFINE_PROPERTY);
+	                write(JSEmitterTokens.DEFINE_PROPERTIES);
 	                write(ASEmitterTokens.PAREN_OPEN);
 	                write(className);
 	                writeToken(ASEmitterTokens.COMMA);
-	                write(ASEmitterTokens.SINGLE_QUOTE);
+                    writeToken(ASEmitterTokens.BLOCK_OPEN);
 		            writeFieldName(node, fjs);
-	                write(ASEmitterTokens.SINGLE_QUOTE);
-	                writeToken(ASEmitterTokens.COMMA);
+	                writeToken(ASEmitterTokens.COLON);
 	                write("{ value: value, writable: true }");
+                    write(ASEmitterTokens.BLOCK_CLOSE);
 	                write(ASEmitterTokens.PAREN_CLOSE);
 	                indentPop();
 	                writeNewline(ASEmitterTokens.SEMICOLON);
diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLScript.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLScript.java
index cfd5acf..2cea553 100644
--- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLScript.java
+++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLScript.java
@@ -370,11 +370,11 @@ public class TestRoyaleMXMLScript extends RoyaleTestBase
 				"\n" +
 				"AppName.get__foo = function() {\n" +
 				"  var value = org.apache.royale.events.CloseEvent.CLOSE;\n" +
-				"  Object.defineProperty(AppName, 'foo', { value: value, writable: true });\n" +
+				"  Object.defineProperties(AppName, { foo: { value: value, writable: true }});\n" +
 				"  return value;\n" +
 				"};\n" +
 				"AppName.set__foo = function(value) {\n" +
-				"  Object.defineProperty(AppName, 'foo', { value: value, writable: true });\n" +
+				"  Object.defineProperties(AppName, { foo: { value: value, writable: true }});\n" +
 				"};\n" +
 				"/**\n" +
 				" * @type {string}\n" +
@@ -668,7 +668,7 @@ public class TestRoyaleMXMLScript extends RoyaleTestBase
 				"\n" +
 				"AppName.get__foo = function() {\n" +
 				"  var value = org.apache.royale.events.CloseEvent.CLOSE;\n" +
-				"  Object.defineProperty(AppName, 'foo', { value: value, writable: false });\n" +
+				"  Object.defineProperties(AppName, { foo: { value: value, writable: false }});\n" +
 				"  return value;\n" +
 				"};\n" +
 				"/**\n" +