text:
# Automatically generated using Clang.jl wrap_c, version 0.0.0
#
# Note: This file is for reference only.  The relevant parts are
# translated to more idiomatic Julia in format.jl

const FLAC__MAX_METADATA_TYPE_CODE = 126
const FLAC__MIN_BLOCK_SIZE = 16
const FLAC__MAX_BLOCK_SIZE = 65535
const FLAC__SUBSET_MAX_BLOCK_SIZE_48000HZ = 4608
const FLAC__MAX_CHANNELS = 8
const FLAC__MIN_BITS_PER_SAMPLE = 4
const FLAC__MAX_BITS_PER_SAMPLE = 32
const FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE = 24
const FLAC__MAX_SAMPLE_RATE = 655350
const FLAC__MAX_LPC_ORDER = 32
const FLAC__SUBSET_MAX_LPC_ORDER_48000HZ = 12
const FLAC__MIN_QLP_COEFF_PRECISION = 5
const FLAC__MAX_QLP_COEFF_PRECISION = 15
const FLAC__MAX_FIXED_ORDER = 4
const FLAC__MAX_RICE_PARTITION_ORDER = 15
const FLAC__SUBSET_MAX_RICE_PARTITION_ORDER = 8
const FLAC__STREAM_SYNC_LENGTH = 4
const FLAC__STREAM_METADATA_STREAMINFO_LENGTH = 34
const FLAC__STREAM_METADATA_SEEKPOINT_LENGTH = 18
const FLAC__STREAM_METADATA_HEADER_LENGTH = 4

# begin enum ANONYMOUS_1
typealias ANONYMOUS_1 UInt32
const FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = (UInt32)(0)
const FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = (UInt32)(1)
# end enum ANONYMOUS_1

# begin enum FLAC__EntropyCodingMethodType
typealias FLAC__EntropyCodingMethodType UInt32
const FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = (UInt32)(0)
const FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = (UInt32)(1)
# end enum FLAC__EntropyCodingMethodType

type FLAC__EntropyCodingMethod_PartitionedRiceContents
    parameters::Ptr{UInt32}
    raw_bits::Ptr{UInt32}
    capacity_by_order::UInt32
end

type FLAC__EntropyCodingMethod_PartitionedRice
    order::UInt32
    contents::Ptr{FLAC__EntropyCodingMethod_PartitionedRiceContents}
end

type FLAC__EntropyCodingMethod
    _type::FLAC__EntropyCodingMethodType
    data::Void
end

# begin enum ANONYMOUS_2
typealias ANONYMOUS_2 UInt32
const FLAC__SUBFRAME_TYPE_CONSTANT = (UInt32)(0)
const FLAC__SUBFRAME_TYPE_VERBATIM = (UInt32)(1)
const FLAC__SUBFRAME_TYPE_FIXED = (UInt32)(2)
const FLAC__SUBFRAME_TYPE_LPC = (UInt32)(3)
# end enum ANONYMOUS_2

# begin enum FLAC__SubframeType
typealias FLAC__SubframeType UInt32
const FLAC__SUBFRAME_TYPE_CONSTANT = (UInt32)(0)
const FLAC__SUBFRAME_TYPE_VERBATIM = (UInt32)(1)
const FLAC__SUBFRAME_TYPE_FIXED = (UInt32)(2)
const FLAC__SUBFRAME_TYPE_LPC = (UInt32)(3)
# end enum FLAC__SubframeType

typealias FLAC__bool Bool
typealias FLAC__byte UInt8
typealias FLAC__int32 Int32
typealias FLAC__UInt8 UInt8
typealias FLAC__UInt16 UInt16
typealias FLAC__UInt32 UInt32
typealias FLAC__uint64 UInt64

type FLAC__Subframe_Constant
    value::FLAC__int32
end

type FLAC__Subframe_Verbatim
    data::Ptr{FLAC__int32}
end

immutable Array_4_FLAC__int32
    d1::FLAC__int32
    d2::FLAC__int32
    d3::FLAC__int32
    d4::FLAC__int32
end

zero(::Type{Array_4_FLAC__int32}) = begin  # /home/bates/.julia/v0.4/Clang/src/wrap_c.jl, line 264:
        Array_4_FLAC__int32(fill(zero(FLAC__int32),4)...)
    end

type FLAC__Subframe_Fixed
    entropy_coding_method::FLAC__EntropyCodingMethod
    order::UInt32
    warmup::Array_4_FLAC__int32
    residual::Ptr{FLAC__int32}
end

immutable Array_32_FLAC__int32
    d1::FLAC__int32
    d2::FLAC__int32
    d3::FLAC__int32
    d4::FLAC__int32
    d5::FLAC__int32
    d6::FLAC__int32
    d7::FLAC__int32
    d8::FLAC__int32
    d9::FLAC__int32
    d10::FLAC__int32
    d11::FLAC__int32
    d12::FLAC__int32
    d13::FLAC__int32
    d14::FLAC__int32
    d15::FLAC__int32
    d16::FLAC__int32
    d17::FLAC__int32
    d18::FLAC__int32
    d19::FLAC__int32
    d20::FLAC__int32
    d21::FLAC__int32
    d22::FLAC__int32
    d23::FLAC__int32
    d24::FLAC__int32
    d25::FLAC__int32
    d26::FLAC__int32
    d27::FLAC__int32
    d28::FLAC__int32
    d29::FLAC__int32
    d30::FLAC__int32
    d31::FLAC__int32
    d32::FLAC__int32
end

zero(::Type{Array_32_FLAC__int32}) = begin  # /home/bates/.julia/v0.4/Clang/src/wrap_c.jl, line 264:
        Array_32_FLAC__int32(fill(zero(FLAC__int32),32)...)
    end

type FLAC__Subframe_LPC
    entropy_coding_method::FLAC__EntropyCodingMethod
    order::UInt32
    qlp_coeff_precision::UInt32
    quantization_level::Cint
    qlp_coeff::Array_32_FLAC__int32
    warmup::Array_32_FLAC__int32
    residual::Ptr{FLAC__int32}
end

type FLAC__Subframe
    _type::FLAC__SubframeType
    data::Void
    wasted_bits::UInt32
end

# begin enum ANONYMOUS_3
typealias ANONYMOUS_3 UInt32
const FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = (UInt32)(0)
const FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = (UInt32)(1)
const FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = (UInt32)(2)
const FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = (UInt32)(3)
# end enum ANONYMOUS_3

# begin enum FLAC__ChannelAssignment
typealias FLAC__ChannelAssignment UInt32
const FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = (UInt32)(0)
const FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = (UInt32)(1)
const FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = (UInt32)(2)
const FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = (UInt32)(3)
# end enum FLAC__ChannelAssignment

# begin enum ANONYMOUS_4
typealias ANONYMOUS_4 UInt32
const FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER = (UInt32)(0)
const FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER = (UInt32)(1)
# end enum ANONYMOUS_4

# begin enum FLAC__FrameNumberType
typealias FLAC__FrameNumberType UInt32
const FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER = (UInt32)(0)
const FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER = (UInt32)(1)
# end enum FLAC__FrameNumberType

type FLAC__FrameHeader
    blocksize::UInt32
    sample_rate::UInt32
    channels::UInt32
    channel_assignment::FLAC__ChannelAssignment
    bits_per_sample::UInt32
    number_type::FLAC__FrameNumberType
    number::Void
    crc::FLAC__UInt8
end

type FLAC__FrameFooter
    crc::FLAC__UInt16
end

immutable Array_8_FLAC__Subframe
    d1::FLAC__Subframe
    d2::FLAC__Subframe
    d3::FLAC__Subframe
    d4::FLAC__Subframe
    d5::FLAC__Subframe
    d6::FLAC__Subframe
    d7::FLAC__Subframe
    d8::FLAC__Subframe
end

zero(::Type{Array_8_FLAC__Subframe}) = begin  # /home/bates/.julia/v0.4/Clang/src/wrap_c.jl, line 264:
        Array_8_FLAC__Subframe(fill(zero(FLAC__Subframe),8)...)
    end

type FLAC__Frame
    header::FLAC__FrameHeader
    subframes::Array_8_FLAC__Subframe
    footer::FLAC__FrameFooter
end

# begin enum ANONYMOUS_5
typealias ANONYMOUS_5 UInt32
const FLAC__METADATA_TYPE_STREAMINFO = (UInt32)(0)
const FLAC__METADATA_TYPE_PADDING = (UInt32)(1)
const FLAC__METADATA_TYPE_APPLICATION = (UInt32)(2)
const FLAC__METADATA_TYPE_SEEKTABLE = (UInt32)(3)
const FLAC__METADATA_TYPE_VORBIS_COMMENT = (UInt32)(4)
const FLAC__METADATA_TYPE_CUESHEET = (UInt32)(5)
const FLAC__METADATA_TYPE_PICTURE = (UInt32)(6)
const FLAC__METADATA_TYPE_UNDEFINED = (UInt32)(7)
const FLAC__MAX_METADATA_TYPE = (UInt32)(126)
# end enum ANONYMOUS_5

# begin enum FLAC__MetadataType
typealias FLAC__MetadataType UInt32
const FLAC__METADATA_TYPE_STREAMINFO = (UInt32)(0)
const FLAC__METADATA_TYPE_PADDING = (UInt32)(1)
const FLAC__METADATA_TYPE_APPLICATION = (UInt32)(2)
const FLAC__METADATA_TYPE_SEEKTABLE = (UInt32)(3)
const FLAC__METADATA_TYPE_VORBIS_COMMENT = (UInt32)(4)
const FLAC__METADATA_TYPE_CUESHEET = (UInt32)(5)
const FLAC__METADATA_TYPE_PICTURE = (UInt32)(6)
const FLAC__METADATA_TYPE_UNDEFINED = (UInt32)(7)
const FLAC__MAX_METADATA_TYPE = (UInt32)(126)
# end enum FLAC__MetadataType

immutable Array_16_FLAC__byte
    d1::FLAC__byte
    d2::FLAC__byte
    d3::FLAC__byte
    d4::FLAC__byte
    d5::FLAC__byte
    d6::FLAC__byte
    d7::FLAC__byte
    d8::FLAC__byte
    d9::FLAC__byte
    d10::FLAC__byte
    d11::FLAC__byte
    d12::FLAC__byte
    d13::FLAC__byte
    d14::FLAC__byte
    d15::FLAC__byte
    d16::FLAC__byte
end

zero(::Type{Array_16_FLAC__byte}) = begin  # /home/bates/.julia/v0.4/Clang/src/wrap_c.jl, line 264:
        Array_16_FLAC__byte(fill(zero(FLAC__byte),16)...)
    end

type FLAC__StreamMetadata_StreamInfo
    min_blocksize::UInt32
    max_blocksize::UInt32
    min_framesize::UInt32
    max_framesize::UInt32
    sample_rate::UInt32
    channels::UInt32
    bits_per_sample::UInt32
    total_samples::FLAC__uint64
    md5sum::Array_16_FLAC__byte
end

type FLAC__StreamMetadata_Padding
    dummy::Cint
end

immutable Array_4_FLAC__byte
    d1::FLAC__byte
    d2::FLAC__byte
    d3::FLAC__byte
    d4::FLAC__byte
end

zero(::Type{Array_4_FLAC__byte}) = begin  # /home/bates/.julia/v0.4/Clang/src/wrap_c.jl, line 264:
        Array_4_FLAC__byte(fill(zero(FLAC__byte),4)...)
    end

type FLAC__StreamMetadata_Application
    id::Array_4_FLAC__byte
    data::Ptr{FLAC__byte}
end

type FLAC__StreamMetadata_SeekPoint
    sample_number::FLAC__uint64
    stream_offset::FLAC__uint64
    frame_samples::UInt32
end

type FLAC__StreamMetadata_SeekTable
    num_points::UInt32
    points::Ptr{FLAC__StreamMetadata_SeekPoint}
end

type FLAC__StreamMetadata_VorbisComment_Entry
    length::FLAC__UInt32
    entry::Ptr{FLAC__byte}
end

type FLAC__StreamMetadata_VorbisComment
    vendor_string::FLAC__StreamMetadata_VorbisComment_Entry
    num_comments::FLAC__UInt32
    comments::Ptr{FLAC__StreamMetadata_VorbisComment_Entry}
end

type FLAC__StreamMetadata_CueSheet_Index
    offset::FLAC__uint64
    number::FLAC__byte
end

immutable Array_13_UInt8
    d1::UInt8
    d2::UInt8
    d3::UInt8
    d4::UInt8
    d5::UInt8
    d6::UInt8
    d7::UInt8
    d8::UInt8
    d9::UInt8
    d10::UInt8
    d11::UInt8
    d12::UInt8
    d13::UInt8
end

zero(::Type{Array_13_UInt8}) = begin  # /home/bates/.julia/v0.4/Clang/src/wrap_c.jl, line 264:
        Array_13_UInt8(fill(zero(UInt8),13)...)
    end

type FLAC__StreamMetadata_CueSheet_Track
    offset::FLAC__uint64
    number::FLAC__byte
    isrc::Array_13_UInt8
    _type::UInt32
    pre_emphasis::UInt32
    num_indices::FLAC__byte
    indices::Ptr{FLAC__StreamMetadata_CueSheet_Index}
end

