playerglobal-source-gen: fix issue where XML/XMLList methods should accept * instead of a specific type
The docs here are wrong and don't match the compiler behavior
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 88f1449..5d0ae34 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,10 @@
}
private static final List<String> VECTOR_SUFFIXES = Arrays.asList("$double", "$int", "$uint", "$object");
+ 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",
+ "setNamespace");
private File sourceFolder;
private File targetFolder;
@@ -958,10 +962,18 @@
}
}
+ private boolean isXMLMethodThatNeedsParamsTypedAsAny(String contextClassName, String contextFunctionName) {
+ if (!"XML".equals(contextClassName) && !"XMLList".equals(contextClassName)) {
+ return false;
+ }
+ return XML_ANY_METHODS.contains(contextFunctionName);
+ }
+
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 forceAnyType = isXMLMethodThatNeedsParamsTypedAsAny(contextClassName, contextFunctionName);
for (int i = 0; i < apiParamElements.size(); i++) {
if (i > 0) {
functionBuilder.append(", ");
@@ -990,6 +1002,9 @@
paramType = apiOperationClassifierElement.getTextTrim();
paramType = paramType.replace(":", ".");
}
+ if (forceAnyType) {
+ paramType = "*";
+ }
if (paramType != null) {
functionBuilder.append(":");
functionBuilder.append(paramType);