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 8237995D6 for ; Tue, 12 Jun 2012 22:08:18 +0000 (UTC) Received: (qmail 66377 invoked by uid 500); 12 Jun 2012 22:08:18 -0000 Delivered-To: apmail-incubator-flex-commits-archive@incubator.apache.org Received: (qmail 66341 invoked by uid 500); 12 Jun 2012 22:08:18 -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 66333 invoked by uid 99); 12 Jun 2012 22:08:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Jun 2012 22:08:18 +0000 X-ASF-Spam-Status: No, hits=-1999.0 required=5.0 tests=ALL_TRUSTED,FRT_ADOBE2 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; Tue, 12 Jun 2012 22:08:16 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 24DC42388C38; Tue, 12 Jun 2012 22:07:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1349560 [10/10] - in /incubator/flex/trunk: ./ frameworks/ frameworks/projects/airframework/ frameworks/projects/airframework/assets/ frameworks/projects/framework/ frameworks/projects/framework/assets/ frameworks/projects/framework/assets... Date: Tue, 12 Jun 2012 22:07:07 -0000 To: flex-commits@incubator.apache.org From: aharui@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120612220717.24DC42388C38@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FXGCompiler.java URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FXGCompiler.java?rev=1349560&r1=1349559&r2=1349560&view=diff ============================================================================== --- incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FXGCompiler.java (original) +++ incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FXGCompiler.java Tue Jun 12 22:06:59 2012 @@ -37,6 +37,7 @@ import com.adobe.fxg.dom.FXGNode; import com.adobe.fxg.util.FXGLocalizationUtil; import com.adobe.fxg.util.FXGLog; import com.adobe.fxg.util.FXGLogger; +import com.adobe.internal.fxg.dom.GraphicNode; import flash.localization.LocalizationManager; import flash.util.FileUtils; @@ -62,6 +63,7 @@ import flex2.compiler.mxml.reflect.TypeT import flex2.compiler.util.CompilerMessage; import flex2.compiler.util.MimeMappings; import flex2.compiler.util.MultiName; +import flex2.compiler.util.NameFormatter; import flex2.compiler.util.NameMappings; import flex2.compiler.util.QName; import flex2.compiler.util.ThreadLocalToolkit; @@ -564,10 +566,28 @@ public class FXGCompiler extends Abstrac QName topLevelQName = getQNameFromSource(source); unit.topLevelDefinitions.add(topLevelQName); + MultiName baseMultiName = MULTINAME_SPRITEVISUALELEMENT; + if (node instanceof GraphicNode) + { + GraphicNode graphicNode = (GraphicNode)node; + if (graphicNode.baseClassName != null) + { + String pkg = ""; + String baseClassName = graphicNode.baseClassName; + String className = baseClassName; + int lastDot = baseClassName.lastIndexOf("."); + if (lastDot > -1) + { + pkg = baseClassName.substring(0, lastDot); + className = baseClassName.substring(lastDot + 1); + } + baseMultiName = new MultiName(NameFormatter.toColon(pkg, className)); + } + } // We add the base class for our generated skeleton here so that // the type will be resolved after returning from parse1() and // before we get to analyze2(). - unit.inheritance.add(MULTINAME_SPRITEVISUALELEMENT); + unit.inheritance.add(baseMultiName); } catch (FXGException ex) { @@ -600,6 +620,7 @@ public class FXGCompiler extends Abstrac // Determine whether we need to introduce text class dependencies FXGNode rootNode = (FXGNode)unit.getContext().getAttribute(FXG_DOM_ROOT); boolean hasTextGraphic = false; + String baseClassName = null; double version = 1.0; if (rootNode instanceof FlexGraphicNode) @@ -608,11 +629,12 @@ public class FXGCompiler extends Abstrac FXGVersion v = graphicNode.getVersion(); version = v != null ? v.asDouble() : 1.0; hasTextGraphic = graphicNode.hasText; + baseClassName = graphicNode.baseClassName; } try { - generatedSource = generateSource(originalSource, symbolTable, version, hasTextGraphic); + generatedSource = generateSource(originalSource, symbolTable, version, hasTextGraphic, baseClassName); } catch (IOException ex) { @@ -689,7 +711,7 @@ public class FXGCompiler extends Abstrac * @param hasText - whether the document made use of text */ private Source generateSource(Source originalSource, SymbolTable symbolTable, - double version, boolean hasText) throws IOException + double version, boolean hasText, String baseClassName) throws IOException { // Derive package/class names from source name and location String className = originalSource.getShortName(); @@ -715,8 +737,20 @@ public class FXGCompiler extends Abstrac buf.append("import spark.components.RichText;\n"); } - buf.append("import spark.core.SpriteVisualElement;\n\n"); - buf.append("public class ").append(className).append(" extends SpriteVisualElement\n{\n"); + if (baseClassName != null) + { + buf.append("import "); + buf.append(baseClassName); + buf.append(";\n\n"); + buf.append("public class ").append(className).append(" extends "); + buf.append(baseClassName); + buf.append("\n{\n"); + } + else + { + buf.append("import spark.core.SpriteVisualElement;\n\n"); + buf.append("public class ").append(className).append(" extends SpriteVisualElement\n{\n"); + } buf.append(" public function ").append(className).append("()\n"); buf.append(" {\n"); buf.append(" super();\n"); Modified: incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FlexFXG2SWFTranscoder.java URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FlexFXG2SWFTranscoder.java?rev=1349560&r1=1349559&r2=1349560&view=diff ============================================================================== --- incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FlexFXG2SWFTranscoder.java (original) +++ incubator/flex/trunk/modules/compiler/src/java/flex2/compiler/fxg/FlexFXG2SWFTranscoder.java Tue Jun 12 22:06:59 2012 @@ -135,13 +135,29 @@ public class FlexFXG2SWFTranscoder exten DefineSprite sprite = (DefineSprite)transcode(graphicNode); graphicClass.setSymbol(sprite); + + // use specified className if specified + if (graphicNode.className != null) + sprite.name = graphicNode.className; // Create a new sprite class to map to this Graphic's DefineSprite StringBuilder buf = new StringBuilder(512); buf.append("package ").append(packageName).append("\n"); buf.append("{\n\n"); - buf.append("import spark.core.SpriteVisualElement;\n\n"); - buf.append("public class ").append(className).append(" extends SpriteVisualElement\n"); + if (graphicNode.baseClassName != null) + { + buf.append("import "); + buf.append(graphicNode.baseClassName); + buf.append(";\n\n"); + buf.append("public class ").append(className).append(" extends "); + buf.append(graphicNode.baseClassName); + buf.append("\n"); + } + else + { + buf.append("import spark.core.SpriteVisualElement;\n\n"); + buf.append("public class ").append(className).append(" extends SpriteVisualElement\n"); + } buf.append("{\n"); buf.append(" public function ").append(className).append("()\n"); buf.append(" {\n"); Modified: incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/dom/GraphicNode.java URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/dom/GraphicNode.java?rev=1349560&r1=1349559&r2=1349560&view=diff ============================================================================== --- incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/dom/GraphicNode.java (original) +++ incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/dom/GraphicNode.java Tue Jun 12 22:06:59 2012 @@ -39,6 +39,9 @@ import com.adobe.internal.fxg.dom.types. */ public class GraphicNode extends AbstractFXGNode implements MaskableNode { + public static final String APACHE_FLEX_CLASSNAME = "className"; + public static final String APACHE_FLEX_BASECLASSNAME = "baseClassName"; + private FXGVersion compilerVersion = null; // The version of FXG compiler. private String profile; private String documentName = null; @@ -74,6 +77,12 @@ public class GraphicNode extends Abstrac /** The view height. */ public double viewHeight = Double.NaN; + + /** an optional class name */ + public String className = null; + + /** an optional base class name */ + public String baseClassName = null; /** The mask type. */ public MaskType maskType = MaskType.CLIP; @@ -358,6 +367,14 @@ public class GraphicNode extends Abstrac { luminosityClip = DOMParserHelper.parseBoolean(this, value, name); } + else if (APACHE_FLEX_CLASSNAME.equals(name)) + { + className = value; + } + else if (APACHE_FLEX_BASECLASSNAME.equals(name)) + { + baseClassName = value; + } else { super.setAttribute(name, value); Modified: incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/sax/FXGSAXScanner.java URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/sax/FXGSAXScanner.java?rev=1349560&r1=1349559&r2=1349560&view=diff ============================================================================== --- incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/sax/FXGSAXScanner.java (original) +++ incubator/flex/trunk/modules/fxgutils/src/java/com/adobe/internal/fxg/sax/FXGSAXScanner.java Tue Jun 12 22:06:59 2012 @@ -55,6 +55,9 @@ import static com.adobe.fxg.FXGConstants */ public class FXGSAXScanner extends DefaultHandler { + // Namespaces + public static final String APACHE_FLEX_NAMESPACE = "http://ns.apache.org/flex/2012"; + private static boolean REJECT_MAJOR_VERSION_MISMATCH = false; // A special case needed to short circuit GroupNode creation inside a @@ -224,7 +227,9 @@ public class FXGSAXScanner extends Defau for (int i = 0; i < attributes.getLength(); i++) { String attributeURI = attributes.getURI(i); - if (attributeURI == null || attributeURI == "" || isFXGNamespace(attributeURI)) + if (attributeURI == null || attributeURI == "" || + isFXGNamespace(attributeURI) || + isApacheFlexNamespace(attributeURI)) { String attributeName = attributes.getLocalName(i); String attributeValue = attributes.getValue(i); @@ -402,6 +407,15 @@ public class FXGSAXScanner extends Defau } /** + * @param uri - the namespace URI to check + * @return whether the given namespace URI is considered an Apache Flex namespace. + */ + protected boolean isApacheFlexNamespace(String uri) + { + return APACHE_FLEX_NAMESPACE.equals(uri); + } + + /** * Specifies that a particular element should be skipped while scanning for * tokens in an FXG document. All of the element's attributes and child * nodes will be skipped too.