immutable Array_129_UInt8
    d1::UInt8
    d2::UInt8
    d3::UInt8
    d4::UInt8
    d5::UInt8
    d6::UInt8
    d7::UInt8
    d8::UInt8
    d9::UInt8
    d10::UInt8
    d11::UInt8
    d12::UInt8
    d13::UInt8
    d14::UInt8
    d15::UInt8
    d16::UInt8
    d17::UInt8
    d18::UInt8
    d19::UInt8
    d20::UInt8
    d21::UInt8
    d22::UInt8
    d23::UInt8
    d24::UInt8
    d25::UInt8
    d26::UInt8
    d27::UInt8
    d28::UInt8
    d29::UInt8
    d30::UInt8
    d31::UInt8
    d32::UInt8
    d33::UInt8
    d34::UInt8
    d35::UInt8
    d36::UInt8
    d37::UInt8
    d38::UInt8
    d39::UInt8
    d40::UInt8
    d41::UInt8
    d42::UInt8
    d43::UInt8
    d44::UInt8
    d45::UInt8
    d46::UInt8
    d47::UInt8
    d48::UInt8
    d49::UInt8
    d50::UInt8
    d51::UInt8
    d52::UInt8
    d53::UInt8
    d54::UInt8
    d55::UInt8
    d56::UInt8
    d57::UInt8
    d58::UInt8
    d59::UInt8
    d60::UInt8
    d61::UInt8
    d62::UInt8
    d63::UInt8
    d64::UInt8
    d65::UInt8
    d66::UInt8
    d67::UInt8
    d68::UInt8
    d69::UInt8
    d70::UInt8
    d71::UInt8
    d72::UInt8
    d73::UInt8
    d74::UInt8
    d75::UInt8
    d76::UInt8
    d77::UInt8
    d78::UInt8
    d79::UInt8
    d80::UInt8
    d81::UInt8
    d82::UInt8
    d83::UInt8
    d84::UInt8
    d85::UInt8
    d86::UInt8
    d87::UInt8
    d88::UInt8
    d89::UInt8
    d90::UInt8
    d91::UInt8
    d92::UInt8
    d93::UInt8
    d94::UInt8
    d95::UInt8
    d96::UInt8
    d97::UInt8
    d98::UInt8
    d99::UInt8
    d100::UInt8
    d101::UInt8
    d102::UInt8
    d103::UInt8
    d104::UInt8
    d105::UInt8
    d106::UInt8
    d107::UInt8
    d108::UInt8
    d109::UInt8
    d110::UInt8
    d111::UInt8
    d112::UInt8
    d113::UInt8
    d114::UInt8
    d115::UInt8
    d116::UInt8
    d117::UInt8
    d118::UInt8
    d119::UInt8
    d120::UInt8
    d121::UInt8
    d122::UInt8
    d123::UInt8
    d124::UInt8
    d125::UInt8
    d126::UInt8
    d127::UInt8
    d128::UInt8
    d129::UInt8
end

zero(::Type{Array_129_UInt8}) = begin  # /home/bates/.julia/v0.4/Clang/src/wrap_c.jl, line 264:
        Array_129_UInt8(fill(zero(UInt8),129)...)
    end

type FLAC__StreamMetadata_CueSheet
    media_catalog_number::Array_129_UInt8
    lead_in::FLAC__uint64
    is_cd::FLAC__bool
    num_tracks::UInt32
    tracks::Ptr{FLAC__StreamMetadata_CueSheet_Track}
end

# begin enum ANONYMOUS_6
typealias ANONYMOUS_6 UInt32
const FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER = (UInt32)(0)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD = (UInt32)(1)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON = (UInt32)(2)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER = (UInt32)(3)
const FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER = (UInt32)(4)
const FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE = (UInt32)(5)
const FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA = (UInt32)(6)
const FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST = (UInt32)(7)
const FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST = (UInt32)(8)
const FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR = (UInt32)(9)
const FLAC__STREAM_METADATA_PICTURE_TYPE_BAND = (UInt32)(10)
const FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER = (UInt32)(11)
const FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST = (UInt32)(12)
const FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION = (UInt32)(13)
const FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING = (UInt32)(14)
const FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE = (UInt32)(15)
const FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE = (UInt32)(16)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FISH = (UInt32)(17)
const FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION = (UInt32)(18)
const FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE = (UInt32)(19)
const FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE = (UInt32)(20)
const FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED = (UInt32)(21)
# end enum ANONYMOUS_6

# begin enum FLAC__StreamMetadata_Picture_Type
typealias FLAC__StreamMetadata_Picture_Type UInt32
const FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER = (UInt32)(0)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD = (UInt32)(1)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON = (UInt32)(2)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER = (UInt32)(3)
const FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER = (UInt32)(4)
const FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE = (UInt32)(5)
const FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA = (UInt32)(6)
const FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST = (UInt32)(7)
const FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST = (UInt32)(8)
const FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR = (UInt32)(9)
const FLAC__STREAM_METADATA_PICTURE_TYPE_BAND = (UInt32)(10)
const FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER = (UInt32)(11)
const FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST = (UInt32)(12)
const FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION = (UInt32)(13)
const FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING = (UInt32)(14)
const FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE = (UInt32)(15)
const FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE = (UInt32)(16)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FISH = (UInt32)(17)
const FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION = (UInt32)(18)
const FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE = (UInt32)(19)
const FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE = (UInt32)(20)
const FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED = (UInt32)(21)
# end enum FLAC__StreamMetadata_Picture_Type

type FLAC__StreamMetadata_Picture
    _type::FLAC__StreamMetadata_Picture_Type
    mime_type::Ptr{UInt8}
    description::Ptr{FLAC__byte}
    width::FLAC__UInt32
    height::FLAC__UInt32
    depth::FLAC__UInt32
    colors::FLAC__UInt32
    data_length::FLAC__UInt32
    data::Ptr{FLAC__byte}
end

type FLAC__StreamMetadata_Unknown
    data::Ptr{FLAC__byte}
end

type FLAC__StreamMetadata
    _type::FLAC__MetadataType
    is_last::FLAC__bool
    length::UInt32
    data::Void
end

# begin enum ANONYMOUS_7
typealias ANONYMOUS_7 UInt32
const FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = (UInt32)(0)
const FLAC__STREAM_DECODER_READ_METADATA = (UInt32)(1)
const FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC = (UInt32)(2)
const FLAC__STREAM_DECODER_READ_FRAME = (UInt32)(3)
const FLAC__STREAM_DECODER_END_OF_STREAM = (UInt32)(4)
const FLAC__STREAM_DECODER_OGG_ERROR = (UInt32)(5)
const FLAC__STREAM_DECODER_SEEK_ERROR = (UInt32)(6)
const FLAC__STREAM_DECODER_ABORTED = (UInt32)(7)
const FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR = (UInt32)(8)
const FLAC__STREAM_DECODER_UNINITIALIZED = (UInt32)(9)
# end enum ANONYMOUS_7

# begin enum FLAC__StreamDecoderState
typealias FLAC__StreamDecoderState UInt32
const FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = (UInt32)(0)
const FLAC__STREAM_DECODER_READ_METADATA = (UInt32)(1)
const FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC = (UInt32)(2)
const FLAC__STREAM_DECODER_READ_FRAME = (UInt32)(3)
const FLAC__STREAM_DECODER_END_OF_STREAM = (UInt32)(4)
const FLAC__STREAM_DECODER_OGG_ERROR = (UInt32)(5)
const FLAC__STREAM_DECODER_SEEK_ERROR = (UInt32)(6)
const FLAC__STREAM_DECODER_ABORTED = (UInt32)(7)
const FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR = (UInt32)(8)
const FLAC__STREAM_DECODER_UNINITIALIZED = (UInt32)(9)
# end enum FLAC__StreamDecoderState

# begin enum ANONYMOUS_8
typealias ANONYMOUS_8 UInt32
const FLAC__STREAM_DECODER_INIT_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER = (UInt32)(1)
const FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS = (UInt32)(2)
const FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR = (UInt32)(3)
const FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE = (UInt32)(4)
const FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED = (UInt32)(5)
# end enum ANONYMOUS_8

# begin enum FLAC__StreamDecoderInitStatus
typealias FLAC__StreamDecoderInitStatus UInt32
const FLAC__STREAM_DECODER_INIT_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER = (UInt32)(1)
const FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS = (UInt32)(2)
const FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR = (UInt32)(3)
const FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE = (UInt32)(4)
const FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED = (UInt32)(5)
# end enum FLAC__StreamDecoderInitStatus

# begin enum ANONYMOUS_9
typealias ANONYMOUS_9 UInt32
const FLAC__STREAM_DECODER_READ_STATUS_CONTINUE = (UInt32)(0)
const FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM = (UInt32)(1)
const FLAC__STREAM_DECODER_READ_STATUS_ABORT = (UInt32)(2)
# end enum ANONYMOUS_9

# begin enum FLAC__StreamDecoderReadStatus
typealias FLAC__StreamDecoderReadStatus UInt32
const FLAC__STREAM_DECODER_READ_STATUS_CONTINUE = (UInt32)(0)
const FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM = (UInt32)(1)
const FLAC__STREAM_DECODER_READ_STATUS_ABORT = (UInt32)(2)
# end enum FLAC__StreamDecoderReadStatus

# begin enum ANONYMOUS_10
typealias ANONYMOUS_10 UInt32
const FLAC__STREAM_DECODER_SEEK_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_SEEK_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_10

# begin enum FLAC__StreamDecoderSeekStatus
typealias FLAC__StreamDecoderSeekStatus UInt32
const FLAC__STREAM_DECODER_SEEK_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_SEEK_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum FLAC__StreamDecoderSeekStatus

# begin enum ANONYMOUS_11
typealias ANONYMOUS_11 UInt32
const FLAC__STREAM_DECODER_TELL_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_TELL_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_11

# begin enum FLAC__StreamDecoderTellStatus
typealias FLAC__StreamDecoderTellStatus UInt32
const FLAC__STREAM_DECODER_TELL_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_TELL_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum FLAC__StreamDecoderTellStatus

# begin enum ANONYMOUS_12
typealias ANONYMOUS_12 UInt32
const FLAC__STREAM_DECODER_LENGTH_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_12

# begin enum FLAC__StreamDecoderLengthStatus
typealias FLAC__StreamDecoderLengthStatus UInt32
const FLAC__STREAM_DECODER_LENGTH_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum FLAC__StreamDecoderLengthStatus

# begin enum ANONYMOUS_13
typealias ANONYMOUS_13 UInt32
const FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE = (UInt32)(0)
const FLAC__STREAM_DECODER_WRITE_STATUS_ABORT = (UInt32)(1)
# end enum ANONYMOUS_13

# begin enum FLAC__StreamDecoderWriteStatus
typealias FLAC__StreamDecoderWriteStatus UInt32
const FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE = (UInt32)(0)
const FLAC__STREAM_DECODER_WRITE_STATUS_ABORT = (UInt32)(1)
# end enum FLAC__StreamDecoderWriteStatus

# begin enum ANONYMOUS_14
typealias ANONYMOUS_14 UInt32
const FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC = (UInt32)(0)
const FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER = (UInt32)(1)
const FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH = (UInt32)(2)
const FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM = (UInt32)(3)
# end enum ANONYMOUS_14

# begin enum FLAC__StreamDecoderErrorStatus
typealias FLAC__StreamDecoderErrorStatus UInt32
const FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC = (UInt32)(0)
const FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER = (UInt32)(1)
const FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH = (UInt32)(2)
const FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM = (UInt32)(3)
# end enum FLAC__StreamDecoderErrorStatus

type FLAC__StreamDecoderProtected
end

type FLAC__StreamDecoderPrivate
end

type FLAC__StreamDecoder
    protected_::Ptr{FLAC__StreamDecoderProtected}
    private_::Ptr{FLAC__StreamDecoderPrivate}
end

typealias FLAC__StreamDecoderReadCallback Ptr{Void}
typealias FLAC__StreamDecoderSeekCallback Ptr{Void}
typealias FLAC__StreamDecoderTellCallback Ptr{Void}
typealias FLAC__StreamDecoderLengthCallback Ptr{Void}
typealias FLAC__StreamDecoderEofCallback Ptr{Void}
typealias FLAC__StreamDecoderWriteCallback Ptr{Void}
typealias FLAC__StreamDecoderMetadataCallback Ptr{Void}
typealias FLAC__StreamDecoderErrorCallback Ptr{Void}

# begin enum ANONYMOUS_15
typealias ANONYMOUS_15 UInt32
const FLAC__STREAM_ENCODER_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_UNINITIALIZED = (UInt32)(1)
const FLAC__STREAM_ENCODER_OGG_ERROR = (UInt32)(2)
const FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR = (UInt32)(3)
const FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA = (UInt32)(4)
const FLAC__STREAM_ENCODER_CLIENT_ERROR = (UInt32)(5)
const FLAC__STREAM_ENCODER_IO_ERROR = (UInt32)(6)
const FLAC__STREAM_ENCODER_FRAMING_ERROR = (UInt32)(7)
const FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR = (UInt32)(8)
# end enum ANONYMOUS_15

# begin enum FLAC__StreamEncoderState
typealias FLAC__StreamEncoderState UInt32
const FLAC__STREAM_ENCODER_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_UNINITIALIZED = (UInt32)(1)
const FLAC__STREAM_ENCODER_OGG_ERROR = (UInt32)(2)
const FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR = (UInt32)(3)
const FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA = (UInt32)(4)
const FLAC__STREAM_ENCODER_CLIENT_ERROR = (UInt32)(5)
const FLAC__STREAM_ENCODER_IO_ERROR = (UInt32)(6)
const FLAC__STREAM_ENCODER_FRAMING_ERROR = (UInt32)(7)
const FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR = (UInt32)(8)
# end enum FLAC__StreamEncoderState

# begin enum ANONYMOUS_16
typealias ANONYMOUS_16 UInt32
const FLAC__STREAM_ENCODER_INIT_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR = (UInt32)(1)
const FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER = (UInt32)(2)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS = (UInt32)(3)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS = (UInt32)(4)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE = (UInt32)(5)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE = (UInt32)(6)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE = (UInt32)(7)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER = (UInt32)(8)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION = (UInt32)(9)
const FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER = (UInt32)(10)
const FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE = (UInt32)(11)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA = (UInt32)(12)
const FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED = (UInt32)(13)
# end enum ANONYMOUS_16

