You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2016/09/07 19:24:26 UTC

[20/21] git commit: [flex-asjs] [refs/heads/spark] - more fixes to try to get MX hello world to run

more fixes to try to get MX hello world to run


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/5f700e5b
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/5f700e5b
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/5f700e5b

Branch: refs/heads/spark
Commit: 5f700e5b69c59283796147761e37d16c403017e8
Parents: ffb7f61
Author: Alex Harui <ah...@apache.org>
Authored: Tue Sep 6 21:31:26 2016 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Sep 6 21:31:26 2016 -0700

----------------------------------------------------------------------
 .../flex/org/apache/flex/core/Application.as    |  12 +-
 .../main/flex/flex/system/DefinitionManager.as  |   4 +
 .../MX/src/main/flex/mx/core/Application.as     |  55 +++++++-
 .../MX/src/main/flex/mx/core/Container.as       |  36 +++++
 .../src/main/flex/mx/managers/SystemManager.as  |  66 +++++++---
 .../mx/managers/systemClasses/ChildManager.as   | 131 ++++++++++---------
 .../flex/mx/resources/ResourceManagerImpl.as    |   2 +
 .../flex/reflection/getDefinitionByName.as      |   1 +
 8 files changed, 218 insertions(+), 89 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f700e5b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as
index fcc91b6..84a58b5 100644
--- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as
+++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as
@@ -577,15 +577,21 @@ package org.apache.flex.core
 		COMPILE::JS
 		protected var startupTimer:Timer;
 
+        COMPILE::JS
+        protected function createElement():void
+        {
+            element = document.getElementsByTagName('body')[0];
+            element.flexjs_wrapper = this;
+            element.className = 'Application';            
+        }
+        
 		/**
 		 * @flexjsignorecoercion org.apache.flex.core.IBead
 		 */
 		COMPILE::JS
 		public function start():void
 		{
-			element = document.getElementsByTagName('body')[0];
-			element.flexjs_wrapper = this;
-			element.className = 'Application';
+            createElement();
 			
 			if (model is IBead) addBead(model as IBead);
 			if (controller is IBead) addBead(controller as IBead);

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f700e5b/frameworks/projects/MX/src/main/flex/flex/system/DefinitionManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/flex/system/DefinitionManager.as b/frameworks/projects/MX/src/main/flex/flex/system/DefinitionManager.as
index 6f3acbe..879e233 100644
--- a/frameworks/projects/MX/src/main/flex/flex/system/DefinitionManager.as
+++ b/frameworks/projects/MX/src/main/flex/flex/system/DefinitionManager.as
@@ -46,6 +46,8 @@ COMPILE::SWF
 			}
 			COMPILE::JS
 			{
+                // may not work in release optimized mode
+                name = name.replace("::", ".");
 				var parts:Array = name.split(".");
 				var obj:* = window;
 				for each (var part:String in parts)
@@ -66,6 +68,8 @@ COMPILE::SWF
 			}
 			COMPILE::JS
 			{
+                // may not work in release optimized mode
+                name = name.replace("::", ".");
 				var parts:Array = name.split(".");
 				var obj:* = window;
 				for each (var part:String in parts)

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f700e5b/frameworks/projects/MX/src/main/flex/mx/core/Application.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/core/Application.as b/frameworks/projects/MX/src/main/flex/mx/core/Application.as
index 10dab2a..04f1055 100644
--- a/frameworks/projects/MX/src/main/flex/mx/core/Application.as
+++ b/frameworks/projects/MX/src/main/flex/mx/core/Application.as
@@ -40,6 +40,9 @@ COMPILE::JS
     import flex.display.DisplayObject;
     import flex.display.InteractiveObject;
     import flex.events.Event;
+    import org.apache.flex.core.WrappedHTMLElement;
+    import mx.managers.SystemManager;
+    import mx.managers.systemClasses.ChildManager;
 }
 
 import mx.containers.utilityClasses.ApplicationLayout;
@@ -50,13 +53,15 @@ import mx.managers.IActiveWindowManager;
 import mx.managers.ILayoutManager;
 import mx.managers.ISystemManager;
 // force-link this here. In flex-sdk, it gets dragged in by Effect.
-import mx.managers.LayoutManager; LayoutManager; 
+import mx.managers.LayoutManager; // LayoutManager; force-link syntax not supported by FalconJX 
 // force-link this here. In flex-sdk, it gets injected somehow.
