diff --git a/src/Hpricot.cs b/src/Hpricot.cs index 9e068e1..83b198e 100644 --- a/src/Hpricot.cs +++ b/src/Hpricot.cs @@ -9,12 +9,12 @@ namespace IronRuby.Libraries.Hpricot { [RubyModule("Hpricot")] public static class Hpricot { [RubyMethod("scan", RubyMethodAttributes.PublicSingleton)] - public static Object Scan(ConversionStorage/*!*/ toMutableStringStorage, RespondToStorage/*!*/ respondsTo, - RubyContext/*!*/ context, BlockParam/*!*/ block, RubyModule/*!*/ self, Object/*!*/ source) { + public static Object Scan(ConversionStorage/*!*/ toMutableStringStorage, RespondToStorage/*!*/ respondsTo, + BinaryOpStorage/*!*/ readIOStorage, BlockParam/*!*/ block, RubyModule/*!*/ self, Object/*!*/ source) { if (block == null) { throw RubyExceptions.NoBlockGiven(); } - HpricotScanner scanner = new HpricotScanner(respondsTo, toMutableStringStorage, context, block); + HpricotScanner scanner = new HpricotScanner(respondsTo, toMutableStringStorage, readIOStorage, block); return scanner.Scan(source); } diff --git a/src/HpricotScanner.cs b/src/HpricotScanner.cs index e23219a..0caa920 100644 --- a/src/HpricotScanner.cs +++ b/src/HpricotScanner.cs @@ -9,7 +9,7 @@ using Microsoft.Scripting.Runtime; namespace IronRuby.Libraries.Hpricot { - using RubyIOReadCallSite = CallSite>; + using RubyIOReadCallSite = CallSite>; public class HpricotScanner { #region fields @@ -22,6 +22,7 @@ public class HpricotScanner { private BlockParam/*!*/ _blockParam; private RespondToStorage/*!*/ _respondToStorage; private ConversionStorage _toMutableString; + private BinaryOpStorage _readIOStorage; #endregion @@ -60,11 +61,12 @@ public class HpricotScanner { #region constructors - public HpricotScanner(RespondToStorage/*!*/ respondToStorage, ConversionStorage/*!*/ toMutableString, - RubyContext/*!*/ context, BlockParam/*!*/ block) { + public HpricotScanner(RespondToStorage/*!*/ respondToStorage, ConversionStorage/*!*/ toMutableString, + BinaryOpStorage/*!*/ readIOStorage, BlockParam block) { + _currentContext = respondToStorage.Context; _respondToStorage = respondToStorage; _toMutableString = toMutableString; - _currentContext = context; + _readIOStorage = readIOStorage; _blockParam = block; } @@ -1150,9 +1152,9 @@ public Object Scan(Object/*!*/ source) { bool sourceRespondsToRead = Protocols.RespondTo(_respondToStorage, source, "read"); - RubyIOReadCallSite readCallSite = null; + RubyIOReadCallSite readIOCallSite = null; if (sourceRespondsToRead) { - readCallSite = RubyIOReadCallSite.Create(RubyCallAction.Make(_currentContext, "read", 3)); + readIOCallSite = _readIOStorage.GetCallSite("read", 1); } else if (Protocols.RespondTo(_respondToStorage, source, "to_str")) { source = Protocols.CastToString(_toMutableString, source); @@ -1184,7 +1186,7 @@ public Object Scan(Object/*!*/ source) { char[] chars; if (sourceRespondsToRead) { - chars = BinaryEncoding.Instance.GetChars(readCallSite.Target(readCallSite, _currentContext, source, space).ToByteArray()); + chars = BinaryEncoding.Instance.GetChars((readIOCallSite.Target(readIOCallSite, source, space) as MutableString).ToByteArray()); } else { MutableString str = source as MutableString; diff --git a/src/Initializers.Generated.cs b/src/Initializers.Generated.cs index afbcb9b..8848b6c 100644 --- a/src/Initializers.Generated.cs +++ b/src/Initializers.Generated.cs @@ -22,7 +22,7 @@ private static void LoadHpricot_Class(IronRuby.Builtins.RubyModule/*!*/ module) ); module.DefineLibraryMethod("scan", 0x21, - new System.Func, IronRuby.Runtime.RespondToStorage, IronRuby.Runtime.RubyContext, IronRuby.Runtime.BlockParam, IronRuby.Builtins.RubyModule, System.Object, System.Object>(IronRuby.Libraries.Hpricot.Hpricot.Scan) + new System.Func, IronRuby.Runtime.RespondToStorage, IronRuby.Runtime.BinaryOpStorage, IronRuby.Runtime.BlockParam, IronRuby.Builtins.RubyModule, System.Object, System.Object>(IronRuby.Libraries.Hpricot.Hpricot.Scan) ); }