# begin enum FLAC__StreamEncoderInitStatus
typealias FLAC__StreamEncoderInitStatus UInt32
const FLAC__STREAM_ENCODER_INIT_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR = (UInt32)(1)
const FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER = (UInt32)(2)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS = (UInt32)(3)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS = (UInt32)(4)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE = (UInt32)(5)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE = (UInt32)(6)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE = (UInt32)(7)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER = (UInt32)(8)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION = (UInt32)(9)
const FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER = (UInt32)(10)
const FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE = (UInt32)(11)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA = (UInt32)(12)
const FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED = (UInt32)(13)
# end enum FLAC__StreamEncoderInitStatus

# begin enum ANONYMOUS_17
typealias ANONYMOUS_17 UInt32
const FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE = (UInt32)(0)
const FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM = (UInt32)(1)
const FLAC__STREAM_ENCODER_READ_STATUS_ABORT = (UInt32)(2)
const FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED = (UInt32)(3)
# end enum ANONYMOUS_17

# begin enum FLAC__StreamEncoderReadStatus
typealias FLAC__StreamEncoderReadStatus UInt32
const FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE = (UInt32)(0)
const FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM = (UInt32)(1)
const FLAC__STREAM_ENCODER_READ_STATUS_ABORT = (UInt32)(2)
const FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED = (UInt32)(3)
# end enum FLAC__StreamEncoderReadStatus

# begin enum ANONYMOUS_18
typealias ANONYMOUS_18 UInt32
const FLAC__STREAM_ENCODER_WRITE_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR = (UInt32)(1)
# end enum ANONYMOUS_18

# begin enum FLAC__StreamEncoderWriteStatus
typealias FLAC__StreamEncoderWriteStatus UInt32
const FLAC__STREAM_ENCODER_WRITE_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR = (UInt32)(1)
# end enum FLAC__StreamEncoderWriteStatus

# begin enum ANONYMOUS_19
typealias ANONYMOUS_19 UInt32
const FLAC__STREAM_ENCODER_SEEK_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_19

# begin enum FLAC__StreamEncoderSeekStatus
typealias FLAC__StreamEncoderSeekStatus UInt32
const FLAC__STREAM_ENCODER_SEEK_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum FLAC__StreamEncoderSeekStatus

# begin enum ANONYMOUS_20
typealias ANONYMOUS_20 UInt32
const FLAC__STREAM_ENCODER_TELL_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_TELL_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_20

# begin enum FLAC__StreamEncoderTellStatus
typealias FLAC__StreamEncoderTellStatus UInt32
const FLAC__STREAM_ENCODER_TELL_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_TELL_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum FLAC__StreamEncoderTellStatus

type FLAC__StreamEncoderProtected
end

type FLAC__StreamEncoderPrivate
end

type FLAC__StreamEncoder
    protected_::Ptr{FLAC__StreamEncoderProtected}
    private_::Ptr{FLAC__StreamEncoderPrivate}
end

typealias FLAC__StreamEncoderReadCallback Ptr{Void}
typealias FLAC__StreamEncoderWriteCallback Ptr{Void}
typealias FLAC__StreamEncoderSeekCallback Ptr{Void}
typealias FLAC__StreamEncoderTellCallback Ptr{Void}
typealias FLAC__StreamEncoderMetadataCallback Ptr{Void}
typealias FLAC__StreamEncoderProgressCallback Ptr{Void}

# begin enum ANONYMOUS_21
typealias ANONYMOUS_21 UInt32
const FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = (UInt32)(0)
const FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = (UInt32)(1)
# end enum ANONYMOUS_21

# begin enum ANONYMOUS_22
typealias ANONYMOUS_22 UInt32
const FLAC__SUBFRAME_TYPE_CONSTANT = (UInt32)(0)
const FLAC__SUBFRAME_TYPE_VERBATIM = (UInt32)(1)
const FLAC__SUBFRAME_TYPE_FIXED = (UInt32)(2)
const FLAC__SUBFRAME_TYPE_LPC = (UInt32)(3)
# end enum ANONYMOUS_22

# begin enum ANONYMOUS_23
typealias ANONYMOUS_23 UInt32
const FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = (UInt32)(0)
const FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = (UInt32)(1)
const FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = (UInt32)(2)
const FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = (UInt32)(3)
# end enum ANONYMOUS_23

# begin enum ANONYMOUS_24
typealias ANONYMOUS_24 UInt32
const FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER = (UInt32)(0)
const FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER = (UInt32)(1)
# end enum ANONYMOUS_24

# begin enum ANONYMOUS_25
typealias ANONYMOUS_25 UInt32
const FLAC__METADATA_TYPE_STREAMINFO = (UInt32)(0)
const FLAC__METADATA_TYPE_PADDING = (UInt32)(1)
const FLAC__METADATA_TYPE_APPLICATION = (UInt32)(2)
const FLAC__METADATA_TYPE_SEEKTABLE = (UInt32)(3)
const FLAC__METADATA_TYPE_VORBIS_COMMENT = (UInt32)(4)
const FLAC__METADATA_TYPE_CUESHEET = (UInt32)(5)
const FLAC__METADATA_TYPE_PICTURE = (UInt32)(6)
const FLAC__METADATA_TYPE_UNDEFINED = (UInt32)(7)
const FLAC__MAX_METADATA_TYPE = (UInt32)(126)
# end enum ANONYMOUS_25

# begin enum ANONYMOUS_26
typealias ANONYMOUS_26 UInt32
const FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER = (UInt32)(0)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD = (UInt32)(1)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON = (UInt32)(2)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER = (UInt32)(3)
const FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER = (UInt32)(4)
const FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE = (UInt32)(5)
const FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA = (UInt32)(6)
const FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST = (UInt32)(7)
const FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST = (UInt32)(8)
const FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR = (UInt32)(9)
const FLAC__STREAM_METADATA_PICTURE_TYPE_BAND = (UInt32)(10)
const FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER = (UInt32)(11)
const FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST = (UInt32)(12)
const FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION = (UInt32)(13)
const FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING = (UInt32)(14)
const FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE = (UInt32)(15)
const FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE = (UInt32)(16)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FISH = (UInt32)(17)
const FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION = (UInt32)(18)
const FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE = (UInt32)(19)
const FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE = (UInt32)(20)
const FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED = (UInt32)(21)
# end enum ANONYMOUS_26

# begin enum ANONYMOUS_27
typealias ANONYMOUS_27 UInt32
const FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = (UInt32)(0)
const FLAC__STREAM_DECODER_READ_METADATA = (UInt32)(1)
const FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC = (UInt32)(2)
const FLAC__STREAM_DECODER_READ_FRAME = (UInt32)(3)
const FLAC__STREAM_DECODER_END_OF_STREAM = (UInt32)(4)
const FLAC__STREAM_DECODER_OGG_ERROR = (UInt32)(5)
const FLAC__STREAM_DECODER_SEEK_ERROR = (UInt32)(6)
const FLAC__STREAM_DECODER_ABORTED = (UInt32)(7)
const FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR = (UInt32)(8)
const FLAC__STREAM_DECODER_UNINITIALIZED = (UInt32)(9)
# end enum ANONYMOUS_27

# begin enum ANONYMOUS_28
typealias ANONYMOUS_28 UInt32
const FLAC__STREAM_DECODER_INIT_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER = (UInt32)(1)
const FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS = (UInt32)(2)
const FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR = (UInt32)(3)
const FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE = (UInt32)(4)
const FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED = (UInt32)(5)
# end enum ANONYMOUS_28

# begin enum ANONYMOUS_29
typealias ANONYMOUS_29 UInt32
const FLAC__STREAM_DECODER_READ_STATUS_CONTINUE = (UInt32)(0)
const FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM = (UInt32)(1)
const FLAC__STREAM_DECODER_READ_STATUS_ABORT = (UInt32)(2)
# end enum ANONYMOUS_29

# begin enum ANONYMOUS_30
typealias ANONYMOUS_30 UInt32
const FLAC__STREAM_DECODER_SEEK_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_SEEK_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_30

# begin enum ANONYMOUS_31
typealias ANONYMOUS_31 UInt32
const FLAC__STREAM_DECODER_TELL_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_TELL_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_31

# begin enum ANONYMOUS_32
typealias ANONYMOUS_32 UInt32
const FLAC__STREAM_DECODER_LENGTH_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_32

# begin enum ANONYMOUS_33
typealias ANONYMOUS_33 UInt32
const FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE = (UInt32)(0)
const FLAC__STREAM_DECODER_WRITE_STATUS_ABORT = (UInt32)(1)
# end enum ANONYMOUS_33

# begin enum ANONYMOUS_34
typealias ANONYMOUS_34 UInt32
const FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC = (UInt32)(0)
const FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER = (UInt32)(1)
const FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH = (UInt32)(2)
const FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM = (UInt32)(3)
# end enum ANONYMOUS_34

typealias ogg_int16_t Int16
typealias ogg_UInt16_t UInt16
typealias ogg_int32_t Int32
typealias ogg_UInt32_t UInt32
typealias ogg_int64_t Int64

type ogg_iovec_t
    iov_base::Ptr{Void}
    iov_len::Cint
end

type oggpack_buffer
    endbyte::Clong
    endbit::Cint
    buffer::Ptr{Cuchar}
    ptr::Ptr{Cuchar}
    storage::Clong
end

type ogg_page
    header::Ptr{Cuchar}
    header_len::Clong
    body::Ptr{Cuchar}
    body_len::Clong
end

immutable Array_282_Cuchar
    d1::Cuchar
    d2::Cuchar
    d3::Cuchar
    d4::Cuchar
    d5::Cuchar
    d6::Cuchar
    d7::Cuchar
    d8::Cuchar
    d9::Cuchar
    d10::Cuchar
    d11::Cuchar
    d12::Cuchar
    d13::Cuchar
    d14::Cuchar
    d15::Cuchar
    d16::Cuchar
    d17::Cuchar
    d18::Cuchar
    d19::Cuchar
    d20::Cuchar
    d21::Cuchar
    d22::Cuchar
    d23::Cuchar
    d24::Cuchar
    d25::Cuchar
    d26::Cuchar
    d27::Cuchar
    d28::Cuchar
    d29::Cuchar
    d30::Cuchar
    d31::Cuchar
    d32::Cuchar
    d33::Cuchar
    d34::Cuchar
    d35::Cuchar
    d36::Cuchar
    d37::Cuchar
    d38::Cuchar
    d39::Cuchar
    d40::Cuchar
    d41::Cuchar
    d42::Cuchar
    d43::Cuchar
    d44::Cuchar
    d45::Cuchar
    d46::Cuchar
    d47::Cuchar
    d48::Cuchar
    d49::Cuchar
    d50::Cuchar
    d51::Cuchar
    d52::Cuchar
    d53::Cuchar
    d54::Cuchar
    d55::Cuchar
    d56::Cuchar
    d57::Cuchar
    d58::Cuchar
    d59::Cuchar
    d60::Cuchar
    d61::Cuchar
    d62::Cuchar
    d63::Cuchar
    d64::Cuchar
    d65::Cuchar
    d66::Cuchar
    d67::Cuchar
    d68::Cuchar
    d69::Cuchar
    d70::Cuchar
    d71::Cuchar
    d72::Cuchar
    d73::Cuchar
    d74::Cuchar
    d75::Cuchar
    d76::Cuchar
    d77::Cuchar
    d78::Cuchar
    d79::Cuchar
    d80::Cuchar
    d81::Cuchar
    d82::Cuchar
    d83::Cuchar
    d84::Cuchar
    d85::Cuchar
    d86::Cuchar
    d87::Cuchar
    d88::Cuchar
    d89::Cuchar
    d90::Cuchar
    d91::Cuchar
    d92::Cuchar
    d93::Cuchar
    d94::Cuchar
    d95::Cuchar
    d96::Cuchar
    d97::Cuchar
    d98::Cuchar
    d99::Cuchar
    d100::Cuchar
    d101::Cuchar
    d102::Cuchar
    d103::Cuchar
    d104::Cuchar
    d105::Cuchar
    d106::Cuchar
    d107::Cuchar
    d108::Cuchar
    d109::Cuchar
    d110::Cuchar
    d111::Cuchar
    d112::Cuchar
    d113::Cuchar
    d114::Cuchar
    d115::Cuchar
    d116::Cuchar
    d117::Cuchar
    d118::Cuchar
    d119::Cuchar
    d120::Cuchar
    d121::Cuchar
    d122::Cuchar
    d123::Cuchar
    d124::Cuchar
    d125::Cuchar
    d126::Cuchar
    d127::Cuchar
    d128::Cuchar
    d129::Cuchar
    d130::Cuchar
    d131::Cuchar
    d132::Cuchar
    d133::Cuchar
    d134::Cuchar
    d135::Cuchar
    d136::Cuchar
    d137::Cuchar
    d138::Cuchar
    d139::Cuchar
    d140::Cuchar
    d141::Cuchar
    d142::Cuchar
    d143::Cuchar
    d144::Cuchar
    d145::Cuchar
    d146::Cuchar
    d147::Cuchar
    d148::Cuchar
    d149::Cuchar
    d150::Cuchar
    d151::Cuchar
    d152::Cuchar
    d153::Cuchar
    d154::Cuchar
    d155::Cuchar
    d156::Cuchar
    d157::Cuchar
    d158::Cuchar
    d159::Cuchar
    d160::Cuchar
    d161::Cuchar
    d162::Cuchar
    d163::Cuchar
    d164::Cuchar
    d165::Cuchar
    d166::Cuchar
    d167::Cuchar
    d168::Cuchar
    d169::Cuchar
    d170::Cuchar
    d171::Cuchar
    d172::Cuchar
    d173::Cuchar
    d174::Cuchar
    d175::Cuchar
    d176::Cuchar
    d177::Cuchar
    d178::Cuchar
    d179::Cuchar
    d180::Cuchar
    d181::Cuchar
    d182::Cuchar
    d183::Cuchar
    d184::Cuchar
    d185::Cuchar
    d186::Cuchar
    d187::Cuchar
    d188::Cuchar
    d189::Cuchar
    d190::Cuchar
    d191::Cuchar
    d192::Cuchar
    d193::Cuchar
    d194::Cuchar
    d195::Cuchar
    d196::Cuchar
    d197::Cuchar
    d198::Cuchar
    d199::Cuchar
    d200::Cuchar
    d201::Cuchar
    d202::Cuchar
    d203::Cuchar
    d204::Cuchar
    d205::Cuchar
    d206::Cuchar
    d207::Cuchar
    d208::Cuchar
    d209::Cuchar
    d210::Cuchar
    d211::Cuchar
    d212::Cuchar
    d213::Cuchar
    d214::Cuchar
    d215::Cuchar
    d216::Cuchar
    d217::Cuchar
    d218::Cuchar
    d219::Cuchar
    d220::Cuchar
    d221::Cuchar
    d222::Cuchar
    d223::Cuchar
    d224::Cuchar
    d225::Cuchar
    d226::Cuchar
    d227::Cuchar
    d228::Cuchar
    d229::Cuchar
    d230::Cuchar
    d231::Cuchar
    d232::Cuchar
    d233::Cuchar
    d234::Cuchar
    d235::Cuchar
    d236::Cuchar
    d237::Cuchar
    d238::Cuchar
    d239::Cuchar
    d240::Cuchar
    d241::Cuchar
    d242::Cuchar
    d243::Cuchar
    d244::Cuchar
    d245::Cuchar
    d246::Cuchar
    d247::Cuchar
    d248::Cuchar
    d249::Cuchar
    d250::Cuchar
    d251::Cuchar
    d252::Cuchar
    d253::Cuchar
    d254::Cuchar
    d255::Cuchar
    d256::Cuchar
    d257::Cuchar
    d258::Cuchar
    d259::Cuchar
    d260::Cuchar
    d261::Cuchar
    d262::Cuchar
    d263::Cuchar
    d264::Cuchar
    d265::Cuchar
    d266::Cuchar
    d267::Cuchar
    d268::Cuchar
    d269::Cuchar
    d270::Cuchar
    d271::Cuchar
    d272::Cuchar
    d273::Cuchar
    d274::Cuchar
    d275::Cuchar
    d276::Cuchar
    d277::Cuchar
    d278::Cuchar
    d279::Cuchar
    d280::Cuchar
    d281::Cuchar
    d282::Cuchar
