You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2019/12/18 19:48:34 UTC

[royale-asjs] branch develop updated (42a6edf -> 4ba1c82)

This is an automated email from the ASF dual-hosted git repository.

harbs pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git.


    from 42a6edf  RoyaleUnitUI: add to release stuff
     new d08f942  Added delete test
     new e4d1fac  Fixed delete issues Removed XMLText and XMLAttribute classes
     new 4ba1c82  Merge branch 'fix_xml_delete' into develop

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 frameworks/projects/XML/src/main/royale/XML.as     | 55 ++++++++++++++--------
 .../projects/XML/src/main/royale/XMLAttribute.as   | 55 ----------------------
 frameworks/projects/XML/src/main/royale/XMLText.as | 55 ----------------------
 .../flexUnitTests/xml/XMLTesterGeneralTest.as      | 16 +++++++
 4 files changed, 52 insertions(+), 129 deletions(-)
 delete mode 100644 frameworks/projects/XML/src/main/royale/XMLAttribute.as
 delete mode 100644 frameworks/projects/XML/src/main/royale/XMLText.as


[royale-asjs] 01/03: Added delete test

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit d08f9427434fafaaa61f66e0b614cb11818ddc22
Author: Harbs <ha...@in-tools.com>
AuthorDate: Wed Dec 18 20:32:25 2019 +0200

    Added delete test
---
 .../test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as    | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
index 6139fd1..3affad8 100644
--- a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
+++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
@@ -1120,5 +1120,17 @@ package flexUnitTests.xml
     
             XML.setSettings(XML.defaultSettings());
         }
+
+        [Test]
+        public function testDelete():void{
+            XML.setSettings(XML.defaultSettings());
+            XML.prettyPrinting = false;
+            var xml:XML = <root name="foo"><baz name="baz1"/><baz name="baz2"/></root>;
+            delete xml.@name;
+            assertEquals(xml.toString(),'<root><baz name="baz1"/><baz name="baz2"/></root>',"name attribute should have been removed.");
+            delete xml.baz[0];
+            assertEquals(xml.toString(),'<root><baz name="baz2"/></root>',"the first baz element should have been removed.");
+            XML.setSettings(XML.defaultSettings());
+        }
     }
 }


Re: [royale-asjs] 02/03: Fixed delete issues Removed XMLText and XMLAttribute classes

Posted by Greg Dove <gr...@gmail.com>.
Great to hear! That is part of the reason for having the tests in the first
place, it should allow us to collaborate easier.

fyi I still usually do a lot of the test driven development in the
manualtests/UnitTest project and then migrate the tests to RoyaleUnit for a
couple of reasons:

1. RoyaleUnit does not (yet, I think?) offer the option to run the same
tests in js-release mode. Sometimes that is important when you are doing
low level emulation work because it might 'break a few rules' for normal
actionscript and be sensitive to how GCC minifies stuff. So while I mainly
do the work in js-debug, I always check in js-release as well.
2. I can compare things side by side and trace to the same browser console
from both flash (via EI) and js versions of the tests at the same time to
compare. This can sometimes be useful during development.

When I am working that way, I normally limit the tests to the specific
library I am working on. And then add all the (many) tests back when done
as another check that there is no regression in other areas that may depend
on whatever I just did.
Once I am confident that things are working as they should I then migrate
the new tests to RoyaleUnit.

Not saying you should do the same, just explaining why I do it that way....


On Thu, Dec 19, 2019 at 8:52 AM Harbs <ha...@gmail.com> wrote:

