public static object Close(RubyContext /*!*/ context, object self) { //TODO: See http://redmine.ruby-lang.org/issues/show/1633 // this should raise an error if called twice on an object, currently // it will just advance the stream which actually matches 1.8.6 behavior // but matz has said current 1.8.6 behavior is a bug. RubyIOOps.Close(context.InputProvider.GetOrResetCurrentStream()); return(self); }
public static RubyFile /*!*/ CreateFile(RubyClass /*!*/ self, [DefaultProtocol, NotNull] Union <int, MutableString> descriptorOrPath, int mode, [Optional] int permission) { if (descriptorOrPath.IsFixnum()) { return(new RubyFile( self.Context, RubyIOOps.GetDescriptorStream(self.Context, descriptorOrPath.Fixnum()), descriptorOrPath.Fixnum(), (IOMode)mode )); } else { // TODO: permissions return(CreateFile(self, descriptorOrPath.Second, mode)); } }
public static RubyArray /*!*/ TOA(RubyContext /*!*/ context, object self) { RubyArray result = new RubyArray(); RubyArray lines; while (context.InputProvider.HasMoreFiles()) { lines = RubyIOOps.ReadLines(context, context.InputProvider.GetOrResetCurrentStream(), -1); //TODO: result.append(lines)??? foreach (var line in lines) { result.Add(line); } } return(result); }
public static object Load(ReaderSites /*!*/ sites, RespondToStorage /*!*/ respondToStorage, RubyScope /*!*/ scope, RubyModule /*!*/ self, object source, [Optional] Proc proc) { Stream stream = null; if (source != null) { stream = RubyIOOps.CreateIOWrapper(respondToStorage, source, FileAccess.Read); } if (stream == null || !stream.CanRead) { throw RubyExceptions.CreateTypeError("instance of IO needed"); } BinaryReader reader = new BinaryReader(stream); MarshalReader loader = new MarshalReader(sites, reader, scope.GlobalScope, proc); return(loader.Load()); }
public static object Dump(WriterSites /*!*/ sites, RespondToStorage /*!*/ respondToStorage, RubyModule /*!*/ self, object obj, object io, [Optional] int?limit) { Stream stream = null; if (io != null) { stream = RubyIOOps.CreateIOWrapper(respondToStorage, io, FileAccess.Write); } if (stream == null || !stream.CanWrite) { throw RubyExceptions.CreateTypeError("instance of IO needed"); } BinaryWriter writer = new BinaryWriter(stream); MarshalWriter dumper = new MarshalWriter(sites, writer, self.Context, limit); dumper.Dump(obj); return(io); }
public static object BinMode(RubyContext /*!*/ context, object self) { RubyIOOps.Binmode(context.InputProvider.GetCurrentStream()); context.InputProvider.DefaultMode = context.InputProvider.DefaultMode | IOMode.PreserveEndOfLines; return(self); }
public static int FileNo(RubyContext /*!*/ context, object self) { return(RubyIOOps.FileNo(context.InputProvider.GetCurrentStream())); }
public static MutableString /*!*/ ReadLine(RubyScope /*!*/ scope, object self) { return(RubyIOOps.ReadLine(scope, scope.RubyContext.InputProvider.GetOrResetCurrentStream())); }
public static object Open(BlockParam /*!*/ block, RubyClass /*!*/ self, object path) { RubyIO io = RubyIOOps._CreateIOSharedSite3.Target(RubyIOOps._CreateIOSharedSite3, self.Context, self, Protocols.CastToString(self.Context, path)); return(RubyIOOps.TryInvokeOpenBlock(self.Context, block, io)); }
public static int GetLineNumber(RubyContext /*!*/ context, object self) { return(RubyIOOps.GetLineNumber(context.InputProvider.GetCurrentStream())); }
public static void Pos(RubyContext /*!*/ context, object self, [DefaultProtocol] IntegerValue pos) { RubyIOOps.Pos(context.InputProvider.GetCurrentStream(), pos); }
public static RubyArray /*!*/ ReadLines(RubyContext /*!*/ context, object self, [DefaultProtocol] MutableString separator, [DefaultProtocol] int limit) { return(RubyIOOps.ReadLines(context, context.InputProvider.GetOrResetCurrentStream(), separator, limit)); }
public static RubyArray /*!*/ ReadLines(RubyContext /*!*/ context, object self, [DefaultProtocol, NotNull] Union <MutableString, int> separatorOrLimit) { return(RubyIOOps.ReadLines(context, context.InputProvider.GetOrResetCurrentStream(), separatorOrLimit)); }
public static RubyArray /*!*/ ReadLines(RubyContext /*!*/ context, object self, DynamicNull separator) { return(RubyIOOps.ReadLines(context, context.InputProvider.GetOrResetCurrentStream(), separator)); }
public static RubyArray /*!*/ ReadLines(RubyContext /*!*/ context, object self) { return(RubyIOOps.ReadLines(context, context.InputProvider.GetOrResetCurrentStream())); }
public static int ReadChar(RubyContext /*!*/ context, object self) { return(RubyIOOps.ReadChar(context.InputProvider.GetOrResetCurrentStream())); }
public static MutableString /*!*/ Read(RubyContext /*!*/ context, [DefaultProtocol] int bytes, [DefaultProtocol, Optional] MutableString buffer) { return(RubyIOOps.Read(context.InputProvider.GetOrResetCurrentStream(), bytes, buffer)); }
public static MutableString /*!*/ Read(RubyContext /*!*/ context, object self) { return(RubyIOOps.Read(context.InputProvider.GetOrResetCurrentStream())); }
public static object Pos(RubyContext /*!*/ context, object self) { return(RubyIOOps.Pos(context.InputProvider.GetCurrentStream())); }
public static MutableString Gets(RubyScope /*!*/ scope, object self, DynamicNull separator) { return(RubyIOOps.Gets(scope, scope.RubyContext.InputProvider.GetOrResetCurrentStream(), separator)); }
public static void SetLineNumber(RubyContext /*!*/ context, object self, [DefaultProtocol] int value) { RubyIOOps.SetLineNumber(context, context.InputProvider.GetCurrentStream(), value); }
public static MutableString Gets(RubyScope /*!*/ scope, object self, [DefaultProtocol, NotNull] Union <MutableString, int> separatorOrLimit) { return(RubyIOOps.Gets(scope, scope.RubyContext.InputProvider.GetOrResetCurrentStream(), separatorOrLimit)); }
public static void Rewind(RubyContext /*!*/ context, object self) { RubyIOOps.Rewind(context, context.InputProvider.GetCurrentStream()); }
public static MutableString Gets(RubyScope /*!*/ scope, object self, [DefaultProtocol] MutableString separator, [DefaultProtocol] int limit) { return(RubyIOOps.Gets(scope, scope.RubyContext.InputProvider.GetOrResetCurrentStream(), separator, limit)); }
public static object Open(BlockParam /*!*/ block, RubyClass /*!*/ self, object path, int fileMode, int permissions) { RubyIO io = RubyIOOps._CreateIOSharedSite5.Target(RubyIOOps._CreateIOSharedSite5, self.Context, self, Protocols.CastToString(self.Context, path), fileMode, permissions); return(RubyIOOps.TryInvokeOpenBlock(self.Context, block, io)); }
public static object Each(RubyContext /*!*/ context, BlockParam block, object self, [DefaultProtocol] MutableString separator, [DefaultProtocol] int limit) { RubyIOOps.Each(context, block, context.InputProvider.GetOrResetCurrentStream(), separator, limit); return(self); }
public static object Open(BlockParam /*!*/ block, RubyClass /*!*/ self, [NotNull] MutableString /*!*/ path, int fileMode) { RubyIO io = RubyIOOps._CreateIOSharedSite4.Target(RubyIOOps._CreateIOSharedSite4, self.Context, self, path, fileMode); return(RubyIOOps.TryInvokeOpenBlock(self.Context, block, io)); }
public static object EachByte(RubyContext /*!*/ context, BlockParam block, object self) { RubyIOOps.EachByte(block, context.InputProvider.GetOrResetCurrentStream()); return(self); }
public static object Open(BlockParam /*!*/ block, RubyClass /*!*/ self, MutableString /*!*/ path, MutableString /*!*/ mode, int permissions) { RubyIO io = RubyIOOps._CreateIOSharedSite7.Target(RubyIOOps._CreateIOSharedSite7, self.Context, self, path, mode, permissions); return(RubyIOOps.TryInvokeOpenBlock(self.Context, block, io)); }
public static bool Closed(RubyContext /*!*/ context, object self) { return(RubyIOOps.Closed(context.InputProvider.GetCurrentStream())); }