This is an automated email from the ASF dual-hosted git repository. aharui 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 2be08f7 Closure Compiler does not like our custom namespace output format that uses bracket syntax, so reformat the names so we don't need brackets. This should also let the debugger call stacks show the decorated name of the identifier, which will make the call stacks make more sense 2be08f7 is described below commit 2be08f7cc99a7aca2e48cf69985b138bb5a71800 Author: Alex Harui <aha...@apache.org> AuthorDate: Wed Dec 26 17:49:04 2018 -0800 Closure Compiler does not like our custom namespace output format that uses bracket syntax, so reformat the names so we don't need brackets. This should also let the debugger call stacks show the decorated name of the identifier, which will make the call stacks make more sense --- .../codegen/typedefs/TypedefsTestUtils.java | 1 - .../internal/codegen/js/jx/AccessorEmitter.java | 28 +++++++++++----------- .../internal/codegen/js/jx/IdentifierEmitter.java | 6 ++--- .../internal/codegen/js/jx/SuperCallEmitter.java | 16 +++---------- .../codegen/js/royale/JSRoyaleEmitter.java | 18 ++++++++++++-- .../codegen/js/royale/TestRoyaleAccessors.java | 8 +++---- .../codegen/js/royale/TestRoyaleClass.java | 12 +++++----- .../codegen/js/royale/TestRoyaleExpressions.java | 6 ++--- .../codegen/js/royale/TestRoyaleFieldMembers.java | 2 +- .../codegen/js/royale/TestRoyaleMethodMembers.java | 2 +- 10 files changed, 51 insertions(+), 48 deletions(-) diff --git a/compiler-externc/src/test/java/org/apache/royale/compiler/internal/codegen/typedefs/TypedefsTestUtils.java b/compiler-externc/src/test/java/org/apache/royale/compiler/internal/codegen/typedefs/TypedefsTestUtils.java index 87daab5..0378c14 100644 --- a/compiler-externc/src/test/java/org/apache/royale/compiler/internal/codegen/typedefs/TypedefsTestUtils.java +++ b/compiler-externc/src/test/java/org/apache/royale/compiler/internal/codegen/typedefs/TypedefsTestUtils.java @@ -174,7 +174,6 @@ public class TypedefsTestUtils config.addTypedef(coreRoot + "/browser/whatwg_encoding.js"); - config.addTypedef(coreRoot + "/browser/chrome.js"); //config.addTypedef(coreRoot + "/browser/fetchapi.js"); config.addTypedef(coreRoot + "/browser/fileapi.js"); config.addTypedef(coreRoot + "/browser/flash.js"); diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java index 8f5bdce..428f542 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java @@ -117,7 +117,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + propName + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(s, propName, true)); } else { @@ -143,7 +143,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + JSRoyaleEmitterTokens.GETTER_PREFIX.getToken() + propName + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(s, JSRoyaleEmitterTokens.GETTER_PREFIX.getToken() + propName, true)); } else { @@ -205,7 +205,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + JSRoyaleEmitterTokens.SETTER_PREFIX.getToken() + propName + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(s, JSRoyaleEmitterTokens.SETTER_PREFIX.getToken() + propName, true)); } else { @@ -331,7 +331,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("\"" + s + "::" + propName + "\""); + write(JSRoyaleEmitter.formatNamespacedProperty(s, propName, false)); } else write(propName); @@ -353,7 +353,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + JSRoyaleEmitterTokens.GETTER_PREFIX.getToken() + propName + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(s, JSRoyaleEmitterTokens.GETTER_PREFIX.getToken() + propName, true)); } else { @@ -386,7 +386,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + JSRoyaleEmitterTokens.GETTER_PREFIX.getToken() + propName + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(s, JSRoyaleEmitterTokens.GETTER_PREFIX.getToken() + propName, true)); } else { @@ -414,7 +414,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + JSRoyaleEmitterTokens.SETTER_PREFIX.getToken() + propName + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(s, JSRoyaleEmitterTokens.SETTER_PREFIX.getToken() + propName, true)); } else { @@ -448,7 +448,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + JSRoyaleEmitterTokens.SETTER_PREFIX.getToken() + propName + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(s, JSRoyaleEmitterTokens.SETTER_PREFIX.getToken() + propName, true)); } else { @@ -493,7 +493,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + propName + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(s, propName, true)); } else { @@ -516,7 +516,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + JSRoyaleEmitterTokens.GETTER_PREFIX.getToken() + propName + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(s, JSRoyaleEmitterTokens.GETTER_PREFIX.getToken() + propName, true)); } else { @@ -546,7 +546,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + JSRoyaleEmitterTokens.SETTER_PREFIX.getToken() + propName + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(s, JSRoyaleEmitterTokens.SETTER_PREFIX.getToken() + propName, true)); } else { @@ -622,7 +622,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + JSRoyaleEmitterTokens.GETTER_PREFIX.getToken() + propName + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(s, JSRoyaleEmitterTokens.GETTER_PREFIX.getToken() + propName, true)); } else { @@ -646,7 +646,7 @@ public class AccessorEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + JSRoyaleEmitterTokens.SETTER_PREFIX.getToken() + propName + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(s, JSRoyaleEmitterTokens.SETTER_PREFIX.getToken() + propName, true)); } else { @@ -663,7 +663,7 @@ public class AccessorEmitter extends JSSubEmitter implements } } - public void emitGet(IGetterNode node) + public void emitGet(IGetterNode node) { // TODO (mschmalle) will remove this cast as more things get abstracted JSRoyaleEmitter fjs = (JSRoyaleEmitter) getEmitter(); diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java index f058c17..b7dbe46 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java @@ -240,7 +240,7 @@ public class IdentifierEmitter extends JSSubEmitter implements INamespaceDefinition nsDef = ((FunctionDefinition)nodeDef).getNamespaceReference().resolveNamespaceReference(getProject()); fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String nsName = ns.getName(); - write("[\"" + nsName + "::" + node.getName() + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(nsName, node.getName(), true)); } else { @@ -310,7 +310,7 @@ public class IdentifierEmitter extends JSSubEmitter implements else if (isCustomNamespace) { String ns = ((INamespaceResolvedReference)((FunctionDefinition)nodeDef).getNamespaceReference()).resolveAETNamespace(getProject()).getName(); - write("[\"" + ns + "::" + qname + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(ns, qname, true)); } else if (identifierIsAccessorFunction && isStatic) { @@ -331,7 +331,7 @@ public class IdentifierEmitter extends JSSubEmitter implements else if (isCustomNamespace) { String ns = ((INamespaceResolvedReference)((FunctionDefinition)nodeDef).getNamespaceReference()).resolveAETNamespace(getProject()).getName(); - write("[\"" + ns + "::" + qname + "\"]"); + write(JSRoyaleEmitter.formatNamespacedProperty(ns, qname, true)); } else if (identifierIsAccessorFunction && isStatic) { diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/SuperCallEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/SuperCallEmitter.java index 02f6972..510de7a 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/SuperCallEmitter.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/SuperCallEmitter.java @@ -204,7 +204,6 @@ public class SuperCallEmitter extends JSSubEmitter } boolean usingApply = false; - boolean isCustomNamespace = false; if (fnode != null && !fnode.isConstructor()) { write(ASEmitterTokens.MEMBER_ACCESS); @@ -226,21 +225,12 @@ public class SuperCallEmitter extends JSSubEmitter if (nsDef.getContainingScope() != null) // was null for flash_proxy in unit test fjs.formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - superName = s + "::" + superName; - isCustomNamespace = true; - } - if (isCustomNamespace) - { - write(ASEmitterTokens.SQUARE_OPEN); - write(ASEmitterTokens.SINGLE_QUOTE); + write(JSRoyaleEmitter.formatNamespacedProperty(s, superName, true)); } else - write(ASEmitterTokens.MEMBER_ACCESS); - write(superName); - if (isCustomNamespace) { - write(ASEmitterTokens.SINGLE_QUOTE); - write(ASEmitterTokens.SQUARE_CLOSE); + write(ASEmitterTokens.MEMBER_ACCESS); + write(superName); } write(ASEmitterTokens.MEMBER_ACCESS); write(JSEmitterTokens.APPLY); diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java index 66df48a..ef24712 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java @@ -27,6 +27,7 @@ import java.util.List; import org.apache.commons.io.FileUtils; import org.apache.royale.compiler.codegen.js.royale.IJSRoyaleEmitter; +import org.apache.royale.compiler.codegen.IEmitterTokens; import org.apache.royale.compiler.codegen.js.goog.IJSGoogDocEmitter; import org.apache.royale.compiler.constants.IASKeywordConstants; import org.apache.royale.compiler.constants.IASLanguageConstants; @@ -534,7 +535,7 @@ public class JSRoyaleEmitter extends JSGoogEmitter implements IJSRoyaleEmitter INamespaceDefinition nsDef = (INamespaceDefinition)ns.resolve(project); formatQualifiedName(nsDef.getQualifiedName()); // register with used names String s = nsDef.getURI(); - write("[\"" + s + "::" + node.getName() + "\"]"); + write(formatNamespacedProperty(s, node.getName(), true)); return; } } @@ -545,7 +546,20 @@ public class JSRoyaleEmitter extends JSGoogEmitter implements IJSRoyaleEmitter write(qname); } - @Override + public static String formatNamespacedProperty(String s, String propName, boolean access) { + //closure compiler choked on this syntax so stop using bracket notation for now + //if (access) return "[\"" + s + "::" + propName + "\"]"; + //return "\"" + s + "::" + propName + "\""; + s = s.replace(":", "_"); + s = s.replace(".", "_"); + s = s.replace("/", "$"); + s += "__" + propName; + if (access) + s = ASEmitterTokens.MEMBER_ACCESS.getToken() + s; + return s; + } + + @Override public String formatQualifiedName(String name) { return formatQualifiedName(name, false); diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessors.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessors.java index af854af..8e7a8c7 100644 --- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessors.java +++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleAccessors.java @@ -106,10 +106,10 @@ public class TestRoyaleAccessors extends ASTestBase "import custom.custom_namespace;use namespace custom_namespace;public class B { public function B() {}; public function doStuff():void {var theLabel:String = label; label = theLabel;}; private var _label:String; custom_namespace function get label():String {return _label}; custom_namespace function set label(value:String):void {_label = value};}", IClassNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitClass(node); - String expected = "/**\n * @constructor\n */\nB = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('B', B);\n\n\n/**\n * @export\n */\nB.prototype.doStuff = function() {\n var /** @type {string} */ theLabel = this[\"http://ns.apache.org/2017/custom/namespace::label\"];\n this[\"http://ns.apache.org/2017/custom/namespace::label\"] = theLabel;\n};\n\n\n/**\n * @private\n * @type {string}\n */\nB.prototype._label;\n\n\n" + - "B.prototype[\"http://ns.apache.org/2017/custom/namespace::get__label\"] = function() {\n return this._label;\n};\n\n\n" + - "B.prototype[\"http://ns.apache.org/2017/custom/namespace::set__label\"] = function(value) {\n this._label = value;\n};\n\n\n" + - "Object.defineProperties(B.prototype, /** @lends {B.prototype} */ {\n/**\n * @export\n * @type {string} */\n\"http://ns.apache.org/2017/custom/namespace::label\": {\nget: B.prototype[\"http://ns.apache.org/2017/custom/namespace::get__label\"],\nset: B.prototype[\"http://ns.apache.org/2017/custom/namespace::set__label\"]}}\n);"; + String expected = "/**\n * @constructor\n */\nB = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('B', B);\n\n\n/**\n * @export\n */\nB.prototype.doStuff = function() {\n var /** @type {string} */ theLabel = this.http_$$ns_apache_org$2017$custom$namespace__label;\n this.http_$$ns_apache_org$2017$custom$namespace__label = theLabel;\n};\n\n\n/**\n * @private\n * @type {string}\n */\nB.prototype._label;\n\n\n" + + "B.prototype.http_$$ns_apache_org$2017$custom$namespace__get__label = function() {\n return this._label;\n};\n\n\n" + + "B.prototype.http_$$ns_apache_org$2017$custom$namespace__set__label = function(value) {\n this._label = value;\n};\n\n\n" + + "Object.defineProperties(B.prototype, /** @lends {B.prototype} */ {\n/**\n * @export\n * @type {string} */\nhttp_$$ns_apache_org$2017$custom$namespace__label: {\nget: B.prototype.http_$$ns_apache_org$2017$custom$namespace__get__label,\nset: B.prototype.http_$$ns_apache_org$2017$custom$namespace__set__label}}\n);"; assertOut(expected); } diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java index f223030..f496a4e 100644 --- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java +++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleClass.java @@ -198,7 +198,7 @@ public class TestRoyaleClass extends TestGoogClass { IClassNode node = getClassNode("import custom.custom_namespace; use namespace custom_namespace; public class B {public function B() {}; custom_namespace function foo():void {};}"); asBlockWalker.visitClass(node); - String expected = "/**\n * @constructor\n */\norg.apache.royale.B = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('org.apache.royale.B', org.apache.royale.B);\n\n\n/**\n */\norg.apache.royale.B.prototype[\"http://ns.apache.org/2017/custom/namespace::foo\"] = function() {\n};"; + String expected = "/**\n * @constructor\n */\norg.apache.royale.B = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('org.apache.royale.B', org.apache.royale.B);\n\n\n/**\n */\norg.apache.royale.B.prototype.http_$$ns_apache_org$2017$custom$namespace__foo = function() {\n};"; assertOut(expected); } @@ -509,15 +509,15 @@ public class TestRoyaleClass extends TestGoogClass "org.apache.royale.A.prototype.set__foo3 = function(value) {\n};\n\n\n" + "org.apache.royale.A.prototype.get__foo5 = function() {\n return null;\n};\n\n\n" + "org.apache.royale.A.prototype.set__foo5 = function(value) {\n};\n\n\n" + - "org.apache.royale.A.prototype[\"http://ns.apache.org/2017/custom/namespace::get__foo6\"] = function() {\n return null;\n};\n\n\n" + - "org.apache.royale.A.prototype[\"http://ns.apache.org/2017/custom/namespace::set__foo6\"] = function(value) {\n};\n\n\n" + + "org.apache.royale.A.prototype.http_$$ns_apache_org$2017$custom$namespace__get__foo6 = function() {\n return null;\n};\n\n\n" + + "org.apache.royale.A.prototype.http_$$ns_apache_org$2017$custom$namespace__set__foo6 = function(value) {\n};\n\n\n" + "Object.defineProperties(org.apache.royale.A.prototype, /** @lends {org.apache.royale.A.prototype} */ {\n/**\n * @export\n * @type {Object} */\n" + "foo1: {\nget: org.apache.royale.A.prototype.get__foo1,\nset: org.apache.royale.A.prototype.set__foo1},\n/**\n * @export\n * @type {Object} */\n" + "foo2: {\nget: org.apache.royale.A.prototype.get__foo2,\nset: org.apache.royale.A.prototype.set__foo2},\n/**\n * @export\n * @type {Object} */\n" + "foo3: {\nget: org.apache.royale.A.prototype.get__foo3,\nset: org.apache.royale.A.prototype.set__foo3},\n/**\n * @export\n * @type {Object} */\n" + "foo5: {\nget: org.apache.royale.A.prototype.get__foo5,\nset: org.apache.royale.A.prototype.set__foo5},\n/**\n * @export\n * @type {Object} */\n" + - "\"http://ns.apache.org/2017/custom/namespace::foo6\": {\nget: org.apache.royale.A.prototype[\"http://ns.apache.org/2017/custom/namespace::get__foo6\"],\n" + - "set: org.apache.royale.A.prototype[\"http://ns.apache.org/2017/custom/namespace::set__foo6\"]}}\n);"); + "http_$$ns_apache_org$2017$custom$namespace__foo6: {\nget: org.apache.royale.A.prototype.http_$$ns_apache_org$2017$custom$namespace__get__foo6,\n" + + "set: org.apache.royale.A.prototype.http_$$ns_apache_org$2017$custom$namespace__set__foo6}}\n);"); } @Override @@ -535,7 +535,7 @@ public class TestRoyaleClass extends TestGoogClass + "public static function foo7(value:Object):void{}" + "custom_namespace static function foo7(value:Object):void{}" + "}"); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('org.apache.royale.A', org.apache.royale.A);\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.royale.A.prototype.foo1 = function() {\n return null;\n};\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.royale.A.prototype.foo1a = function() {\n return null;\n};\n\n\n/**\n * @export\n * @override\n * [...] + assertOut("/**\n * @constructor\n */\norg.apache.royale.A = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('org.apache.royale.A', org.apache.royale.A);\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.royale.A.prototype.foo1 = function() {\n return null;\n};\n\n\n/**\n * @export\n * @return {Object}\n */\norg.apache.royale.A.prototype.foo1a = function() {\n return null;\n};\n\n\n/**\n * @export\n * @override\n * [...] } @Test diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java index 399c93e..bf9d38a 100644 --- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java +++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java @@ -130,7 +130,7 @@ public class TestRoyaleExpressions extends TestGoogExpressions IFunctionNode node = (IFunctionNode)getNode("import custom.TestProxy;import custom.custom_namespace;use namespace custom_namespace;public class RoyaleTest_A extends TestProxy { custom_namespace function foo(){if (a) super.setProperty(a, b);}}", IFunctionNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitFunction(node); - assertOut("/**\n */\nRoyaleTest_A.prototype[\"http://ns.apache.org/2017/custom/namespace::foo\"] = function() {\n if (a)\n RoyaleTest_A.superClass_['http://ns.apache.org/2017/custom/namespace::setProperty'].apply(this, [ a, b] );\n}"); + assertOut("/**\n */\nRoyaleTest_A.prototype.http_$$ns_apache_org$2017$custom$namespace__foo = function() {\n if (a)\n RoyaleTest_A.superClass_.http_$$ns_apache_org$2017$custom$namespace__setProperty.apply(this, [ a, b] );\n}"); } @Test @@ -903,7 +903,7 @@ public class TestRoyaleExpressions extends TestGoogExpressions "import custom.custom_namespace; use namespace custom_namespace;public class B {custom_namespace function b() { function c(f:Function):void {}; var f:Function = b; c(f); }}", IFunctionNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitFunction(node); - assertOut("/**\n */\nB.prototype[\"http://ns.apache.org/2017/custom/namespace::b\"] = function() {\n var self = this;\n function c(f) {\n };\n var /** @type {Function} */ f = org.apache.royale.utils.Language.closure(this[\"http://ns.apache.org/2017/custom/namespace::b\"], this, 'http://ns.apache.org/2017/custom/namespace::b');\n c(f);\n}"); + assertOut("/**\n */\nB.prototype.http_$$ns_apache_org$2017$custom$namespace__b = function() {\n var self = this;\n function c(f) {\n };\n var /** @type {Function} */ f = org.apache.royale.utils.Language.closure(this.http_$$ns_apache_org$2017$custom$namespace__b, this, 'http://ns.apache.org/2017/custom/namespace::b');\n c(f);\n}"); } @Test @@ -913,7 +913,7 @@ public class TestRoyaleExpressions extends TestGoogExpressions "import custom.custom_namespace; use namespace custom_namespace;public class B {custom_namespace function b():int { return this.b(); }}", IFunctionNode.class, WRAP_LEVEL_PACKAGE); asBlockWalker.visitFunction(node); - assertOut("/**\n * @return {number}\n */\nB.prototype[\"http://ns.apache.org/2017/custom/namespace::b\"] = function() {\n return this[\"http://ns.apache.org/2017/custom/namespace::b\"]();\n}"); + assertOut("/**\n * @return {number}\n */\nB.prototype.http_$$ns_apache_org$2017$custom$namespace__b = function() {\n return this.http_$$ns_apache_org$2017$custom$namespace__b();\n}"); } @Test diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFieldMembers.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFieldMembers.java index ea844f8..ca03475 100644 --- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFieldMembers.java +++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleFieldMembers.java @@ -185,7 +185,7 @@ public class TestRoyaleFieldMembers extends TestGoogFieldMembers IClassNode node = (IClassNode) getNode("import custom.custom_namespace;use namespace custom_namespace;public static var foo:Object = initFoo(); custom_namespace static function initFoo():Object { return null; }", IClassNode.class, WRAP_LEVEL_CLASS); asBlockWalker.visitClass(node); - assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('RoyaleTest_A', RoyaleTest_A);\n\n\n/**\n * @export\n * @type {Object}\n */\nRoyaleTest_A.foo;\n\n\n/**\n * @return {Object}\n */\nRoyaleTest_A[\"http://ns.apache.org/2017/custom/namespace::initFoo\"] = function() {\n return null;\n};\n\nRoyaleTest_A.foo = RoyaleTest_A[\"http://ns.apache.org/2017/custom/namespace::initFoo\"] [...] + assertOut("/**\n * @constructor\n */\nRoyaleTest_A = function() {\n};\n\n\n/**\n * Prevent renaming of class. Needed for reflection.\n */\ngoog.exportSymbol('RoyaleTest_A', RoyaleTest_A);\n\n\n/**\n * @export\n * @type {Object}\n */\nRoyaleTest_A.foo;\n\n\n/**\n * @return {Object}\n */\nRoyaleTest_A.http_$$ns_apache_org$2017$custom$namespace__initFoo = function() {\n return null;\n};\n\nRoyaleTest_A.foo = RoyaleTest_A.http_$$ns_apache_org$2017$custom$namespace__initFoo();\n\n"); } @Test diff --git a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleMethodMembers.java b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleMethodMembers.java index f05f4bc..dc251a3 100644 --- a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleMethodMembers.java +++ b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleMethodMembers.java @@ -100,7 +100,7 @@ public class TestRoyaleMethodMembers extends TestGoogMethodMembers { IFunctionNode node = getMethod("import custom.custom_namespace;custom_namespace function foo(bar:String, baz:int = null):int{ return -1;}"); asBlockWalker.visitFunction(node); - assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nRoyaleTest_A.prototype[\"http://ns.apache.org/2017/custom/namespace::foo\"] = function(bar, baz) {\n baz = typeof baz !== 'undefined' ? baz : null;\n return -1;\n}"); + assertOut("/**\n * @param {string} bar\n * @param {number=} baz\n * @return {number}\n */\nRoyaleTest_A.prototype.http_$$ns_apache_org$2017$custom$namespace__foo = function(bar, baz) {\n baz = typeof baz !== 'undefined' ? baz : null;\n return -1;\n}"); } //--------------------------------------------------------------------------