-import mx.core.TextFieldFactory; TextFieldFactory; 
+import mx.core.TextFieldFactory; // TextFieldFactory; force-link syntax not supported by FalconJX 
 import mx.styles.CSSStyleDeclaration;
 import mx.styles.IStyleClient;
 import mx.utils.LoaderUtil;
 import mx.utils.Platform;
+import org.apache.flex.core.SimpleCSSValuesImpl;
+import org.apache.flex.core.ValuesManager;
 
 use namespace mx_internal;
 
@@ -348,6 +353,35 @@ public class Application extends LayoutContainer
      */
     public function Application()
     {
+        start();
+    }
+    
+    /**
+     *  Entry point for JS.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function start():void
+    {
+        var forceLinkLayoutManager:Class = LayoutManager;
+        var forceLinkTextFieldFactory:Class = TextFieldFactory;
+        ValuesManager.valuesImpl = new SimpleCSSValuesImpl();
+        ValuesManager.valuesImpl.init(this);
+        
+        COMPILE::JS
+        {
+            // this is a hack until we get falconjx to put the info on the factory
+            SystemManager.setInfo(this["info"]());
+            var sm:SystemManager = new SystemManager();
+            sm.document = this;
+            systemManager = sm;
+            new ChildManager(sm);
+            sm.kickOff();
+        }
+                
         UIComponentGlobals.layoutManager = ILayoutManager(
             Singleton.getInstance("mx.managers::ILayoutManager"));
         UIComponentGlobals.layoutManager.usePhasedInstantiation = true;
@@ -355,8 +389,6 @@ public class Application extends LayoutContainer
         if (!FlexGlobals.topLevelApplication)
             FlexGlobals.topLevelApplication = this;
 
-        super();
-
         layoutObject = new ApplicationLayout();
         layoutObject.target = this;
         boxLayoutClass = ApplicationLayout;
@@ -370,6 +402,21 @@ public class Application extends LayoutContainer
         initResizeBehavior();
     }
 
+    /**
+     * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement 
+     */
+    COMPILE::JS
+    override protected function createElement():WrappedHTMLElement
+    {
+        element = window.document.createElement('div') as WrappedHTMLElement;
+        element.flexjs_wrapper = this;
+        element.className = 'Application';
+        
+        positioner = element;
+        
+        return element;
+    }
+    
     //--------------------------------------------------------------------------
     //
     //  Variables

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f700e5b/frameworks/projects/MX/src/main/flex/mx/core/Container.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/core/Container.as b/frameworks/projects/MX/src/main/flex/mx/core/Container.as
index 1216189..ed2c0b5 100644
--- a/frameworks/projects/MX/src/main/flex/mx/core/Container.as
+++ b/frameworks/projects/MX/src/main/flex/mx/core/Container.as
@@ -357,6 +357,8 @@ include "../styles/metadata/TextStyles.as"
 
 [ResourceBundle("core")]
 
+[DefaultProperty("mxmlContent")] 
+
 /**
  *  The Container class is an abstract base class for components that
  *  controls the layout characteristics of child components.
@@ -1893,6 +1895,40 @@ public class Container extends UIComponent
     }
 
     //----------------------------------
+    //  mxmlContent
+    //----------------------------------
+    
+    private var _mxmlContent:Array;
+    
+    [ArrayElementType("mx.core.IVisualElement")]
+    
+    /**
+     *  The visual content children for this Group.
+     * 
+     *  This method is used internally by Flex and is not intended for direct
+     *  use by developers.
+     *
+     *  <p>The content items should only be IVisualElement objects.  
+     *  An <code>mxmlContent</code> Array should not be shared between multiple
+     *  Group containers because visual elements can only live in one container 
+     *  at a time.</p>
+     * 
+     *  <p>If the content is an Array, do not modify the Array 
+     *  directly. Use the methods defined by the Group class instead.</p>
+     *
+     *  @default null
+     *
+     *  @langversion 3.0
+     *  @playerversion Flash 10
+     *  @playerversion AIR 1.5
+     *  @productversion Flex 4
+     */
+    public function set mxmlContent(value:Array):void
+    {
+        _mxmlContent = value;
+    }
+
+    //----------------------------------
     //  numChildrenCreated
     //----------------------------------
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f700e5b/frameworks/projects/MX/src/main/flex/mx/managers/SystemManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/managers/SystemManager.as b/frameworks/projects/MX/src/main/flex/mx/managers/SystemManager.as
index ab629e3..73052fb 100644
--- a/frameworks/projects/MX/src/main/flex/mx/managers/SystemManager.as
+++ b/frameworks/projects/MX/src/main/flex/mx/managers/SystemManager.as
@@ -59,6 +59,7 @@ COMPILE::JS
 	import flex.events.EventPhase;
 	import flex.ui.Keyboard;
 	
