Skip to content

Commit

Permalink
The parent of an Hpricot element is always an IHpricotDataContainer.
Browse files Browse the repository at this point in the history
  • Loading branch information
nrk committed Jul 17, 2010
1 parent 24be749 commit 6eea7e8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/Data/BasicData.cs
Expand Up @@ -4,14 +4,14 @@
namespace IronRuby.Hpricot { namespace IronRuby.Hpricot {
public class BasicData { public class BasicData {
private Object _tag; private Object _tag;
private Object _parent; private IHpricotDataContainer _parent;


public Object Tag { public Object Tag {
get { return _tag; } get { return _tag; }
set { _tag = value; } set { _tag = value; }
} }


public Object Parent { public IHpricotDataContainer Parent {
get { return _parent; } get { return _parent; }
set { _parent = value; } set { _parent = value; }
} }
Expand Down
4 changes: 2 additions & 2 deletions src/Elements/BaseEle.cs
Expand Up @@ -44,12 +44,12 @@ public BaseElement(RubyContext context)
} }


[RubyMethod("parent")] [RubyMethod("parent")]
public static Object GetParent(BaseElement/*!*/ self) { public static IHpricotDataContainer GetParent(BaseElement/*!*/ self) {
return self._data.Parent; return self._data.Parent;
} }


[RubyMethod("parent=")] [RubyMethod("parent=")]
public static void SetParent(BaseElement/*!*/ self, Object/*!*/ parent) { public static void SetParent(BaseElement/*!*/ self, IHpricotDataContainer/*!*/ parent) {
self._data.Parent = parent; self._data.Parent = parent;
} }
} }
Expand Down
11 changes: 3 additions & 8 deletions src/HpricotScanner.cs
Expand Up @@ -1163,10 +1163,7 @@ public class HpricotScanner {
} }
} }


if (he.Parent != null) { e = hee.Parent;
Debug.Assert(he.Parent is IHpricotDataContainer, "he.Parent is not an instance of IHpricotDataContainer");
}
e = hee.Parent as IHpricotDataContainer;
} }


if (match == null) { if (match == null) {
Expand Down Expand Up @@ -1218,8 +1215,7 @@ public class HpricotScanner {
match = e; match = e;
break; break;
} }

e = he.Parent;
e = he.Parent as IHpricotDataContainer;
} }


if (match == null) { if (match == null) {
Expand All @@ -1233,8 +1229,7 @@ public class HpricotScanner {
// TODO: couldn't find this in the original implementation but it still sounds right. // TODO: couldn't find this in the original implementation but it still sounds right.
he.ETag = ele; he.ETag = ele;


Debug.Assert(he.Parent is IHpricotDataContainer, "he.Parent is not an instance of IHpricotDataContainer"); state.Focus = he.Parent;
state.Focus = he.Parent as IHpricotDataContainer;
state.Last = null; state.Last = null;
} }


Expand Down
8 changes: 4 additions & 4 deletions src/Initializers.Generated.cs
Expand Up @@ -89,13 +89,13 @@ public sealed class HpricotLibraryInitializer : IronRuby.Builtins.LibraryInitial


private static void LoadHpricot__BaseEle_Instance(IronRuby.Builtins.RubyModule/*!*/ module) { private static void LoadHpricot__BaseEle_Instance(IronRuby.Builtins.RubyModule/*!*/ module) {
DefineLibraryMethod(module, "parent", 0x11, DefineLibraryMethod(module, "parent", 0x11,
0x00000000U, 0x00000000U,
new Func<IronRuby.Hpricot.BaseElement, System.Object>(IronRuby.Hpricot.BaseElement.GetParent) new Func<IronRuby.Hpricot.BaseElement, IronRuby.Hpricot.IHpricotDataContainer>(IronRuby.Hpricot.BaseElement.GetParent)
); );


DefineLibraryMethod(module, "parent=", 0x11, DefineLibraryMethod(module, "parent=", 0x11,
0x00000000U, 0x00000000U,
new Action<IronRuby.Hpricot.BaseElement, System.Object>(IronRuby.Hpricot.BaseElement.SetParent) new Action<IronRuby.Hpricot.BaseElement, IronRuby.Hpricot.IHpricotDataContainer>(IronRuby.Hpricot.BaseElement.SetParent)
); );


DefineLibraryMethod(module, "raw_string", 0x11, DefineLibraryMethod(module, "raw_string", 0x11,
Expand Down

0 comments on commit 6eea7e8

Please sign in to comment.