ÿØÿà JFIF    ÿÛ „ ( %!1!%*+...983,7(-.- PK ]#rexternal%3f-i.rinu[U:RDoc::AnyMethod[iI"external?:ETI"IO::Buffer#external?;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@ FI" Buffer;TcRDoc::NormalClass00PK ]&+ free-i.rinu[U:RDoc::AnyMethod[iI" free:ETI"IO::Buffer#free;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"NIf the buffer references memory, release it back to the operating system.;To:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"3for a _mapped_ buffer (e.g. from file): unmap.;To;;0; [o; ; [I"4for a buffer created from scratch: free memory.;To;;0; [o; ; [I" # ;TI" ;TI"buffer.get_value(:U8, 0) ;TI"R# in `get_value': The buffer is not allocated! (IO::Buffer::AllocationError) ;TI" ;TI"buffer.get_string ;TI"S# in `get_string': The buffer is not allocated! (IO::Buffer::AllocationError) ;TI" ;TI"buffer.null? ;TI"# => true ;T: @format0o; ; [I"5You can resize a freed buffer to re-allocate it.;T: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"free -> self ;T0[I"();T@4FI" Buffer;TcRDoc::NormalClass00PK ]> pread-i.rinu[U:RDoc::AnyMethod[iI" pread:ETI"IO::Buffer#pread;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below000[I"(p1, p2, p3);T@ FI" Buffer;TcRDoc::NormalClass00PK ]Qy inspect-i.rinu[U:RDoc::AnyMethod[iI" inspect:ETI"IO::Buffer#inspect;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@ FI" Buffer;TcRDoc::NormalClass00PK ]Preadonly%3f-i.rinu[U:RDoc::AnyMethod[iI"readonly?:ETI"IO::Buffer#readonly?;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@ FI" Buffer;TcRDoc::NormalClass00PK ]] clear-i.rinu[U:RDoc::AnyMethod[iI" clear:ETI"IO::Buffer#clear;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"MFill buffer with +value+, starting with +offset+ and going for +length+ ;TI" bytes.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"%buffer = IO::Buffer.for('test') ;TI" # => ;TI"1# ;TI".# 0x00000000 74 65 73 74 test ;TI" ;TI"buffer.clear ;TI" # => ;TI"1# ;TI".# 0x00000000 00 00 00 00 .... ;TI" ;TI" buf.clear(1) # fill with 1 ;TI" # => ;TI"1# ;TI".# 0x00000000 01 01 01 01 .... ;TI" ;TI"Nbuffer.clear(2, 1, 2) # fill with 2, starting from offset 1, for 2 bytes ;TI" # => ;TI"1# ;TI".# 0x00000000 01 02 02 01 .... ;TI" ;TI">buffer.clear(2, 1) # fill with 2, starting from offset 1 ;TI" # => ;TI"1# ;TI"-# 0x00000000 01 02 02 02 ....;T: @format0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"2clear(value = 0, [offset, [length]]) -> self ;T0[I" (*args);T@*FI" Buffer;TcRDoc::NormalClass00PK ]doointernal%3f-i.rinu[U:RDoc::AnyMethod[iI"internal?:ETI"IO::Buffer#internal?;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"PIf the buffer is _internal_, meaning it references memory allocated by the ;TI"buffer itself.;To:RDoc::Markup::BlankLineo; ; [I"QAn internal buffer is not associated with any external memory (e.g. string) ;TI"or file mapping.;T@o; ; [I"JInternal buffers are created using ::new and is the default when the ;TI"Jrequested size is less than the IO::Buffer::PAGE_SIZE and it was not ;TI"(requested to be mapped on creation.;T@o; ; [I"KInternal buffers can be resized, and such an operation will typically ;TI"+invalidate all slices, but not always.;T: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I" internal? -> true or false ;T0[I"();T@FI" Buffer;TcRDoc::NormalClass00PK ]W1 copy-i.rinu[U:RDoc::AnyMethod[iI" copy:ETI"IO::Buffer#copy;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"EEfficiently copy data from a source IO::Buffer into the buffer, ;TI"Oat +offset+ using +memcpy+. For copying String instances, see #set_string.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"!buffer = IO::Buffer.new(32) ;TI" # => ;TI"4# # ;TI"T# 0x00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ ;TI"W# 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ * ;TI" ;TI",buffer.copy(IO::Buffer.for("test"), 8) ;TI"## => 4 -- size of data copied ;TI" buffer ;TI" # => ;TI"4# # ;TI"T# 0x00000000 00 00 00 00 00 00 00 00 74 65 73 74 00 00 00 00 ........test.... ;TI"V# 0x00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ * ;T: @format0o; ; [I"G#copy can be used to put data into strings associated with buffer:;T@o; ; [ I"string= "data: " ;TI"# => "data: " ;TI""buffer = IO::Buffer.for(str) ;TI",buffer.copy(IO::Buffer.for("test"), 5) ;TI" # => 4 ;TI" string ;TI"# => "data:test" ;T; 0o; ; [I"7Attempt to copy into a read-only buffer will fail:;T@o; ; [ I"$File.write('test.txt', 'test') ;TI"Rbuffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY) ;TI",buffer.copy(IO::Buffer.for("test"), 8) ;TI"D# in `copy': Buffer is not writable! (IO::Buffer::AccessError) ;T; 0o; ; [I"KSee ::map for details of creation of mutable file mappings, this will ;TI" work:;T@o; ; [ I":buffer = IO::Buffer.map(File.open('test.txt', 'r+')) ;TI"buffer.copy("boom", 0) ;TI" # => 4 ;TI"File.read('test.txt') ;TI"# => "boom" ;T; 0o; ; [I"HAttempt to copy the data which will need place outside of buffer's ;TI"bounds will fail:;T@o; ; [I" buffer = IO::Buffer.new(2) ;TI"buffer.copy('test', 0) ;TI"N# in `copy': Specified offset+length exceeds source size! (ArgumentError);T; 0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"?copy(source, [offset, [length, [source_offset]]]) -> size ;T0[I" (*args);T@HFI" Buffer;TcRDoc::NormalClass00PK ]9 LockedError/cdesc-LockedError.rinu[U:RDoc::NormalClass[iI"LockedError:ETI"IO::Buffer::LockedError;TI"RuntimeError;To:RDoc::Markup::Document: @parts[o;;[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[; [[; [[[U:RDoc::Context::Section[i0o;;[; 0; 0[I" io.rb;TI"IO::Buffer;TcRDoc::NormalClassPK ]Bf8Gnew-c.rinu[U:RDoc::AnyMethod[iI"new:ETI"IO::Buffer::new;TT: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [ I":Create a new zero-filled IO::Buffer of +size+ bytes. ;TI"IBy default, the buffer will be _internal_: directly allocated chunk ;TI"Iof the memory. But if the requested +size+ is more than OS-specific ;TI"CIO::Bufer::PAGE_SIZE, the buffer would be allocated using the ;TI"Hvirtual memory mechanism (anonymous +mmap+ on Unix, +VirtualAlloc+ ;TI"Kon Windows). The behavior can be forced by passing IO::Buffer::MAPPED ;TI"as a second parameter.;To:RDoc::Markup::BlankLineo; ; [I" Examples;T@o:RDoc::Markup::Verbatim; [I" buffer = IO::Buffer.new(4) ;TI" # => ;TI"4# # ;TI"I# 0x00000000 00 00 00 00 .... ;TI" ;TI")buffer.get_string(0, 1) # => "\x00" ;TI" ;TI"buffer.set_string("test") ;TI" buffer ;TI" # => ;TI"3# # ;TI"G# 0x00000000 74 65 73 74 test;T: @format0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"EIO::Buffer.new([size = DEFAULT_SIZE, [flags = 0]]) -> io_buffer ;T0[I" (*args);T@&FI" Buffer;TcRDoc::NormalClass00PK ]Klocked%3f-i.rinu[U:RDoc::AnyMethod[iI" locked?:ETI"IO::Buffer#locked?;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"NIf the buffer is _locked_, meaning it is inside #locked block execution. ;TI"QLocked buffer can't be resized or freed, and another lock can't be acquired ;TI" on it.;To:RDoc::Markup::BlankLineo; ; [I"PLocking is not thread safe, but is a semantic used to ensure buffers don't ;TI",move while being used by a system call.;T@o:RDoc::Markup::Verbatim; [I"buffer.locked do ;TI"< buffer.write(io) # theoretical system call interface ;TI"end;T: @format0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"locked? -> true or false ;T0[I"();T@FI" Buffer;TcRDoc::NormalClass00PK ]N^^ empty%3f-i.rinu[U:RDoc::AnyMethod[iI" empty?:ETI"IO::Buffer#empty?;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Verbatim; [ I"QIf the buffer is _external_, meaning it references from memory which is not ;TI"/allocated or mapped by the buffer itself. ;TI" ;TI"LA buffer created using ::for has an external reference to the string's ;TI" memory. ;T: @format0o:RDoc::Markup::Paragraph; [I"&External buffer can't be resized.;T: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I" external? -> true or false ;T0[I"();T@FI" Buffer;TcRDoc::NormalClass00PK ]CFFcdesc-Buffer.rinu[U:RDoc::NormalClass[iI" Buffer:ETI"IO::Buffer;TI" Object;To:RDoc::Markup::Document: @parts[o;;[o:RDoc::Markup::Paragraph;[I"RIO::Buffer is a low-level efficient buffer for input/output. There are three ;TI"ways of using buffer:;To:RDoc::Markup::BlankLineo:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0;[o; ;[I"ICreate an empty buffer with ::new, fill it with data using #copy or ;TI"8#set_value, #set_string, get data with #get_string;;To;;0;[o; ;[I"MCreate a buffer mapped to some string with ::for, then it could be used ;TI"Pboth for reading with #get_string or #get_value, and writing (writing will ;TI"$change the source string, too);;To;;0;[o; ;[I"OCreate a buffer mapped to some file with ::map, then it could be used for ;TI"-reading and writing the underlying file.;T@o; ;[I"QInteraction with string and file memory is performed by efficient low-level ;TI" C mechanisms like `memcpy`.;T@o; ;[I"UThe class is meant to be an utility for implementing more high-level mechanisms ;TI"Slike Fiber::SchedulerInterface#io_read and Fiber::SchedulerInterface#io_write.;T@o; ;[I"Examples of usage:;T@o; ;[I"Empty buffer:;T@o:RDoc::Markup::Verbatim;[I">buffer = IO::Buffer.new(8) # create empty 8-byte buffer ;TI" # => ;TI"3# # ;TI" # ... ;TI" buffer ;TI" # => ;TI"2# ;TI"+# 0x00000000 00 00 00 00 00 00 00 00 ;TI"abuffer.set_string('test', 2) # put there bytes of the "test" string, starting from offset 2 ;TI" # => 4 ;TI")buffer.get_string # get the result ;TI"!# => "\x00\x00test\x00\x00" ;T: @format0o; ;[I"\Buffer from string:;T@o;;[I"string = 'data' ;TI""buffer = IO::Buffer.for(str) ;TI" # => ;TI"0# # ;TI" # ... ;TI" buffer ;TI" # => ;TI"0# # ;TI"H# 0x00000000 64 61 74 61 data ;TI" ;TI"Abuffer.get_string(2) # read content starting from offset 2 ;TI"# => "ta" ;TI"Ibuffer.set_string('---', 1) # write content, starting from offset 1 ;TI" # => 3 ;TI" buffer ;TI" # => ;TI"0# # ;TI"H# 0x00000000 64 2d 2d 2d d--- ;TI",string # original string changed, too ;TI"# => "d---" ;T;0o; ;[I"\Buffer from file:;T@o;;[I")File.write('test.txt', 'test data') ;TI" # => 9 ;TI"4buffer = IO::Buffer.map(File.open('test.txt')) ;TI" # => ;TI";# # ;TI" # ... ;TI"Dbuffer.get_string(5, 2) # read 2 bytes, starting from offset 5 ;TI"# => "da" ;TI"4buffer.set_string('---', 1) # attempt to write ;TI"J# in `set_string': Buffer is not writable! (IO::Buffer::AccessError) ;TI" ;TI"-# To create writable file-mapped buffer ;TI"@# Open file for read-write, pass size, offset, and flags=0 ;TI"Cbuffer = IO::Buffer.map(File.open('test.txt', 'r+'), 9, 0, 0) ;TI"!buffer.set_string('---', 1) ;TI"# => 3 -- bytes written ;TI"File.read('test.txt') ;TI"# => "t--- data" ;T;0o; ;[I"MThe class is experimental and the interface is subject to change.;T: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0;0;0[[U:RDoc::Constant[iI"PAGE_SIZE;TI"IO::Buffer::PAGE_SIZE;T: public0o;;[;@w;0@w@cRDoc::NormalClass0U;[iI"DEFAULT_SIZE;TI"IO::Buffer::DEFAULT_SIZE;T;0o;;[;@w;0@w@@{0U;[iI" EXTERNAL;TI"IO::Buffer::EXTERNAL;T;0o;;[;@w;0@w@@{0U;[iI" INTERNAL;TI"IO::Buffer::INTERNAL;T;0o;;[;@w;0@w@@{0U;[iI" MAPPED;TI"IO::Buffer::MAPPED;T;0o;;[;@w;0@w@@{0U;[iI" LOCKED;TI"IO::Buffer::LOCKED;T;0o;;[;@w;0@w@@{0U;[iI" PRIVATE;TI"IO::Buffer::PRIVATE;T;0o;;[;@w;0@w@@{0U;[iI" READONLY;TI"IO::Buffer::READONLY;T;0o;;[;@w;0@w@@{0U;[iI"LITTLE_ENDIAN;TI"IO::Buffer::LITTLE_ENDIAN;T;0o;;[;@w;0@w@@{0U;[iI"BIG_ENDIAN;TI"IO::Buffer::BIG_ENDIAN;T;0o;;[;@w;0@w@@{0U;[iI"HOST_ENDIAN;TI"IO::Buffer::HOST_ENDIAN;T;0o;;[;@w;0@w@@{0U;[iI"NETWORK_ENDIAN;TI"IO::Buffer::NETWORK_ENDIAN;T;0o;;[;@w;0@w@@{0[[I"Comparable;To;;[;@w;0I"io_buffer.c;T[[I" class;T[[;[[:protected[[: private[[I"for;T@[I"map;T@[I"new;T@[I" instance;T[[;[[;[[;[![I"<=>;T@[I" clear;T@[I" copy;T@[I" empty?;T@[I"external?;T@[I" free;T@[I"get_string;T@[I"get_value;T@[I" hexdump;T@[I" inspect;T@[I"internal?;T@[I" locked;T@[I" locked?;T@[I" mapped?;T@[I" null?;T@[I" pread;T@[I" pwrite;T@[I" read;T@[I"readonly?;T@[I" resize;T@[I"set_string;T@[I"set_value;T@[I" size;T@[I" slice;T@[I" to_s;T@[I" transfer;T@[I" valid?;T@[I" write;T@[[U:RDoc::Context::Section[i0o;;[;0;0[I"ext/io/console/console.c;TI"IO;T@{PK ]Uo resize-i.rinu[U:RDoc::AnyMethod[iI" resize:ETI"IO::Buffer#resize;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [ I"EResizes a buffer to a +new_size+ bytes, preserving its content. ;TI"HDepending on the old and new size, the memory area associated with ;TI"Ethe buffer might be either extended, or rellocated at different ;TI"'address with content being copied.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I" buffer = IO::Buffer.new(4) ;TI""buffer.set_string("test", 0) ;TI"*buffer.resize(8) # resize to 8 bytes ;TI" # => ;TI"3# # ;TI"L# 0x00000000 74 65 73 74 00 00 00 00 test.... ;T: @format0o; ; [I"=External buffer (created with ::for), and locked buffer ;TI"can not be resized.;T: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"resize(new_size) -> self ;T0[I" (p1);T@FI" Buffer;TcRDoc::NormalClass00PK ].Cset_string-i.rinu[U:RDoc::AnyMethod[iI"set_string:ETI"IO::Buffer#set_string;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below000[I" (*args);T@ FI" Buffer;TcRDoc::NormalClass00PK ]̨*InvalidatedError/cdesc-InvalidatedError.rinu[U:RDoc::NormalClass[iI"InvalidatedError:ETI"!IO::Buffer::InvalidatedError;TI"RuntimeError;To:RDoc::Markup::Document: @parts[o;;[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[; [[; [[[U:RDoc::Context::Section[i0o;;[; 0; 0[I" io.rb;TI"IO::Buffer;TcRDoc::NormalClassPK ]Dget_string-i.rinu[U:RDoc::AnyMethod[iI"get_string:ETI"IO::Buffer#get_string;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GRead a chunk or all of the buffer into a string, in the specified ;TI"G+encoding+. If no encoding is provided +Encoding::BINARY+ is used.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [ I"%buffer = IO::Buffer.for('test') ;TI"buffer.get_string ;TI"# => "test" ;TI"buffer.get_string(2) ;TI"# => "st" ;TI"buffer.get_string(2, 1) ;TI" # => "s";T: @format0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I":get_string([offset, [length, [encoding]]]) -> string ;T0[I" (*args);T@FI" Buffer;TcRDoc::NormalClass00PK ]CF8 size-i.rinu[U:RDoc::AnyMethod[iI" size:ETI"IO::Buffer#size;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"TReturns the size of the buffer that was explicitly set (on creation with ::new ;TI"Ior on #resize), or deduced on buffer's creation from string or file.;T: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"size -> integer ;T0[I"();T@FI" Buffer;TcRDoc::NormalClass00PK ]iset_value-i.rinu[U:RDoc::AnyMethod[iI"set_value:ETI"IO::Buffer#set_value;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"PWrite to a buffer a +value+ of +type+ at +offset+. +type+ should be one of ;TI"%symbols described in #get_value.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I" buffer = IO::Buffer.new(8) ;TI" # => ;TI"3# # ;TI"+# 0x00000000 00 00 00 00 00 00 00 00 ;TI"#buffer.set_value(:U8, 1, 111) ;TI" # => 1 ;TI" buffer ;TI" # => ;TI"3# # ;TI"L# 0x00000000 00 6f 00 00 00 00 00 00 .o...... ;T: @format0o; ; [I"cNote that if the +type+ is integer and +value+ is Float, the implicit truncation is performed:;T@o; ; [ I" buffer = IO::Buffer.new(8) ;TI"$buffer.set_value(:U32, 0, 2.5) ;TI" buffer ;TI" # => ;TI"4# # ;TI",# 0x00000000 00 00 00 02 00 00 00 00 ;TI"G# ^^ the same as if we'd pass just integer 2;T; 0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I".set_value(type, offset, value) -> offset ;T0[I"(p1, p2, p3);T@(FI" Buffer;TcRDoc::NormalClass00PK ]t^ hexdump-i.rinu[U:RDoc::AnyMethod[iI" hexdump:ETI"IO::Buffer#hexdump;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below000[I"();T@ FI" Buffer;TcRDoc::NormalClass00PK ]!vFF to_s-i.rinu[U:RDoc::AnyMethod[iI" to_s:ETI"IO::Buffer#to_s;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"KShort representation of the buffer. It includes the address, size and ;TI"6symbolic flags. This format is subject to change.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"3puts IO::Buffer.new(4) # uses to_s internally ;TI"2# #;T: @format0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"to_s -> string ;T0[I"();T@FI" Buffer;TcRDoc::NormalClass00PK ]q pwrite-i.rinu[U:RDoc::AnyMethod[iI" pwrite:ETI"IO::Buffer#pwrite;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below000[I"(p1, p2, p3);T@ FI" Buffer;TcRDoc::NormalClass00PK ] write-i.rinu[U:RDoc::AnyMethod[iI" write:ETI"IO::Buffer#write;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below000[I" (p1, p2);T@ FI" Buffer;TcRDoc::NormalClass00PK ]}e#zz null%3f-i.rinu[U:RDoc::AnyMethod[iI" null?:ETI"IO::Buffer#null?;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LIf the buffer was freed with #free or was never allocated in the first ;TI" place.;T: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"null? -> true or false ;T0[I"();T@FI" Buffer;TcRDoc::NormalClass00PK ]TŬ read-i.rinu[U:RDoc::AnyMethod[iI" read:ETI"IO::Buffer#read;TF: privateo:RDoc::Markup::Document: @parts[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below000[I" (p1, p2);T@ FI" Buffer;TcRDoc::NormalClass00PK ]E transfer-i.rinu[U:RDoc::AnyMethod[iI" transfer:ETI"IO::Buffer#transfer;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"GTransfers ownership to a new buffer, deallocating the current one.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I"%buffer = IO::Buffer.new('test') ;TI"other = buffer.transfer ;TI" other ;TI" # => ;TI"0# # ;TI"H# 0x00000000 74 65 73 74 test ;TI" buffer ;TI" # => ;TI"/# # ;TI"buffer.null? ;TI"# => true;T: @format0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"transfer -> new_io_buffer ;T0[I"();T@FI" Buffer;TcRDoc::NormalClass00PK ]JM~~get_value-i.rinu[U:RDoc::AnyMethod[iI"get_value:ETI"IO::Buffer#get_value;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"JRead from buffer a value of +type+ at +offset+. +type+ should be one ;TI"of symbols:;To:RDoc::Markup::BlankLineo:RDoc::Markup::List: @type: BULLET: @items[o:RDoc::Markup::ListItem: @label0; [o; ; [I"$+:U8+: unsigned integer, 1 byte;To;;0; [o; ; [I""+:S8+: signed integer, 1 byte;To;;0; [o; ; [I"5+:u16+: unsigned integer, 2 bytes, little-endian;To;;0; [o; ; [I"2+:U16+: unsigned integer, 2 bytes, big-endian;To;;0; [o; ; [I"3+:s16+: signed integer, 2 bytes, little-endian;To;;0; [o; ; [I"0+:S16+: signed integer, 2 bytes, big-endian;To;;0; [o; ; [I"5+:u32+: unsigned integer, 4 bytes, little-endian;To;;0; [o; ; [I"2+:U32+: unsigned integer, 4 bytes, big-endian;To;;0; [o; ; [I"3+:s32+: signed integer, 4 bytes, little-endian;To;;0; [o; ; [I"0+:S32+: signed integer, 4 bytes, big-endian;To;;0; [o; ; [I"5+:u64+: unsigned integer, 8 bytes, little-endian;To;;0; [o; ; [I"2+:U64+: unsigned integer, 8 bytes, big-endian;To;;0; [o; ; [I"3+:s64+: signed integer, 8 bytes, little-endian;To;;0; [o; ; [I"0+:S64+: signed integer, 8 bytes, big-endian;To;;0; [o; ; [I"*+:f32+: float, 4 bytes, little-endian;To;;0; [o; ; [I"'+:F32+: float, 4 bytes, big-endian;To;;0; [o; ; [I"++:f64+: double, 8 bytes, little-endian;To;;0; [o; ; [I"(+:F64+: double, 8 bytes, big-endian;T@o; ; [I" Example:;T@o:RDoc::Markup::Verbatim; [ I"string = [1.5].pack('f') ;TI"# => "\x00\x00\xC0?" ;TI"/IO::Buffer.for(string).get_value(:f32, 0) ;TI" # => 1.5;T: @format0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"(get_value(type, offset) -> numeric ;T0[I" (p1, p2);T@uFI" Buffer;TcRDoc::NormalClass00PK ]^^map-c.rinu[U:RDoc::AnyMethod[iI"map:ETI"IO::Buffer::map;TT: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"NCreate an IO::Buffer for reading from +file+ by memory-mapping the file. ;TI"?+file_io+ should be a +File+ instance, opened for reading.;To:RDoc::Markup::BlankLineo; ; [I">Optional +size+ and +offset+ of mapping can be specified.;T@o; ; [I"QBy default, the buffer would be immutable (read only); to create a writable ;TI"Nmapping, you need to open a file in read-write mode, and explicitly pass ;TI"4+flags+ argument without IO::Buffer::IMMUTABLE.;T@o:RDoc::Markup::Verbatim; [I"$File.write('test.txt', 'test') ;TI" ;TI"Rbuffer = IO::Buffer.map(File.open('test.txt'), nil, 0, IO::Buffer::READONLY) ;TI"=# => # ;TI" ;TI""buffer.readonly? # => true ;TI" ;TI"buffer.get_string ;TI"# => "test" ;TI" ;TI"buffer.set_string('b', 0) ;TI"G# `set_string': Buffer is not writable! (IO::Buffer::AccessError) ;TI" ;TI"D# create read/write mapping: length 4 bytes, offset 0, flags 0 ;TI"@buffer = IO::Buffer.map(File.open('test.txt', 'r+'), 4, 0) ;TI"buffer.set_string('b', 0) ;TI" # => 1 ;TI" ;TI"# Check it ;TI"File.read('test.txt') ;TI"# => "best" ;T: @format0o; ; [I"RNote that some operating systems may not have cache coherency between mapped ;TI"buffers and file reads.;T: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"BIO::Buffer.map(file, [size, [offset, [flags]]]) -> io_buffer ;T0[I" (*args);T@3FI" Buffer;TcRDoc::NormalClass00PK ]Vfor-c.rinu[U:RDoc::AnyMethod[iI"for:ETI"IO::Buffer::for;TT: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [ I"LCreates a IO::Buffer from the given string's memory. Without a block a ;TI"Ofrozen internal copy of the string is created efficiently and used as the ;TI"Pbuffer source. When a block is provided, the buffer is associated directly ;TI"Mwith the string's internal data and updating the buffer will update the ;TI" string.;To:RDoc::Markup::BlankLineo; ; [I"PUntil #free is invoked on the buffer, either explicitly or via the garbage ;TI"Hcollector, the source string will be locked and cannot be modified.;T@o; ; [I"PIf the string is frozen, it will create a read-only buffer which cannot be ;TI"Lmodified. If the string is shared, it may trigger a copy-on-write when ;TI"using the block form.;T@o:RDoc::Markup::Verbatim; [I"string = 'test' ;TI"%buffer = IO::Buffer.for(string) ;TI"buffer.external? #=> true ;TI" ;TI"buffer.get_string(0, 1) ;TI"# => "t" ;TI" string ;TI"# => "best" ;TI" ;TI"buffer.resize(100) ;TI"M# in `resize': Cannot resize external buffer! (IO::Buffer::AccessError) ;TI" ;TI"(IO::Buffer.for(string) do |buffer| ;TI" buffer.set_string("T") ;TI" string ;TI" # => "Test" ;TI"end;T: @format0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"tIO::Buffer.for(string) -> readonly io_buffer IO::Buffer.for(string) {|io_buffer| ... read/write io_buffer ...} ;T0[I" (p1);T@/FI" Buffer;TcRDoc::NormalClass00PK ]ZCg(AllocationError/cdesc-AllocationError.rinu[U:RDoc::NormalClass[iI"AllocationError:ETI" IO::Buffer::AllocationError;TI"RuntimeError;To:RDoc::Markup::Document: @parts[o;;[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[; [[; [[[U:RDoc::Context::Section[i0o;;[; 0; 0[I" io.rb;TI"IO::Buffer;TcRDoc::NormalClassPK ]   locked-i.rinu[U:RDoc::AnyMethod[iI" locked:ETI"IO::Buffer#locked;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [ I"PAllows to process a buffer in exclusive way, for concurrency-safety. While ;TI"Pthe block is performed, the buffer is considered locked, and no other code ;TI"Ncan enter the lock. Also, locked buffer can't be changed with #resize or ;TI" #free.;To:RDoc::Markup::BlankLineo:RDoc::Markup::Verbatim; [I" buffer = IO::Buffer.new(4) ;TI"buffer.locked? #=> false ;TI" ;TI"Fiber.schedule do ;TI" buffer.locked do ;TI"> buffer.write(io) # theoretical system call interface ;TI" end ;TI" end ;TI" ;TI"Fiber.schedule do ;TI"G # in `locked': Buffer already locked! (IO::Buffer::LockedError) ;TI" buffer.locked do ;TI" buffer.set_string(...) ;TI" end ;TI" end ;T: @format0o; ; [I"=The following operations acquire a lock: #resize, #free.;T@o; ; [I"GLocking is not thread safe. It is designed as a safety net around ;TI"Qnon-blocking system calls. You can only share a buffer between threads with ;TI",appropriate synchronisation techniques.;T: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"locked { ... } ;T0[I"();T@+FI" Buffer;TcRDoc::NormalClass00PK ]mapped%3f-i.rinu[U:RDoc::AnyMethod[iI" mapped?:ETI"IO::Buffer#mapped?;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"KIf the buffer is _mapped_, meaning it references memory mapped by the ;TI" buffer.;To:RDoc::Markup::BlankLineo; ; [I"GMapped buffers are either anonymous, if created by ::new with the ;TI"PIO::Buffer::MAPPED flag or if the size was at least IO::Buffer::PAGE_SIZE, ;TI"/or backed by a file if created with ::map.;T@o; ; [I"QMapped buffers can usually be resized, and such an operation will typically ;TI"+invalidate all slices, but not always.;T: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"mapped? -> true or false ;T0[I"();T@FI" Buffer;TcRDoc::NormalClass00PK ]5Q%3c%3d%3e-i.rinu[U:RDoc::AnyMethod[iI"<=>:ETI"IO::Buffer#<=>;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"LBuffers are compared by size and exact contents of the memory they are ;TI" referencing using +memcmp+.;T: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"!<=>(other) -> true or false ;T0[I" (p1);T@FI" Buffer;TcRDoc::NormalClass00PK ]n AccessError/cdesc-AccessError.rinu[U:RDoc::NormalClass[iI"AccessError:ETI"IO::Buffer::AccessError;TI"RuntimeError;To:RDoc::Markup::Document: @parts[o;;[: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0; 0; 0[[[[[I" class;T[[: public[[:protected[[: private[[I" instance;T[[; [[; [[; [[[U:RDoc::Context::Section[i0o;;[; 0; 0[I" io.rb;TI"IO::Buffer;TcRDoc::NormalClassPK ]24 valid%3f-i.rinu[U:RDoc::AnyMethod[iI" valid?:ETI"IO::Buffer#valid?;TF: privateo:RDoc::Markup::Document: @parts[o:RDoc::Markup::Paragraph; [I"3Returns whether the buffer data is accessible.;To:RDoc::Markup::BlankLineo; ; [I"PA buffer becomes invalid if it is a slice of another buffer which has been ;TI" freed.;T: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"valid? -> true or false ;T0[I"();T@FI" Buffer;TcRDoc::NormalClass00PK ]V@ slice-i.rinu[U:RDoc::AnyMethod[iI" slice:ETI"IO::Buffer#slice;TF: privateo:RDoc::Markup::Document: @parts[ o:RDoc::Markup::Paragraph; [I"PProduce another IO::Buffer which is a slice (or view into) the current one ;TI"=starting at +offset+ bytes and going for +length+ bytes.;To:RDoc::Markup::BlankLineo; ; [I"NThe slicing happens without copying of memory, and the slice keeps being ;TI"Lassociated with the original buffer's source (string, or file), if any.;T@o; ; [I"LRaises RuntimeError if the offset+length is out of the current ;TI"buffer's bounds.;T@o:RDoc::Markup::Verbatim; [I"string = 'test' ;TI"%buffer = IO::Buffer.for(string) ;TI" ;TI" slice = buffer.slice(1, 2) ;TI" # => ;TI"1# # ;TI"G# 0x00000000 65 73 es ;TI" ;TI"-# Put "o" into 0s position of the slice ;TI"slice.set_string('o', 0) ;TI" slice ;TI" # => ;TI"1# # ;TI"G# 0x00000000 6f 73 os ;TI" ;TI"?# it is also visible at position 1 of the original buffer ;TI" buffer ;TI" # => ;TI"1# # ;TI"I# 0x00000000 74 6f 73 74 tost ;TI" ;TI"# ...and original string ;TI" string ;TI"# => tost;T: @format0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"(slice(offset, length) -> io_buffer ;T0[I" (p1, p2);T@2FI" Buffer;TcRDoc::NormalClass00PK ]#rexternal%3f-i.rinu[PK ]&+ +free-i.rinu[PK ]> ^pread-i.rinu[PK ]Qy inspect-i.rinu[PK ]Preadonly%3f-i.rinu[PK ]]  clear-i.rinu[PK ]doointernal%3f-i.rinu[PK ]W1 copy-i.rinu[PK ]9 LockedError/cdesc-LockedError.rinu[PK ]Bf8Gnew-c.rinu[PK ]K/#locked%3f-i.rinu[PK ]N^^ o&empty%3f-i.rinu[PK ]CFF )cdesc-Buffer.rinu[PK ]Uo =resize-i.rinu[PK ].CAset_string-i.rinu[PK ]̨*BInvalidatedError/cdesc-InvalidatedError.rinu[PK ]DDget_string-i.rinu[PK ]CF8 Gsize-i.rinu[PK ]iIset_value-i.rinu[PK ]t^ Nhexdump-i.rinu[PK ]!vFF Pto_s-i.rinu[PK ]q Rpwrite-i.rinu[PK ] Swrite-i.rinu[PK ]}e#zz Tnull%3f-i.rinu[PK ]TŬ Vread-i.rinu[PK ]E Wtransfer-i.rinu[PK ]JM~~Zget_value-i.rinu[PK ]^^bmap-c.rinu[PK ]VEifor-c.rinu[PK ]ZCg(oAllocationError/cdesc-AllocationError.rinu[PK ]   qlocked-i.rinu[PK ]vmapped%3f-i.rinu[PK ]5Qz%3c%3d%3e-i.rinu[PK ]n {AccessError/cdesc-AccessError.rinu[PK ]24 }valid%3f-i.rinu[PK ]V@ slice-i.rinu[PK$$ A