class Mingle::BinWriter

Public Class Methods

as_bin_writer( io_wr ) click to toggle source
# File lib/mingle.rb, line 2839
def self.as_bin_writer( io_wr )
    self.send( :new, :wr => io_wr )
end

Public Instance Methods

write_identifier( id ) click to toggle source
# File lib/mingle.rb, line 2776
def write_identifier( id )
    
    write_type_code( TYPE_CODE_ID )

    @wr.write_uint8( id.parts.size )
    id.parts.each { |part| @wr.write_buffer32( part ) }
end
write_type_reference( typ ) click to toggle source
# File lib/mingle.rb, line 2829
def write_type_reference( typ )
    
    case typ
    when AtomicTypeReference then write_atomic_type_reference( typ )
    when ListTypeReference then write_list_type_reference( typ )
    when NullableTypeReference then write_nullable_type_reference( typ )
    else raise error( "Unhandled type reference: #{typ.class}" )
    end
end

Private Instance Methods

write_atomic_type_reference( typ ) click to toggle source
# File lib/mingle.rb, line 2817
def write_atomic_type_reference( typ )
    
    write_type_code( TYPE_CODE_ATOM_TYP )
    write_type_name( typ.name )

    case typ.restriction
    when nil then write_nil
    else raise error( "Unhandled restriction: #{typ}" )
    end
end
write_declared_type_name( nm ) click to toggle source
# File lib/mingle.rb, line 2800
def write_declared_type_name( nm )
    
    write_type_code( TYPE_CODE_DECL_NM )
    @wr.write_buffer32( nm.name )
end
write_identifiers( ids ) click to toggle source
# File lib/mingle.rb, line 2785
def write_identifiers( ids )

    @wr.write_uint8( ids.size )
    ids.each { |id| write_identifier( id ) }
end
write_namespace( ns ) click to toggle source
# File lib/mingle.rb, line 2792
def write_namespace( ns )

    write_type_code( TYPE_CODE_NS )
    write_identifiers( ns.parts )
    write_identifier( ns.version )
end
write_nil() click to toggle source
# File lib/mingle.rb, line 2763
def write_nil
    write_type_code( TYPE_CODE_NIL )
end
write_qualified_type_name( qn ) click to toggle source
# File lib/mingle.rb, line 2768
def write_qualified_type_name( qn )
    
    write_type_code( TYPE_CODE_QN )
    write_namespace( qn.namespace )
    write_declared_type_name( qn.name )
end
write_type_code( tc ) click to toggle source
# File lib/mingle.rb, line 2758
def write_type_code( tc )
    @wr.write_uint8( tc )
end
write_type_name( nm ) click to toggle source
# File lib/mingle.rb, line 2807
def write_type_name( nm )

    case nm
    when DeclaredTypeName then write_declared_type_name( nm )
    when QualifiedTypeName then write_qualified_type_name( nm )
    else raise error( "Unhandled type name: #{nm.class}" )
    end
end