end

zero(::Type{Array_282_Cuchar}) = begin  # /home/bates/.julia/v0.4/Clang/src/wrap_c.jl, line 264:
        Array_282_Cuchar(fill(zero(Cuchar),282)...)
    end

type ogg_stream_state
    body_data::Ptr{Cuchar}
    body_storage::Clong
    body_fill::Clong
    body_returned::Clong
    lacing_vals::Ptr{Cint}
    granule_vals::Ptr{ogg_int64_t}
    lacing_storage::Clong
    lacing_fill::Clong
    lacing_packet::Clong
    lacing_returned::Clong
    header::Array_282_Cuchar
    header_fill::Cint
    e_o_s::Cint
    b_o_s::Cint
    serialno::Clong
    pageno::Clong
    packetno::ogg_int64_t
    granulepos::ogg_int64_t
end

type ogg_packet
    packet::Ptr{Cuchar}
    bytes::Clong
    b_o_s::Clong
    e_o_s::Clong
    granulepos::ogg_int64_t
    packetno::ogg_int64_t
end

type ogg_sync_state
    data::Ptr{Cuchar}
    storage::Cint
    fill::Cint
    returned::Cint
    unsynced::Cint
    headerbytes::Cint
    bodybytes::Cint
end

# begin enum OggzError
typealias OggzError Cint
const OGGZ_ERR_OK = (Int32)(0)
const OGGZ_ERR_GENERIC = (Int32)(-1)
const OGGZ_ERR_BAD_OGGZ = (Int32)(-2)
const OGGZ_ERR_INVALID = (Int32)(-3)
const OGGZ_ERR_NO_STREAMS = (Int32)(-4)
const OGGZ_ERR_BOS = (Int32)(-5)
const OGGZ_ERR_EOS = (Int32)(-6)
const OGGZ_ERR_BAD_METRIC = (Int32)(-7)
const OGGZ_ERR_SYSTEM = (Int32)(-10)
const OGGZ_ERR_DISABLED = (Int32)(-11)
const OGGZ_ERR_NOSEEK = (Int32)(-13)
const OGGZ_ERR_STOP_OK = (Int32)(-14)
const OGGZ_ERR_STOP_ERR = (Int32)(-15)
const OGGZ_ERR_IO_AGAIN = (Int32)(-16)
const OGGZ_ERR_HOLE_IN_DATA = (Int32)(-17)
const OGGZ_ERR_OUT_OF_MEMORY = (Int32)(-18)
const OGGZ_ERR_BAD_SERIALNO = (Int32)(-20)
const OGGZ_ERR_BAD_BYTES = (Int32)(-21)
const OGGZ_ERR_BAD_B_O_S = (Int32)(-22)
const OGGZ_ERR_BAD_E_O_S = (Int32)(-23)
const OGGZ_ERR_BAD_GRANULEPOS = (Int32)(-24)
const OGGZ_ERR_BAD_PACKETNO = (Int32)(-25)
const OGGZ_ERR_COMMENT_INVALID = (Int32)(-129)
const OGGZ_ERR_BAD_GUARD = (Int32)(-210)
const OGGZ_ERR_RECURSIVE_WRITE = (Int32)(-266)
# end enum OggzError

const OGGZ_ERR_USER_STOPPED = OGGZ_ERR_STOP_OK
const OGGZ_ERR_READ_STOP_OK = OGGZ_ERR_STOP_OK
const OGGZ_ERR_READ_STOP_ERR = OGGZ_ERR_STOP_ERR

# begin enum OggzFlags
typealias OggzFlags UInt32
const OGGZ_READ = (UInt32)(0)
const OGGZ_WRITE = (UInt32)(1)
const OGGZ_NONSTRICT = (UInt32)(16)
const OGGZ_AUTO = (UInt32)(32)
const OGGZ_PREFIX = (UInt32)(64)
const OGGZ_SUFFIX = (UInt32)(128)
# end enum OggzFlags

# begin enum OggzStopCtl
typealias OggzStopCtl Cint
const OGGZ_CONTINUE = (Int32)(0)
const OGGZ_STOP_OK = (Int32)(1)
const OGGZ_STOP_ERR = (Int32)(-1)
# end enum OggzStopCtl

# begin enum OggzFlushOpts
typealias OggzFlushOpts UInt32
const OGGZ_FLUSH_BEFORE = (UInt32)(1)
const OGGZ_FLUSH_AFTER = (UInt32)(2)
# end enum OggzFlushOpts

# begin enum OggzStreamContent
typealias OggzStreamContent UInt32
const OGGZ_CONTENT_THEORA = (UInt32)(0)
const OGGZ_CONTENT_VORBIS = (UInt32)(1)
const OGGZ_CONTENT_SPEEX = (UInt32)(2)
const OGGZ_CONTENT_PCM = (UInt32)(3)
const OGGZ_CONTENT_CMML = (UInt32)(4)
const OGGZ_CONTENT_ANX2 = (UInt32)(5)
const OGGZ_CONTENT_SKELETON = (UInt32)(6)
const OGGZ_CONTENT_FLAC0 = (UInt32)(7)
const OGGZ_CONTENT_FLAC = (UInt32)(8)
const OGGZ_CONTENT_ANXDATA = (UInt32)(9)
const OGGZ_CONTENT_CELT = (UInt32)(10)
const OGGZ_CONTENT_KATE = (UInt32)(11)
const OGGZ_CONTENT_DIRAC = (UInt32)(12)
const OGGZ_CONTENT_UNKNOWN = (UInt32)(13)
# end enum OggzStreamContent

typealias OggzTable Void
typealias OGGZ Void
typealias oggz_off_t Coff_t

type oggz_position
    calc_granulepos::ogg_int64_t
    begin_page_offset::oggz_off_t
    end_page_offset::oggz_off_t
    pages::Cint
    begin_segment_index::Cint
end

type oggz_packet
    op::ogg_packet
    pos::oggz_position
end

typealias OggzReadPacket Ptr{Void}
typealias OggzReadPage Ptr{Void}
typealias OggzMetric Ptr{Void}
typealias OggzWriteHungry Ptr{Void}
typealias OggzIOWrite Ptr{Void}
typealias OggzIOSeek Ptr{Void}
typealias OggzIOTell Ptr{Void}
typealias OggzIOFlush Ptr{Void}

type OggzComment
    name::Ptr{UInt8}
    value::Ptr{UInt8}
end

typealias FLAC__IOHandle Ptr{Void}
typealias FLAC__IOCallback_Write Ptr{Void}
typealias FLAC__IOCallback_Seek Ptr{Void}
typealias FLAC__IOCallback_Tell Ptr{Void}
typealias FLAC__IOCallback_Eof Ptr{Void}
typealias FLAC__IOCallback_Close Ptr{Void}

type FLAC__IOCallbacks
    read::Cint
    write::FLAC__IOCallback_Write
    seek::FLAC__IOCallback_Seek
    tell::FLAC__IOCallback_Tell
    eof::FLAC__IOCallback_Eof
    close::FLAC__IOCallback_Close
end

# begin enum ANONYMOUS_36
typealias ANONYMOUS_36 UInt32
const FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = (UInt32)(0)
const FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = (UInt32)(1)
# end enum ANONYMOUS_36

# begin enum ANONYMOUS_37
typealias ANONYMOUS_37 UInt32
const FLAC__SUBFRAME_TYPE_CONSTANT = (UInt32)(0)
const FLAC__SUBFRAME_TYPE_VERBATIM = (UInt32)(1)
const FLAC__SUBFRAME_TYPE_FIXED = (UInt32)(2)
const FLAC__SUBFRAME_TYPE_LPC = (UInt32)(3)
# end enum ANONYMOUS_37

# begin enum ANONYMOUS_38
typealias ANONYMOUS_38 UInt32
const FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = (UInt32)(0)
const FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = (UInt32)(1)
const FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = (UInt32)(2)
const FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = (UInt32)(3)
# end enum ANONYMOUS_38

# begin enum ANONYMOUS_39
typealias ANONYMOUS_39 UInt32
const FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER = (UInt32)(0)
const FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER = (UInt32)(1)
# end enum ANONYMOUS_39

# begin enum ANONYMOUS_40
typealias ANONYMOUS_40 UInt32
const FLAC__METADATA_TYPE_STREAMINFO = (UInt32)(0)
const FLAC__METADATA_TYPE_PADDING = (UInt32)(1)
const FLAC__METADATA_TYPE_APPLICATION = (UInt32)(2)
const FLAC__METADATA_TYPE_SEEKTABLE = (UInt32)(3)
const FLAC__METADATA_TYPE_VORBIS_COMMENT = (UInt32)(4)
const FLAC__METADATA_TYPE_CUESHEET = (UInt32)(5)
const FLAC__METADATA_TYPE_PICTURE = (UInt32)(6)
const FLAC__METADATA_TYPE_UNDEFINED = (UInt32)(7)
const FLAC__MAX_METADATA_TYPE = (UInt32)(126)
# end enum ANONYMOUS_40

# begin enum ANONYMOUS_41
typealias ANONYMOUS_41 UInt32
const FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER = (UInt32)(0)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD = (UInt32)(1)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON = (UInt32)(2)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER = (UInt32)(3)
const FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER = (UInt32)(4)
const FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE = (UInt32)(5)
const FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA = (UInt32)(6)
const FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST = (UInt32)(7)
const FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST = (UInt32)(8)
const FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR = (UInt32)(9)
const FLAC__STREAM_METADATA_PICTURE_TYPE_BAND = (UInt32)(10)
const FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER = (UInt32)(11)
const FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST = (UInt32)(12)
const FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION = (UInt32)(13)
const FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING = (UInt32)(14)
const FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE = (UInt32)(15)
const FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE = (UInt32)(16)
const FLAC__STREAM_METADATA_PICTURE_TYPE_FISH = (UInt32)(17)
const FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION = (UInt32)(18)
const FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE = (UInt32)(19)
const FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE = (UInt32)(20)
const FLAC__STREAM_METADATA_PICTURE_TYPE_UNDEFINED = (UInt32)(21)
# end enum ANONYMOUS_41

type FLAC__Metadata_SimpleIterator
end

# begin enum ANONYMOUS_42
typealias ANONYMOUS_42 UInt32
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK = (UInt32)(0)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT = (UInt32)(1)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE = (UInt32)(2)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE = (UInt32)(3)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE = (UInt32)(4)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA = (UInt32)(5)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR = (UInt32)(6)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR = (UInt32)(7)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR = (UInt32)(8)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR = (UInt32)(9)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR = (UInt32)(10)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR = (UInt32)(11)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR = (UInt32)(12)
# end enum ANONYMOUS_42

# begin enum FLAC__Metadata_SimpleIteratorStatus
typealias FLAC__Metadata_SimpleIteratorStatus UInt32
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK = (UInt32)(0)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT = (UInt32)(1)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE = (UInt32)(2)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE = (UInt32)(3)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE = (UInt32)(4)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA = (UInt32)(5)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR = (UInt32)(6)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR = (UInt32)(7)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR = (UInt32)(8)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR = (UInt32)(9)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR = (UInt32)(10)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR = (UInt32)(11)
const FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR = (UInt32)(12)
# end enum FLAC__Metadata_SimpleIteratorStatus

type FLAC__Metadata_Chain
end

type FLAC__Metadata_Iterator
end

# begin enum ANONYMOUS_43
typealias ANONYMOUS_43 UInt32
const FLAC__METADATA_CHAIN_STATUS_OK = (UInt32)(0)
const FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT = (UInt32)(1)
const FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE = (UInt32)(2)
const FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE = (UInt32)(3)
const FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE = (UInt32)(4)
const FLAC__METADATA_CHAIN_STATUS_BAD_METADATA = (UInt32)(5)
const FLAC__METADATA_CHAIN_STATUS_READ_ERROR = (UInt32)(6)
const FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR = (UInt32)(7)
const FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR = (UInt32)(8)
const FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR = (UInt32)(9)
const FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR = (UInt32)(10)
const FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR = (UInt32)(11)
const FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR = (UInt32)(12)
const FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS = (UInt32)(13)
const FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH = (UInt32)(14)
const FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL = (UInt32)(15)
# end enum ANONYMOUS_43

