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 2021/02/18 23:15:23 UTC

[royale-compiler] 08/08: playerglobal-source-gen: object methods on prototype

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 2c48598960a796937351884126a2c0df7f9fca1c
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Feb 18 14:06:23 2021 -0800

    playerglobal-source-gen: object methods on prototype
---
 .../org/apache/royale/playerglobal/PlayerglobalSourceGen.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java b/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
index 5d0ae34..4da3a3d 100644
--- a/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
+++ b/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
@@ -67,6 +67,9 @@ class PlayerglobalSourceGen {
 	}
 
 	private static final List<String> VECTOR_SUFFIXES = Arrays.asList("$double", "$int", "$uint", "$object");
+	//From the docs: Methods of the Object class are dynamically created on Object's prototype.
+	private static final List<String> OBJECT_PROTOTYPE_METHODS = Arrays.asList("hasOwnProperty", "isPrototypeOf",
+			"propertyIsEnumerable", "setPropertyIsEnumerable", "toString", "toLocaleString", "valueOf");
 	private static final List<String> XML_ANY_METHODS = Arrays.asList("addNamespace", "appendChild", "attribute",
 			"child", "contains", "descendants", "elements", "insertChildAfter", "insertChildBefore", "namespace",
 			"prependChild", "processingInstructions", "removeNamespace", "replace", "setChildren", "setName",
@@ -728,9 +731,10 @@ class PlayerglobalSourceGen {
 
 		List<Element> apiParamElements = apiOperationDefElement.elements("apiParam");
 
-		if ("public".equals(access) && ("toString".equals(functionName) || "toLocaleString".equals(functionName))
-				|| "valueOf".equals(functionName) || "hasOwnProperty".equals(functionName)
-				|| "propertyIsEnumerable".equals(functionName)) {
+		if ("Object".equals(contextClassName) && OBJECT_PROTOTYPE_METHODS.contains(functionName)) {
+			return;
+		}
+		if ("toString".equals(functionName) && isOverride) {
 			return;
 		}