class Mingle::BinReader
Public Class Methods
as_bin_reader( io_rd )
click to toggle source
# File lib/mingle.rb, line 2746 def self.as_bin_reader( io_rd ) self.send( :new, :rd => io_rd ) end
Public Instance Methods
read_identifier()
click to toggle source
# File lib/mingle.rb, line 2661 def read_identifier expect_type_code( TYPE_CODE_ID ) parts = Array.new( @rd.read_uint8 ) { buf32_as_utf8 } MingleIdentifier.send( :new, :parts => parts ) end
read_type_reference()
click to toggle source
# File lib/mingle.rb, line 2736 def read_type_reference case tc = peek_type_code when TYPE_CODE_ATOM_TYP then read_atomic_type_reference when TYPE_CODE_LIST_TYP then read_list_type_reference when TYPE_CODE_NULLABLE_TYP then read_nullable_type_reference else raise errorf( "Unrecognized type reference code: 0x%02x", tc ) end end
Private Instance Methods
buf32_as_utf8()
click to toggle source
# File lib/mingle.rb, line 2653 def buf32_as_utf8 RubyVersions.when_19x( @rd.read_buffer32 ) do |buf| buf.force_encoding( "utf-8" ) end end
expect_type_code( tc )
click to toggle source
# File lib/mingle.rb, line 2643 def expect_type_code( tc ) if ( act = read_type_code ) == tc tc else raise errorf( "Expected type code 0x%02x but got 0x%02x", tc, act ) end end
peek_type_code()
click to toggle source
# File lib/mingle.rb, line 2633 def peek_type_code @rd.peek_int8 end
read_atomic_type_reference()
click to toggle source
# File lib/mingle.rb, line 2725 def read_atomic_type_reference expect_type_code( TYPE_CODE_ATOM_TYP ) AtomicTypeReference.send( :new, :name => read_type_name, :restriction => read_restriction ) end
read_declared_type_name()
click to toggle source
# File lib/mingle.rb, line 2686 def read_declared_type_name expect_type_code( TYPE_CODE_DECL_NM ) DeclaredTypeName.send( :new, :name => buf32_as_utf8 ) end
read_identifiers()
click to toggle source
# File lib/mingle.rb, line 2670 def read_identifiers Array.new( @rd.read_uint8 ) { read_identifier } end
read_namespace()
click to toggle source
# File lib/mingle.rb, line 2675 def read_namespace expect_type_code( TYPE_CODE_NS ) MingleNamespace.send( :new, :parts => read_identifiers, :version => read_identifier ) end
read_qualified_type_name()
click to toggle source
# File lib/mingle.rb, line 2694 def read_qualified_type_name expect_type_code( TYPE_CODE_QN ) QualifiedTypeName.new( :namespace => read_namespace, :name => read_declared_type_name ) end
read_restriction()
click to toggle source
# File lib/mingle.rb, line 2715 def read_restriction if ( tc = read_type_code ) == TYPE_CODE_NIL nil else raise error( "Non-nil restrictions not yet implemented" ) end end
read_type_code()
click to toggle source
# File lib/mingle.rb, line 2638 def read_type_code @rd.read_int8 end
read_type_name()
click to toggle source
# File lib/mingle.rb, line 2705 def read_type_name case tc = peek_type_code when TYPE_CODE_DECL_NM then read_declared_type_name when TYPE_CODE_QN then read_qualified_type_name else raise errorf( "Unrecognized type name code: 0x%02x", tc ) end end