# begin enum FLAC__Metadata_ChainStatus
typealias FLAC__Metadata_ChainStatus UInt32
const FLAC__METADATA_CHAIN_STATUS_OK = (UInt32)(0)
const FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT = (UInt32)(1)
const FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE = (UInt32)(2)
const FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE = (UInt32)(3)
const FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE = (UInt32)(4)
const FLAC__METADATA_CHAIN_STATUS_BAD_METADATA = (UInt32)(5)
const FLAC__METADATA_CHAIN_STATUS_READ_ERROR = (UInt32)(6)
const FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR = (UInt32)(7)
const FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR = (UInt32)(8)
const FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR = (UInt32)(9)
const FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR = (UInt32)(10)
const FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR = (UInt32)(11)
const FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR = (UInt32)(12)
const FLAC__METADATA_CHAIN_STATUS_INVALID_CALLBACKS = (UInt32)(13)
const FLAC__METADATA_CHAIN_STATUS_READ_WRITE_MISMATCH = (UInt32)(14)
const FLAC__METADATA_CHAIN_STATUS_WRONG_WRITE_CALL = (UInt32)(15)
# end enum FLAC__Metadata_ChainStatus

immutable Array_27_UInt8
    d1::UInt8
    d2::UInt8
    d3::UInt8
    d4::UInt8
    d5::UInt8
    d6::UInt8
    d7::UInt8
    d8::UInt8
    d9::UInt8
    d10::UInt8
    d11::UInt8
    d12::UInt8
    d13::UInt8
    d14::UInt8
    d15::UInt8
    d16::UInt8
    d17::UInt8
    d18::UInt8
    d19::UInt8
    d20::UInt8
    d21::UInt8
    d22::UInt8
    d23::UInt8
    d24::UInt8
    d25::UInt8
    d26::UInt8
    d27::UInt8
end

zero(::Type{Array_27_UInt8}) = begin  # /home/bates/.julia/v0.4/Clang/src/wrap_c.jl, line 264:
        Array_27_UInt8(fill(zero(UInt8),27)...)
    end

# begin enum ANONYMOUS_44
typealias ANONYMOUS_44 UInt32
const FLAC__STREAM_DECODER_SEARCH_FOR_METADATA = (UInt32)(0)
const FLAC__STREAM_DECODER_READ_METADATA = (UInt32)(1)
const FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC = (UInt32)(2)
const FLAC__STREAM_DECODER_READ_FRAME = (UInt32)(3)
const FLAC__STREAM_DECODER_END_OF_STREAM = (UInt32)(4)
const FLAC__STREAM_DECODER_OGG_ERROR = (UInt32)(5)
const FLAC__STREAM_DECODER_SEEK_ERROR = (UInt32)(6)
const FLAC__STREAM_DECODER_ABORTED = (UInt32)(7)
const FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR = (UInt32)(8)
const FLAC__STREAM_DECODER_UNINITIALIZED = (UInt32)(9)
# end enum ANONYMOUS_44

# begin enum ANONYMOUS_45
typealias ANONYMOUS_45 UInt32
const FLAC__STREAM_DECODER_INIT_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER = (UInt32)(1)
const FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS = (UInt32)(2)
const FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR = (UInt32)(3)
const FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE = (UInt32)(4)
const FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED = (UInt32)(5)
# end enum ANONYMOUS_45

# begin enum ANONYMOUS_46
typealias ANONYMOUS_46 UInt32
const FLAC__STREAM_DECODER_READ_STATUS_CONTINUE = (UInt32)(0)
const FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM = (UInt32)(1)
const FLAC__STREAM_DECODER_READ_STATUS_ABORT = (UInt32)(2)
# end enum ANONYMOUS_46

# begin enum ANONYMOUS_47
typealias ANONYMOUS_47 UInt32
const FLAC__STREAM_DECODER_SEEK_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_SEEK_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_47

# begin enum ANONYMOUS_48
typealias ANONYMOUS_48 UInt32
const FLAC__STREAM_DECODER_TELL_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_TELL_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_48

# begin enum ANONYMOUS_49
typealias ANONYMOUS_49 UInt32
const FLAC__STREAM_DECODER_LENGTH_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_49

# begin enum ANONYMOUS_50
typealias ANONYMOUS_50 UInt32
const FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE = (UInt32)(0)
const FLAC__STREAM_DECODER_WRITE_STATUS_ABORT = (UInt32)(1)
# end enum ANONYMOUS_50

# begin enum ANONYMOUS_51
typealias ANONYMOUS_51 UInt32
const FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC = (UInt32)(0)
const FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER = (UInt32)(1)
const FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH = (UInt32)(2)
const FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM = (UInt32)(3)
# end enum ANONYMOUS_51

# begin enum ANONYMOUS_52
typealias ANONYMOUS_52 UInt32
const FLAC__STREAM_ENCODER_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_UNINITIALIZED = (UInt32)(1)
const FLAC__STREAM_ENCODER_OGG_ERROR = (UInt32)(2)
const FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR = (UInt32)(3)
const FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA = (UInt32)(4)
const FLAC__STREAM_ENCODER_CLIENT_ERROR = (UInt32)(5)
const FLAC__STREAM_ENCODER_IO_ERROR = (UInt32)(6)
const FLAC__STREAM_ENCODER_FRAMING_ERROR = (UInt32)(7)
const FLAC__STREAM_ENCODER_MEMORY_ALLOCATION_ERROR = (UInt32)(8)
# end enum ANONYMOUS_52

# begin enum ANONYMOUS_53
typealias ANONYMOUS_53 UInt32
const FLAC__STREAM_ENCODER_INIT_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR = (UInt32)(1)
const FLAC__STREAM_ENCODER_INIT_STATUS_UNSUPPORTED_CONTAINER = (UInt32)(2)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_CALLBACKS = (UInt32)(3)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_NUMBER_OF_CHANNELS = (UInt32)(4)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BITS_PER_SAMPLE = (UInt32)(5)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_SAMPLE_RATE = (UInt32)(6)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_BLOCK_SIZE = (UInt32)(7)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_MAX_LPC_ORDER = (UInt32)(8)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_QLP_COEFF_PRECISION = (UInt32)(9)
const FLAC__STREAM_ENCODER_INIT_STATUS_BLOCK_SIZE_TOO_SMALL_FOR_LPC_ORDER = (UInt32)(10)
const FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE = (UInt32)(11)
const FLAC__STREAM_ENCODER_INIT_STATUS_INVALID_METADATA = (UInt32)(12)
const FLAC__STREAM_ENCODER_INIT_STATUS_ALREADY_INITIALIZED = (UInt32)(13)
# end enum ANONYMOUS_53

# begin enum ANONYMOUS_54
typealias ANONYMOUS_54 UInt32
const FLAC__STREAM_ENCODER_READ_STATUS_CONTINUE = (UInt32)(0)
const FLAC__STREAM_ENCODER_READ_STATUS_END_OF_STREAM = (UInt32)(1)
const FLAC__STREAM_ENCODER_READ_STATUS_ABORT = (UInt32)(2)
const FLAC__STREAM_ENCODER_READ_STATUS_UNSUPPORTED = (UInt32)(3)
# end enum ANONYMOUS_54

# begin enum ANONYMOUS_55
typealias ANONYMOUS_55 UInt32
const FLAC__STREAM_ENCODER_WRITE_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR = (UInt32)(1)
# end enum ANONYMOUS_55

# begin enum ANONYMOUS_56
typealias ANONYMOUS_56 UInt32
const FLAC__STREAM_ENCODER_SEEK_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_56

# begin enum ANONYMOUS_57
typealias ANONYMOUS_57 UInt32
const FLAC__STREAM_ENCODER_TELL_STATUS_OK = (UInt32)(0)
const FLAC__STREAM_ENCODER_TELL_STATUS_ERROR = (UInt32)(1)
const FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED = (UInt32)(2)
# end enum ANONYMOUS_57


text:
function formatinfo(s::Spec, x::Bool)
    isspecified(s.type) && return formatinfo(s, Int(x))
    width = x ? 4 : 5
    return paddingsize(s, width) + width, (0, width)
end

function formatfield(data::Vector{UInt8}, p::Int, s::Spec, x::Bool, (m, width)::Tuple{Int, Int})
    isspecified(s.type) && return formatfield(data, p, s, Int(x), (m, width))
    align = default(s.align, ALIGN_RIGHT)
    pw = paddingwidth(s, width)
    p = padleft(data, p, s.fill, align, pw)
    if x
        p = @copy data p "true"
    else
        p = @copy data p "false"
    end
    p = padright(data, p, s.fill, align, pw)
    return p
end

ext: jl


text:
using Statistics: mean, std
using Printf

struct CFLChecker <: Diagnostic end
struct VelocityDivergence <: Diagnostic end

struct FieldSummary <: Diagnostic
    diagnostic_frequency::Int
    fields::Array{Field,1}
    field_names::Array{AbstractString,1}
end

function run_diagnostic(model::Model, fs::FieldSummary)
    for (field, field_name) in zip(fs.fields, fs.field_names)
        padded_name = lpad(field_name, 4)
        field_min = minimum(field.data)
        field_max = maximum(field.data)
        field_mean = mean(field.data)
        field_abs_mean = mean(abs.(field.data))
        field_std = std(field.data)
        @printf("%s: min=%.6g, max=%.6g, mean=%.6g, absmean=%.6g, std=%.6g\n",
                padded_name, field_min, field_max, field_mean, field_abs_mean, field_std)
    end
end

struct NaNChecker <: Diagnostic
    diagnostic_frequency::Int
    fields::Array{Field,1}
    field_names::Array{AbstractString,1}
end

function run_diagnostic(model::Model, nc::NaNChecker)
    for (field, field_name) in zip(nc.fields, nc.field_names)
        if any(isnan, field.data)  # This is also fast on CuArrays.
            t, i = model.clock.time, model.clock.iteration
            println("time = $t, iteration = $i")
            println("NaN found in $field_name. Aborting simulation.")
            exit(1)
        end
    end
end

mutable struct Nusselt_wT <: Diagnostic
    diagnostic_frequency::Int
    Nu::Array{AbstractFloat,1}
    Nu_inst::Array{AbstractFloat,1}
    wT_cumulative_running_avg::AbstractFloat
end

function run_diagnostic(model::Model, diag::Nusselt_wT)
    α = 207e-6  # Volumetric expansion coefficient [K⁻¹] of water at 20°C.
    g = model.constants.g

    w, T = model.velocities.w.data, model.tracers.T.data
    V = model.grid.Lx * model.grid.Ly * model.grid.Lz
    wT_avg = sum(w .* T) / V

    n = length(diag.Nu)  # Number of "samples" so far.
    diag.wT_cumulative_running_avg = (wT_avg + n*model.clock.Δt*diag.wT_cumulative_running_avg) / ((n+1)*model.clock.Δt)

    Lz, κ, ΔT = model.grid.Lz, model.configuration.κh, 1
    Nu_wT = 1 + (Lz^2 / (κ*α*g*ΔT^2)) * diag.wT_cumulative_running_avg

    push!(diag.Nu, Nu_wT)

    Nu_wT_inst = 1 + (Lz^2 / (κ*α*g*ΔT^2)) * wT_avg
    push!(diag.Nu_inst, Nu_wT_inst)
end

mutable struct Nusselt_Chi <: Diagnostic
    diagnostic_frequency::Int
    Nu::Array{AbstractFloat,1}
    Nu_inst::Array{AbstractFloat,1}
    ∇T²_cumulative_running_avg::AbstractFloat
end

function norm_gradient_squared!(g::RegularCartesianGrid, f::CellField, ∇f²::CellField, stmp::StepperTemporaryFields)
    dfdx, dfdy, dfdz = otmp.fFX, otmp.fFY, otmp.fFZ

    δx!(g, f, dfdx)
    δy!(g, f, dfdy)
    δz!(g, f, dfdz)

    @. ∇f².data = dfdx.data^2 + dfdy.data^2 + dfdz.data^2
    nothing
end

function run_diagnostic(model::Model, diag::Nusselt_Chi)
    T = model.tracers.T
    ∇T² = model.stepper_tmp.fC1
    norm_gradient_squared!(model.grid, T, ∇T², model.stepper_tmp)

    V = model.grid.Lx * model.grid.Ly * model.grid.Lz
    ∇T²_avg = sum(∇T²) / V

    n = length(diag.Nu)  # Number of "samples" so far.
    diag.∇T²_cumulative_running_avg = (∇T²_avg + n*model.clock.Δt*diag.∇T²_cumulative_running_avg) / ((n+1)*model.clock.Δt)

    Lz, ΔT = model.grid.Lz, 1
    Nu_Chi = 1 + (Lz/ΔT)^2 * diag.∇T²_cumulative_running_avg

    push!(diag.Nu, Nu_Chi)

    ∇T²_inst = 1 + (Lz/ΔT)^2 * ∇T²_avg
    push!(diag.Nu_inst, ∇T²_inst)
end


text:
import Tcl

module TclDemos

using Tcl

# Define some shortcuts.
const resume = Tcl.resume
const cget = Tcl.cget
const grid = Tcl.grid
const pack = Tcl.pack
const place = Tcl.place
const list = Tcl.list
#const tkgetpixels = Tcl.getpixels
const getparent = Tcl.getparent
const getpath = Tcl.getpath
const getinterp = Tcl.getinterp
const createcommand = Tcl.createcommand