+    import org.apache.flex.core.WrappedHTMLElement;
 	import org.apache.flex.events.MouseEvent;
 	import org.apache.flex.geom.Point;
 }
@@ -2154,12 +2155,25 @@ public class SystemManager extends MovieClip
 
     /**
      *  @private
+     *  this is overridden by the SWF compiler
      */
     public function info():Object
     {
-        return {};
+        return __info;
     }
 
+    private static var __info:Object;
+    
+    /**
+     *  @private
+     *  this is set by JS code as hack for now.
+     *  eventually, the JS transpiler should generate the object
+     */
+    public static function setInfo(obj:Object):void
+    {
+        __info = obj;
+    }
+    
     //--------------------------------------------------------------------------
     //
     //  Methods
@@ -3016,16 +3030,32 @@ public class SystemManager extends MovieClip
 		}
     }   
 
+    COMPILE::JS
+    override protected function createElement():WrappedHTMLElement
+    {
+        element = window.document.getElementsByTagName('body')[0];
+        element.flexjs_wrapper = this;
+        element.className = 'SystemManager';
+        
+        positioner = element;
+        
+        return element;
+    }
+    
     /**
      *  @private
      *  kick off 
+     *  @flexjsignorecoercion Class
      */
     mx_internal function kickOff():void
     {
-        // already been here
-        if (document)
-            return;
-
+        COMPILE::SWF
+        {
+            // already been here
+            if (document)
+                return;
+        }
+        
         CONFIG::performanceInstrumentation
         {
             var perfUtil:mx.utils.PerfUtil = mx.utils.PerfUtil.getInstance();
@@ -3042,35 +3072,35 @@ public class SystemManager extends MovieClip
 		
         // Generated code will bring in EmbeddedFontRegistry
         Singleton.registerClass("mx.core::IEmbeddedFontRegistry",
-                Class(getDefinitionByName("mx.core::EmbeddedFontRegistry")));
+                getDefinitionByName("mx.core::EmbeddedFontRegistry") as Class);
                 
         Singleton.registerClass("mx.styles::IStyleManager",
-            Class(getDefinitionByName("mx.styles::StyleManagerImpl")));
+            getDefinitionByName("mx.styles::StyleManagerImpl") as Class);
         
         Singleton.registerClass("mx.styles::IStyleManager2",
-            Class(getDefinitionByName("mx.styles::StyleManagerImpl")));
+            getDefinitionByName("mx.styles::StyleManagerImpl") as Class);
 
         // Register other singleton classes.
         // Note: getDefinitionByName() will return null
         // if the class can't be found.
 
         Singleton.registerClass("mx.managers::IBrowserManager",
-            Class(getDefinitionByName("mx.managers::BrowserManagerImpl")));
+            getDefinitionByName("mx.managers::BrowserManagerImpl") as Class);
 
         Singleton.registerClass("mx.managers::ICursorManager",
-            Class(getDefinitionByName("mx.managers::CursorManagerImpl")));
+            getDefinitionByName("mx.managers::CursorManagerImpl") as Class);
 
         Singleton.registerClass("mx.managers::IHistoryManager",
-            Class(getDefinitionByName("mx.managers::HistoryManagerImpl")));
+            getDefinitionByName("mx.managers::HistoryManagerImpl") as Class);
 
         Singleton.registerClass("mx.managers::ILayoutManager",
-            Class(getDefinitionByName("mx.managers::LayoutManager")));
+            getDefinitionByName("mx.managers::LayoutManager") as Class);
 
         Singleton.registerClass("mx.managers::IPopUpManager",
-            Class(getDefinitionByName("mx.managers::PopUpManagerImpl")));
+            getDefinitionByName("mx.managers::PopUpManagerImpl") as Class);
 
         Singleton.registerClass("mx.managers::IToolTipManager2",
-            Class(getDefinitionByName("mx.managers::ToolTipManagerImpl")));
+            getDefinitionByName("mx.managers::ToolTipManagerImpl") as Class);
 
         var dragManagerClass:Class = null;
                 
