Repository: flex-asjs Updated Branches: refs/heads/develop be5c7ab8e -> 94ab3ff85
first attempt at 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/94ab3ff8 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/94ab3ff8 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/94ab3ff8 Branch: refs/heads/develop Commit: 94ab3ff85d8586d61033012b7572588139cfdfd5 Parents: be5c7ab Author: Alex Harui <[email protected]> Authored: Mon Jan 25 16:21:10 2016 -0800 Committer: Alex Harui <[email protected]> Committed: Mon Jan 25 16:21:31 2016 -0800 ---------------------------------------------------------------------- frameworks/build.xml | 6 + .../apache/flex/reflection/DefinitionBase.as | 51 ++++ .../flex/reflection/DefinitionWithMetaData.as | 70 +++++ .../flex/reflection/FunctionDefinition.as | 37 +++ .../flex/reflection/MetaDataArgDefinition.as | 45 ++++ .../flex/reflection/MetaDataDefinition.as | 74 ++++++ .../apache/flex/reflection/MethodDefinition.as | 50 ++++ .../apache/flex/reflection/TypeDefinition.as | 260 +++++++++++++++++++ .../flex/reflection/VariableDefinition.as | 38 +++ .../org/apache/flex/reflection/describeType.as | 47 ++++ .../flex/reflection/getDefinitionByName.as | 51 ++++ .../flex/reflection/getQualifiedClassName.as | 51 ++++ .../reflection/getQualifiedSuperclassName.as | 49 ++++ frameworks/projects/Reflection/build.xml | 165 ++++++++++++ .../projects/Reflection/compile-asjs-config.xml | 77 ++++++ .../projects/Reflection/compile-config.xml | 73 ++++++ manualtests/ReflectionTest/build.xml | 70 +++++ .../ReflectionTest/src/MyInitialView.mxml | 64 +++++ manualtests/ReflectionTest/src/README.txt | 45 ++++ .../ReflectionTest/src/ReflectionTest.mxml | 40 +++ .../src/controllers/MyController.as | 52 ++++ .../ReflectionTest/src/models/MyModel.as | 125 +++++++++ 22 files changed, 1540 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/build.xml ---------------------------------------------------------------------- diff --git a/frameworks/build.xml b/frameworks/build.xml index 733ccab..eebb204 100644 --- a/frameworks/build.xml +++ b/frameworks/build.xml @@ -92,6 +92,7 @@ <antcall target="JQuery"/> <antcall target="Mobile"/> <antcall target="Network"/> + <antcall target="Reflection"/> </target> <target name="fonts"> @@ -134,6 +135,7 @@ <ant dir="${basedir}/projects/JQuery" target="clean"/> <ant dir="${basedir}/projects/Mobile" target="clean"/> <ant dir="${basedir}/projects/Network" target="clean"/> + <ant dir="${basedir}/projects/Reflection" target="clean"/> <ant dir="${basedir}/fontsrc" target="clean"/> <!-- delete the FlashBuilder executable directories --> @@ -218,6 +220,10 @@ <ant dir="${basedir}/projects/Network"/> </target> + <target name="Reflection" description="Clean build of Reflection.swc"> + <ant dir="${basedir}/projects/Reflection"/> + </target> + <target name="flex-config" depends="playerglobal-setswfversion" description="Copy the flex config template to flex-config.xml and inject version numbers"> <copy file="${basedir}/flex-config-template.xml" tofile="${basedir}/flex-config.xml" overwrite="true"> <filterset> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/DefinitionBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/DefinitionBase.as b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/DefinitionBase.as new file mode 100755 index 0000000..f8bdd82 --- /dev/null +++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/DefinitionBase.as @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.reflection +{ + + /** + * The description of a Class or Interface + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DefinitionBase + { + public function DefinitionBase(name:String, rawData:Object = null) + { + _name = name; + _rawData = rawData; + } + + private var _name:String; + public function get name():String + { + return _name; + } + + protected var _rawData:Object; + + protected function get rawData():Object + { + return _rawData; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/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 new file mode 100755 index 0000000..f6555eb --- /dev/null +++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/DefinitionWithMetaData.as @@ -0,0 +1,70 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.reflection +{ + + /** + * The description of a Class or Interface + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class DefinitionWithMetaData extends DefinitionBase + { + public function DefinitionWithMetaData(name:String, rawData:Object = null) + { + super(name, rawData); + } + + public function getMetaData():Array + { + var results:Array = []; + + COMPILE::AS3 + { + var xml:XML = rawData as XML; + var data:XMLList = xml.metadata; + var n:int = data.length(); + for (var i:int = 0; i < n; i++) + { + var item:XML = data[i] as XML; + var qname:String = item.@name; + results.push(new MetaDataDefinition(qname, item)); + } + } + COMPILE::JS + { + var rdata:* = rawData; + if (rdata !== undefined) + { + var metadatas:Array = rdata.metadata(); + if (metadatas) + { + var n:int = metadatas.length; + for each (var mdDef:Object in metadatas) + results.push(new MetaDataDefinition(mdDef.name, mdDef)); + } + } + } + return results; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/FunctionDefinition.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/FunctionDefinition.as b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/FunctionDefinition.as new file mode 100755 index 0000000..5f1f829 --- /dev/null +++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/FunctionDefinition.as @@ -0,0 +1,37 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.reflection +{ + + /** + * The description of a Class or Interface + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class FunctionDefinition extends DefinitionBase + { + public function FunctionDefinition(rawData:Object, packageName:String, name:String) + { + super(packageName, name); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MetaDataArgDefinition.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MetaDataArgDefinition.as b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MetaDataArgDefinition.as new file mode 100755 index 0000000..1f1366f --- /dev/null +++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MetaDataArgDefinition.as @@ -0,0 +1,45 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.reflection +{ + + /** + * The description of a Class or Interface + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class MetaDataArgDefinition extends DefinitionBase + { + public function MetaDataArgDefinition(name:String, value:String) + { + super(name); + _value = value; + } + + private var _value:String; + + public function get value():String + { + return _value; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/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 new file mode 100755 index 0000000..20d50cd --- /dev/null +++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MetaDataDefinition.as @@ -0,0 +1,74 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.reflection +{ + + /** + * The description of a Class or Interface + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class MetaDataDefinition extends DefinitionBase + { + public function MetaDataDefinition(name:String, rawData:Object) + { + super(name, rawData); + } + + public function get args():Array + { + var results:Array = []; + + COMPILE::AS3 + { + var xml:XML = rawData as XML; + var data:XMLList = xml.args; + var n:int = data.length(); + for (var i:int = 0; i < n; i++) + { + var item:XML = data[i] as XML; + var key:String = item.@key; + var value:String = item.@value; + results.push(new MetaDataArgDefinition(key, value)); + } + } + 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(); + if (rdata !== undefined) + { + var args:Array = rdata.args(); + if (args) + { + var n:int = args.length; + for each (var argDef:Object in args) + results.push(new MetaDataArgDefinition(argDef.key, argDef.value)); + } + } + } + return results; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MethodDefinition.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MethodDefinition.as b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MethodDefinition.as new file mode 100755 index 0000000..a16c649 --- /dev/null +++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/MethodDefinition.as @@ -0,0 +1,50 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.reflection +{ + + /** + * The description of a Class or Interface + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class MethodDefinition extends DefinitionWithMetaData + { + public function MethodDefinition(name:String, declaredBy:String, rawData:Object = null) + { + super(name, rawData); + _declaredBy = declaredBy; + } + + private var _declaredBy:String; + private var declaredByDef:TypeDefinition; + + public function get declaredBy():TypeDefinition + { + if (declaredByDef == null) + declaredByDef = new TypeDefinition(_declaredBy); + + return declaredByDef; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/TypeDefinition.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/TypeDefinition.as b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/TypeDefinition.as new file mode 100755 index 0000000..6035bab --- /dev/null +++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/TypeDefinition.as @@ -0,0 +1,260 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.reflection +{ + + /** + * The description of a Class or Interface + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class TypeDefinition extends DefinitionWithMetaData + { + public function TypeDefinition(name:String, rawData:Object = null) + { + var c:int = name.indexOf("::"); + if (c > -1) + { + _packageName = name.substring(0, c); + name = name.substring(c+2); + } + else + _packageName = ""; + super(name, rawData); + } + + private var _packageName:String; + + public function get packageName():String + { + return _packageName; + } + + override protected function get rawData():Object + { + if (_rawData == null) + { + var def:Object = getDefinitionByName(packageName + "::" + name); + COMPILE::AS3 + { + _rawData = describeType(def); + } + COMPILE::JS + { + _rawData = def.prototype.FLEXJS_CLASS_INFO; + } + } + return _rawData; + } + /** + * @flexjsignorecoercion XML + */ + public function get baseClasses():Array + { + var results:Array = []; + + COMPILE::AS3 + { + var xml:XML = rawData as XML; + var data:XMLList = xml.extendsClass; + var n:int = data.length(); + for (var i:int = 0; i < n; i++) + { + var item:XML = data[i] as XML; + var qname:String = item.@type; + results.push(new TypeDefinition(qname)); + } + } + COMPILE::JS + { + var data:Object = rawData; + var name:String = data.names[0].qName; + var def:Object = getDefinitionByName(name); + var prototype:Object = def.prototype; + while (prototype.FLEXJS_CLASS_INFO !== undefined) + { + name = prototype.FLEXJS_CLASS_INFO.names[0].qName; + results.push(new TypeDefinition(name)); + def = getDefinitionByName(name); + prototype = def.prototype; + } + } + return results; + } + + public function get interfaces():Array + { + var results:Array = []; + + COMPILE::AS3 + { + var xml:XML = rawData as XML; + var data:XMLList = xml.implementsInterface; + var n:int = data.length(); + for (var i:int = 0; i < n; i++) + { + var item:XML = data[i] as XML; + var qname:String = item.@type; + results.push(new TypeDefinition(qname)); + } + } + COMPILE::JS + { + var data:* = rawData; + var name:String = data.names[0].qName; + var def:Object = getDefinitionByName(name); + var prototype:Object = def.prototype; + while (data !== undefined) + { + var interfaces:Array = data.interfaces; + if (interfaces) + { + var n:int = interfaces.length; + for each (var s:String in interfaces) + results.push(new TypeDefinition(s)); + } + name = data.names[0].qName; + results.push(new TypeDefinition(name)); + def = getDefinitionByName(name); + prototype = def.prototype; + data = prototype.FLEXJS_CLASS_INFO; + } + } + return results; + } + + public function get variables():Array + { + var results:Array = []; + + COMPILE::AS3 + { + var xml:XML = rawData as XML; + var data:XMLList = xml.variable; + var n:int = data.length(); + for (var i:int = 0; i < n; i++) + { + var item:XML = data[i] as XML; + var qname:String = item.@name; + results.push(new VariableDefinition(qname, item)); + } + } + 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(); + if (rdata !== undefined) + { + var variables:Object = rdata.variables(); + if (variables) + { + for (var v:String in variables) + { + var varDef:Object = variables[v]; + results.push(new VariableDefinition(v, varDef)); + } + } + } + } + return results; + } + + public function get accessors():Array + { + var results:Array = []; + + COMPILE::AS3 + { + var xml:XML = rawData as XML; + var data:XMLList = xml.accessor; + var n:int = data.length(); + for (var i:int = 0; i < n; i++) + { + var item:XML = data[i] as XML; + var qname:String = item.@name; + results.push(new MethodDefinition(qname, item.@declaredBy, item)); + } + } + 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(); + if (rdata !== undefined) + { + var accessors:Object = rdata.accessors(); + if (accessors) + { + for (var prop:String in accessors) + { + var propDef:Object = accessors[prop]; + results.push(new MethodDefinition(prop, propDef.declaredBy, propDef)); + } + } + } + } + return results; + } + + public function get methods():Array + { + var results:Array = []; + + COMPILE::AS3 + { + var xml:XML = rawData as XML; + var data:XMLList = xml.method; + var n:int = data.length(); + for (var i:int = 0; i < n; i++) + { + var item:XML = data[i] as XML; + var qname:String = item.@name; + results.push(new MethodDefinition(qname, item.@declaredBy, item)); + } + } + 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(); + if (rdata !== undefined) + { + var methods:Object = rdata.methods(); + if (methods) + { + for (var fn:String in methods) + { + var fnDef:Object = methods[fn]; + results.push(new MethodDefinition(fn, fnDef.declaredBy, fnDef)); + } + } + } + } + return results; + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/VariableDefinition.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/VariableDefinition.as b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/VariableDefinition.as new file mode 100755 index 0000000..3e87566 --- /dev/null +++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/VariableDefinition.as @@ -0,0 +1,38 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.reflection +{ + + /** + * The description of a Class or Interface + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public class VariableDefinition extends DefinitionWithMetaData + { + public function VariableDefinition(name:String, rawData:Object = null) + { + super(rawData, name); + } + + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/describeType.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/describeType.as b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/describeType.as new file mode 100755 index 0000000..1114a1e --- /dev/null +++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/describeType.as @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.reflection +{ +COMPILE::AS3 +{ + import flash.utils.describeType; +} + + /** + * The equivalent of flash.utils.describeType. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function describeType(value:Object):TypeDefinition + { + COMPILE::AS3 + { + var xml:XML = flash.utils.describeType(value); + return new TypeDefinition(xml.@name, xml); + } + COMPILE::JS + { + var qname:String = getQualifiedClassName(value); + return new TypeDefinition(qname, value.FLEXJS_CLASS_INFO); + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/getDefinitionByName.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/getDefinitionByName.as b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/getDefinitionByName.as new file mode 100755 index 0000000..b18ab3c --- /dev/null +++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/getDefinitionByName.as @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.reflection +{ +COMPILE::AS3 +{ + import flash.utils.getDefinitionByName; +} + + /** + * The equivalent of flash.utils.getQualifiedClassName. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function getDefinitionByName(name:String):Object + { + COMPILE::AS3 + { + return flash.utils.getDefinitionByName(name); + } + COMPILE::JS + { + var parts:Array = name.split('.'); + var n:int = parts.length; + var o:Object = window; + for (var i:int = 0; i < n; i++) { + o = o[parts[i]]; + } + return o; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/getQualifiedClassName.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/getQualifiedClassName.as b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/getQualifiedClassName.as new file mode 100755 index 0000000..42eaa47 --- /dev/null +++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/getQualifiedClassName.as @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.reflection +{ +COMPILE::AS3 +{ + import flash.utils.getQualifiedClassName; +} + + /** + * The equivalent of flash.utils.getQualifiedClassName. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function getQualifiedClassName(value:*):String + { + COMPILE::AS3 + { + return flash.utils.getQualifiedClassName(value); + } + COMPILE::JS + { + if (value.FLEXJS_CLASS_INFO == null) + { + if (value.prototype.FLEXJS_CLASS_INFO == null) + return null; + value = value.prototype; + } + return value.FLEXJS_CLASS_INFO.names[0].qName; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/getQualifiedSuperclassName.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/getQualifiedSuperclassName.as b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/getQualifiedSuperclassName.as new file mode 100755 index 0000000..95c75fa --- /dev/null +++ b/frameworks/projects/Reflection/as/src/org/apache/flex/reflection/getQualifiedSuperclassName.as @@ -0,0 +1,49 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.flex.reflection +{ +COMPILE::AS3 +{ + import flash.utils.getQualifiedSuperclassName; +} + + /** + * The equivalent of flash.utils.getQualifiedSuperclassName. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.0 + */ + public function getQualifiedSuperclassName(value:*):String + { + COMPILE::AS3 + { + return flash.utils.getQualifiedSuperclassName(value); + } + COMPILE::JS + { + var constructorAsObject:Object = value["constructor"]; + value = constructorAsObject.superClass_; + if (value == null || value.FLEXJS_CLASS_INFO == null) + return null; + return value.FLEXJS_CLASS_INFO.names[0].qName; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/build.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/build.xml b/frameworks/projects/Reflection/build.xml new file mode 100644 index 0000000..b88f21d --- /dev/null +++ b/frameworks/projects/Reflection/build.xml @@ -0,0 +1,165 @@ +<?xml version="1.0"?> +<!-- + + 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. + +--> + + +<project name="Reflection" default="main" basedir="."> + <property name="FLEXJS_HOME" location="../../.."/> + + <property file="${FLEXJS_HOME}/env.properties"/> + <property environment="env"/> + <property file="${FLEXJS_HOME}/build.properties"/> + <property name="FLEX_HOME" value="${FLEXJS_HOME}"/> + <property name="FALCON_HOME" value="${env.FALCON_HOME}"/> + <property name="FALCONJX_HOME" value="${env.FALCONJX_HOME}"/> + + <target name="main" depends="clean,compile-asjs,compile-extern-swc,copy-js,compile,test" description="Full build of Reflection.swc"> + </target> + + <target name="test" unless="is.jenkins"> + <!-- no tests yet + <ant dir="as/tests" /> + --> + </target> + + <target name="test-js" unless="is.jenkins"> + <!-- no tests yet + <ant dir="js/tests" /> + --> + </target> + + <target name="clean"> + <delete failonerror="false"> + <fileset dir="${FLEXJS_HOME}/frameworks/libs"> + <include name="Reflection.swc"/> + </fileset> + </delete> + <delete failonerror="false"> + <fileset dir="${basedir}/js/out"> + <include name="**/**"/> + </fileset> + </delete> + </target> + + <path id="lib.path"> + <fileset dir="${FALCON_HOME}/lib" includes="falcon-flexTasks.jar"/> + </path> + + <target name="compile" description="Compiles .as files into .swc"> + <echo message="Compiling libs/Reflection.swc"/> + <echo message="FLEX_HOME: ${FLEX_HOME}"/> + <echo message="FALCON_HOME: ${FALCON_HOME}"/> + <!-- make JS output folder now so include-file doesn't error --> + <mkdir dir="${basedir}/js/out" /> + + <!-- Load the <compc> task. We can't do this at the <project> level --> + <!-- because targets that run before flexTasks.jar gets built would fail. --> + <taskdef resource="flexTasks.tasks" classpathref="lib.path"/> + <!-- + Link in the classes (and their dependencies) for the MXML tags + listed in this project's manifest.xml. + Also link the additional classes (and their dependencies) + listed in ReflectionClasses.as, + because these aren't referenced by the manifest classes. + Keep the standard metadata when compiling. + Include the appropriate CSS files and assets in the SWC. + Don't include any resources in the SWC. + Write a bundle list of referenced resource bundles + into the file bundles.properties in this directory. + --> + <compc fork="true" + output="${FLEXJS_HOME}/frameworks/libs/Reflection.swc"> + <jvmarg line="${compc.jvm.args}"/> + <load-config filename="compile-config.xml" /> + <arg value="+playerglobal.version=${playerglobal.version}" /> + <arg value="+env.AIR_HOME=${env.AIR_HOME}" /> + <arg value="-define=COMPILE::AS3,true" /> + <arg value="-define=COMPILE::JS,false" /> + </compc> + </target> + + <target name="compile-asjs" > + <echo message="Cross-compiling Reflection/asjs"/> + <echo message="FALCONJX_HOME: ${FALCONJX_HOME}"/> + <java jar="${FALCONJX_HOME}/lib/compc.jar" fork="true" > + <jvmarg value="-Xmx384m" /> + <jvmarg value="-Dsun.io.useCanonCaches=false" /> + <jvmarg value="-Dflexcompiler=${FALCONJX_HOME}/../compiler" /> + <jvmarg value="-Dflexlib=${FLEXJS_HOME}/frameworks" /> + <arg value="+flexlib=${FLEX_HOME}/frameworks" /> + <arg value="-js-output-type=FLEXJS" /> + <arg value="-keep-asdoc" /><!-- allows compiler to see @flexjsignorecoercion annotations --> + <arg value="-output=${basedir}/js/out" /> + <arg value="-load-config=${basedir}/compile-asjs-config.xml" /> + <arg value="+playerglobal.version=${playerglobal.version}" /> + <arg value="+env.PLAYERGLOBAL_HOME=${env.PLAYERGLOBAL_HOME}" /> + <arg value="+env.AIR_HOME=${env.AIR_HOME}" /> + <arg value="-external-library-path+=${FALCONJX_HOME}/../externs/js/out/bin/js.swc" /> + <!-- this is not on external-library path otherwise goog.requires are not generated --> + <arg value="-library-path+=${FALCONJX_HOME}/../externs/GCL/out/bin/GCL.swc" /> + <arg value="-define=COMPILE::AS3,false" /> + <arg value="-define=COMPILE::JS,true" /> + </java> + </target> + + <target name="compile-extern-swc" description="Compiles .as files into .swc used for cross-compiling other projects"> + <echo message="Compiling externs/Reflection.swc"/> + <echo message="FLEX_HOME: ${FLEX_HOME}"/> + <echo message="FALCON_HOME: ${FALCON_HOME}"/> + <!-- make JS output folder now so include-file doesn't error --> + <mkdir dir="${FLEXJS_HOME}/frameworks/externs"/> + + <!-- Load the <compc> task. We can't do this at the <project> level --> + <!-- because targets that run before flexTasks.jar gets built would fail. --> + <taskdef resource="flexTasks.tasks" classpathref="lib.path"/> + <!-- + Link in the classes (and their dependencies) for the MXML tags + listed in this project's manifest.xml. + Also link the additional classes (and their dependencies) + listed in CoreClasses.as, + because these aren't referenced by the manifest classes. + Keep the standard metadata when compiling. + Include the appropriate CSS files and assets in the SWC. + Don't include any resources in the SWC. + Write a bundle list of referenced resource bundles + into the file bundles.properties in this directory. + --> + <compc fork="true" + output="${FLEXJS_HOME}/frameworks/externs/Reflection.swc"> + <jvmarg line="${compc.jvm.args}"/> + <load-config filename="compile-asjs-config.xml" /> + <arg value="+playerglobal.version=${playerglobal.version}" /> + <arg value="+env.AIR_HOME=${env.AIR_HOME}" /> + <arg value="-external-library-path+=${FALCONJX_HOME}/../externs/js/out/bin/js.swc" /> + <!-- this is not on external-library path otherwise goog.requires are not generated --> + <arg value="-library-path+=${FALCONJX_HOME}/../externs/GCL/out/bin/GCL.swc" /> + <arg value="-define=COMPILE::AS3,false" /> + <arg value="-define=COMPILE::JS,true" /> + </compc> + </target> + + <target name="copy-js" > + <copy todir="${FLEXJS_HOME}/frameworks/js/FlexJS/libs"> + <fileset dir="${basedir}/js/out"> + <include name="**/**" /> + </fileset> + </copy> + </target> + +</project> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/compile-asjs-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/compile-asjs-config.xml b/frameworks/projects/Reflection/compile-asjs-config.xml new file mode 100644 index 0000000..92f5a0f --- /dev/null +++ b/frameworks/projects/Reflection/compile-asjs-config.xml @@ -0,0 +1,77 @@ +<!-- + + 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. + +--> +<flex-config> + + <compiler> + <accessible>false</accessible> + + <external-library-path> + </external-library-path> + + <mxml> + <children-as-data>true</children-as-data> + </mxml> + <binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event> + <binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind> + <binding-value-change-event-type>valueChange</binding-value-change-event-type> + + <keep-as3-metadata> + <name>Bindable</name> + <name>Managed</name> + <name>ChangeEvent</name> + <name>NonCommittingChangeEvent</name> + <name>Transient</name> + </keep-as3-metadata> + + <locale/> + + <library-path> + <!-- asjscompc won't 'link' these classes in, but will list their requires + if these swcs are on the external-library-path then their requires + will not be listed --> + <path-element>../../externs/Core.swc</path-element> + </library-path> + + <namespaces> + </namespaces> + + <source-path> + <path-element>as/src</path-element> + </source-path> + + <warn-no-constructor>false</warn-no-constructor> + </compiler> + + <include-file> + </include-file> + + <include-sources> + <path-element>as/src</path-element> + </include-sources> + + <include-classes> + </include-classes> + + <include-namespaces> + </include-namespaces> + + <target-player>${playerglobal.version}</target-player> + + +</flex-config> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/frameworks/projects/Reflection/compile-config.xml ---------------------------------------------------------------------- diff --git a/frameworks/projects/Reflection/compile-config.xml b/frameworks/projects/Reflection/compile-config.xml new file mode 100644 index 0000000..e02f6b2 --- /dev/null +++ b/frameworks/projects/Reflection/compile-config.xml @@ -0,0 +1,73 @@ +<!-- + + 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. + +--> +<flex-config> + + <compiler> + <accessible>false</accessible> + + <external-library-path> + <path-element>${env.AIR_HOME}/frameworks/libs/air/airglobal.swc</path-element> + <path-element>../../libs/Core.swc</path-element> + </external-library-path> + + <mxml> + <children-as-data>true</children-as-data> + </mxml> + <binding-value-change-event>org.apache.flex.events.ValueChangeEvent</binding-value-change-event> + <binding-value-change-event-kind>org.apache.flex.events.ValueChangeEvent</binding-value-change-event-kind> + <binding-value-change-event-type>valueChange</binding-value-change-event-type> + + <keep-as3-metadata> + <name>Bindable</name> + <name>Managed</name> + <name>ChangeEvent</name> + <name>NonCommittingChangeEvent</name> + <name>Transient</name> + </keep-as3-metadata> + + <locale/> + + <library-path/> + + <namespaces> + </namespaces> + + <source-path> + <path-element>as/src</path-element> + </source-path> + + <warn-no-constructor>false</warn-no-constructor> + </compiler> + + <include-file> + <name>js/out/*</name> + <path>js/out/*</path> + </include-file> + + <include-sources> + <path-element>as/src</path-element> + </include-sources> + + <include-namespaces> + </include-namespaces> + + <target-player>${playerglobal.version}</target-player> + + +</flex-config> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/manualtests/ReflectionTest/build.xml ---------------------------------------------------------------------- diff --git a/manualtests/ReflectionTest/build.xml b/manualtests/ReflectionTest/build.xml new file mode 100644 index 0000000..c705edf --- /dev/null +++ b/manualtests/ReflectionTest/build.xml @@ -0,0 +1,70 @@ +<?xml version="1.0"?> +<!-- + + 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. + +--> + + +<project name="reflectiontest" default="main" basedir="."> + <property name="FLEXJS_HOME" location="../.."/> + <property name="example" value="ReflectionTest" /> + + <property environment="env"/> + <property file="${FLEXJS_HOME}/build.properties"/> + <property name="FLEX_HOME" value="${FLEXJS_HOME}"/> + <available file="${env.FALCON_HOME}/lib/falcon-mxmlc.jar" + type="file" + property="FALCON_HOME" + value="${env.FALCON_HOME}"/> + + <available file="${FLEXJS_HOME}/../flex-falcon/compiler/generated/dist/sdk/lib/falcon-mxmlc.jar" + type="file" + property="FALCON_HOME" + value="${FLEXJS_HOME}/../flex-falcon/compiler/generated/dist/sdk"/> + + <available file="${env.FALCONJX_HOME}/lib/jsc.jar" + type="file" + property="FALCONJX_HOME" + value="${env.FALCONJX_HOME}"/> + + <available file="${FLEXJS_HOME}/../flex-falcon/compiler.jx/lib/jsc.jar" + type="file" + property="FALCONJX_HOME" + value="${FLEXJS_HOME}/../flex-falcon/compiler.jx"/> + + <available file="${env.GOOG_HOME}/closure/goog/base.js" + type="file" + property="GOOG_HOME" + value="${env.GOOG_HOME}"/> + + <available file="${FLEXJS_HOME}/js/lib/google/closure-library/closure/goog/base.js" + type="file" + property="GOOG_HOME" + value="${FLEXJS_HOME}/js/lib/google/closure-library"/> + + <include file="${basedir}/../build_example.xml" /> + + <target name="main" depends="clean,build_example.compile,build_example.compilejs" description="Clean build of FlexJSUI.swc"> + </target> + + <target name="clean"> + <delete dir="${basedir}/bin" failonerror="false" /> + <delete dir="${basedir}/bin-debug" failonerror="false" /> + <delete dir="${basedir}/bin-release" failonerror="false" /> + </target> + +</project> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/manualtests/ReflectionTest/src/MyInitialView.mxml ---------------------------------------------------------------------- diff --git a/manualtests/ReflectionTest/src/MyInitialView.mxml b/manualtests/ReflectionTest/src/MyInitialView.mxml new file mode 100644 index 0000000..7334c43 --- /dev/null +++ b/manualtests/ReflectionTest/src/MyInitialView.mxml @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +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. + +--> +<js:ViewBase xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:js="library://ns.apache.org/flexjs/basic" + xmlns:local="*" + xmlns:models="models.*" + xmlns:acc="org.apache.flex.html.accessories.*"> + + <fx:Style> + .title { + font-size: 14pt; + font-weight: bold; + } + + </fx:Style> + + <fx:Script> + <![CDATA[ + import org.apache.flex.core.IPopUpHost; + import org.apache.flex.events.Event; + import org.apache.flex.utils.UIUtils; + + import org.apache.flex.reflection.describeType; + import org.apache.flex.reflection.MethodDefinition; + import org.apache.flex.reflection.TypeDefinition; + + public function runTest():void + { + var td:TypeDefinition = describeType(this); + trace(td.name); + var methods:Array = td.methods; + var md:MethodDefinition = methods[0] as MethodDefinition; + trace(md.name); + } + ]]> + </fx:Script> + + <js:Container width="600" height="700" x="50" y="50"> + <js:beads> + <js:VerticalLayout /> + </js:beads> + + <js:Label text="Reflection Test" className="title" /> + <js:TextButton text="Test" click="runTest()" /> + </js:Container> + +</js:ViewBase> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/manualtests/ReflectionTest/src/README.txt ---------------------------------------------------------------------- diff --git a/manualtests/ReflectionTest/src/README.txt b/manualtests/ReflectionTest/src/README.txt new file mode 100644 index 0000000..f38df7f --- /dev/null +++ b/manualtests/ReflectionTest/src/README.txt @@ -0,0 +1,45 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// + +DESCRIPTION + +The FormExample application demonstrates several FlexJS components and how they +can be aligned in a column, much like you would see in a form. + +This Flex application may be run as a Flash SWF or cross-compiled (using Falcon JX) +into JavaScript and HTML and run without Flash. + +The components are placed into a Container with a VerticalColumnLayout bead. This bead +examines each of the children in the Container and aligns them in two columns. + +COMPONENTS and BEADS + +- Container +- DateField +- Label +- TextInput + +- NonVirtualVerticalLayout +- NumericOnlyTextInputBead +- VerticalColumnLayout + +NOTES + +The cross-compilation to JavaScript often results in non-fatal warnings. Some of these warnings +should be addressed in future releases of the Falcon JX compiler. http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/manualtests/ReflectionTest/src/ReflectionTest.mxml ---------------------------------------------------------------------- diff --git a/manualtests/ReflectionTest/src/ReflectionTest.mxml b/manualtests/ReflectionTest/src/ReflectionTest.mxml new file mode 100644 index 0000000..27e97b5 --- /dev/null +++ b/manualtests/ReflectionTest/src/ReflectionTest.mxml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<!--- +// +// 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. +// +//////////////////////////////////////////////////////////////////////////////// +--> +<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:local="*" + xmlns:models="models.*" + xmlns:controllers="controllers.*" + xmlns:js="library://ns.apache.org/flexjs/basic" + > + + <js:valuesImpl> + <js:SimpleCSSValuesImpl /> + </js:valuesImpl> + <js:controller> + <controllers:MyController /> + </js:controller> + <js:model> + <models:MyModel /> + </js:model> + <js:initialView> + <local:MyInitialView /> + </js:initialView> +</js:Application> http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/manualtests/ReflectionTest/src/controllers/MyController.as ---------------------------------------------------------------------- diff --git a/manualtests/ReflectionTest/src/controllers/MyController.as b/manualtests/ReflectionTest/src/controllers/MyController.as new file mode 100644 index 0000000..81eb963 --- /dev/null +++ b/manualtests/ReflectionTest/src/controllers/MyController.as @@ -0,0 +1,52 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 controllers +{ + import org.apache.flex.events.Event; + + import org.apache.flex.core.Application; + import org.apache.flex.core.IDocument; + + import models.MyModel; + + public class MyController implements IDocument + { + public function MyController(app:Application = null) + { + if (app) + { + this.app = app as ReflectionTest; + app.addEventListener("viewChanged", viewChangeHandler); + } + } + + private var app:ReflectionTest; + + private function viewChangeHandler(event:Event):void + { + } + + public function setDocument(document:Object, id:String = null):void + { + this.app = document as ReflectionTest; + app.addEventListener("viewChanged", viewChangeHandler); + } + + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/94ab3ff8/manualtests/ReflectionTest/src/models/MyModel.as ---------------------------------------------------------------------- diff --git a/manualtests/ReflectionTest/src/models/MyModel.as b/manualtests/ReflectionTest/src/models/MyModel.as new file mode 100644 index 0000000..5a16d02 --- /dev/null +++ b/manualtests/ReflectionTest/src/models/MyModel.as @@ -0,0 +1,125 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 models +{ + import org.apache.flex.events.Event; + import org.apache.flex.events.EventDispatcher; + + public class MyModel extends EventDispatcher + { + public function MyModel() + { + } + + private var _requestedField:String = "Ask"; + + [Bindable("requestedFieldChanged")] + public function get requestedField():String + { + return _requestedField; + } + + public function set requestedField(value:String):void + { + if (value != _requestedField) + { + _requestedField = value; + dispatchEvent(new Event("requestedFieldChanged")); + if (_responseData) + dispatchEvent(new Event("responseTextChanged")); + } + } + + [Bindable("responseTextChanged")] + public function get responseText():String + { + if (_responseData == null) + return ""; + if (_responseData == "No Data") + return _responseData as String; + var s:String = _responseData[_requestedField]; + if (s == null) + { + if (_requestedField == "Ask") + s = _responseData["Bid"]; + } + return s; + } + + private var _responseData:Object; + + [Bindable("responseDataChanged")] + public function get responseData():Object + { + return _responseData; + } + + public function set responseData(value:Object):void + { + if (value != _responseData) + { + _responseData = value; + _allData = ""; + dispatchEvent(new Event("responseDataChanged")); + dispatchEvent(new Event("responseTextChanged")); + } + } + + private var _allData:String = ""; + + [Bindable("responseDataChanged")] + public function get allData():String + { + if (_allData == "" && _responseData != null) + { + for (var p:String in _responseData) + { + _allData += p + ": " + _responseData[p] + "\n"; + } + } + return _allData; + } + + + private var _stockSymbol:String; + + [Bindable("stockSymbolChanged")] + public function get stockSymbol():String + { + return _stockSymbol; + } + + public function set stockSymbol(value:String):void + { + if (value != _stockSymbol) + { + _stockSymbol = value; + dispatchEvent(new Event("stockSymbolChanged")); + } + } + + private var _strings:Array = ["AAPL", "ADBE", "GOOG", "MSFT", "YHOO"]; + [Bindable("__NoChangeEvent__")] + public function get strings():Array + { + return _strings; + } + + } +} \ No newline at end of file