function addseedismiss(parent, child)
    #import Tcl: list
    ## See Code / Dismiss buttons
    interp = getinterp(parent)
    w = TtkFrame(parent, child)
    if isdefined(:TtkSeparator)
        sep = TtkSeparator(w, "sep")
    else
        sep = TtkFrame(w, "sep", height=2, relief="sunken")
    end
    grid(sep, columnspan=4, row=0, sticky="ew", pady="2")
    dismiss = TtkButton(w,"dismiss", text="Dismiss",
                        #image="::img::delete",
                        compound="left",
                        command=list("destroy",
                                     interp("winfo","toplevel",w)))

    # createcommand(interp, "jlcallback", (args...) -> println("Ouch!"))
    code = TtkButton(w, "code", text="See Code",
                     #image="::img::view",
                     compound = "left",
                     command = (args...) -> println("Ouch!"))
    buttons = (dismiss, code)

    #set buttons [list x $w.code $w.dismiss]
    #if {[llength $vars]} {
    #    TtkButton $w.vars -text [mc "See Variables"] \
    #        -image ::img::view -compound left \
    #        -command [concat [list showVars $w.dialog] $vars]
    #    set buttons [linsert $buttons 1 $w.vars]
    #}
    #if {$extra ne ""} {
    #    set buttons [linsert $buttons 1 [uplevel 1 $extra]]
    #}
    #grid {*}$buttons -padx 4 -pady 4
    #grid columnconfigure $w 0 -weight 1

    grid(buttons..., padx=4, pady=4)
    grid("columnconfigure", w, 0, weight=1)

    #if {[tk windowingsystem] eq "aqua"} {
    #    foreach b [lrange $buttons 1 end] {$b configure -takefocus 0}
    #    grid configure sep -pady 0
    #    grid configure {*}$buttons -pady {10 12}
    #    grid configure [lindex $buttons 1] -padx {16 4}
    #    grid configure [lindex $buttons end] -padx {4 18}
    #}
    return w
end

function labelframedemo()
    interp = tkstart()
    wname = ".labelframe"
    interp("catch {destroy $wname}")
    w = TkToplevel(wname)
    interp("wm","title",w,"Labelframe Demonstration")
    interp("wm","iconname",w,"labelframe")

    # Some information
    msg = TkLabel(w, "msg", #font="Helveltica",
                  wraplength="4i", justify="left",
                  text="Labelframes are used to group related widgets together.  The label may be either plain text or another widget.")
    pack(msg, side="top")

    ## See Code / Dismiss buttons
    btns = addseedismiss(w, "buttons")
    pack(btns, side="bottom", fill="x")

    # Demo area
    wf = TkFrame(w, "f")
    pack(wf, side="bottom", fill="both", expand=true)

    # A group of radiobuttons in a labelframe

    f = TkLabelframe(wf, "f", text="Value", padx=2, pady=2)
    grid(f, row=0, column=0, pady="2m", padx="2m")

    for value in 1:4
        pack(TkRadiobutton(f,"b$value", text="This is value $value",
                           variable="lfdummy", value=value),
             side="top", fill="x", pady=2)
    end

    # Using a label window to control a group of options.
    interp(raw"""
            proc lfEnableButtons {w} {
                foreach child [winfo children $w] {
                    if {$child == "$w.cb"} continue
                    if {$::lfdummy2} {
                        $child configure -state normal
                    } else {
                        $child configure -state disabled
                    }
                }
            }
        """)

    f2 = TkLabelframe(wf,"f2", pady=2, padx=2)
    f2_cb = TkCheckbutton(f2,"cb", text="Use this option.",
                          variable="lfdummy2",
                          command="lfEnableButtons $f2", padx=0)
    f2("configure",labelwidget=f2_cb)
    grid(f2, row=0, column=1, pady="2m", padx="2m")

    for t in 0:2
        pack(TkCheckbutton(f2,"b$t", text="Option$(t+1)"),
             side="top", fill="x", pady=2)
    end
    interp("lfEnableButtons", f2)

    grid("columnconfigure", wf, (0,1), weight=1)
end

function runtests2()
    if false
        interp = getinterp()
        interp("package require Tk");
        resume()
        name = interp("image create photo -file /home/eric/work/code/CImg/CImg-1.5.5/examples/img/lena.pgm")
        interp("pack [button .b -image $name]")
        d = Tcl.getpixels(interp, name, Val{:red});
    else
        Tcl.eval("package require Tk");
        resume()
        name = Tcl.eval("image create photo -file /home/eric/work/code/CImg/CImg-1.5.5/examples/img/lena.pgm")
        Tcl.eval("pack [button .b -image $name]")
        d = Tcl.getpixels(name, Val{:red});
    end
    return d;
end

end


text:
export neighbors, connectednodes, connectedparts

function neighbors(graph::Vector, startnode::Integer)
    nodes = union(graph[startnode], startnode)
    return sort!(nodes)
end

function neighbors(graph::Matrix{Bool}, startnode::Integer)
    nodes = findall(graph[startnode,:])
    union!(nodes, startnode)
    return sort!(nodes)
end

function connectednodes(graph::Union{Vector, Matrix{Bool}}, startnode::Integer)
    # depth first search?
    nodestack = [startnode]
    nodes = Vector{Integer}()
    while !isempty(nodestack)
        currentnode = pop!(nodestack)
        push!(nodes, currentnode)
        neighbornodes = neighbors(graph, currentnode)
        union!(nodestack, setdiff(neighbornodes, nodes))
    end
    return sort!(nodes)
end

function connectedparts(graph::Union{Vector, Matrix{Bool}})
    parts=Vector{Vector{Integer}}()
    for currentnode in 1:size(graph,1)
        nodes = connectednodes(graph, currentnode)
        mergeind=[]
        for currentpart in 1: size(parts,1)
            if !isempty(intersect(parts[currentpart], nodes))
                sort!(union!(parts[currentpart], nodes))
                push!(mergeind, currentpart)
            end

        end
        if size(mergeind,1)==0
            # if cannot find overlapping in the existing node, create a new one
            push!(parts, nodes)
        elseif size(mergeind,1)>1
            # if there are multiple parts that the current node connected to, merge them all
            for ii in 2:size(mergeind,1)
                union!(parts[mergeind[1]], parts[mergeind[ii]])
            end
            sort!(parts[mergeind[1]])
            deleteat!(parts, mergeind[2:end])
        end
    end
    return parts
end


text:
adjacentelementsproduct(array) =
    maximum( v -> v[1]*v[2], zip(array,array[2:end]) )

max_stars_repo_name: UlrichBerntien/Codewars-Katas

max_issues_repo_name: UlrichBerntien/Codewars-Katas

max_forks_repo_name: UlrichBerntien/Codewars-Katas


text:
using Base.Test
using Duiz

Duiz.set_output(string)

@test Duiz.iter([(1,2),(5,6)]) == """
          e  = Tuple{Int64,Int64}[(1,2),(5,6)]
          1 == start(e)
      false == done(e, 1)
 ((1,2), 2) == next(e, 1)
      false == done(e, 2)
 ((5,6), 3) == next(e, 2)
       true == done(e, 3)
"""

@test Duiz.iter(([1,2],[5,6])) == """
          e  = ([1,2],[5,6])
          1 == start(e)
      false == done(e, 1)
 ([1,2], 2) == next(e, 1)
      false == done(e, 2)
 ([5,6], 3) == next(e, 2)
       true == done(e, 3)
"""

@test Duiz.iter(Dict(:a=>5,:b=>6,:c=>7)) == """
          e  = Dict(:c=>7,:a=>5,:b=>6)
          1 == start(e)
      false == done(e, 1)
(:c=>7, 10) == next(e, 1)
      false == done(e, 10)
(:a=>5, 11) == next(e, 10)
      false == done(e, 11)
(:b=>6, 17) == next(e, 11)
       true == done(e, 17)
"""

@test Duiz.iter([5 7; 6 8]) == """
          e  = [5 7; 6 8]
          1 == start(e)
      false == done(e, 1)
     (5, 2) == next(e, 1)
      false == done(e, 2)
     (6, 3) == next(e, 2)
      false == done(e, 3)
     (7, 4) == next(e, 3)
      false == done(e, 4)
     (8, 5) == next(e, 4)
       true == done(e, 5)
"""

@test Duiz.iter([5,6,7,8]) == """
          e  = [5,6,7,8]
          1 == start(e)
      false == done(e, 1)
     (5, 2) == next(e, 1)
      false == done(e, 2)
     (6, 3) == next(e, 2)
      false == done(e, 3)
     (7, 4) == next(e, 3)
      false == done(e, 4)
     (8, 5) == next(e, 4)
       true == done(e, 5)
"""

@test Duiz.iter((5,6,7,8)) == """
          e  = (5,6,7,8)
          1 == start(e)
      false == done(e, 1)
     (5, 2) == next(e, 1)
      false == done(e, 2)
     (6, 3) == next(e, 2)
      false == done(e, 3)
     (7, 4) == next(e, 3)
      false == done(e, 4)
     (8, 5) == next(e, 4)
       true == done(e, 5)
"""

@test Duiz.iter(7:10) == """
          e  = 7:10
          7 == start(e)
      false == done(e, 7)
     (7, 8) == next(e, 7)
      false == done(e, 8)
     (8, 9) == next(e, 8)
      false == done(e, 9)
    (9, 10) == next(e, 9)
      false == done(e, 10)
   (10, 11) == next(e, 10)
       true == done(e, 11)
"""

@test Duiz.iter(1:5:11) == """
          e  = 1:5:11
          1 == start(e)
      false == done(e, 1)
     (1, 6) == next(e, 1)
      false == done(e, 6)
    (6, 11) == next(e, 6)
      false == done(e, 11)
   (11, 16) == next(e, 11)
       true == done(e, 16)
"""

@test Duiz.iter(12.0:-5:0.0) == """
          e  = 12.0:-5.0:2.0
          0 == start(e)
      false == done(e, 0)
  (12.0, 1) == next(e, 0)
      false == done(e, 1)
   (7.0, 2) == next(e, 1)
      false == done(e, 2)
   (2.0, 3) == next(e, 2)
       true == done(e, 3)
"""

@test Duiz.iter((2x for x in [5,6,7,90])) == """
          e  = [5,6,7,90]
          1 == start(e)
      false == done(e, 1)
     (5, 2) == next(e, 1)
      false == done(e, 2)
     (6, 3) == next(e, 2)
      false == done(e, 3)
     (7, 4) == next(e, 3)
      false == done(e, 4)
    (90, 5) == next(e, 4)
       true == done(e, 5)
"""


text:
products = [
    LibraryProduct(prefix, ["libcrypto"], :libcrypto),
    LibraryProduct(prefix, ["libssl"], :libssl),
]

# Download binaries from hosted location
bin_prefix = "https://github.com/JuliaBinaryWrappers/OpenSSL_jll.jl/releases/download/OpenSSL-v1.1.1%2B0"

# Listing of files generated by BinaryBuilder:
download_info = Dict(
    Linux(:aarch64, libc=:glibc) => ("$bin_prefix/OpenSSL.v1.1.1+c.aarch64-linux-gnu.tar.gz", "afaac1c4f8388fbc4b5e6b02ef2084e58654b16510bac756d4fa8bd693b84f9e"),
    Linux(:aarch64, libc=:musl) => ("$bin_prefix/OpenSSL.v1.1.1+c.aarch64-linux-musl.tar.gz", "9bdccf83afa75e4c82379d9ce591c48a4da975daad78fac436f174a9cb1a1486"),
    Linux(:armv7l, libc=:glibc, call_abi=:eabihf) => ("$bin_prefix/OpenSSL.v1.1.1+c.arm-linux-gnueabihf.tar.gz", "e11c47d1f05bee82e086f03a299b4837fe4aba35661c8af9c36ba2125049f7bd"),
    Linux(:armv7l, libc=:musl, call_abi=:eabihf) => ("$bin_prefix/OpenSSL.v1.1.1+c.arm-linux-musleabihf.tar.gz", "86fca6c56d619f65dcdaf453dbd31701c2937e1407fc686ed3471b046610b88c"),
    Linux(:i686, libc=:glibc) => ("$bin_prefix/OpenSSL.v1.1.1+c.i686-linux-gnu.tar.gz", "e6620ac75d424246434f2fe24021e61fea92d239318a7b04deead3a234b8f978"),
    Linux(:i686, libc=:musl) => ("$bin_prefix/OpenSSL.v1.1.1+c.i686-linux-musl.tar.gz", "ef63d029419bd00ff6010f412f1f56fc281d22c73f04ca2253e3ed131ff45323"),
    Windows(:i686) => ("$bin_prefix/OpenSSL.v1.1.1+c.i686-w64-mingw32.tar.gz", "6cf6c7cde07a62befb871fc8c79eb97864d9da9fcb1d96043ce492dc84902938"),
    Linux(:powerpc64le, libc=:glibc) => ("$bin_prefix/OpenSSL.v1.1.1+c.powerpc64le-linux-gnu.tar.gz", "a76e22af9dcd9e108ea2025eff0dbcd6382b97a170a0c6a777fb16c7250edb4c"),
    MacOS(:x86_64) => ("$bin_prefix/OpenSSL.v1.1.1+c.x86_64-apple-darwin14.tar.gz", "e03a6b5b396462df2ae82a87b03b9f186f32b75a4277a1a284f0584a79b22840"),
    Linux(:x86_64, libc=:glibc) => ("$bin_prefix/OpenSSL.v1.1.1+c.x86_64-linux-gnu.tar.gz", "0628df28f09c29e87e07747b81319e0ca839b9ff54059a7db35acfe3b4641be4"),
    Linux(:x86_64, libc=:musl) => ("$bin_prefix/OpenSSL.v1.1.1+c.x86_64-linux-musl.tar.gz", "dc3fe9c3c1375674f13fe98aa3d684eb10682450945759108df778f622a7955f"),
    FreeBSD(:x86_64) => ("$bin_prefix/OpenSSL.v1.1.1+c.x86_64-unknown-freebsd11.1.tar.gz", "53544564caf3c0301b424c36d579aed408695bbef1e51f95856d7093cb6c694d"),
    Windows(:x86_64) => ("$bin_prefix/OpenSSL.v1.1.1+c.x86_64-w64-mingw32.tar.gz", "d11e5d7a90d3e2024809bef0f31d12d56c436327eb4bb7d6684baa709c5dbcb1"),
)

