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] - initial support for QName and Namespaces in JS
Date Fri, 11 Mar 2016 03:32:43 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 1c4d36c08 -> b4f50115d


initial support for QName and Namespaces in JS


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

Branch: refs/heads/develop
Commit: b4f50115d5169b90212f51254b0710430ad218f3
Parents: 1c4d36c
Author: Alex Harui <aharui@apache.org>
Authored: Thu Mar 10 19:28:11 2016 -0800
Committer: Alex Harui <aharui@apache.org>
Committed: Thu Mar 10 19:28:20 2016 -0800

----------------------------------------------------------------------
 .../projects/Core/src/main/flex/CoreClasses.as  |  2 +
 .../projects/Core/src/main/flex/Namespace.as    | 50 ++++++++++++++++++
 frameworks/projects/Core/src/main/flex/QName.as | 53 ++++++++++++++++++++
 manualtests/LanguageTests/src/LanguageTests.as  | 26 ++++++++--
 4 files changed, 128 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b4f50115/frameworks/projects/Core/src/main/flex/CoreClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/CoreClasses.as b/frameworks/projects/Core/src/main/flex/CoreClasses.as
index 5ad1688..b806f68 100644
--- a/frameworks/projects/Core/src/main/flex/CoreClasses.as
+++ b/frameworks/projects/Core/src/main/flex/CoreClasses.as
@@ -145,6 +145,8 @@ internal class CoreClasses
 	COMPILE::JS
 	{
 	    import org.apache.flex.utils.Language; Language;
+		import QName; QName;
+		import Namespace; Namespace;
 	}
 }
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b4f50115/frameworks/projects/Core/src/main/flex/Namespace.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/Namespace.as b/frameworks/projects/Core/src/main/flex/Namespace.as
new file mode 100644
index 0000000..305d88c
--- /dev/null
+++ b/frameworks/projects/Core/src/main/flex/Namespace.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 {
+
+/**
+ *  Namespace implementation for JS
+ */
+public class Namespace
+{
+    public function Namespace(param1:*, param2:* = undefined)
+	{
+		if (param2 !== undefined)
+		{
+			uri = param2;
+			prefix = param1;
+		}
+		else
+		{
+			uri = param1;
+		}
+	}
+	
+	public var uri:String;
+	public var prefix:String;
+	
+	public function toString():String
+	{
+		return uri;
+	}
+	
+}
+
+}
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b4f50115/frameworks/projects/Core/src/main/flex/QName.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Core/src/main/flex/QName.as b/frameworks/projects/Core/src/main/flex/QName.as
new file mode 100644
index 0000000..26c398b
--- /dev/null
+++ b/frameworks/projects/Core/src/main/flex/QName.as
@@ -0,0 +1,53 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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 {
+
+/**
+ *  QName implementation for JS
+ */
+public class QName
+{
+    public function QName(param1:Object, localName:String = null)
+	{
+		if (param1 is QName)
+		{
+			var q:QName = param1 as QName;
+			uri = q.uri;
+			localName = q.localName;
+		}
+		else if (param1 is Namespace)
+		{
+			var n:Namespace = param1 as Namespace;
+			uri = n.uri;
+			this.localName = localName;
+		}
+	}
+	
+	public var uri:String;
+	public var localName:String;
+	
+	public function toString():String
+	{
+		return uri + "::" + localName;
+	}
+	
+}
+
+}
+

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/b4f50115/manualtests/LanguageTests/src/LanguageTests.as
----------------------------------------------------------------------
diff --git a/manualtests/LanguageTests/src/LanguageTests.as b/manualtests/LanguageTests/src/LanguageTests.as
index 1343abe..8ed9c38 100644
--- a/manualtests/LanguageTests/src/LanguageTests.as
+++ b/manualtests/LanguageTests/src/LanguageTests.as
@@ -19,9 +19,6 @@
 package
 {
 
-import org.apache.flex.core.SimpleApplication;
-import org.apache.flex.events.Event;
-
 import classes.B;
 
 import interfaces.IA;
@@ -31,6 +28,9 @@ import interfaces.ID;
 import interfaces.IE;
 import interfaces.IF;
 
+import org.apache.flex.core.SimpleApplication;
+import org.apache.flex.events.Event;
+
 public class LanguageTests extends SimpleApplication implements IA, IE
 {
 	public function LanguageTests()
@@ -149,6 +149,19 @@ public class LanguageTests extends SimpleApplication implements IA, IE
             trace("removeEventListener worked");
         else
             trace("This shouldn't show!");
+        
+        var n:Namespace = new Namespace("my_ns", "http://www.apache.org/2016/flex/ns/internal");
+        trace("Namespace.prefix (should be my_ns): ", n.prefix);
+        trace("Namespace.uri (should be http://www.apache.org/2016/flex/ns/internal): ",
n.uri);
+        var q:QName = new QName(n, "my_namespaced_property");
+        trace("QName.localName (should be my_namespaced_property): ", q.localName);
+        trace("QName.uri (should be http://www.apache.org/2016/flex/ns/internal): ", q.uri);
+        var o:MyDynamicClass = new MyDynamicClass;
+        o[q] = "value_of_namespaced_property";
+        trace("Get namespaced property via []: ", o[q]);
+        trace("Get namespaced property via ::: ", o.n::my_namespaced_property);
+        trace("Get namespaced property via my_ns: ", o.my_ns::my_namespaced_property);
+        
 	}
     
     public function eventHandler(e:Event):void
@@ -156,4 +169,11 @@ public class LanguageTests extends SimpleApplication implements IA, IE
         
     }
 }
+}
+
+namespace my_ns = "http://www.apache.org/2016/flex/ns/internal";
+
+dynamic class MyDynamicClass
+{
+    my_ns var my_namespaced_property:String;    
 }
\ No newline at end of file


Mime
View raw message