@@ -3085,15 +3115,15 @@ public class SystemManager extends MovieClip
         var useNative:Boolean = dmInfo == null ? true : String(dmInfo) == "true";
          
         if (useNative)
-            dragManagerClass = Class(getDefinitionByName("mx.managers::NativeDragManagerImpl"));
+            dragManagerClass = getDefinitionByName("mx.managers::NativeDragManagerImpl") as Class;
     
         if (dragManagerClass == null)
-            dragManagerClass = Class(getDefinitionByName("mx.managers::DragManagerImpl"));
+            dragManagerClass = getDefinitionByName("mx.managers::DragManagerImpl") as Class;
         
         Singleton.registerClass("mx.managers::IDragManager", dragManagerClass);
 
         Singleton.registerClass("mx.core::ITextFieldFactory", 
-            Class(getDefinitionByName("mx.core::TextFieldFactory")));
+            getDefinitionByName("mx.core::TextFieldFactory") as Class);
 
         var mixinList:Array = info()["mixins"];
         if (mixinList && mixinList.length > 0)
@@ -3107,7 +3137,7 @@ public class SystemManager extends MovieClip
                 }
                 
                 // trace("initializing mixin " + mixinList[i]);
-                var c:Class = Class(getDefinitionByName(mixinList[i]));
+                var c:Class = getDefinitionByName(mixinList[i]) as Class;
                 c["init"](this);
 
                 CONFIG::performanceInstrumentation

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f700e5b/frameworks/projects/MX/src/main/flex/mx/managers/systemClasses/ChildManager.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/managers/systemClasses/ChildManager.as b/frameworks/projects/MX/src/main/flex/mx/managers/systemClasses/ChildManager.as
index 9129891..0b2203e 100644
--- a/frameworks/projects/MX/src/main/flex/mx/managers/systemClasses/ChildManager.as
+++ b/frameworks/projects/MX/src/main/flex/mx/managers/systemClasses/ChildManager.as
@@ -332,77 +332,80 @@ public class ChildManager implements ISystemManagerChildManager
         }
         
 		var app:IUIComponent;
-		// Create a new instance of the toplevel class
-        systemManager.document = app = topLevelWindow = IUIComponent(systemManager.create());
-		COMPILE::SWF
-		{
-			FlashEventConverter.setupAllConverters(app as DisplayObject);
-		}			
-
-        CONFIG::performanceInstrumentation
+        if (!systemManager.document)
         {
-            perfUtil.markTime("SystemManager.create().end");
-        }        
-
-		if (systemManager.document)
-		{
-			// Add listener for the creationComplete event
-			IEventDispatcher(app).addEventListener(FlexEvent.CREATION_COMPLETE,
-												   appCreationCompleteHandler);
-
-			COMPILE::LATER
-			{
-			// if somebody has set this in our applicationdomain hierarchy, don't overwrite it
-			if (!LoaderConfig._url)
-			{
-				LoaderConfig._url = LoaderUtil.normalizeURL(systemManager.loaderInfo);
-				LoaderConfig._parameters = systemManager.loaderInfo.parameters;
-                LoaderConfig._swfVersion = systemManager.loaderInfo.swfVersion;
-            }
-			}
-			
-			IFlexDisplayObject(app).setActualSize(width, height);
-
-			// Wait for the app to finish its initialization sequence
-			// before doing an addChild(). 
-			// Otherwise, the measurement/layout code will cause the
-			// player to do a bunch of unnecessary screen repaints,
-			// which slows application startup time.
-			
-			// Pass the application instance to the preloader.
-			// Note: preloader can be null when the user chooses
-			// Control > Play in the standalone player.
-			if (preloader)
-				preloader.registerApplication(app);
-						
-			// The Application doesn't get added to the SystemManager in the standard way.
-			// We want to recursively create the entire application subtree and process
-			// it with the LayoutManager before putting the Application on the display list.
-			// So here we what would normally happen inside an override of addChild().
-			// Leter, when we actually attach the Application instance,
-			// we call super.addChild(), which is the bare player method.
-			addingChild(DisplayObject(app));
-
+    		// Create a new instance of the toplevel class
+            systemManager.document = app = topLevelWindow = IUIComponent(systemManager.create());
+    		COMPILE::SWF
+    		{
+    			FlashEventConverter.setupAllConverters(app as DisplayObject);
+    		}			
+    
             CONFIG::performanceInstrumentation
             {
-                perfUtil.markTime("Application.createChildren().start");
-            }
+                perfUtil.markTime("SystemManager.create().end");
+            }        
+    
+    		if (systemManager.document)
+    		{
+    			// Add listener for the creationComplete event
+    			IEventDispatcher(app).addEventListener(FlexEvent.CREATION_COMPLETE,
+    												   appCreationCompleteHandler);
+    
+    			COMPILE::LATER
+    			{
+    			// if somebody has set this in our applicationdomain hierarchy, don't overwrite it
+    			if (!LoaderConfig._url)
+    			{
+    				LoaderConfig._url = LoaderUtil.normalizeURL(systemManager.loaderInfo);
+    				LoaderConfig._parameters = systemManager.loaderInfo.parameters;
+                    LoaderConfig._swfVersion = systemManager.loaderInfo.swfVersion;
+                }
+    			}
+    			
+    			IFlexDisplayObject(app).setActualSize(width, height);
+    
+    			// Wait for the app to finish its initialization sequence
+    			// before doing an addChild(). 
+    			// Otherwise, the measurement/layout code will cause the
+    			// player to do a bunch of unnecessary screen repaints,
+    			// which slows application startup time.
+    			
+    			// Pass the application instance to the preloader.
+    			// Note: preloader can be null when the user chooses
+    			// Control > Play in the standalone player.
+    			if (preloader)
+    				preloader.registerApplication(app);
+    						
+    			// The Application doesn't get added to the SystemManager in the standard way.
+    			// We want to recursively create the entire application subtree and process
+    			// it with the LayoutManager before putting the Application on the display list.
+    			// So here we what would normally happen inside an override of addChild().
+    			// Leter, when we actually attach the Application instance,
+    			// we call super.addChild(), which is the bare player method.
+    			addingChild(DisplayObject(app));
+    
+                CONFIG::performanceInstrumentation
+                {
+                    perfUtil.markTime("Application.createChildren().start");
+                }
+                
+                childAdded(DisplayObject(app)); // calls app.createChildren()
+    
+                CONFIG::performanceInstrumentation
+                {
+                    perfUtil.markTime("Application.createChildren().end");
+                }
+    		}
+    		else
+    		{
+    			systemManager.document = this;
+    		}
             