# Install unsatisfied or updated dependencies:
if any(!satisfied(p; verbose=verbose) for p in products)
    try
        # Download and install binaries
        url, tarball_hash = choose_download(download_info)
        install(url, tarball_hash; prefix=prefix, force=true, verbose=true)
    catch e
        if typeof(e) <: ArgumentError
            error("Your platform $(Sys.MACHINE) is not supported by this package!")
        else
            rethrow(e)
        end
    end

    # Finally, write out a deps.jl file
    # this is never used but will catch some failures
    write_deps_file(joinpath(@__DIR__, "deps_OpenSSL.jl"), products)
end


text:
const MKL_DOMAIN_PARDISO = Int32(4)

mutable struct MKLPardisoSolver <: AbstractPardisoSolver
    pt::Vector{Int}
    iparm::Vector{MklInt}
    mtype::MatrixType
    solver::Solver
    phase::Phase
    msglvl::MessageLevel
    maxfct::MklInt
    mnum::MklInt
    perm::Vector{MklInt}
end

function MKLPardisoSolver()
    pt = zeros(Int, 64)
    iparm = zeros(MklInt, 64)
    mtype = REAL_NONSYM
    solver = DIRECT_SOLVER
    phase = ANALYSIS_NUM_FACT_SOLVE_REFINE
    msglvl = MESSAGE_LEVEL_OFF
    mnum = MklInt(1)
    maxfct = MklInt(1)
    perm = MklInt[]

    ps = MKLPardisoSolver(pt, iparm, mtype, solver,
                      phase, msglvl, maxfct, mnum, perm)

    return ps
end

show(io::IO, ps::MKLPardisoSolver) = print(io, string("$MKLPardisoSolver:\n",
                                  "\tMatrix type: $(MATRIX_STRING[get_matrixtype(ps)])\n",
                                  "\tPhase: $(PHASE_STRING[get_phase(ps)])"))

set_nprocs!(ps::MKLPardisoSolver, n::Integer) = set_nprocs_mkl!(n)
set_nprocs_mkl!(n::Integer) =
    ccall((:mkl_domain_set_num_threads, libmkl_rt[]), Cvoid, (Ptr{Int32}, Ptr{Int32}), Ref((Int32(n))), Ref(MKL_DOMAIN_PARDISO))
get_nprocs(ps::MKLPardisoSolver) = get_nprocs_mkl()
get_nprocs_mkl() =
    ccall((:mkl_domain_get_max_threads, libmkl_rt[]), Int32, (Ptr{Int32},), Ref(MKL_DOMAIN_PARDISO))

valid_phases(ps::MKLPardisoSolver) = keys(MKL_PHASES)
phases(ps::MKLPardisoSolver) = MKL_PHASES

function ccall_pardisoinit(ps::MKLPardisoSolver)
    ERR = Ref{MklInt}(0)
    ccall((:pardisoinit, libmkl_rt[]), Cvoid,
          (Ptr{Int}, Ptr{MklInt}, Ptr{MklInt}),
          ps.pt, Ref(MklInt(ps.mtype)), ps.iparm)
    check_error(ps, ERR[])
end

function ccall_pardiso(ps::MKLPardisoSolver, N, nzval::Vector{Tv}, colptr, rowval,
                       NRHS, B::StridedVecOrMat{Tv}, X::StridedVecOrMat{Tv}) where {Tv}
    N = MklInt(N)
    colptr = convert(Vector{MklInt}, colptr)
    rowval = convert(Vector{MklInt}, rowval)
    resize!(ps.perm, size(B, 1))
    NRHS = MklInt(NRHS)

    ERR = Ref{MklInt}(0)
    ccall((PARDISO_FUNC, libmkl_rt[]), Cvoid,
          (Ptr{Int}, Ptr{MklInt}, Ptr{MklInt}, Ptr{MklInt}, Ptr{MklInt},
           Ptr{MklInt}, Ptr{Tv}, Ptr{MklInt}, Ptr{MklInt}, Ptr{MklInt},
           Ptr{MklInt}, Ptr{MklInt}, Ptr{MklInt}, Ptr{Tv}, Ptr{Tv},
           Ptr{MklInt}),
          ps.pt, Ref(ps.maxfct), Ref(ps.mnum), Ref(MklInt(ps.mtype)), Ref(MklInt(ps.phase)),
          Ref(N), nzval, colptr, rowval, ps.perm,
          Ref(NRHS), ps.iparm, Ref(MklInt(ps.msglvl)), B, X,
          ERR)
    check_error(ps, ERR[])
end

function check_error(ps::MKLPardisoSolver, err::Integer)
    err != -1  || throw(PardisoException("Input inconsistent."))
    err != -2  || throw(PardisoException("Not enough memory."))
    err != -3  || throw(PardisoException("Reordering problem."))
    err != -4  || throw(PardisoPosDefException("Zero pivot, numerical fact. or iterative refinement problem."))
    err != -5  || throw(PardisoException("Unclassified (internal) error."))
    err != -6  || throw(PardisoException("Preordering failed (matrix types 11, 13 only)."))
    err != -7  || throw(PardisoException("Diagonal matrix is singular"))
    err != -8  || throw(PardisoException("32-bit integer overflow problem."))
    err != -9  || throw(PardisoException("Not enough memory for OOC."))
    err != -10 || throw(PardisoException("Error opening OOC files."))
    err != -11 || throw(PardisoException("Read/write error with OOC files."))
    err != -12 || throw(PardisoException("pardiso_64 called from 32-bit library"))
    return
end


text:
"""

Exported names are
$(EXPORTS)
"""
module Geometry

using Test
using DocStringExtensions
using FillArrays
using LinearAlgebra: ⋅

using Gridap.Helpers
using Gridap.Arrays
using Gridap.Fields
using Gridap.Polynomials
using Gridap.ReferenceFEs
using Gridap.TensorValues
using Gridap.Io
using Gridap.Integration
using Gridap.CellData

using Gridap.ReferenceFEs: _num_faces
using Gridap.ReferenceFEs: _num_facets
using Gridap.ReferenceFEs: _num_vertices
using Gridap.ReferenceFEs: _num_edges
using Gridap.ReferenceFEs: _get_facedims
using Gridap.ReferenceFEs: _get_offsets
using Gridap.ReferenceFEs: _get_offset
using Gridap.ReferenceFEs: _find_unique_with_indices

using Gridap.Arrays: Reindexed
using Gridap.Arrays: IdentityVector

import Gridap.Arrays: array_cache
import Gridap.Arrays: getindex!
import Gridap.Arrays: reindex
import Gridap.Arrays: get_array
import Gridap.Arrays: lazy_append
import Gridap.CellData: CellField
import Gridap.CellData: CellQuadrature
import Gridap.CellData: QPointCellField
import Gridap.CellData: get_cell_map

import Gridap.Fields: field_cache
import Gridap.Fields: evaluate_field!
import Gridap.Fields: evaluate_field_array
import Gridap.Fields: gradient
import Gridap.Fields: grad2curl
import Gridap.Helpers: operate

import Gridap.Integration: get_coordinates
import Gridap.Integration: get_weights

import Gridap.Io: to_dict
import Gridap.Io: from_dict

using Gridap.Fields: AffineMapGrad

import Gridap.ReferenceFEs: get_node_coordinates
import Gridap.ReferenceFEs: num_nodes
import Gridap.ReferenceFEs: is_affine
import Gridap.ReferenceFEs: is_first_order
import Gridap.ReferenceFEs: get_faces
import Gridap.ReferenceFEs: get_face_vertices
import Gridap.ReferenceFEs: get_dimranges
import Gridap.ReferenceFEs: get_dimrange
import Gridap.ReferenceFEs: num_faces
import Gridap.ReferenceFEs: num_facets
import Gridap.ReferenceFEs: num_edges
import Gridap.ReferenceFEs: num_vertices
import Gridap.ReferenceFEs: get_facedims
import Gridap.ReferenceFEs: get_offsets
import Gridap.ReferenceFEs: get_offset
import Gridap.ReferenceFEs: get_vertex_coordinates
import Gridap.ReferenceFEs: get_face_nodes
import Gridap.ReferenceFEs: get_face_own_nodes
import Gridap.ReferenceFEs: get_polytope
import Gridap.ReferenceFEs: get_vertex_node
import Gridap.ReferenceFEs: is_simplex
import Gridap.ReferenceFEs: is_n_cube
import Gridap.ReferenceFEs: get_reffaces
import Gridap.ReferenceFEs: get_face_type
import Gridap.ReferenceFEs: num_dims
import Gridap.ReferenceFEs: num_cell_dims
import Gridap.ReferenceFEs: num_point_dims
import Gridap.ReferenceFEs: simplexify

import Gridap.Fields: field_array_gradient
import Gridap.Fields: apply_lincomb
import Gridap.Fields: evaluate_field_array
import Gridap.Fields: kernel_evaluate
import Gridap.Fields: evaluate
import Gridap.Fields: integrate

import Gridap.Arrays: apply_kernel!

export GridTopology
export num_cells
export get_polytopes
export get_cell_type
export get_cell_vertices
export get_reffaces_offsets
export compute_reffaces
export compute_cell_faces
export compute_face_vertices
export compute_isboundary_face
export get_cell_permutations
export compute_cell_permutations
export test_grid_topology
export get_cell_faces
export get_isboundary_face
export OrientationStyle
export RegularityStyle
export is_oriented
export is_regular

export UnstructuredGridTopology

export Triangulation
export get_reffes
export get_cell_coordinates
export get_cell_reffes
export get_cell_shapefuns
export get_normal_vector
export test_triangulation
export restrict
export get_physical_coordinate
export get_cell_id
export cell_measure
export get_cell_map

export Grid
export get_cell_nodes
export test_grid
export compute_linear_grid
export compute_reference_grid

export TriangulationPortion
export RestrictedTriangulation
export GridPortion
export UnstructuredGrid

export CartesianGrid
export CartesianDescriptor
export get_cartesian_descriptor

export FaceLabeling
export num_tags
export num_entities
export get_face_entity
export get_tag_entities
export get_tag_name
export get_tag_from_name
export get_tags_from_names
export add_tag!
export add_tag_from_tags!
export get_face_mask
export get_face_tag
export get_face_tag_index
export get_cell_entity

export DiscreteModel
export DiscreteModelFromFile
export get_grid
export get_grid_topology
export get_face_labeling
export test_discrete_model
export compute_face_nodes
export compute_face_own_nodes
export compute_vertex_node
export get_node_face_owner
export compute_node_face_owner
export get_triangulation

export UnstructuredDiscreteModel
export CartesianDiscreteModel

export BoundaryTriangulation
export get_volume_triangulation
export get_face_to_cell
export get_face_to_lface
export get_face_to_cell_map
export get_face_to_face
export get_cell_around
export test_boundary_triangulation

export GenericBoundaryTriangulation

export DiscreteModelPortion

export SkeletonPair
export SkeletonTriangulation
export InterfaceTriangulation
export get_left_boundary
export get_right_boundary

export RestrictedDiscreteModel

export AppendedTriangulation

include("GridTopologies.jl")

include("GridTopologyMocks.jl")

include("UnstructuredGridTopologies.jl")

include("SkeletonPairs.jl")

include("Triangulations.jl")

include("Grids.jl")

include("GridMocks.jl")

include("RestrictedTriangulations.jl")

include("TriangulationPortions.jl")

include("GridPortions.jl")

include("UnstructuredGrids.jl")

include("CartesianGrids.jl")

include("FaceLabelings.jl")

include("DiscreteModels.jl")

include("DiscreteModelPortions.jl")

include("DiscreteModelMocks.jl")

include("UnstructuredDiscreteModels.jl")

include("CartesianDiscreteModels.jl")

include("BoundaryTriangulations.jl")

include("GenericBoundaryTriangulations.jl")

include("SkeletonTriangulations.jl")

include("AppendedTriangulations.jl")

include("RestrictedDiscreteModels.jl")

end # module


text:
#First delete any existing nc-files
fn1 = tempname2()
fn2 = tempname2()
fn3 = tempname2()
fn4 = tempname2()
fn5 = tempname2()

# Test Medium level Interface
# Test Dimension Creation
d1 = NcDim("Dim1", 2; values = [5.0, 10.0], atts = Dict("units" => "deg C"));
d2 = NcDim("Dim2", collect(1:10));
d3 = NcDim("Dim3", 20; atts = Dict("max" => 10));
d4 = NcDim("DimUnlim", 0, unlimited = true)
d5 = NcDim("str_len", 15)

# Test Variable creation
v1 = NcVar("v1", [d1, d2, d3], compress = 5)  # With several dims in an Array, and compressed
v2 = NcVar("v2", [d1, d2, d3], atts = Dict("a1" => "varatts"))  # with given attributes
v3 = NcVar("v3", d1)
vs = NcVar("vstr", d2, t = String)
vc = NcVar("vchar", [d5, d2], t = NetCDF.NC_CHAR)
vscal = NcVar("vscal", NcDim[])

vt = Array{NcVar}(undef, length(tlist))
for i = 1:length(tlist)
    vt[i] = NcVar("vt$i", d2, t = tlist[i])
end
vunlim = NcVar("vunlim", d4, t = Float64)

numberatts = Dict{Any,Any}("Additional $t attribute" => t(20) for t in tlist)
numberatts["Additional String attribute"] = "string attribute"
arrayatts = Dict{Any,Any}("Additional $t attribute" => t[i for i = 1:20] for t in tlist)
arrayatts["Additional String attribute"] = String[string("string attribute ", i) for i = 1:20]

#Test writing data
#
#First generate the data
x1 = rand(2, 10, 20)
x2 = rand(2, 10, 20)
xt = [rand(tl, 10) for tl in tlist]
xs = [
    "a",
    "bb",
    "ccc",
    "dddd",
    "eeeee",
    "ffffff",
    "ggggggg",
    "hhhhhhhh",
    "iiiiiiiii",
    "jjjjjjjjjj",
]
xscal = Array{Float64,0}(undef);
xscal[1] = 2.5;
x4 = [1, 2]
#