> I figured out a way to determine XML “type” for “element” “text” and
> “attribute” without writing an instance variable at all.
>
> I also discovered and fixed some issues with delete in the XML
> implementation. (I added tests for that.)
>
> Greg, thanks for all the tests! It makes fixing issues (and confirming
> fixes) much easier! ;-)
>
> Harbs
>
> > On Dec 18, 2019, at 9:48 PM, harbs@apache.org wrote:
> >
> > This is an automated email from the ASF dual-hosted git repository.
> >
> > harbs pushed a commit to branch develop
> > in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
> >
> > commit e4d1facc591c2a57d430878c78146a2760215032
> > Author: Harbs <ha...@in-tools.com>
> > AuthorDate: Wed Dec 18 21:45:47 2019 +0200
> >
> >    Fixed delete issues
> >    Removed XMLText and XMLAttribute classes
> > ---
> > frameworks/projects/XML/src/main/royale/XML.as     | 55
> ++++++++++++++--------
> > .../projects/XML/src/main/royale/XMLAttribute.as   | 55
> ----------------------
> > frameworks/projects/XML/src/main/royale/XMLText.as | 55
> ----------------------
> > .../flexUnitTests/xml/XMLTesterGeneralTest.as      |  4 ++
> > 4 files changed, 40 insertions(+), 129 deletions(-)
> >
> > diff --git a/frameworks/projects/XML/src/main/royale/XML.as
> b/frameworks/projects/XML/src/main/royale/XML.as
> > index 9df4b14..ccd283d 100644
> > --- a/frameworks/projects/XML/src/main/royale/XML.as
> > +++ b/frameworks/projects/XML/src/main/royale/XML.as
> > @@ -324,7 +324,7 @@ package
> >
> >               static private function
> insertAttribute(att:Attr,parent:XML):XML
> >               {
> > -                     var xml:XML = new XMLAttribute();
> > +                     var xml:XML = new XML();
> >                       xml._parent = parent;
> >                       xml._name = getQName(att.localName, '',
> att.namespaceURI, true);
> >                       xml._value = att.value;
> > @@ -407,12 +407,12 @@ package
> >                                               data = data.trim();
> >                                               if (!data) return null;
> >                                       }
> > -                                     xml = new XMLText();
> > +                                     xml = new XML();
> >                                       xml.setValue(data);
> >                                       break;
> >                               case 4:
> >                                       //CDATA_SECTION_NODE
> > -                                     xml = new XMLText();
> > +                                     xml = new XML();
> >                                       data = "<![CDATA[" + data + "]]>";
> >                                       xml.setValue(data);
> >                                       break;
> > @@ -540,8 +540,6 @@ package
> >                               var className:String =
> xml.ROYALE_CLASS_INFO.names[0].name;
> >                               switch(className){
> >                                       case "XML":
> > -                                     case "XMLAttribute":
> > -                                     case "XMLText":
> >                                               return xml;
> >                                       case "XMLList":
> >                                               var xmlList:XMLList = xml
> as XMLList;
> > @@ -572,7 +570,7 @@ package
> >                               var xmlStr:String = ignoreWhitespace ?
> trimXMLWhitespace("" + xml) : "" + xml;
> >                               if(xmlStr.indexOf("<") == -1)
> >                               {
> > -                                     _nodeKind = TEXT;
> > +                                     // _nodeKind = TEXT;
> >                                       _value = xmlStr;
> >                               }
> >                               else
> > @@ -581,7 +579,7 @@ package
> >                               }
> >                       } else {
> >                               if (!_internal) {
> > -                                     _nodeKind = TEXT;
> > +                                     // _nodeKind = TEXT;
> >                                       _value = '';
> >                               }
> >                       }
> > @@ -685,7 +683,7 @@ package
> >                                       if (node.nodeType == 7) {
> >                                               if
> (XML.ignoreProcessingInstructions) {
> >                                                       if (!foundCount) {
> > -
>  this._nodeKind = TEXT;
> > +                                                             //
> this._nodeKind = TEXT;
> >                                                               //e4x: The
> value of the [[Name]] property is null if and only if the XML object
> represents an XML comment or text node
> >                                                               delete
> this._name;
> >
>  this.setValue('');
> > @@ -698,7 +696,7 @@ package
> >                                               }
> >                                       } else if (node.nodeType == 4) {
> >                                               if (!foundCount) {
> > -                                                     this._nodeKind =
> TEXT;
> > +                                                     // this._nodeKind
> = TEXT;
> >                                                       //e4x: The value
> of the [[Name]] property is null if and only if the XML object represents
> an XML comment or text node
> >                                                       delete this._name;
> >
>  this.setValue('<![CDATA[' + node.nodeValue + ']]>');
> > @@ -709,7 +707,7 @@ package
> >                                               delete this._name;
> >                                               if (XML.ignoreComments) {
> >                                                       if (!foundCount) {
> > -
>  this._nodeKind = TEXT;
> > +                                                             //
> this._nodeKind = TEXT;
> >
>  this.setValue('');
> >                                                       }
> >                                               } else {
> > @@ -724,7 +722,8 @@ package
> >                                               var whiteSpace:Boolean =
> isWhitespace.test(node.nodeValue);
> >                                               if (!whiteSpace ||
> !XML.ignoreWhitespace) {
> >                                                       if (!foundCount) {
> > -
>  this._nodeKind = TEXT;
> > +                                                             delete
> this._name;
> > +                                                             //
> this._nodeKind = TEXT;
> >
>  this.setValue(node.nodeValue);
> >                                                       }
> >                                                       foundCount++;
> > @@ -902,7 +901,7 @@ package
> >                                       const wrapper:XML = new XML();
> >                                       wrapper.resetNodeKind();
> >                                       child = new XML(child.toString());
> > -                                     wrapper.setName(lastChild.name());
> > +                                     wrapper._name = lastChild._name;
> >                                       child.setParent(wrapper);
> >                                       wrapper.getChildren().push(child);
> >                                       child = wrapper;
> > @@ -1165,7 +1164,7 @@ package
> >                       var xml:XML = new XML();
> >                       xml.resetNodeKind();
> >                       xml.setNodeKind(getNodeKindInternal());
> > -                     xml.setName(name());
> > +                     xml._name = _name;
> >                       if(_value){
> >                               xml.setValue(_value);
> >                       }
> > @@ -1880,7 +1879,14 @@ package
> >               }
> >
> >               protected function getNodeRef():String{
> > -                     return _nodeKind ? _nodeKind : ELEMENT;
> > +                     if(_nodeKind)
> > +                             return _nodeKind;
> > +                     if(!_name)
> > +                             return TEXT;
> > +                     if(_name.isAttribute){
> > +                             return ATTRIBUTE;
> > +                     }
> > +                     return ELEMENT;
> >               }
> >
> >               private static const kindNameLookup:Object = {
> > @@ -1967,7 +1973,7 @@ package
> >               private function xmlFromStringable(value:*):XML
> >               {
> >                       var str:String = value.toString();
> > -                     var xml:XML = new XMLText();
> > +                     var xml:XML = new XML();
> >                       xml.setValue(str);
> >                       return xml;
> >               }
> > @@ -2060,16 +2066,26 @@ package
> >                               7. Return true.
> >                       */
> >                       var i:int;
> > +                     var len:int;
> >                       var removed:XML;
> >                       if(!child)
> >                               return false;
> > -
> > +                     if(child is XMLList){
> > +                             var val:Boolean = false;
> > +                             len = child.length();
> > +                             for(i=len-1;i>=0;i--){
> > +                                     if(removeChild(child[i])){
> > +                                             val = true;
> > +                                     }
> > +                             }
> > +                             return val;
> > +                     }
> >                       if(!(child is XML))
> >                               return removeChildByName(child);
> >
> >                       if(child.getNodeRef() == ATTRIBUTE)
> >                       {
> > -                             var len:int = attributeLength();
> > +                             len = attributeLength();
> >                               for(i=0;i<len;i++)
> >                               {
> >                                       if(child.equals(_attributes[i]))
> > @@ -2397,8 +2413,9 @@ package
> >                       else
> >                       {
> >                               //it's a regular attribute string
> > -                             var attrXML:XML = new XMLAttribute();
> > -                             attrXML.setName(toAttributeName(attr));
> > +                             var attrXML:XML = new XML();
> > +                             var nameRef:QName = toAttributeName(attr);
> > +                             attrXML._name =
> getQName(nameRef.localName,nameRef.prefix,nameRef.uri,true);
> >                               attrXML.setValue(value);
> >                               len = attributeLength();
> >                               for(i=0;i<len;i++)
> > diff --git a/frameworks/projects/XML/src/main/royale/XMLAttribute.as
> b/frameworks/projects/XML/src/main/royale/XMLAttribute.as
> > deleted file mode 100644
> > index 8a26c1f..0000000
> > --- a/frameworks/projects/XML/src/main/royale/XMLAttribute.as
> > +++ /dev/null
> > @@ -1,55 +0,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.
> > -//
> >
> -////////////////////////////////////////////////////////////////////////////////
> > -package
> > -{
> > -  public class XMLAttribute extends XML
> > -  {
> > -    public function XMLAttribute()
> > -    {
> > -      super();
> > -                     resetNodeKind();
> > -    }
> > -             override protected function getNodeRef():String{
> > -                     return "a";
> > -             }
> > -             override public function copy():XML
> > -             {
> > -                     var i:int;
> > -                     var xml:XML = new XMLAttribute();
> > -                     xml.setName(name());
> > -                     if(_value)xml.setValue(_value);
> > -
> > -                     var len:int;
> > -                     len = namespaceLength();
> > -                     for(i=0;i<len;i++)
> > -                     {
> > -                             xml.addNamespace(new
> Namespace(_namespaces[i]));
> > -                     }
> > -                     //parent should be null by default
> > -                     len = attributeLength();
> > -                     for(i=0;i<len;i++)
> > -
>  xml.addChildInternal(_attributes[i].copy());
> > -                     len = childrenLength();
> > -                     for(i=0;i<len;i++)
> > -                             xml.addChildInternal(_children[i].copy());
> > -
> > -                     return xml;
> > -             }
> > -  }
> > -}
> > \ No newline at end of file
> > diff --git a/frameworks/projects/XML/src/main/royale/XMLText.as
> b/frameworks/projects/XML/src/main/royale/XMLText.as
> > deleted file mode 100644
> > index a2f47ed..0000000
> > --- a/frameworks/projects/XML/src/main/royale/XMLText.as
> > +++ /dev/null
> > @@ -1,55 +0,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.
> > -//
> >
> -////////////////////////////////////////////////////////////////////////////////
> > -package
> > -{
> > -  public class XMLText extends XML
> > -  {
> > -    public function XMLText()
> > -    {
> > -      super();
> > -                     resetNodeKind();
> > -    }
> > -             override protected function getNodeRef():String{
> > -                     return "t";
> > -             }
> > -
> > -             override public function copy():XML
> > -             {
> > -                     var i:int;
> > -                     var xml:XML = new XMLText();
> > -                     xml.setName(name());
> > -                     if(_value)xml.setValue(_value);
> > -                     var len:int;
> > -                     len = namespaceLength();
> > -                     for(i=0;i<len;i++)
> > -                     {
> > -                             xml.addNamespace(new
> Namespace(_namespaces[i]));
> > -                     }
> > -                     //parent should be null by default
> > -                     len = attributeLength();
> > -                     for(i=0;i<len;i++)
> > -
>  xml.addChildInternal(_attributes[i].copy());
> > -                     len = childrenLength();
> > -                     for(i=0;i<len;i++)
> > -                             xml.addChildInternal(_children[i].copy());
> > -
> > -                     return xml;
> > -             }
> > -  }
> > -}
> > \ No newline at end of file
> > diff --git
> a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
> b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
> > index 3affad8..2d3e57c 100644
> > ---
> a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
> > +++
> b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
> > @@ -1130,6 +1130,10 @@ package flexUnitTests.xml
> >             assertEquals(xml.toString(),'<root><baz name="baz1"/><baz
> name="baz2"/></root>',"name attribute should have been removed.");
> >             delete xml.baz[0];
> >             assertEquals(xml.toString(),'<root><baz
> name="baz2"/></root>',"the first baz element should have been removed.");
> > +            xml = <root name="foo"><baz name="baz1"/><baz
> name="baz2"/></root>;
> > +            delete xml.baz;
> > +            // delete xml.baz[0];
> > +            assertEquals(xml.toXMLString(),'<root name="foo"/>',"the
> first baz element should have been removed.");
> >             XML.setSettings(XML.defaultSettings());
> >         }
> >     }
> >
>
>

Re: [royale-asjs] 02/03: Fixed delete issues Removed XMLText and XMLAttribute classes

Posted by Harbs <ha...@gmail.com>.
I figured out a way to determine XML “type” for “element” “text” and “attribute” without writing an instance variable at all.

I also discovered and fixed some issues with delete in the XML implementation. (I added tests for that.)

Greg, thanks for all the tests! It makes fixing issues (and confirming fixes) much easier! ;-)

Harbs

> On Dec 18, 2019, at 9:48 PM, harbs@apache.org wrote:
> 
> This is an automated email from the ASF dual-hosted git repository.
> 
> harbs pushed a commit to branch develop
> in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
> 
> commit e4d1facc591c2a57d430878c78146a2760215032
> Author: Harbs <ha...@in-tools.com>
> AuthorDate: Wed Dec 18 21:45:47 2019 +0200
> 
>    Fixed delete issues
>    Removed XMLText and XMLAttribute classes
> ---
> frameworks/projects/XML/src/main/royale/XML.as     | 55 ++++++++++++++--------
> .../projects/XML/src/main/royale/XMLAttribute.as   | 55 ----------------------
> frameworks/projects/XML/src/main/royale/XMLText.as | 55 ----------------------
> .../flexUnitTests/xml/XMLTesterGeneralTest.as      |  4 ++
> 4 files changed, 40 insertions(+), 129 deletions(-)
> 
> diff --git a/frameworks/projects/XML/src/main/royale/XML.as b/frameworks/projects/XML/src/main/royale/XML.as
> index 9df4b14..ccd283d 100644
> --- a/frameworks/projects/XML/src/main/royale/XML.as
> +++ b/frameworks/projects/XML/src/main/royale/XML.as
> @@ -324,7 +324,7 @@ package
> 		
> 		static private function insertAttribute(att:Attr,parent:XML):XML
> 		{
> -			var xml:XML = new XMLAttribute();
> +			var xml:XML = new XML();
> 			xml._parent = parent;
> 			xml._name = getQName(att.localName, '', att.namespaceURI, true);
> 			xml._value = att.value;
> @@ -407,12 +407,12 @@ package
> 						data = data.trim();
> 						if (!data) return null;
> 					}
> -					xml = new XMLText();
> +					xml = new XML();
> 					xml.setValue(data);
> 					break;
> 				case 4:
> 					//CDATA_SECTION_NODE
> -					xml = new XMLText();
> +					xml = new XML();
> 					data = "<![CDATA[" + data + "]]>";
> 					xml.setValue(data);
> 					break;
> @@ -540,8 +540,6 @@ package
> 				var className:String = xml.ROYALE_CLASS_INFO.names[0].name;
> 				switch(className){
> 					case "XML":
> -					case "XMLAttribute":
> -					case "XMLText":
> 						return xml;
> 					case "XMLList":
> 						var xmlList:XMLList = xml as XMLList;
> @@ -572,7 +570,7 @@ package
> 				var xmlStr:String = ignoreWhitespace ? trimXMLWhitespace("" + xml) : "" + xml;
> 				if(xmlStr.indexOf("<") == -1)
> 				{
> -					_nodeKind = TEXT;
> +					// _nodeKind = TEXT;
> 					_value = xmlStr;
> 				}
> 				else
> @@ -581,7 +579,7 @@ package
> 				}
> 			} else {
> 				if (!_internal) {
> -					_nodeKind = TEXT;
> +					// _nodeKind = TEXT;
> 					_value = '';
> 				}
> 			}
> @@ -685,7 +683,7 @@ package
> 					if (node.nodeType == 7) {
> 						if (XML.ignoreProcessingInstructions) {
> 							if (!foundCount) {
> -								this._nodeKind = TEXT;
> +								// this._nodeKind = TEXT;
> 								//e4x: The value of the [[Name]] property is null if and only if the XML object represents an XML comment or text node
> 								delete this._name;
> 								this.setValue('');
> @@ -698,7 +696,7 @@ package
> 						}
> 					} else if (node.nodeType == 4) {
> 						if (!foundCount) {
> -							this._nodeKind = TEXT;
> +							// this._nodeKind = TEXT;
> 							//e4x: The value of the [[Name]] property is null if and only if the XML object represents an XML comment or text node
> 							delete this._name;
> 							this.setValue('<![CDATA[' + node.nodeValue + ']]>');
> @@ -709,7 +707,7 @@ package
> 						delete this._name;
> 						if (XML.ignoreComments) {
> 							if (!foundCount) {
> -								this._nodeKind = TEXT;
> +								// this._nodeKind = TEXT;
> 								this.setValue('');
> 							}
> 						} else {
> @@ -724,7 +722,8 @@ package
> 						var whiteSpace:Boolean = isWhitespace.test(node.nodeValue);
> 						if (!whiteSpace || !XML.ignoreWhitespace) {
> 							if (!foundCount) {
> -								this._nodeKind = TEXT;
> +								delete this._name;
> +								// this._nodeKind = TEXT;
> 								this.setValue(node.nodeValue);
> 							}
> 							foundCount++;
> @@ -902,7 +901,7 @@ package
> 					const wrapper:XML = new XML();
> 					wrapper.resetNodeKind();
> 					child = new XML(child.toString());
> -					wrapper.setName(lastChild.name());
> +					wrapper._name = lastChild._name;
> 					child.setParent(wrapper);
> 					wrapper.getChildren().push(child);
> 					child = wrapper;
> @@ -1165,7 +1164,7 @@ package
> 			var xml:XML = new XML();
> 			xml.resetNodeKind();
> 			xml.setNodeKind(getNodeKindInternal());
> -			xml.setName(name());
> +			xml._name = _name;
> 			if(_value){
> 				xml.setValue(_value);
> 			}
> @@ -1880,7 +1879,14 @@ package
> 		}
> 
> 		protected function getNodeRef():String{
> -			return _nodeKind ? _nodeKind : ELEMENT;
> +			if(_nodeKind)
> +				return _nodeKind;
> +			if(!_name)
> +				return TEXT;
> +			if(_name.isAttribute){
> +				return ATTRIBUTE;
> +			}
> +			return ELEMENT;
> 		}
> 
> 		private static const kindNameLookup:Object = {
> @@ -1967,7 +1973,7 @@ package
> 		private function xmlFromStringable(value:*):XML
> 		{
> 			var str:String = value.toString();
> -			var xml:XML = new XMLText();
> +			var xml:XML = new XML();
> 			xml.setValue(str);
> 			return xml;
> 		}
> @@ -2060,16 +2066,26 @@ package
> 				7. Return true.
> 			*/
> 			var i:int;
> +			var len:int;
> 			var removed:XML;
> 			if(!child)
> 				return false;
> -			
> +			if(child is XMLList){
> +				var val:Boolean = false;
> +				len = child.length();
> +				for(i=len-1;i>=0;i--){
> +					if(removeChild(child[i])){
> +						val = true;
> +					}
> +				}
> +				return val;
> +			}
> 			if(!(child is XML))
> 				return removeChildByName(child);
> 			
> 			if(child.getNodeRef() == ATTRIBUTE)
> 			{
> -				var len:int = attributeLength();
> +				len = attributeLength();
> 				for(i=0;i<len;i++)
> 				{
> 					if(child.equals(_attributes[i]))
> @@ -2397,8 +2413,9 @@ package
> 			else
> 			{
> 				//it's a regular attribute string
> -				var attrXML:XML = new XMLAttribute();
> -				attrXML.setName(toAttributeName(attr));
> +				var attrXML:XML = new XML();
> +				var nameRef:QName = toAttributeName(attr);
> +				attrXML._name = getQName(nameRef.localName,nameRef.prefix,nameRef.uri,true);
> 				attrXML.setValue(value);
> 				len = attributeLength();
> 				for(i=0;i<len;i++)
> diff --git a/frameworks/projects/XML/src/main/royale/XMLAttribute.as b/frameworks/projects/XML/src/main/royale/XMLAttribute.as
> deleted file mode 100644
> index 8a26c1f..0000000
> --- a/frameworks/projects/XML/src/main/royale/XMLAttribute.as
> +++ /dev/null
> @@ -1,55 +0,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.
> -//
> -////////////////////////////////////////////////////////////////////////////////
> -package
> -{
> -  public class XMLAttribute extends XML
> -  {
> -    public function XMLAttribute()
> -    {
> -      super();
> -			resetNodeKind();
> -    }
> -		override protected function getNodeRef():String{
> -			return "a";
> -		}
> -		override public function copy():XML
> -		{
> -			var i:int;
> -			var xml:XML = new XMLAttribute();
> -			xml.setName(name());
> -			if(_value)xml.setValue(_value);
> -			
> -			var len:int;
> -			len = namespaceLength();
> -			for(i=0;i<len;i++)
> -			{
> -				xml.addNamespace(new Namespace(_namespaces[i]));
> -			}
> -			//parent should be null by default
> -			len = attributeLength();
> -			for(i=0;i<len;i++)
> -				xml.addChildInternal(_attributes[i].copy());
> -			len = childrenLength();
> -			for(i=0;i<len;i++)
> -				xml.addChildInternal(_children[i].copy());
> -			
> -			return xml;
> -		}
> -  }
> -}
> \ No newline at end of file
> diff --git a/frameworks/projects/XML/src/main/royale/XMLText.as b/frameworks/projects/XML/src/main/royale/XMLText.as
> deleted file mode 100644
> index a2f47ed..0000000
> --- a/frameworks/projects/XML/src/main/royale/XMLText.as
> +++ /dev/null
> @@ -1,55 +0,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.
> -//
> -////////////////////////////////////////////////////////////////////////////////
> -package
> -{
> -  public class XMLText extends XML
> -  {
> -    public function XMLText()
> -    {
> -      super();
> -			resetNodeKind();
> -    }
> -		override protected function getNodeRef():String{
> -			return "t";
> -		}
> -
> -		override public function copy():XML
> -		{
> -			var i:int;
> -			var xml:XML = new XMLText();
> -			xml.setName(name());
> -			if(_value)xml.setValue(_value);
> -			var len:int;
> -			len = namespaceLength();
> -			for(i=0;i<len;i++)
> -			{
> -				xml.addNamespace(new Namespace(_namespaces[i]));
> -			}
> -			//parent should be null by default
> -			len = attributeLength();
> -			for(i=0;i<len;i++)
> -				xml.addChildInternal(_attributes[i].copy());
> -			len = childrenLength();
> -			for(i=0;i<len;i++)
> -				xml.addChildInternal(_children[i].copy());
> -			
> -			return xml;
> -		}    
> -  }
> -}
> \ No newline at end of file
> diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
> index 3affad8..2d3e57c 100644
> --- a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
> +++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
> @@ -1130,6 +1130,10 @@ package flexUnitTests.xml
>             assertEquals(xml.toString(),'<root><baz name="baz1"/><baz name="baz2"/></root>',"name attribute should have been removed.");
>             delete xml.baz[0];
>             assertEquals(xml.toString(),'<root><baz name="baz2"/></root>',"the first baz element should have been removed.");
> +            xml = <root name="foo"><baz name="baz1"/><baz name="baz2"/></root>;
> +            delete xml.baz;
> +            // delete xml.baz[0];
> +            assertEquals(xml.toXMLString(),'<root name="foo"/>',"the first baz element should have been removed.");
>             XML.setSettings(XML.defaultSettings());
>         }
>     }
> 


[royale-asjs] 02/03: Fixed delete issues Removed XMLText and XMLAttribute classes

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit e4d1facc591c2a57d430878c78146a2760215032
Author: Harbs <ha...@in-tools.com>
AuthorDate: Wed Dec 18 21:45:47 2019 +0200

    Fixed delete issues
    Removed XMLText and XMLAttribute classes
---
 frameworks/projects/XML/src/main/royale/XML.as     | 55 ++++++++++++++--------
 .../projects/XML/src/main/royale/XMLAttribute.as   | 55 ----------------------
 frameworks/projects/XML/src/main/royale/XMLText.as | 55 ----------------------
 .../flexUnitTests/xml/XMLTesterGeneralTest.as      |  4 ++
 4 files changed, 40 insertions(+), 129 deletions(-)

diff --git a/frameworks/projects/XML/src/main/royale/XML.as b/frameworks/projects/XML/src/main/royale/XML.as
index 9df4b14..ccd283d 100644
--- a/frameworks/projects/XML/src/main/royale/XML.as
+++ b/frameworks/projects/XML/src/main/royale/XML.as
@@ -324,7 +324,7 @@ package
 		
 		static private function insertAttribute(att:Attr,parent:XML):XML
 		{
-			var xml:XML = new XMLAttribute();
+			var xml:XML = new XML();
 			xml._parent = parent;
 			xml._name = getQName(att.localName, '', att.namespaceURI, true);
 			xml._value = att.value;
@@ -407,12 +407,12 @@ package
 						data = data.trim();
 						if (!data) return null;
 					}
-					xml = new XMLText();
+					xml = new XML();
 					xml.setValue(data);
 					break;
 				case 4:
 					//CDATA_SECTION_NODE
-					xml = new XMLText();
+					xml = new XML();
 					data = "<![CDATA[" + data + "]]>";
 					xml.setValue(data);
 					break;
@@ -540,8 +540,6 @@ package
 				var className:String = xml.ROYALE_CLASS_INFO.names[0].name;
 				switch(className){
 					case "XML":
-					case "XMLAttribute":
-					case "XMLText":
 						return xml;
 					case "XMLList":
 						var xmlList:XMLList = xml as XMLList;
@@ -572,7 +570,7 @@ package
 				var xmlStr:String = ignoreWhitespace ? trimXMLWhitespace("" + xml) : "" + xml;
 				if(xmlStr.indexOf("<") == -1)
 				{
-					_nodeKind = TEXT;
+					// _nodeKind = TEXT;
 					_value = xmlStr;
 				}
 				else
@@ -581,7 +579,7 @@ package
 				}
 			} else {
 				if (!_internal) {
-					_nodeKind = TEXT;
+					// _nodeKind = TEXT;
 					_value = '';
 				}
 			}
@@ -685,7 +683,7 @@ package
 					if (node.nodeType == 7) {
 						if (XML.ignoreProcessingInstructions) {
 							if (!foundCount) {
-								this._nodeKind = TEXT;
+								// this._nodeKind = TEXT;
 								//e4x: The value of the [[Name]] property is null if and only if the XML object represents an XML comment or text node
 								delete this._name;
 								this.setValue('');
@@ -698,7 +696,7 @@ package
 						}
 					} else if (node.nodeType == 4) {
 						if (!foundCount) {
-							this._nodeKind = TEXT;
+							// this._nodeKind = TEXT;
 							//e4x: The value of the [[Name]] property is null if and only if the XML object represents an XML comment or text node
 							delete this._name;
 							this.setValue('<![CDATA[' + node.nodeValue + ']]>');
@@ -709,7 +707,7 @@ package
 						delete this._name;
 						if (XML.ignoreComments) {
 							if (!foundCount) {
-								this._nodeKind = TEXT;
+								// this._nodeKind = TEXT;
 								this.setValue('');
 							}
 						} else {
@@ -724,7 +722,8 @@ package
 						var whiteSpace:Boolean = isWhitespace.test(node.nodeValue);
 						if (!whiteSpace || !XML.ignoreWhitespace) {
 							if (!foundCount) {
-								this._nodeKind = TEXT;
+								delete this._name;
+								// this._nodeKind = TEXT;
 								this.setValue(node.nodeValue);
 							}
 							foundCount++;
@@ -902,7 +901,7 @@ package
 					const wrapper:XML = new XML();
 					wrapper.resetNodeKind();
 					child = new XML(child.toString());
-					wrapper.setName(lastChild.name());
+					wrapper._name = lastChild._name;
 					child.setParent(wrapper);
 					wrapper.getChildren().push(child);
 					child = wrapper;
@@ -1165,7 +1164,7 @@ package
 			var xml:XML = new XML();
 			xml.resetNodeKind();
 			xml.setNodeKind(getNodeKindInternal());
-			xml.setName(name());
+			xml._name = _name;
 			if(_value){
 				xml.setValue(_value);
 			}
@@ -1880,7 +1879,14 @@ package
 		}
 
 		protected function getNodeRef():String{
-			return _nodeKind ? _nodeKind : ELEMENT;
+			if(_nodeKind)
+				return _nodeKind;
+			if(!_name)
+				return TEXT;
+			if(_name.isAttribute){
+				return ATTRIBUTE;
+			}
+			return ELEMENT;
 		}
 
 		private static const kindNameLookup:Object = {
@@ -1967,7 +1973,7 @@ package
 		private function xmlFromStringable(value:*):XML
 		{
 			var str:String = value.toString();
-			var xml:XML = new XMLText();
+			var xml:XML = new XML();
 			xml.setValue(str);
 			return xml;
 		}
@@ -2060,16 +2066,26 @@ package
 				7. Return true.
 			*/
 			var i:int;
+			var len:int;
 			var removed:XML;
 			if(!child)
 				return false;
-			
+			if(child is XMLList){
+				var val:Boolean = false;
+				len = child.length();
+				for(i=len-1;i>=0;i--){
+					if(removeChild(child[i])){
+						val = true;
+					}
+				}
+				return val;
+			}
 			if(!(child is XML))
 				return removeChildByName(child);
 			
 			if(child.getNodeRef() == ATTRIBUTE)
 			{
-				var len:int = attributeLength();
+				len = attributeLength();
 				for(i=0;i<len;i++)
 				{
 					if(child.equals(_attributes[i]))
@@ -2397,8 +2413,9 @@ package
 			else
 			{
 				//it's a regular attribute string
-				var attrXML:XML = new XMLAttribute();
-				attrXML.setName(toAttributeName(attr));
+				var attrXML:XML = new XML();
+				var nameRef:QName = toAttributeName(attr);
+				attrXML._name = getQName(nameRef.localName,nameRef.prefix,nameRef.uri,true);
 				attrXML.setValue(value);
 				len = attributeLength();
 				for(i=0;i<len;i++)
diff --git a/frameworks/projects/XML/src/main/royale/XMLAttribute.as b/frameworks/projects/XML/src/main/royale/XMLAttribute.as
deleted file mode 100644
index 8a26c1f..0000000
--- a/frameworks/projects/XML/src/main/royale/XMLAttribute.as
+++ /dev/null
@@ -1,55 +0,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.
-//
-////////////////////////////////////////////////////////////////////////////////
-package
-{
-  public class XMLAttribute extends XML
-  {
-    public function XMLAttribute()
-    {
-      super();
-			resetNodeKind();
-    }
-		override protected function getNodeRef():String{
-			return "a";
-		}
-		override public function copy():XML
-		{
-			var i:int;
-			var xml:XML = new XMLAttribute();
-			xml.setName(name());
-			if(_value)xml.setValue(_value);
-			
-			var len:int;
-			len = namespaceLength();
-			for(i=0;i<len;i++)
-			{
-				xml.addNamespace(new Namespace(_namespaces[i]));
-			}
-			//parent should be null by default
-			len = attributeLength();
-			for(i=0;i<len;i++)
-				xml.addChildInternal(_attributes[i].copy());
-			len = childrenLength();
-			for(i=0;i<len;i++)
-				xml.addChildInternal(_children[i].copy());
-			
-			return xml;
-		}
-  }
-}
\ No newline at end of file
diff --git a/frameworks/projects/XML/src/main/royale/XMLText.as b/frameworks/projects/XML/src/main/royale/XMLText.as
deleted file mode 100644
index a2f47ed..0000000
--- a/frameworks/projects/XML/src/main/royale/XMLText.as
+++ /dev/null
@@ -1,55 +0,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.
-//
-////////////////////////////////////////////////////////////////////////////////
-package
-{
-  public class XMLText extends XML
-  {
-    public function XMLText()
-    {
-      super();
-			resetNodeKind();
-    }
-		override protected function getNodeRef():String{
-			return "t";
-		}
-
-		override public function copy():XML
-		{
-			var i:int;
-			var xml:XML = new XMLText();
-			xml.setName(name());
-			if(_value)xml.setValue(_value);
-			var len:int;
-			len = namespaceLength();
-			for(i=0;i<len;i++)
-			{
-				xml.addNamespace(new Namespace(_namespaces[i]));
-			}
-			//parent should be null by default
-			len = attributeLength();
-			for(i=0;i<len;i++)
-				xml.addChildInternal(_attributes[i].copy());
-			len = childrenLength();
-			for(i=0;i<len;i++)
-				xml.addChildInternal(_children[i].copy());
-			
-			return xml;
-		}    
-  }
-}
\ No newline at end of file
diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
index 3affad8..2d3e57c 100644
--- a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
+++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterGeneralTest.as
@@ -1130,6 +1130,10 @@ package flexUnitTests.xml
             assertEquals(xml.toString(),'<root><baz name="baz1"/><baz name="baz2"/></root>',"name attribute should have been removed.");
             delete xml.baz[0];
             assertEquals(xml.toString(),'<root><baz name="baz2"/></root>',"the first baz element should have been removed.");
+            xml = <root name="foo"><baz name="baz1"/><baz name="baz2"/></root>;
+            delete xml.baz;
+            // delete xml.baz[0];
+            assertEquals(xml.toXMLString(),'<root name="foo"/>',"the first baz element should have been removed.");
             XML.setSettings(XML.defaultSettings());
         }
     }


[royale-asjs] 03/03: Merge branch 'fix_xml_delete' into develop

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git

commit 4ba1c82dba3c1aad6a84c69acd10a67aca9f0605
Merge: 42a6edf e4d1fac
Author: Harbs <ha...@in-tools.com>
AuthorDate: Wed Dec 18 21:47:50 2019 +0200

    Merge branch 'fix_xml_delete' into develop

 frameworks/projects/XML/src/main/royale/XML.as     | 55 ++++++++++++++--------
 .../projects/XML/src/main/royale/XMLAttribute.as   | 55 ----------------------
 frameworks/projects/XML/src/main/royale/XMLText.as | 55 ----------------------
 .../flexUnitTests/xml/XMLTesterGeneralTest.as      | 16 +++++++
 4 files changed, 52 insertions(+), 129 deletions(-)