Permalink
Browse files

The parent of an Hpricot element is always an IHpricotDataContainer.

  • Loading branch information...
1 parent 24be749 commit 6eea7e8bf5017c1a3949412371551bd7a39d49b5 @nrk committed Jul 17, 2010
Showing with 11 additions and 16 deletions.
  1. +2 −2 src/Data/BasicData.cs
  2. +2 −2 src/Elements/BaseEle.cs
  3. +3 −8 src/HpricotScanner.cs
  4. +4 −4 src/Initializers.Generated.cs
View
@@ -4,14 +4,14 @@
namespace IronRuby.Hpricot {
public class BasicData {
private Object _tag;
- private Object _parent;
+ private IHpricotDataContainer _parent;
public Object Tag {
get { return _tag; }
set { _tag = value; }
}
- public Object Parent {
+ public IHpricotDataContainer Parent {
get { return _parent; }
set { _parent = value; }
}
View
@@ -44,12 +44,12 @@ public BaseElement(RubyContext context)
}
[RubyMethod("parent")]
- public static Object GetParent(BaseElement/*!*/ self) {
+ public static IHpricotDataContainer GetParent(BaseElement/*!*/ self) {
return self._data.Parent;
}
[RubyMethod("parent=")]
- public static void SetParent(BaseElement/*!*/ self, Object/*!*/ parent) {
+ public static void SetParent(BaseElement/*!*/ self, IHpricotDataContainer/*!*/ parent) {
self._data.Parent = parent;
}
}
View
@@ -1163,10 +1163,7 @@ public class HpricotScanner {
}
}
- if (he.Parent != null) {
- Debug.Assert(he.Parent is IHpricotDataContainer, "he.Parent is not an instance of IHpricotDataContainer");
- }
- e = hee.Parent as IHpricotDataContainer;
+ e = hee.Parent;
}
if (match == null) {
@@ -1218,8 +1215,7 @@ public class HpricotScanner {
match = e;
break;
}
-
- e = he.Parent as IHpricotDataContainer;
+ e = he.Parent;
}
if (match == null) {
@@ -1233,8 +1229,7 @@ public class HpricotScanner {
// TODO: couldn't find this in the original implementation but it still sounds right.
he.ETag = ele;
- Debug.Assert(he.Parent is IHpricotDataContainer, "he.Parent is not an instance of IHpricotDataContainer");
- state.Focus = he.Parent as IHpricotDataContainer;
+ state.Focus = he.Parent;
state.Last = null;
}
@@ -89,13 +89,13 @@ public sealed class HpricotLibraryInitializer : IronRuby.Builtins.LibraryInitial
private static void LoadHpricot__BaseEle_Instance(IronRuby.Builtins.RubyModule/*!*/ module) {
DefineLibraryMethod(module, "parent", 0x11,
- 0x00000000U,
- new Func<IronRuby.Hpricot.BaseElement, System.Object>(IronRuby.Hpricot.BaseElement.GetParent)
+ 0x00000000U,
+ new Func<IronRuby.Hpricot.BaseElement, IronRuby.Hpricot.IHpricotDataContainer>(IronRuby.Hpricot.BaseElement.GetParent)
);
DefineLibraryMethod(module, "parent=", 0x11,
- 0x00000000U,
- new Action<IronRuby.Hpricot.BaseElement, System.Object>(IronRuby.Hpricot.BaseElement.SetParent)
+ 0x00000000U,
+ new Action<IronRuby.Hpricot.BaseElement, IronRuby.Hpricot.IHpricotDataContainer>(IronRuby.Hpricot.BaseElement.SetParent)
);
DefineLibraryMethod(module, "raw_string", 0x11,

0 comments on commit 6eea7e8

Please sign in to comment.