Return-Path: X-Original-To: apmail-incubator-flex-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-flex-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1625A9E40 for ; Fri, 21 Dec 2012 22:38:57 +0000 (UTC) Received: (qmail 82952 invoked by uid 500); 21 Dec 2012 22:38:56 -0000 Delivered-To: apmail-incubator-flex-commits-archive@incubator.apache.org Received: (qmail 82920 invoked by uid 500); 21 Dec 2012 22:38:56 -0000 Mailing-List: contact flex-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: flex-dev@incubator.apache.org Delivered-To: mailing list flex-commits@incubator.apache.org Received: (qmail 82912 invoked by uid 99); 21 Dec 2012 22:38:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Dec 2012 22:38:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Dec 2012 22:38:52 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1588E238896F; Fri, 21 Dec 2012 22:38:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1425170 - in /incubator/flex/falcon/trunk: compiler.tests/feature-tests/mxml/tags/ compiler/src/org/apache/flex/compiler/internal/as/codegen/ compiler/src/org/apache/flex/compiler/internal/tree/mxml/ Date: Fri, 21 Dec 2012 22:38:30 -0000 To: flex-commits@incubator.apache.org From: gordonsmith@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121221223831.1588E238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gordonsmith Date: Fri Dec 21 22:38:30 2012 New Revision: 1425170 URL: http://svn.apache.org/viewvc?rev=1425170&view=rev Log: Falcon feature tests: Added a feature test for the tag. It appears that Falcon doesn't automatically keep such metadata; you have to use -keep-as3-metadata if it isn't one of the types like Event and Style that are kept by default. This is probably a bug. Made it possible to pass additional compilation options like -keep-as3-metadata when compiling feature tests. Added: incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLMetadataTagTests.java (with props) Modified: incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLHTTPServiceTagTests.java incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLIntTagTests.java incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLRemoteObjectTagTests.java incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLWebServiceTagTests.java incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLArrayNode.java Modified: incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java?rev=1425170&r1=1425169&r2=1425170&view=diff ============================================================================== --- incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java (original) +++ incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLFeatureTestsBase.java Fri Dec 21 22:38:30 2012 @@ -63,7 +63,7 @@ public class MXMLFeatureTestsBase // The Ant script for compiler.tests copies a standalone player to the temp directory. private static final String FLASHPLAYER = FilenameNormalization.normalize("temp/FlashPlayer.exe"); - protected void compileAndRun(String mxml, boolean withFramework, boolean withRPC, boolean withSpark) + protected void compileAndRun(String mxml, boolean withFramework, boolean withRPC, boolean withSpark, String[] otherOptions) { // Write the MXML into a temp file. String tempDir = FilenameNormalization.normalize("temp"); @@ -101,16 +101,22 @@ public class MXMLFeatureTestsBase } String libraryPath = "-library-path=" + StringUtils.join(swcs.toArray(new String[0]), ","); + List args = new ArrayList(); + args.add("-external-library-path=" + PLAYERGLOBAL_SWC); + args.add(libraryPath); + args.add("-namespace=" + NAMESPACE_2009 + "," + MANIFEST_2009); + if (otherOptions != null) + { + for (String otherOption : otherOptions) + { + args.add(otherOption); + } + } + args.add(tempMXMLFile.getAbsolutePath()); + // Use MXMLC to compile the MXML file against playerglobal.swc and possibly other SWCs. MXMLC mxmlc = new MXMLC(); - String[] args = new String[] - { - "-external-library-path=" + PLAYERGLOBAL_SWC, - libraryPath, - "-namespace=" + NAMESPACE_2009 + "," + MANIFEST_2009, - tempMXMLFile.getAbsolutePath() - }; - int exitCode = mxmlc.mainNoExit(args); + int exitCode = mxmlc.mainNoExit(args.toArray(new String[0])); // Check that there were no compilation problems. List problems = mxmlc.getProblems().getProblems(); @@ -125,10 +131,10 @@ public class MXMLFeatureTestsBase // Run the SWF in the standalone player amd wait until the SWF calls System.exit(). String swf = FilenameNormalization.normalize(tempMXMLFile.getAbsolutePath()); swf = swf.replace(".mxml", ".swf"); - args = new String[] { FLASHPLAYER, swf }; + String[] runArgs = new String[] { FLASHPLAYER, swf }; try { - Process process = Runtime.getRuntime().exec(args); + Process process = Runtime.getRuntime().exec(runArgs); process.waitFor(); exitCode = process.exitValue(); } @@ -143,6 +149,6 @@ public class MXMLFeatureTestsBase protected void compileAndRun(String mxml) { - compileAndRun(mxml, false, false, false); + compileAndRun(mxml, false, false, false, null); } } Modified: incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLHTTPServiceTagTests.java URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLHTTPServiceTagTests.java?rev=1425170&r1=1425169&r2=1425170&view=diff ============================================================================== --- incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLHTTPServiceTagTests.java (original) +++ incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLHTTPServiceTagTests.java Fri Dec 21 22:38:30 2012 @@ -71,6 +71,6 @@ public class MXMLHTTPServiceTagTests ext "assertEqual('hs1.method', hs1.method, 'POST');" }; String mxml = getMXML(declarations, asserts); - compileAndRun(mxml, true, true, false); + compileAndRun(mxml, true, true, false, null); } } Modified: incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLIntTagTests.java URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLIntTagTests.java?rev=1425170&r1=1425169&r2=1425170&view=diff ============================================================================== --- incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLIntTagTests.java (original) +++ incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLIntTagTests.java Fri Dec 21 22:38:30 2012 @@ -22,7 +22,7 @@ package mxml.tags; import org.junit.Test; /** - * Feature tests for the MXML [@code } tag. + * Feature tests for the MXML {@code } tag. * * @author Gordon Smith */ Added: incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLMetadataTagTests.java URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLMetadataTagTests.java?rev=1425170&view=auto ============================================================================== --- incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLMetadataTagTests.java (added) +++ incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLMetadataTagTests.java Fri Dec 21 22:38:30 2012 @@ -0,0 +1,141 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package mxml.tags; + +import org.apache.flex.utils.StringUtils; +import org.junit.Test; + +/** + * Feature tests for the MXML {@code } tag. + * + * @author Gordon Smith + */ +public class MXMLMetadataTagTests extends MXMLFeatureTestsBase +{ + /** + * Combines various code snippets to make a complete one-file MXML Sprite-based application. + */ + protected String getMXML(String[] metadata, String[] moreMetadata, String[] asserts) + { + String[] template = new String[] + { + "", + " %1", + " ", + " ", + " ", + " %2", + "" + }; + String mxml = StringUtils.join(template, "\n"); + mxml = mxml.replace("%1", StringUtils.join(metadata, "\n ")); + mxml = mxml.replace("%2", StringUtils.join(moreMetadata, "\n ")); + mxml = mxml.replace("%3", StringUtils.join(asserts, "\n ")); + return mxml; + } + + protected String getMXML(String[] metadata, String[] asserts) + { + return getMXML(metadata, new String[0], asserts); + } + + @Test + public void MXMLMetadataTag_oneTag() + { + String[] metadata = new String[] + { + "", + " [AAA(a1='1', a2='2')]", + "" + }; + String[] asserts = new String[] + { + // The tag should produce class-level metadata + // that we can inspect at runtime with describeType(). + // Inside the root tag returned by describeType() should be + // + // + // + // + "var dt:XML = describeType(this);", + "var aaa:XMLList = dt.metadata.(@name == 'AAA');", + "assertEqual('aaa.arg[0].@key.toString()', aaa.arg[0].@key.toString(), 'a1');", + "assertEqual('aaa.arg[0].@value.toString()', aaa.arg[0].@value.toString(), '1');", + "assertEqual('aaa.arg[1].@key.toString()', aaa.arg[1].@key.toString(), 'a2');", + "assertEqual('aaa.arg[1].@value.toString()', aaa.arg[1].@value.toString(), '2');", + }; + String mxml = getMXML(metadata, asserts); + String[] otherOptions = new String[] + { + "-keep-as3-metadata=AAA" // this should not be necessary; the old compiler seems to have kept all MXML metadata + }; + compileAndRun(mxml, false, false, false, otherOptions); + } + + @Test + public void MXMLMetadataTag_twoTags() + { + String[] metadata = new String[] + { + "", + " [AAA(a1='1')]", + "" + }; + String[] moreMetadata = new String[] + { + "", + " [BBB(b1='1')]", + "" + }; + String[] asserts = new String[] + { + "var dt:XML = describeType(this);", + "var aaa:XMLList = dt.metadata.(@name == 'AAA');", + "assertEqual('aaa.arg[0].@key.toString()', aaa.arg[0].@key.toString(), 'a1');", + "assertEqual('aaa.arg[0].@value.toString()', aaa.arg[0].@value.toString(), '1');", + "var bbb:XMLList = dt.metadata.(@name == 'BBB');", + "assertEqual('bbb.arg[0].@key.toString()', bbb.arg[0].@key.toString(), 'b1');", + "assertEqual('bbb.arg[0].@value.toString()', bbb.arg[0].@value.toString(), '1');", + }; + String mxml = getMXML(metadata, moreMetadata, asserts); + String[] otherOptions = new String[] + { + "-keep-as3-metadata=AAA,BBB" // this should not be necessary; the old compiler seems to have kept all MXML metadata + }; + compileAndRun(mxml, false, false, false, otherOptions); + } + + // TODO Add tests with CDATA, comments, entities, etc. +} Propchange: incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLMetadataTagTests.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLRemoteObjectTagTests.java URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLRemoteObjectTagTests.java?rev=1425170&r1=1425169&r2=1425170&view=diff ============================================================================== --- incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLRemoteObjectTagTests.java (original) +++ incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLRemoteObjectTagTests.java Fri Dec 21 22:38:30 2012 @@ -68,6 +68,6 @@ public class MXMLRemoteObjectTagTests ex "assertEqual('ro1.operations.m2.name', ro1.operations['m2'].name, 'm2');", }; String mxml = getMXML(declarations, scriptDeclarations, asserts); - compileAndRun(mxml, true, true, false); + compileAndRun(mxml, true, true, false, null); } } Modified: incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLWebServiceTagTests.java URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLWebServiceTagTests.java?rev=1425170&r1=1425169&r2=1425170&view=diff ============================================================================== --- incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLWebServiceTagTests.java (original) +++ incubator/flex/falcon/trunk/compiler.tests/feature-tests/mxml/tags/MXMLWebServiceTagTests.java Fri Dec 21 22:38:30 2012 @@ -69,6 +69,6 @@ public class MXMLWebServiceTagTests exte "assertEqual('ws1.operations.op2.name', ws1.operations['op2'].name, 'op2');", }; String mxml = getMXML(declarations, scriptDeclarations, asserts); - compileAndRun(mxml, true, true, false); + compileAndRun(mxml, true, true, false, null); } } Modified: incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java?rev=1425170&r1=1425169&r2=1425170&view=diff ============================================================================== --- incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java (original) +++ incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java Fri Dec 21 22:38:30 2012 @@ -122,6 +122,7 @@ import org.apache.flex.abc.visitors.IMet import org.apache.flex.abc.visitors.ITraitVisitor; import org.apache.flex.abc.visitors.ITraitsVisitor; import org.apache.flex.compiler.common.DependencyType; +import org.apache.flex.compiler.common.IMetaInfo; import org.apache.flex.compiler.constants.IASLanguageConstants; import org.apache.flex.compiler.constants.IASLanguageConstants.BuiltinType; import org.apache.flex.compiler.css.ICSSDocument; @@ -978,9 +979,9 @@ public class MXMLClassDirectiveProcessor { // add "goto_definition_help" metadata to user defined metadata. ITraitVisitor tv = classScope.getGlobalScope().traitsVisitor.visitClassTrait( - TRAIT_Class, className, 0, cinfo); - this.classScope.processMetadata(tv, - ClassDirectiveProcessor.getAllMetaTags(classDefinition)); + TRAIT_Class, className, 0, cinfo); + IMetaInfo[] metaTags = ClassDirectiveProcessor.getAllMetaTags(classDefinition); + classScope.processMetadata(tv, metaTags); tv.visitEnd(); // Make any vistEnd method calls @@ -3569,7 +3570,10 @@ public class MXMLClassDirectiveProcessor private void processMXMLMetadata(IMXMLMetadataNode metadataNode, Context context) { - // TODO + // Nothing to do. + // The metadata inside a tag was set onto the class definition + // when the file scope for the MXML file was created by MXMLScopeBuilder. + // Then finishClassDefinition() of this class will process it into ABC. } /** Modified: incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLArrayNode.java URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLArrayNode.java?rev=1425170&r1=1425169&r2=1425170&view=diff ============================================================================== --- incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLArrayNode.java (original) +++ incubator/flex/falcon/trunk/compiler/src/org/apache/flex/compiler/internal/tree/mxml/MXMLArrayNode.java Fri Dec 21 22:38:30 2012 @@ -25,7 +25,6 @@ import java.util.List; import org.apache.flex.compiler.common.SourceLocation; import org.apache.flex.compiler.constants.IASLanguageConstants; -import org.apache.flex.compiler.constants.IASLanguageConstants.BuiltinType; import org.apache.flex.compiler.definitions.IClassDefinition; import org.apache.flex.compiler.definitions.IDefinition; import org.apache.flex.compiler.definitions.ITypeDefinition;