# Creating Files
NetCDF.create(fn1, [v1, vs, vc], mode = NC_NETCDF4) do nc1
          #Test Adding attributes
    NetCDF.putatt(nc1, "v1", Dict("Additional String attribute" => "att"))
    NetCDF.putatt(nc1, "global", Dict("Additional global attribute" => "gatt"))
    NetCDF.putatt(
        nc1,
        "global",
        Dict(
            "Additional Int8 attribute" => Int8(20),
            "Additional Int16 attribute" => Int16(20),
            "Additional Int32 attribute" => Int32(20),
            "Additional Float32 attribute" => Float32(20),
            "Additional Float64 attribute" => Float64(20),
        ),
    )
    NetCDF.putatt(
        nc1,
        "v1",
        Dict(
            "Additional Int8 array attribute" => Int8[i for i = 1:20],
            "Additional Int16 array attribute" => Int16[i for i = 1:20],
            "Additional Int32 array attribute" => Int32[i for i = 1:20],
            "Additional Float32 array attribute" => Float32[i for i = 1:20],
            "Additional Float64 array attribute" => Float64[i for i = 1:20],
        ),
    )

          #Test Adding attributes
    NetCDF.putatt(nc1, "v1", Dict("Additional String attribute" => "att"))
    NetCDF.putatt(nc1, "global", Dict("Additional global attribute" => "gatt"))
    NetCDF.putatt(nc1, "global", numberatts)
    NetCDF.putatt(nc1, "v1", arrayatts)

    NetCDF.putvar(nc1, "v1", x1)
    NetCDF.putvar(nc1, "vstr", xs)
    NetCDF.putvar(nc1, "vchar", nc_string2char(xs))

end

NetCDF.create(
    fn2,
    NcVar[v2, v3, vscal],
    gatts = Dict("Some global attributes" => 2010),
) do nc2
    #Test sequential writing along one dimension
    for i = 1:10
        NetCDF.putvar(nc2, "v2", x2[:, i, :], start = [1, i, 1], count = [-1, 1, -1])
    end
    #Test automatic type conversion
    NetCDF.putvar(nc2, "v3", x4)

    NetCDF.putvar(nc2, "vscal", xscal)
end

NetCDF.create(fn3, vt) do nc3
    for i = 1:length(tlist)
        NetCDF.putvar(nc3, "vt$i", xt[i])
    end
end

NetCDF.create(fn4, vunlim) do ncunlim
    NetCDF.putvar(ncunlim, "vunlim", collect(1:10))
end

##Read the data back and compare
NetCDF.open(fn1, mode = NC_NOWRITE) do nc1
    @test x1 == NetCDF.readvar(nc1, "v1")
    @test xs == NetCDF.readvar(nc1, "vstr")
    NetCDF.readvar(nc1, "v1", start = [1, 1, 1], count = [-1, -1, -1])
    @test xs == NetCDF.nc_char2string(NetCDF.readvar(nc1, "vchar"))
    @test sort(["vstr", "Dim2", "v1", "Dim1", "vchar"]) == sort(collect(keys(nc1)))
end

NetCDF.open(fn2, mode = NC_NOWRITE) do nc2
    @test x2 == NetCDF.readvar(nc2, "v2")
    @test x4 == NetCDF.readvar(nc2, "v3")
    @test xscal == NetCDF.readvar(nc2, "vscal")
end

# #Test dimension variables type
dim1 = NcDim("dim1", 4, atts = Dict("units" => "m"), values = collect(Int32, 1:4))
x5_1 = NcVar("x5_1", [dim1], atts = Dict("units" => "m"), t = Int32)

dim2 = NcDim("dim2", 4, atts = Dict("units" => "m"), values = collect(Float32, 1:4))
x5_2 = NcVar("x5_2", [dim2], atts = Dict("units" => "m"), t = Int32)

NetCDF.create(fn5, [x5_1, x5_2]) do _
end

NetCDF.open(fn5) do nc5
    @test typeof(NetCDF.readvar(nc5, "dim1")) == Array{Int32,1}
    @test typeof(NetCDF.readvar(nc5, "dim2")) == Array{Float32,1}
end

# Test finalizer when working interactively with Nc objects, by trying to manually close the ncid
nc5 = NetCDF.open(fn5)
ncid = nc5.ncid
nc5 = nothing
GC.gc()
@test_throws NetCDF.NetCDFError NetCDF.nc_close(ncid)


text:
const IMGUI_DEMO_LISTBOX_STATES = Dict(
    "basic_listbox" => ListBoxes.State(
        "listbox\n(single select)",
        [
            "Apple",
            "Banana",
            "Cherry",
            "Kiwi",
            "Mango",
            "Orange",
            "Pineapple",
            "Strawberry",
            "Watermelon",
        ],
        1,
        4,
    ),
)


text:
using CSV
using DataFrames

function read_congress(fname)
    party_map = Dict{Int64,Int64}()
    name_map = Dict{Int64,String}()
    house = CSV.File(fname) |> DataFrame
    for grp in groupby(house, :id)
        party = unique(grp[!, :party])
        if length(party) != 1
            println("more than one party affiliation")
            @show grp
            error(0)
        end
        party = party[1]
        id = grp[1, :id]
        if party != 100 && party != 200
            if id == 13100
                # James L. Buckley (conservative, map to republican)
                party = 200
            elseif id == 29147
                # Bernie Sanders (independent, map to democratic)
                party = 100
            elseif id == 10802
                # Harry F. Byrd, Jr. (independent democrat, map to democrat)
                party = 100
            elseif id == 94240
                # Jim Jeffords after he left Republicans. This is Probably the
                # most complicated, but he mostly voted with the democrats.
                party = 100
            else
                println("nontraditional party affiliation")
                @show grp
                error(0)
            end
        else
            party_map[id] = party
            name_map[id] = grp[1, :name]
        end
    end
    return party_map, name_map
end

function get_members()
    spm, snm = read_congress("senate.csv")
    hpm, hnm = read_congress("house.csv")
    for key in keys(spm) ∩ keys(hpm)
        if spm[key] != hpm[key]
            println("different parties...")
            @show key
            error(0)
        end
    end

    # merge party maps
    pm = Dict{Int64,Int64}()
    for (key, val) in spm
        pm[key] = val ÷ 100
    end
    for (key, val) in hpm
        pm[key] = val ÷ 100
    end

    # merge name maps
    nm = Dict{Int64,String}()
    for (key, val) in snm
        nm[key] = val
    end
    for (key, val) in hnm
        nm[key] = val
    end

    return pm, nm
end

# Get out hyperedges of sponsor + cosponsors, partitioned by bill type
function bill_hedges(pm)
    sponsors = readlines("sponsors.txt")
    all_cosponsors = readlines("cosponsors.txt")
    bill_types = [String(bill[1:2]) for bill in readlines("bills.txt")]
    hedges = Dict{String, Vector{Vector{Int64}}}()
    for bill_type in unique(bill_types)
        hedges[bill_type] = Vector{Vector{Int64}}()
    end

    for (sponsor, cosponsors, bill_type) in zip(sponsors, all_cosponsors, bill_types)
        bill_sponsors = [sponsor]
        for cosponsor in split(cosponsors)
            push!(bill_sponsors, cosponsor)
        end
        bill_sponsors = filter(sp -> sp != "NA", bill_sponsors)
        bill_sponsors = map(sp -> parse(Int64, sp), bill_sponsors)
        bill_sponsors = filter(sp -> haskey(pm, sp), bill_sponsors)
        if length(bill_sponsors) > 1
            push!(hedges[bill_type], bill_sponsors)
        end
    end

    return hedges
end

# Map hypergraph node IDs to 1...N
function mapped_hedges(hedges)
    id_map = Dict{Int64,Int64}()
    inv_id_map = Dict{Int64,Int64}()
    function get_key(v)
        if !haskey(id_map, v)
            val = length(id_map) + 1
            id_map[v] = val
            inv_id_map[val] = v
        end
        return id_map[v]
    end

    new_hedges = []
    for hedge in hedges
        new_hedge = [get_key(v) for v in hedge]
        push!(new_hedges, new_hedge)
    end

    return new_hedges, inv_id_map
end

function write_dataset(hedges, pm, nm, basename)
    new_hedges, inv_id_map = mapped_hedges(hedges)

    dir = string("$(basename)-congress-bills")
    if !isdir(dir)
        mkdir(dir)
    end

    # hyperedge data
    open("$dir/hyperedges-$dir.txt", "w") do f
        for hedge in new_hedges
            write(f, join(hedge, ','))
            write(f, "\n")
        end
    end

    # names of the integer labels
    open("$dir/label-names-$dir.txt", "w") do f
        write(f, "Democrat\n")
        write(f, "Republican\n")
    end

    # labels for each node
    open("$dir/node-labels-$dir.txt", "w") do f
        for i = 1:length(inv_id_map)
            party = pm[inv_id_map[i]]
            write(f, "$(party)\n")
        end
    end

    # names of the nodes
    open("$dir/node-names-$dir.txt", "w") do f
        for i = 1:length(inv_id_map)
            name = nm[inv_id_map[i]]
            write(f, "$(name)\n")
        end
    end
end

function main()
    pm, nm = get_members()
    all_hedges = bill_hedges(pm)
    for (bt, hedges) in all_hedges
        # Ignore house ammendments (small)
        if bt != "HZ"
            write_dataset(hedges, pm, nm, bt)
        end
    end
end

max_stars_repo_name: PhilChodrow/HypergraphModularity

max_issues_repo_name: nveldt/TestPkg

max_forks_repo_name: PhilChodrow/HypergraphModularity


text:
using Revise
using PyPlot, DelimitedFiles, Random, Statistics, HiQGA.transD_GP

Random.seed!(23)

zfixed = [-1e5]
ρfixed = [1e12]
nmax = 100

zstart = 0.0
extendfrac, dz = 1.03, 1.5
zall, znall, zboundaries = transD_GP.setupz(zstart, extendfrac, dz=dz, n=65, showplot=true)
z, ρ, nfixed = transD_GP.makezρ(zboundaries; zfixed=zfixed, ρfixed=ρfixed)

## geometry parameters for tempest
zTx = -120
zRx = -82
x_rx = -113.0
y_rx = 0.
rx_roll = 0.
rx_pitch = 2.
rx_yaw = 0.
tx_roll = 0.
tx_pitch = 0.
tx_yaw = 0.
# electronics and stuff
include("electronics_halt.jl")
## fill in detail in ohm-m
## fill in detail in ohm-m
ρ[(z.>=zstart) .& (z.<50)] .= 20.
ρ[(z.>=50) .&(z.<80)] .= 1
ρ[(z.>=80) .&(z.<100)] .= 20
ρ[(z.>=100) .&(z.<200)] .= 50
ρ[(z.>=200) .&(z.<250)] .= 80
ρ[(z.>=250)]            .= 150
# add jitter to model in log10 domain
Random.seed!(11)
ρ = 10 .^(0.1*randn(length(ρ)) + log10.(ρ))
## create total field operator (required for nuisance inversion)
tempest = transD_GP.TEMPEST1DInversion.Bfield(
    zTx = zTx, zRx = zRx, x_rx = x_rx, y_rx = y_rx,
    rx_roll = rx_roll, rx_pitch = rx_pitch, rx_yaw = rx_yaw,
    tx_roll = tx_roll, tx_pitch = tx_pitch, tx_yaw = tx_yaw,
	ramp = ramp, times = times,
	z=z,
	ρ=ρ,
	addprimary = true, #this ensures that the geometry update actually changes everything that needs to be
    vectorsum  = true #amplitude only inversions
)
# plot before adding noise
transD_GP.TEMPEST1DInversion.plotmodelfield!(tempest,z,ρ)
## compute noisy data to invert
# remember noise in electronics_halt.jl are in fT!!
transD_GP.TEMPEST1DInversion.set_noisy_data!(tempest, z, ρ,
                        noisefracx = 0.02, noisefracz = 0.02,
                        halt_X = Hx_add_noise*1e-15, halt_Z = Hz_add_noise*1e-15)
# but model with a coarser grid
extendfrac, dz = 1.06, 1.15
zall, znall, zboundaries = transD_GP.setupz(zstart, extendfrac, dz=dz, n=50, showplot=true)
zgrid, ρgrid, nfixed = transD_GP.makezρ(zboundaries; zfixed=zfixed, ρfixed=ρfixed)
tempest.z, tempest.ρ = zgrid, copy(ρgrid)
## only primary field stuff if you want for GA-AEM
Hxp, Hyp, Hzp = transD_GP.TEMPEST1DInversion.returnprimary!(tempest)
@assert isapprox(Hxp[1], Hxp[end], atol=1e-4)
@assert isapprox(Hzp[1], Hzp[end], atol=1e-4)
Xnoisy, Znoisy = tempest.dataHx - Hxp, tempest.dataHz - Hzp # raw SI units!!
using DelimitedFiles
# geometry set to nominal
frameheight, frame_dx, frame_dy, frame_dz = 120, -115, 0, -40
rollrx, pitchrx, yawrx, rolltx, pitchtx, yawtx = 0, 0, 0, 0, 0, 0
X, Y, Z, fid, linenum = 0, 0, 0, 0, 0
# now write this out
μ = transD_GP.TEMPEST1DInversion.μ₀
M = [μ*1e15*Xnoisy'..., μ*1e15*Znoisy'..., μ*1e15*Hxp[1], μ*1e15*Hzp[1], X, Y, Z, fid, linenum, frameheight, frame_dx, frame_dy, frame_dz, rollrx, pitchrx, yawrx, rolltx, pitchtx, yawtx]
writedlm("data.txt", M')
A = μ*1e15*[tempest.σx'; tempest.σz']
writedlm("additive_noise.txt", A)

max_stars_repo_name: GeoscienceAustralia/HiQGA

max_issues_repo_name: GeoscienceAustralia/HiQGA

max_forks_repo_name: GeoscienceAustralia/HiQGA