Explorar el Código

2004-05-13 Atsushi Enomoto <[email protected]>

	* DefaultContext.cs : Removed MonoTODO. done.
	* Expression.cs : handle XPathResultType.Navigator in some places and
	  removed MonoTODO. Mark MonoTODO with explicit comments (though they
	  are mostly pointing out possibilities of optimization).
	  Removed extra check that depended on the old bugs.
	* XPathResultType.cs : Fixed .Navigator that had the same value as
	  .String.

svn path=/trunk/mcs/; revision=27224
Atsushi Eno hace 21 años
padre
commit
da650ba480

+ 10 - 0
mcs/class/System.XML/System.Xml.XPath/ChangeLog

@@ -1,3 +1,13 @@
+2004-05-13  Atsushi Enomoto  <[email protected]>
+
+	* DefaultContext.cs : Removed MonoTODO. done.
+	* Expression.cs : handle XPathResultType.Navigator in some places and
+	  removed MonoTODO. Mark MonoTODO with explicit comments (though they
+	  are mostly pointing out possibilities of optimization).
+	  Removed extra check that depended on the old bugs.
+	* XPathResultType.cs : Fixed .Navigator that had the same value as
+	  .String.
+
 2004-05-12  Atsushi Enomoto  <[email protected]>
 
 	* Parser.jay : made class internal.

+ 1 - 2
mcs/class/System.XML/System.Xml.XPath/DefaultContext.cs

@@ -58,7 +58,6 @@ namespace System.Xml.XPath
 			return iter != null && iter.MoveNext ();
 		}
 
-		[MonoTODO]
 		public static string ToString (object arg)
 		{
 			if (arg == null)
@@ -78,7 +77,7 @@ namespace System.Xml.XPath
 			}
 			throw new ArgumentException ();
 		}
-		[MonoTODO]
+
 		public static double ToNumber (object arg)
 		{
 			if (arg == null)

+ 20 - 17
mcs/class/System.XML/System.Xml.XPath/Expression.cs

@@ -369,7 +369,6 @@ namespace System.Xml.XPath
 			get { return false; }
 		}
 
-		[MonoTODO]
 		public virtual double EvaluateNumber (BaseIterator iter)
 		{
 			object result;
@@ -394,12 +393,14 @@ namespace System.Xml.XPath
 				case XPathResultType.NodeSet:
 					return XPathFunctions.ToNumber (EvaluateString (iter));
 				case XPathResultType.String:
-					return XPathFunctions.ToNumber ((string) result);	// TODO: spec? convert string to number
+					return XPathFunctions.ToNumber ((string) result);
+				case XPathResultType.Navigator:
+					return XPathFunctions.ToNumber (((XPathNavigator) (result)).Value);
 				default:
-					throw new XPathException ("invalid node type"); // TODO: handle other types
+					throw new XPathException ("invalid node type");
 			}
 		}
-		[MonoTODO]
+
 		public virtual string EvaluateString (BaseIterator iter)
 		{
 			object result = Evaluate (iter);
@@ -409,7 +410,7 @@ namespace System.Xml.XPath
 			switch (type)
 			{
 				case XPathResultType.Number:
-					return (string) XmlConvert.ToString ((double)result);	// TODO: spec? convert number to string
+					return (string) XmlConvert.ToString ((double)result);
 				case XPathResultType.Boolean:
 					return ((bool) result) ? "true" : "false";
 				case XPathResultType.String:
@@ -421,11 +422,13 @@ namespace System.Xml.XPath
 						return "";
 					return iterResult.Current.Value;
 				}
+				case XPathResultType.Navigator:
+					return ((XPathNavigator) result).Value;
 				default:
-					throw new XPathException ("invalid node type"); // TODO: handle other types
+					throw new XPathException ("invalid node type");
 			}
 		}
-		[MonoTODO]
+
 		public virtual bool EvaluateBoolean (BaseIterator iter)
 		{
 			object result = Evaluate (iter);
@@ -448,8 +451,10 @@ namespace System.Xml.XPath
 					BaseIterator iterResult = (BaseIterator) result;
 					return (iterResult != null && iterResult.MoveNext ());
 				}
+				case XPathResultType.Navigator:
+					return ((string) ((XPathNavigator) result).Value).Length != 0;
 				default:
-					throw new XPathException ("invalid node type"); // TODO: handle other types
+					throw new XPathException ("invalid node type");
 			}
 		}
 		public object EvaluateAs (BaseIterator iter, XPathResultType type)
@@ -550,7 +555,8 @@ namespace System.Xml.XPath
 		{
 			this.trueVal = trueVal;
 		}
-		[MonoTODO]
+
+		[MonoTODO ("Avoid extraneous evaluation")]
 		public override bool EvaluateBoolean (BaseIterator iter)
 		{
 			XPathResultType typeL = _left.GetReturnType (iter);
@@ -640,13 +646,12 @@ namespace System.Xml.XPath
 	internal abstract class RelationalExpr : ExprBoolean
 	{
 		public RelationalExpr (Expression left, Expression right) : base (left, right) {}
-		[MonoTODO]
+		[MonoTODO ("Avoid extraneous evaluation.")]
 		public override bool EvaluateBoolean (BaseIterator iter)
 		{
 			XPathResultType typeL = _left.GetReturnType (iter);
 			XPathResultType typeR = _right.GetReturnType (iter);
 
-			// TODO: avoid double evaluations
 			if (typeL == XPathResultType.Any)
 				typeL = GetReturnType (_left.Evaluate (iter));
 			if (typeR == XPathResultType.Any)
@@ -811,10 +816,10 @@ namespace System.Xml.XPath
 	{
 		public ExprMOD (Expression left, Expression right) : base (left, right) {}
 		protected override String Operator { get { return "%"; }}
-		[MonoTODO]
+
 		public override double EvaluateNumber (BaseIterator iter)
 		{
-			return _left.EvaluateNumber (iter) % _right.EvaluateNumber (iter);	// TODO: spec?
+			return _left.EvaluateNumber (iter) % _right.EvaluateNumber (iter);
 		}
 	}
 
@@ -1125,7 +1130,7 @@ namespace System.Xml.XPath
 		{
 			this.type = type;
 		}
-		[MonoTODO]
+		[MonoTODO ("Better description.")]
 		public NodeTypeTest (Axes axis, XPathNodeType type, String param) : base (axis)
 		{
 			this.type = type;
@@ -1235,14 +1240,12 @@ namespace System.Xml.XPath
 				if (resolvedName)
 					strURI1 = _name.Namespace;
 				else
-					strURI1 = nsm.LookupNamespace (_name.Namespace);	// TODO: check to see if this returns null or ""
+					strURI1 = nsm.LookupNamespace (_name.Namespace);
 				if (strURI1 == null)
 					throw new XPathException ("Invalid namespace prefix: "+_name.Namespace);
 			}
 
 			string strURI = nav.NamespaceURI;
-			if (strURI == null && strURI1 == "")	// TODO: remove when bug #26855 fixed
-				return true;
 
 			// test the prefixes
 			return strURI1 == nav.NamespaceURI;

+ 1 - 1
mcs/class/System.XML/System.Xml.XPath/XPathResultType.cs

@@ -15,7 +15,7 @@ namespace System.Xml.XPath
 		String = 1,
 		Boolean = 2,
 		NodeSet = 3,
-		Navigator = 1,
+		Navigator = 4,
 		Any = 5,
 		Error = 6,
 	}