-            childAdded(DisplayObject(app)); // calls app.createChildren()
-
             CONFIG::performanceInstrumentation
             {
-                perfUtil.markTime("Application.createChildren().end");
+                perfUtil.markTime("ChildManager.initializeTopLevelWindow().end");
             }
-		}
-		else
-		{
-			systemManager.document = this;
-		}
-        
-        CONFIG::performanceInstrumentation
-        {
-            perfUtil.markTime("ChildManager.initializeTopLevelWindow().end");
         }
 	}
 	

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f700e5b/frameworks/projects/MX/src/main/flex/mx/resources/ResourceManagerImpl.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/MX/src/main/flex/mx/resources/ResourceManagerImpl.as b/frameworks/projects/MX/src/main/flex/mx/resources/ResourceManagerImpl.as
index cfb5245..8ce4e33 100644
--- a/frameworks/projects/MX/src/main/flex/mx/resources/ResourceManagerImpl.as
+++ b/frameworks/projects/MX/src/main/flex/mx/resources/ResourceManagerImpl.as
@@ -512,6 +512,8 @@ public class ResourceManagerImpl extends EventDispatcher implements IResourceMan
      */
     public function initializeLocaleChain(compiledLocales:Array):void
     {
+        if (!compiledLocales) return;
+        
         localeChain = LocaleSorter.sortLocalesByPreference(
             compiledLocales, getSystemPreferredLocales(), null, true);
     }

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/5f700e5b/frameworks/projects/Reflection/src/main/flex/org/apache/flex/reflection/getDefinitionByName.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Reflection/src/main/flex/org/apache/flex/reflection/getDefinitionByName.as b/frameworks/projects/Reflection/src/main/flex/org/apache/flex/reflection/getDefinitionByName.as
index 3710c62..fa2177a 100755
--- a/frameworks/projects/Reflection/src/main/flex/org/apache/flex/reflection/getDefinitionByName.as
+++ b/frameworks/projects/Reflection/src/main/flex/org/apache/flex/reflection/getDefinitionByName.as
@@ -39,6 +39,7 @@ COMPILE::SWF
         }
         COMPILE::JS
         {
+            name = name.replace("::", ".");
             var parts:Array = name.split('.');
             var n:int = parts.length;
             var o:Object = window;