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/19 00:02:46 UTC
[royale-compiler] branch develop updated: playerglobal-source-gen:
constructors for built-ins should be forced to be optional
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 8461535 playerglobal-source-gen: constructors for built-ins should be forced to be optional
8461535 is described below
commit 846153597d83ef6e43585c74d274c719104c6640
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Feb 18 16:02:39 2021 -0800
playerglobal-source-gen: constructors for built-ins should be forced to be optional
---
.../apache/royale/playerglobal/PlayerglobalSourceGen.java | 15 ++++++++++++---
1 file changed, 12 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 4da3a3d..b24a11d 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
@@ -70,6 +70,8 @@ class PlayerglobalSourceGen {
//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> ANY_CONSTRUCTORS = Arrays.asList("Boolean", "Date", "int", "Number", "RegExp",
+ "String", "uint", "XML", "XMLList");
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",
@@ -966,6 +968,13 @@ class PlayerglobalSourceGen {
}
}
+ private boolean isConstructorThatNeedsParamsTypedAsAny(String contextClassName, String contextFunctionName) {
+ if (!contextFunctionName.equals(contextClassName)) {
+ return false;
+ }
+ return ANY_CONSTRUCTORS.contains(contextFunctionName);
+ }
+
private boolean isXMLMethodThatNeedsParamsTypedAsAny(String contextClassName, String contextFunctionName) {
if (!"XML".equals(contextClassName) && !"XMLList".equals(contextClassName)) {
return false;
@@ -975,8 +984,8 @@ class PlayerglobalSourceGen {
private void parseParameters(List<Element> apiParamElements, String contextClassName, String contextFunctionName,
StringBuilder functionBuilder) throws Exception {
- boolean isXMLConstructor = ("XML".equals(contextClassName) && "XML".equals(contextFunctionName))
- || ("XMLList".equals(contextClassName) && "XMLList".equals(contextFunctionName));
+ boolean forceOptionalConstructor = isConstructorThatNeedsParamsTypedAsAny(contextClassName,
+ contextFunctionName);
boolean forceAnyType = isXMLMethodThatNeedsParamsTypedAsAny(contextClassName, contextFunctionName);
for (int i = 0; i < apiParamElements.size(); i++) {
if (i > 0) {
@@ -997,7 +1006,7 @@ class PlayerglobalSourceGen {
throw new Exception("apiItemName not found");
}
functionBuilder.append(apiItemNameElement.getTextTrim());
- if (isXMLConstructor) {
+ if (forceOptionalConstructor) {
//workaround for missing data in asdoc dita
functionBuilder.append(":* = null");
} else {