flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - fix metadata handling in reflection
Date Wed, 27 Jan 2016 07:31:59 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 94ab3ff85 -> b3e7785af


fix metadata handling in reflection


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

Branch: refs/heads/develop
Commit: b3e7785af967da1f6cebc1b32f7454d0c648fbe3
Parents: 94ab3ff
Author: Alex Harui <aharui@apache.org>
Authored: Tue Jan 26 23:31:48 2016 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Tue Jan 26 23:31:48 2016 -0800

----------------------------------------------------------------------
 .../flex/reflection/DefinitionWithMetaData.as   | 15 ++++--
 .../flex/reflection/MetaDataDefinition.as       |  9 ++--
 manualtests/ReflectionTest/build.xml            |  2 +
 .../ReflectionTest/src/MyInitialView.mxml       | 54 ++++++++++++++++++--
 4 files changed, 67 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b3e7785a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/DefinitionWithMetaData.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/DefinitionWithMetaData.as
b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/DefinitionWithMetaData.as
index f6555eb..3ca31ba 100755
--- a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/DefinitionWithMetaData.as
+++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/DefinitionWithMetaData.as
@@ -34,7 +34,7 @@ package org.apache.flex.reflection
             super(name, rawData);
         }
         
-        public function getMetaData():Array
+        public function get metadata():Array
         {
             var results:Array = [];
             
@@ -52,8 +52,17 @@ package org.apache.flex.reflection
             }
             COMPILE::JS
             {
-                var rdata:* = rawData;
-                if (rdata !== undefined)
+                var rdata:*;
+                var data:Object = rawData;
+                if (data.names !== undefined)
+                {
+                    var name:String = data.names[0].qName;
+                    var def:Object = getDefinitionByName(name);
+                    rdata = def.prototype.FLEXJS_REFLECTION_INFO();
+                }
+                else
+                    rdata = data;
+                if (rdata !== undefined && rdata.metadata !== undefined)
                 {
                     var metadatas:Array = rdata.metadata();
                     if (metadatas)

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b3e7785a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MetaDataDefinition.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MetaDataDefinition.as
b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MetaDataDefinition.as
index 20d50cd..4b9a8c9 100755
--- a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MetaDataDefinition.as
+++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MetaDataDefinition.as
@@ -41,7 +41,7 @@ package org.apache.flex.reflection
             COMPILE::AS3
             {
                 var xml:XML = rawData as XML;
-                var data:XMLList = xml.args;
+                var data:XMLList = xml.arg;
                 var n:int = data.length();
                 for (var i:int = 0; i < n; i++)
                 {
@@ -53,13 +53,10 @@ package org.apache.flex.reflection
             }
             COMPILE::JS
             {
-                var data:Object = rawData;
-                var name:String = data.names[0].qName;
-                var def:Object = getDefinitionByName(name);
-                var rdata:* = def.prototype.FLEXJS_REFLECTION_INFO();
+                var rdata:* = rawData;
                 if (rdata !== undefined)
                 {
-                    var args:Array = rdata.args();
+                    var args:Array = rdata.args;
                     if (args)
                     {
                         var n:int = args.length;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b3e7785a/manualtests/ReflectionTest/build.xml
----------------------------------------------------------------------
diff --git a/manualtests/ReflectionTest/build.xml b/manualtests/ReflectionTest/build.xml
index c705edf..d65e7a8 100644
--- a/manualtests/ReflectionTest/build.xml
+++ b/manualtests/ReflectionTest/build.xml
@@ -26,6 +26,8 @@
     <property environment="env"/>
     <property file="${FLEXJS_HOME}/build.properties"/>
     <property name="FLEX_HOME" value="${FLEXJS_HOME}"/>
+    <!-- use this to add keep metadata option -->
+    <property name="theme_arg" value="-keep-as3-metadata+=Event" />
     <available file="${env.FALCON_HOME}/lib/falcon-mxmlc.jar"
     type="file"
     property="FALCON_HOME"

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b3e7785a/manualtests/ReflectionTest/src/MyInitialView.mxml
----------------------------------------------------------------------
diff --git a/manualtests/ReflectionTest/src/MyInitialView.mxml b/manualtests/ReflectionTest/src/MyInitialView.mxml
index 7334c43..9d9df84 100644
--- a/manualtests/ReflectionTest/src/MyInitialView.mxml
+++ b/manualtests/ReflectionTest/src/MyInitialView.mxml
@@ -38,21 +38,67 @@ limitations under the License.
 			import org.apache.flex.utils.UIUtils;
 						
             import org.apache.flex.reflection.describeType;
+            import org.apache.flex.reflection.MetaDataArgDefinition;
+            import org.apache.flex.reflection.MetaDataDefinition;
             import org.apache.flex.reflection.MethodDefinition;
             import org.apache.flex.reflection.TypeDefinition;
-                       
+            
+            [Event(name="foo", type="org.apache.flex.events.Event")]
             public function runTest():void
             {
+                var metadata:Array;
+                var mtd:MetaDataDefinition;
+                var mtdarg:MetaDataArgDefinition;
+                var args:Array;
+                var j:int;
+                var m:int;
+                
                 var td:TypeDefinition = describeType(this);
                 trace(td.name);
                 var methods:Array = td.methods;
-                var md:MethodDefinition = methods[0] as MethodDefinition;
-                trace(md.name);
+                var n:int = methods.length;
+                for (var i:int = 0; i < n; i++)
+                {
+                    var md:MethodDefinition = methods[i] as MethodDefinition;
+                    trace(md.name);
+                    if (md.name == "runTest")
+                    {
+                        metadata = md.metadata;
+                        for each (mtd in metadata)
+                        {
+                            trace(mtd.name);
+                            args = mtd.args;
+                            m = args.length;
+                            for (j = 0; j < m; j++)
+                            {
+                                mtdarg = args[j] as MetaDataArgDefinition;
+                                trace(mtdarg.name, mtdarg.value);
+                            }
+                        }
+                        break;
+                    }
+                }
+                td = describeType(cont);
+                trace(td.name);
+                metadata = td.metadata;
+                n = metadata.length;
+                for (i = 0; i < n; i++)
+                {
+                    mtd = metadata[0] as MetaDataDefinition;
+                    trace(mtd.name);
+                    args = mtd.args;
+                    m = args.length;
+                    for (j = 0; j < m; j++)
+                    {
+                        mtdarg = args[j] as MetaDataArgDefinition;
+                        trace(mtdarg.name, mtdarg.value);
+                    }
+                }
             }
 		]]>
 	</fx:Script>
 	
-	<js:Container width="600" height="700" x="50" y="50">
+	<js:Container id="cont" width="600" height="700" x="50" y="50">
 		<js:beads>
 			<js:VerticalLayout />
 		</js:beads>


Mime
View raw message