text:
//--------------------------------------------------------------------------------------
// File: WaveBankReader.cpp
//
// Functions for loading audio data from Wave Banks
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//
// http://go.microsoft.com/fwlink/?LinkId=248929
// http://go.microsoft.com/fwlink/?LinkID=615561
//-------------------------------------------------------------------------------------

#include "pch.h"
#include "WaveBankReader.h"
#include "Audio.h"
#include "PlatformHelpers.h"

#if defined(_XBOX_ONE) && defined(_TITLE)
#include <apu.h>
#endif

namespace
{
#pragma pack(push, 1)

    static const size_t DVD_SECTOR_SIZE = 2048;
    static const size_t DVD_BLOCK_SIZE = DVD_SECTOR_SIZE * 16;

    static const size_t ALIGNMENT_MIN = 4;
    static const size_t ALIGNMENT_DVD = DVD_SECTOR_SIZE;

    static const size_t MAX_DATA_SEGMENT_SIZE = 0xFFFFFFFF;
    static const size_t MAX_COMPACT_DATA_SEGMENT_SIZE = 0x001FFFFF;

    struct REGION
    {
        uint32_t    dwOffset;   // Region offset, in bytes.
        uint32_t    dwLength;   // Region length, in bytes.

        void BigEndian()
        {
            dwOffset = _byteswap_ulong(dwOffset);
            dwLength = _byteswap_ulong(dwLength);
        }
    };

    struct SAMPLEREGION
    {
        uint32_t    dwStartSample;  // Start sample for the region.
        uint32_t    dwTotalSamples; // Region length in samples.

        void BigEndian()
        {
            dwStartSample = _byteswap_ulong(dwStartSample);
            dwTotalSamples = _byteswap_ulong(dwTotalSamples);
        }
    };

    struct HEADER
    {
        static const uint32_t SIGNATURE = 'DNBW';
        static const uint32_t BE_SIGNATURE = 'WBND';
        static const uint32_t VERSION = 44;

        enum SEGIDX
        {
            SEGIDX_BANKDATA = 0,       // Bank data
            SEGIDX_ENTRYMETADATA,      // Entry meta-data
            SEGIDX_SEEKTABLES,         // Storage for seek tables for the encoded waves.
            SEGIDX_ENTRYNAMES,         // Entry friendly names
            SEGIDX_ENTRYWAVEDATA,      // Entry wave data
            SEGIDX_COUNT
        };

        uint32_t    dwSignature;            // File signature
        uint32_t    dwVersion;              // Version of the tool that created the file
        uint32_t    dwHeaderVersion;        // Version of the file format
        REGION      Segments[SEGIDX_COUNT]; // Segment lookup table

        void BigEndian()
        {
            // Leave dwSignature alone as indicator of BE vs. LE

            dwVersion = _byteswap_ulong(dwVersion);
            dwHeaderVersion = _byteswap_ulong(dwHeaderVersion);
            for (size_t j = 0; j < SEGIDX_COUNT; ++j)
            {
                Segments[j].BigEndian();
            }
        }
    };

#pragma warning( disable : 4201 4203 )

    union MINIWAVEFORMAT
    {
        static const uint32_t TAG_PCM = 0x0;
        static const uint32_t TAG_XMA = 0x1;
        static const uint32_t TAG_ADPCM = 0x2;
        static const uint32_t TAG_WMA = 0x3;

        static const uint32_t BITDEPTH_8 = 0x0; // PCM only
        static const uint32_t BITDEPTH_16 = 0x1; // PCM only

        static const size_t ADPCM_BLOCKALIGN_CONVERSION_OFFSET = 22;

        struct
        {
            uint32_t       wFormatTag : 2;        // Format tag
            uint32_t       nChannels : 3;        // Channel count (1 - 6)
            uint32_t       nSamplesPerSec : 18;       // Sampling rate
            uint32_t       wBlockAlign : 8;        // Block alignment.  For WMA, lower 6 bits block alignment index, upper 2 bits bytes-per-second index.
            uint32_t       wBitsPerSample : 1;        // Bits per sample (8 vs. 16, PCM only); WMAudio2/WMAudio3 (for WMA)
        };

        uint32_t           dwValue;

        void BigEndian()
        {
            dwValue = _byteswap_ulong(dwValue);
        }

        WORD BitsPerSample() const
        {
            if (wFormatTag == TAG_XMA)
                return 16; // XMA_OUTPUT_SAMPLE_BITS == 16
            if (wFormatTag == TAG_WMA)
                return 16;
            if (wFormatTag == TAG_ADPCM)
                return 4; // MSADPCM_BITS_PER_SAMPLE == 4

            // wFormatTag must be TAG_PCM (2 bits can only represent 4 different values)
            return (wBitsPerSample == BITDEPTH_16) ? 16 : 8;
        }

        DWORD BlockAlign() const
        {
            switch (wFormatTag)
            {
                case TAG_PCM:
                    return wBlockAlign;

                case TAG_XMA:
                    return (nChannels * 16 / 8); // XMA_OUTPUT_SAMPLE_BITS = 16

                case TAG_ADPCM:
                    return (wBlockAlign + ADPCM_BLOCKALIGN_CONVERSION_OFFSET) * nChannels;

                case TAG_WMA:
                {
                    static const uint32_t aWMABlockAlign[] =
                    {
                        929,
                        1487,
                        1280,
                        2230,
                        8917,
                        8192,
                        4459,
                        5945,
                        2304,
                        1536,
                        1485,
                        1008,
                        2731,
                        4096,
                        6827,
                        5462,
                        1280
                    };

                    uint32_t dwBlockAlignIndex = wBlockAlign & 0x1F;
                    if (dwBlockAlignIndex < _countof(aWMABlockAlign))
                        return aWMABlockAlign[dwBlockAlignIndex];
                }
                break;
            }

            return 0;
        }

        DWORD AvgBytesPerSec() const
        {
            switch (wFormatTag)
            {
                case TAG_PCM:
                    return nSamplesPerSec * wBlockAlign;

                case TAG_XMA:
                    return nSamplesPerSec * BlockAlign();

                case TAG_ADPCM:
                {
                    uint32_t blockAlign = BlockAlign();
                    uint32_t samplesPerAdpcmBlock = AdpcmSamplesPerBlock();
                    return blockAlign * nSamplesPerSec / samplesPerAdpcmBlock;
                }
                break;

                case TAG_WMA:
                {
                    static const uint32_t aWMAAvgBytesPerSec[] =
                    {
                        12000,
                        24000,
                        4000,
                        6000,
                        8000,
                        20000,
                        2500
                    };
                    // bitrate = entry * 8

                    uint32_t dwBytesPerSecIndex = wBlockAlign >> 5;
                    if (dwBytesPerSecIndex < _countof(aWMAAvgBytesPerSec))
                        return aWMAAvgBytesPerSec[dwBytesPerSecIndex];
                }
                break;
            }

            return 0;
        }

        DWORD AdpcmSamplesPerBlock() const
        {
            uint32_t nBlockAlign = (wBlockAlign + ADPCM_BLOCKALIGN_CONVERSION_OFFSET) * nChannels;
            return nBlockAlign * 2 / (uint32_t)nChannels - 12;
        }

        void AdpcmFillCoefficientTable(ADPCMWAVEFORMAT *fmt) const
        {
            // These are fixed since we are always using MS ADPCM
            fmt->wNumCoef = 7 /* MSADPCM_NUM_COEFFICIENTS */;

            static ADPCMCOEFSET aCoef[7] = { { 256, 0}, {512, -256}, {0,0}, {192,64}, {240,0}, {460, -208}, {392,-232} };
            memcpy(&fmt->aCoef, aCoef, sizeof(aCoef));
        }
    };

    struct BANKDATA
    {
        static const size_t BANKNAME_LENGTH = 64;

        static const uint32_t TYPE_BUFFER = 0x00000000;
        static const uint32_t TYPE_STREAMING = 0x00000001;
        static const uint32_t TYPE_MASK = 0x00000001;

        static const uint32_t FLAGS_ENTRYNAMES = 0x00010000;
        static const uint32_t FLAGS_COMPACT = 0x00020000;
        static const uint32_t FLAGS_SYNC_DISABLED = 0x00040000;
        static const uint32_t FLAGS_SEEKTABLES = 0x00080000;
        static const uint32_t FLAGS_MASK = 0x000F0000;

        uint32_t        dwFlags;                        // Bank flags
        uint32_t        dwEntryCount;                   // Number of entries in the bank
        char            szBankName[BANKNAME_LENGTH];    // Bank friendly name
        uint32_t        dwEntryMetaDataElementSize;     // Size of each entry meta-data element, in bytes
        uint32_t        dwEntryNameElementSize;         // Size of each entry name element, in bytes
        uint32_t        dwAlignment;                    // Entry alignment, in bytes
        MINIWAVEFORMAT  CompactFormat;                  // Format data for compact bank
        FILETIME        BuildTime;                      // Build timestamp

        void BigEndian()
        {
            dwFlags = _byteswap_ulong(dwFlags);
            dwEntryCount = _byteswap_ulong(dwEntryCount);
            dwEntryMetaDataElementSize = _byteswap_ulong(dwEntryMetaDataElementSize);
            dwEntryNameElementSize = _byteswap_ulong(dwEntryNameElementSize);
            dwAlignment = _byteswap_ulong(dwAlignment);
            CompactFormat.BigEndian();
            BuildTime.dwLowDateTime = _byteswap_ulong(BuildTime.dwLowDateTime);
            BuildTime.dwHighDateTime = _byteswap_ulong(BuildTime.dwHighDateTime);
        }
    };

    struct ENTRY
    {
        static const uint32_t FLAGS_READAHEAD = 0x00000001;     // Enable stream read-ahead
        static const uint32_t FLAGS_LOOPCACHE = 0x00000002;     // One or more looping sounds use this wave
        static const uint32_t FLAGS_REMOVELOOPTAIL = 0x00000004;// Remove data after the end of the loop region
        static const uint32_t FLAGS_IGNORELOOP = 0x00000008;    // Used internally when the loop region can't be used
        static const uint32_t FLAGS_MASK = 0x00000008;

        union
        {
            struct
            {
                // Entry flags
                uint32_t                   dwFlags : 4;

                // Duration of the wave, in units of one sample.
                // For instance, a ten second long wave sampled
                // at 48KHz would have a duration of 480,000.
                // This value is not affected by the number of
                // channels, the number of bits per sample, or the
                // compression format of the wave.
                uint32_t                   Duration : 28;
            };
            uint32_t dwFlagsAndDuration;
        };

        MINIWAVEFORMAT  Format;         // Entry format.
        REGION          PlayRegion;     // Region within the wave data segment that contains this entry.
        SAMPLEREGION    LoopRegion;     // Region within the wave data (in samples) that should loop.

        void BigEndian()
        {
            dwFlagsAndDuration = _byteswap_ulong(dwFlagsAndDuration);
            Format.BigEndian();
            PlayRegion.BigEndian();
            LoopRegion.BigEndian();
        }
    };

    struct ENTRYCOMPACT
    {
        uint32_t       dwOffset : 21;       // Data offset, in multiplies of the bank alignment
        uint32_t       dwLengthDeviation : 11;       // Data length deviation, in bytes

        void BigEndian()
        {
            *reinterpret_cast<uint32_t*>(this) = _byteswap_ulong(*reinterpret_cast<const uint32_t*>(this));
        }

        void ComputeLocations(DWORD& offset, DWORD& length, uint32_t index, const HEADER& header, const BANKDATA& data, const ENTRYCOMPACT* entries) const
        {
            offset = dwOffset * data.dwAlignment;

            if (index < (data.dwEntryCount - 1))
            {
                length = (entries[index + 1].dwOffset * data.dwAlignment) - offset - dwLengthDeviation;
            }
            else
            {
                length = header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwLength - offset - dwLengthDeviation;
            }
        }

        static uint32_t GetDuration(DWORD length, const BANKDATA& data, const uint32_t* seekTable)
        {
            switch (data.CompactFormat.wFormatTag)
            {
                case MINIWAVEFORMAT::TAG_ADPCM:
                {
                    uint32_t duration = (length / data.CompactFormat.BlockAlign()) * data.CompactFormat.AdpcmSamplesPerBlock();
                    uint32_t partial = length % data.CompactFormat.BlockAlign();
                    if (partial)
                    {
                        if (partial >= (7 * data.CompactFormat.nChannels))
                            duration += (partial * 2 / data.CompactFormat.nChannels - 12);
                    }
                    return duration;
                }

                case MINIWAVEFORMAT::TAG_WMA:
                    if (seekTable)
                    {
                        uint32_t seekCount = *seekTable;
                        if (seekCount > 0)
                        {
                            return seekTable[seekCount] / uint32_t(2 * data.CompactFormat.nChannels);
                        }
                    }
                    return 0;

                case MINIWAVEFORMAT::TAG_XMA:
                    if (seekTable)
                    {
                        uint32_t seekCount = *seekTable;
                        if (seekCount > 0)
                        {
                            return seekTable[seekCount];
                        }
                    }
                    return 0;

                default:
                    return uint32_t((uint64_t(length) * 8)
                        / (uint64_t(data.CompactFormat.BitsPerSample()) * uint64_t(data.CompactFormat.nChannels)));
            }
        }
    };

#pragma pack(pop)

    inline const uint32_t* FindSeekTable(uint32_t index, const uint8_t* seekTable, const HEADER& header, const BANKDATA& data)
    {
        if (!seekTable || index >= data.dwEntryCount)
            return nullptr;

        uint32_t seekSize = header.Segments[HEADER::SEGIDX_SEEKTABLES].dwLength;

        if ((index * sizeof(uint32_t)) > seekSize)
            return nullptr;

        auto table = reinterpret_cast<const uint32_t*>(seekTable);
        uint32_t offset = table[index];
        if (offset == uint32_t(-1))
            return nullptr;

        offset += sizeof(uint32_t) * data.dwEntryCount;

        if (offset > seekSize)
            return nullptr;

        return reinterpret_cast<const uint32_t*>(seekTable + offset);
    }
}

static_assert(sizeof(REGION) == 8, "Mismatch with xact3wb.h");
static_assert(sizeof(SAMPLEREGION) == 8, "Mismatch with xact3wb.h");
static_assert(sizeof(HEADER) == 52, "Mismatch with xact3wb.h");
static_assert(sizeof(ENTRY) == 24, "Mismatch with xact3wb.h");
static_assert(sizeof(MINIWAVEFORMAT) == 4, "Mismatch with xact3wb.h");
static_assert(sizeof(ENTRY) == 24, "Mismatch with xact3wb.h");
static_assert(sizeof(ENTRYCOMPACT) == 4, "Mismatch with xact3wb.h");
static_assert(sizeof(BANKDATA) == 96, "Mismatch with xact3wb.h");

using namespace DirectX;

//--------------------------------------------------------------------------------------
class WaveBankReader::Impl
{
public:
    Impl() noexcept :
        m_async(INVALID_HANDLE_VALUE),
        m_request{},
        m_prepared(false),
        m_header{},
        m_data{}
    #if defined(_XBOX_ONE) && defined(_TITLE)
        , m_xmaMemory(nullptr)
    #endif
    {
    }

    ~Impl() { Close(); }

    HRESULT Open(_In_z_ const wchar_t* szFileName);
    void Close();

    HRESULT GetFormat(_In_ uint32_t index, _Out_writes_bytes_(maxsize) WAVEFORMATEX* pFormat, _In_ size_t maxsize) const;

    HRESULT GetWaveData(_In_ uint32_t index, _Outptr_ const uint8_t** pData, _Out_ uint32_t& dataSize) const;

    HRESULT GetSeekTable(_In_ uint32_t index, _Out_ const uint32_t** pData, _Out_ uint32_t& dataCount, _Out_ uint32_t& tag) const;

    HRESULT GetMetadata(_In_ uint32_t index, _Out_ Metadata& metadata) const;

    bool UpdatePrepared();

    void Clear()
    {
        memset(&m_header, 0, sizeof(HEADER));
        memset(&m_data, 0, sizeof(BANKDATA));

        m_names.clear();
        m_entries.reset();
        m_seekData.reset();
        m_waveData.reset();

    #if defined(_XBOX_ONE) && defined(_TITLE)
        if (m_xmaMemory)
        {
            ApuFree(m_xmaMemory);
            m_xmaMemory = nullptr;
        }
    #endif
    }

    HANDLE                              m_async;
    ScopedHandle                        m_event;
    OVERLAPPED                          m_request;
    bool                                m_prepared;

    HEADER                              m_header;
    BANKDATA                            m_data;
    std::map<std::string, uint32_t>     m_names;

private:
    std::unique_ptr<uint8_t[]>          m_entries;
    std::unique_ptr<uint8_t[]>          m_seekData;
    std::unique_ptr<uint8_t[]>          m_waveData;

#if defined(_XBOX_ONE) && defined(_TITLE)
public:
    void*                               m_xmaMemory;
#endif
};

_Use_decl_annotations_
HRESULT WaveBankReader::Impl::Open(const wchar_t* szFileName)
{
    Close();
    Clear();

    m_prepared = false;

    m_event.reset(CreateEventEx(nullptr, nullptr, CREATE_EVENT_MANUAL_RESET, EVENT_MODIFY_STATE | SYNCHRONIZE));
    if (!m_event)
    {
        return HRESULT_FROM_WIN32(GetLastError());
    }

#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
    CREATEFILE2_EXTENDED_PARAMETERS params = { sizeof(CREATEFILE2_EXTENDED_PARAMETERS), 0 };
    params.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
    params.dwFileFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN;
    ScopedHandle hFile(safe_handle(CreateFile2(szFileName,
                       GENERIC_READ,
                       FILE_SHARE_READ,
                       OPEN_EXISTING,
                       &params)));
#else
    ScopedHandle hFile(safe_handle(CreateFileW(szFileName,
                       GENERIC_READ,
                       FILE_SHARE_READ,
                       nullptr,
                       OPEN_EXISTING,
                       FILE_FLAG_OVERLAPPED | FILE_FLAG_SEQUENTIAL_SCAN,
                       nullptr)));
#endif

    if (!hFile)
    {
        return HRESULT_FROM_WIN32(GetLastError());
    }

    // Read and verify header
    OVERLAPPED request = {};
    request.hEvent = m_event.get();

    bool wait = false;
    if (!ReadFile(hFile.get(), &m_header, sizeof(m_header), nullptr, &request))
    {
        DWORD error = GetLastError();
        if (error != ERROR_IO_PENDING)
            return HRESULT_FROM_WIN32(error);
        wait = true;
    }

    DWORD bytes;
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
    BOOL result = GetOverlappedResultEx(hFile.get(), &request, &bytes, INFINITE, FALSE);
#else
    if (wait)
        (void)WaitForSingleObject(m_event.get(), INFINITE);

    BOOL result = GetOverlappedResult(hFile.get(), &request, &bytes, FALSE);
#endif

    if (!result || (bytes != sizeof(m_header)))
    {
        return HRESULT_FROM_WIN32(GetLastError());
    }

    if (m_header.dwSignature != HEADER::SIGNATURE && m_header.dwSignature != HEADER::BE_SIGNATURE)
    {
        return E_FAIL;
    }

    bool be = (m_header.dwSignature == HEADER::BE_SIGNATURE);
    if (be)
    {
        DebugTrace("INFO: \"%ls\" is a big-endian (Xbox 360) wave bank\n", szFileName);
        m_header.BigEndian();
    }

    if (m_header.dwHeaderVersion != HEADER::VERSION)
    {
        return E_FAIL;
    }

    // Load bank data
    memset(&request, 0, sizeof(request));
    request.Offset = m_header.Segments[HEADER::SEGIDX_BANKDATA].dwOffset;
    request.hEvent = m_event.get();

    wait = false;
    if (!ReadFile(hFile.get(), &m_data, sizeof(m_data), nullptr, &request))
    {
        DWORD error = GetLastError();
        if (error != ERROR_IO_PENDING)
            return HRESULT_FROM_WIN32(error);
        wait = true;
    }

#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
    result = GetOverlappedResultEx(hFile.get(), &request, &bytes, INFINITE, FALSE);
#else
    if (wait)
        (void)WaitForSingleObject(m_event.get(), INFINITE);

    result = GetOverlappedResult(hFile.get(), &request, &bytes, FALSE);
#endif

    if (!result || (bytes != sizeof(m_data)))
    {
        return HRESULT_FROM_WIN32(GetLastError());
    }

    if (be)
        m_data.BigEndian();

    if (!m_data.dwEntryCount)
    {
        return HRESULT_FROM_WIN32(ERROR_NO_DATA);
    }

    if (m_data.dwFlags & BANKDATA::TYPE_STREAMING)
    {
        if (m_data.dwAlignment < ALIGNMENT_DVD)
            return E_FAIL;
        if (m_data.dwAlignment % DVD_SECTOR_SIZE)
            return E_FAIL;
    }
    else if (m_data.dwAlignment < ALIGNMENT_MIN)
    {
        return E_FAIL;
    }

    if (m_data.dwFlags & BANKDATA::FLAGS_COMPACT)
    {
        if (m_data.dwEntryMetaDataElementSize != sizeof(ENTRYCOMPACT))
        {
            return E_FAIL;
        }

        if (m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwLength > (MAX_COMPACT_DATA_SEGMENT_SIZE * m_data.dwAlignment))
        {
            // Data segment is too large to be valid compact wavebank
            return E_FAIL;
        }
    }
    else
    {
        if (m_data.dwEntryMetaDataElementSize != sizeof(ENTRY))
        {
            return E_FAIL;
        }
    }

    DWORD metadataBytes = m_header.Segments[HEADER::SEGIDX_ENTRYMETADATA].dwLength;
    if (metadataBytes != (m_data.dwEntryCount * m_data.dwEntryMetaDataElementSize))
    {
        return E_FAIL;
    }

    // Load names
    DWORD namesBytes = m_header.Segments[HEADER::SEGIDX_ENTRYNAMES].dwLength;
    if (namesBytes > 0)
    {
        if (namesBytes >= (m_data.dwEntryNameElementSize * m_data.dwEntryCount))
        {
            std::unique_ptr<char[]> temp(new (std::nothrow) char[namesBytes]);
            if (!temp)
                return E_OUTOFMEMORY;

            memset(&request, 0, sizeof(request));
            request.Offset = m_header.Segments[HEADER::SEGIDX_ENTRYNAMES].dwOffset;
            request.hEvent = m_event.get();

            wait = false;
            if (!ReadFile(hFile.get(), temp.get(), namesBytes, nullptr, &request))
            {
                DWORD error = GetLastError();
                if (error != ERROR_IO_PENDING)
                    return HRESULT_FROM_WIN32(error);
                wait = true;
            }

        #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
            result = GetOverlappedResultEx(hFile.get(), &request, &bytes, INFINITE, FALSE);
        #else
            if (wait)
                (void)WaitForSingleObject(m_event.get(), INFINITE);

            result = GetOverlappedResult(hFile.get(), &request, &bytes, FALSE);
        #endif

            if (!result || (namesBytes != bytes))
            {
                return HRESULT_FROM_WIN32(GetLastError());
            }

            for (uint32_t j = 0; j < m_data.dwEntryCount; ++j)
            {
                DWORD n = m_data.dwEntryNameElementSize * j;

                char name[64] = {};
                strncpy_s(name, &temp[n], sizeof(name));

                m_names[name] = j;
            }
        }
    }

    // Load entries
    if (m_data.dwFlags & BANKDATA::FLAGS_COMPACT)
    {
        m_entries.reset(reinterpret_cast<uint8_t*>(new (std::nothrow) ENTRYCOMPACT[m_data.dwEntryCount]));
    }
    else
    {
        m_entries.reset(reinterpret_cast<uint8_t*>(new (std::nothrow) ENTRY[m_data.dwEntryCount]));
    }
    if (!m_entries)
        return E_OUTOFMEMORY;

    memset(&request, 0, sizeof(request));
    request.Offset = m_header.Segments[HEADER::SEGIDX_ENTRYMETADATA].dwOffset;
    request.hEvent = m_event.get();

    wait = false;
    if (!ReadFile(hFile.get(), m_entries.get(), metadataBytes, nullptr, &request))
    {
        DWORD error = GetLastError();
        if (error != ERROR_IO_PENDING)
            return HRESULT_FROM_WIN32(error);
        wait = true;
    }

#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
    result = GetOverlappedResultEx(hFile.get(), &request, &bytes, INFINITE, FALSE);
#else
    if (wait)
        (void)WaitForSingleObject(m_event.get(), INFINITE);

    result = GetOverlappedResult(hFile.get(), &request, &bytes, FALSE);
#endif

    if (!result || (metadataBytes != bytes))
    {
        return HRESULT_FROM_WIN32(GetLastError());
    }

    if (be)
    {
        if (m_data.dwFlags & BANKDATA::FLAGS_COMPACT)
        {
            auto ptr = reinterpret_cast<ENTRYCOMPACT*>(m_entries.get());
            for (size_t j = 0; j < m_data.dwEntryCount; ++j, ++ptr)
                ptr->BigEndian();
        }
        else
        {
            auto ptr = reinterpret_cast<ENTRY*>(m_entries.get());
            for (size_t j = 0; j < m_data.dwEntryCount; ++j, ++ptr)
                ptr->BigEndian();
        }
    }

    // Load seek tables (XMA2 / xWMA)
    DWORD seekLen = m_header.Segments[HEADER::SEGIDX_SEEKTABLES].dwLength;
    if (seekLen > 0)
    {
        m_seekData.reset(new (std::nothrow) uint8_t[seekLen]);
        if (!m_seekData)
            return E_OUTOFMEMORY;

        memset(&request, 0, sizeof(OVERLAPPED));
        request.Offset = m_header.Segments[HEADER::SEGIDX_SEEKTABLES].dwOffset;
        request.hEvent = m_event.get();

        wait = false;
        if (!ReadFile(hFile.get(), m_seekData.get(), seekLen, nullptr, &request))
        {
            DWORD error = GetLastError();
            if (error != ERROR_IO_PENDING)
                return HRESULT_FROM_WIN32(error);
            wait = true;
        }

    #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
        result = GetOverlappedResultEx(hFile.get(), &request, &bytes, INFINITE, FALSE);
    #else
        if (wait)
            (void)WaitForSingleObject(m_event.get(), INFINITE);

        result = GetOverlappedResult(hFile.get(), &request, &bytes, FALSE);
    #endif

        if (!result || (seekLen != bytes))
        {
            return HRESULT_FROM_WIN32(GetLastError());
        }

        if (be)
        {
            auto ptr = reinterpret_cast<uint32_t*>(m_seekData.get());
            for (size_t j = 0; j < seekLen; j += 4, ++ptr)
            {
                *ptr = _byteswap_ulong(*ptr);
            }
        }
    }

    DWORD waveLen = m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwLength;
    if (!waveLen)
    {
        return HRESULT_FROM_WIN32(ERROR_NO_DATA);
    }

    if (m_data.dwFlags & BANKDATA::TYPE_STREAMING)
    {
        // If streaming, reopen without buffering
        hFile.reset();

    #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
        CREATEFILE2_EXTENDED_PARAMETERS params2 = { sizeof(CREATEFILE2_EXTENDED_PARAMETERS), 0 };
        params2.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
        params2.dwFileFlags = FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING;
        m_async = CreateFile2(szFileName,
                              GENERIC_READ,
                              FILE_SHARE_READ,
                              OPEN_EXISTING,
                              &params2);
    #else
        m_async = CreateFileW(szFileName,
                              GENERIC_READ,
                              FILE_SHARE_READ,
                              nullptr,
                              OPEN_EXISTING,
                              FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING,
                              nullptr);
    #endif

        if (m_async == INVALID_HANDLE_VALUE)
        {
            return HRESULT_FROM_WIN32(GetLastError());
        }

        m_prepared = true;
    }
    else
    {
        // If in-memory, kick off read of wave data
        void *dest;

    #if defined(_XBOX_ONE) && defined(_TITLE)
        bool xma = false;
        if (m_data.dwFlags & BANKDATA::FLAGS_COMPACT)
        {
            if (m_data.CompactFormat.wFormatTag == MINIWAVEFORMAT::TAG_XMA)
                xma = true;
        }
        else
        {
            for (uint32_t j = 0; j < m_data.dwEntryCount; ++j)
            {
                auto& entry = reinterpret_cast<const ENTRY*>(m_entries.get())[j];
                if (entry.Format.wFormatTag == MINIWAVEFORMAT::TAG_XMA)
                {
                    xma = true;
                    break;
                }
            }
        }

        if (xma)
        {
            HRESULT hr = ApuAlloc(&m_xmaMemory, nullptr, waveLen, SHAPE_XMA_INPUT_BUFFER_ALIGNMENT);
            if (FAILED(hr))
            {
                DebugTrace("ERROR: ApuAlloc failed. Did you allocate a large enough heap with ApuCreateHeap for all your XMA wave data?\n");
                return hr;
            }

            dest = m_xmaMemory;
        }
        else
        #endif // _XBOX_ONE && _TITLE
        {
            m_waveData.reset(new (std::nothrow) uint8_t[waveLen]);
            if (!m_waveData)
                return E_OUTOFMEMORY;

            dest = m_waveData.get();
        }

        memset(&m_request, 0, sizeof(OVERLAPPED));
        m_request.Offset = m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwOffset;
        m_request.hEvent = m_event.get();

        if (!ReadFile(hFile.get(), dest, waveLen, nullptr, &m_request))
        {
            DWORD error = GetLastError();
            if (error != ERROR_IO_PENDING)
                return HRESULT_FROM_WIN32(error);
        }
        else
        {
            m_prepared = true;
            memset(&m_request, 0, sizeof(OVERLAPPED));
        }

        m_async = hFile.release();
    }

    return S_OK;
}

void WaveBankReader::Impl::Close()
{
    if (m_async != INVALID_HANDLE_VALUE)
    {
        if (m_request.hEvent != 0)
        {
            DWORD bytes;
        #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
            (void)GetOverlappedResultEx(m_async, &m_request, &bytes, INFINITE, FALSE);
        #else
            (void)WaitForSingleObject(m_request.hEvent, INFINITE);

            (void)GetOverlappedResult(m_async, &m_request, &bytes, FALSE);
        #endif
        }

        CloseHandle(m_async);
        m_async = INVALID_HANDLE_VALUE;
    }
    m_event.reset();

#if defined(_XBOX_ONE) && defined(_TITLE)
    if (m_xmaMemory)
    {
        ApuFree(m_xmaMemory);
        m_xmaMemory = nullptr;
    }
#endif
}

_Use_decl_annotations_
HRESULT WaveBankReader::Impl::GetFormat(uint32_t index, WAVEFORMATEX* pFormat, size_t maxsize) const
{
    if (!pFormat || !maxsize)
        return E_INVALIDARG;

    if (index >= m_data.dwEntryCount || !m_entries)
    {
        return E_FAIL;
    }

    auto& miniFmt = (m_data.dwFlags & BANKDATA::FLAGS_COMPACT) ? m_data.CompactFormat : (reinterpret_cast<const ENTRY*>(m_entries.get())[index].Format);

    switch (miniFmt.wFormatTag)
    {
        case MINIWAVEFORMAT::TAG_PCM:
            if (maxsize < sizeof(PCMWAVEFORMAT))
                return HRESULT_FROM_WIN32(ERROR_MORE_DATA);

            pFormat->wFormatTag = WAVE_FORMAT_PCM;

            if (maxsize >= sizeof(WAVEFORMATEX))
            {
                pFormat->cbSize = 0;
            }
            break;

        case MINIWAVEFORMAT::TAG_ADPCM:
            if (maxsize < (sizeof(WAVEFORMATEX) + 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/))
                return HRESULT_FROM_WIN32(ERROR_MORE_DATA);

            pFormat->wFormatTag = WAVE_FORMAT_ADPCM;
            pFormat->cbSize = 32 /*MSADPCM_FORMAT_EXTRA_BYTES*/;
            {
                auto adpcmFmt = reinterpret_cast<ADPCMWAVEFORMAT*>(pFormat);
                adpcmFmt->wSamplesPerBlock = (WORD)miniFmt.AdpcmSamplesPerBlock();
                miniFmt.AdpcmFillCoefficientTable(adpcmFmt);
            }
            break;

        case MINIWAVEFORMAT::TAG_WMA:
            if (maxsize < sizeof(WAVEFORMATEX))
                return HRESULT_FROM_WIN32(ERROR_MORE_DATA);

            pFormat->wFormatTag = (miniFmt.wBitsPerSample & 0x1) ? WAVE_FORMAT_WMAUDIO3 : WAVE_FORMAT_WMAUDIO2;
            pFormat->cbSize = 0;
            break;

        case MINIWAVEFORMAT::TAG_XMA: // XMA2 is supported by Xbox One
        #if defined(_XBOX_ONE) && defined(_TITLE)
            if (maxsize < sizeof(XMA2WAVEFORMATEX))
                return HRESULT_FROM_WIN32(ERROR_MORE_DATA);

            pFormat->wFormatTag = WAVE_FORMAT_XMA2;
            pFormat->cbSize = sizeof(XMA2WAVEFORMATEX) - sizeof(WAVEFORMATEX);
            {
                auto xmaFmt = reinterpret_cast<XMA2WAVEFORMATEX*>(pFormat);

                xmaFmt->NumStreams = static_cast<WORD>((miniFmt.nChannels + 1) / 2);
                xmaFmt->BytesPerBlock = 65536 /* XACT_FIXED_XMA_BLOCK_SIZE */;
                xmaFmt->EncoderVersion = 4 /* XMAENCODER_VERSION_XMA2 */;

                auto seekTable = FindSeekTable(index, m_seekData.get(), m_header, m_data);
                if (seekTable)
                {
                    xmaFmt->BlockCount = static_cast<WORD>(*seekTable);
                }
                else
                {
                    xmaFmt->BlockCount = 0;
                }

                switch (miniFmt.nChannels)
                {
                    case 1: xmaFmt->ChannelMask = SPEAKER_MONO; break;
                    case 2: xmaFmt->ChannelMask = SPEAKER_STEREO; break;
                    case 3: xmaFmt->ChannelMask = SPEAKER_2POINT1; break;
                    case 4: xmaFmt->ChannelMask = SPEAKER_QUAD; break;
                    case 5: xmaFmt->ChannelMask = SPEAKER_4POINT1; break;
                    case 6: xmaFmt->ChannelMask = SPEAKER_5POINT1; break;
                    case 7: xmaFmt->ChannelMask = SPEAKER_5POINT1 | SPEAKER_BACK_CENTER; break;
                    case 8: xmaFmt->ChannelMask = SPEAKER_7POINT1; break;
                    default: xmaFmt->ChannelMask = DWORD(-1); break;
                }

                if (m_data.dwFlags & BANKDATA::FLAGS_COMPACT)
                {
                    auto& entry = reinterpret_cast<const ENTRYCOMPACT*>(m_entries.get())[index];

                    DWORD dwOffset, dwLength;
                    entry.ComputeLocations(dwOffset, dwLength, index, m_header, m_data, reinterpret_cast<const ENTRYCOMPACT*>(m_entries.get()));

                    xmaFmt->SamplesEncoded = entry.GetDuration(dwLength, m_data, seekTable);

                    xmaFmt->PlayBegin = xmaFmt->PlayLength =
                        xmaFmt->LoopBegin = xmaFmt->LoopLength = xmaFmt->LoopCount = 0;
                }
                else
                {
                    auto& entry = reinterpret_cast<const ENTRY*>(m_entries.get())[index];

                    xmaFmt->SamplesEncoded = entry.Duration;
                    xmaFmt->PlayBegin = 0;
                    xmaFmt->PlayLength = entry.PlayRegion.dwLength;

                    if (entry.LoopRegion.dwTotalSamples > 0)
                    {
                        xmaFmt->LoopBegin = entry.LoopRegion.dwStartSample;
                        xmaFmt->LoopLength = entry.LoopRegion.dwTotalSamples;
                        xmaFmt->LoopCount = 0xff /* XACTLOOPCOUNT_INFINITE */;
                    }
                    else
                    {
                        xmaFmt->LoopBegin = xmaFmt->LoopLength = xmaFmt->LoopCount = 0;
                    }
                }
            }
            break;
        #else
            return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
        #endif

        default:
            return E_FAIL;
    }

    pFormat->nChannels = miniFmt.nChannels;
    pFormat->wBitsPerSample = miniFmt.BitsPerSample();
    pFormat->nBlockAlign = (WORD)miniFmt.BlockAlign();
    pFormat->nSamplesPerSec = miniFmt.nSamplesPerSec;
    pFormat->nAvgBytesPerSec = miniFmt.AvgBytesPerSec();

    return S_OK;
}

_Use_decl_annotations_
HRESULT WaveBankReader::Impl::GetWaveData(uint32_t index, const uint8_t** pData, uint32_t& dataSize) const
{
    if (!pData)
        return E_INVALIDARG;

    if (index >= m_data.dwEntryCount || !m_entries)
    {
        return E_FAIL;
    }

#if defined(_XBOX_ONE) && defined(_TITLE)
    const uint8_t* waveData = (m_xmaMemory) ? reinterpret_cast<uint8_t*>(m_xmaMemory) : m_waveData.get();
#else
    const uint8_t* waveData = m_waveData.get();
#endif

    if (!waveData)
        return E_FAIL;

    if (m_data.dwFlags & BANKDATA::TYPE_STREAMING)
    {
        return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
    }

    if (!m_prepared)
    {
        return HRESULT_FROM_WIN32(ERROR_IO_INCOMPLETE);
    }

    if (m_data.dwFlags & BANKDATA::FLAGS_COMPACT)
    {
        auto& entry = reinterpret_cast<const ENTRYCOMPACT*>(m_entries.get())[index];

        DWORD dwOffset, dwLength;
        entry.ComputeLocations(dwOffset, dwLength, index, m_header, m_data, reinterpret_cast<const ENTRYCOMPACT*>(m_entries.get()));

        if ((dwOffset + dwLength) > m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwLength)
        {
            return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
        }

        *pData = &waveData[dwOffset];
        dataSize = dwLength;
    }
    else
    {
        auto& entry = reinterpret_cast<const ENTRY*>(m_entries.get())[index];

        if ((entry.PlayRegion.dwOffset + entry.PlayRegion.dwLength) > m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwLength)
        {
            return HRESULT_FROM_WIN32(ERROR_HANDLE_EOF);
        }

        *pData = &waveData[entry.PlayRegion.dwOffset];
        dataSize = entry.PlayRegion.dwLength;
    }

    return S_OK;
}

_Use_decl_annotations_
HRESULT WaveBankReader::Impl::GetSeekTable(uint32_t index, const uint32_t** pData, uint32_t& dataCount, uint32_t& tag) const
{
    if (!pData)
        return E_INVALIDARG;

    *pData = nullptr;
    dataCount = 0;
    tag = 0;

    if (index >= m_data.dwEntryCount || !m_entries)
    {
        return E_FAIL;
    }

    if (!m_seekData)
        return S_OK;

    auto& miniFmt = (m_data.dwFlags & BANKDATA::FLAGS_COMPACT) ? m_data.CompactFormat : (reinterpret_cast<const ENTRY*>(m_entries.get())[index].Format);

    switch (miniFmt.wFormatTag)
    {
        case MINIWAVEFORMAT::TAG_WMA:
            tag = (miniFmt.wBitsPerSample & 0x1) ? WAVE_FORMAT_WMAUDIO3 : WAVE_FORMAT_WMAUDIO2;
            break;

        case MINIWAVEFORMAT::TAG_XMA:
            tag = 0x166 /* WAVE_FORMAT_XMA2 */;
            break;

        default:
            return S_OK;
    }

    auto seekTable = FindSeekTable(index, m_seekData.get(), m_header, m_data);
    if (!seekTable)
        return S_OK;

    dataCount = *seekTable;
    *pData = seekTable + 1;

    return S_OK;
}

_Use_decl_annotations_
HRESULT WaveBankReader::Impl::GetMetadata(uint32_t index, Metadata& metadata) const
{
    if (index >= m_data.dwEntryCount || !m_entries)
    {
        return E_FAIL;
    }

    if (m_data.dwFlags & BANKDATA::FLAGS_COMPACT)
    {
        auto& entry = reinterpret_cast<const ENTRYCOMPACT*>(m_entries.get())[index];

        DWORD dwOffset, dwLength;
        entry.ComputeLocations(dwOffset, dwLength, index, m_header, m_data, reinterpret_cast<const ENTRYCOMPACT*>(m_entries.get()));

        auto seekTable = FindSeekTable(index, m_seekData.get(), m_header, m_data);
        metadata.duration = entry.GetDuration(dwLength, m_data, seekTable);
        metadata.loopStart = metadata.loopLength = 0;
        metadata.offsetBytes = dwOffset;
        metadata.lengthBytes = dwLength;
    }
    else
    {
        auto& entry = reinterpret_cast<const ENTRY*>(m_entries.get())[index];

        metadata.duration = entry.Duration;
        metadata.loopStart = entry.LoopRegion.dwStartSample;
        metadata.loopLength = entry.LoopRegion.dwTotalSamples;
        metadata.offsetBytes = entry.PlayRegion.dwOffset;
        metadata.lengthBytes = entry.PlayRegion.dwLength;
    }

    return S_OK;
}

bool WaveBankReader::Impl::UpdatePrepared()
{
    if (m_prepared)
        return true;

    if (m_async == INVALID_HANDLE_VALUE)
        return false;

    if (m_request.hEvent != 0)
    {

    #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
        DWORD bytes;
        BOOL result = GetOverlappedResultEx(m_async, &m_request, &bytes, 0, FALSE);
    #else
        bool result = HasOverlappedIoCompleted(&m_request);
    #endif
        if (result)
        {
            m_prepared = true;

            memset(&m_request, 0, sizeof(OVERLAPPED));
        }
    }

    return m_prepared;
}

//--------------------------------------------------------------------------------------
WaveBankReader::WaveBankReader() noexcept(false) :
    pImpl(std::make_unique<Impl>())
{
}

WaveBankReader::~WaveBankReader()
{
}

_Use_decl_annotations_
HRESULT WaveBankReader::Open(const wchar_t* szFileName)
{
    return pImpl->Open(szFileName);
}

_Use_decl_annotations_
uint32_t WaveBankReader::Find(const char* name) const
{
    auto it = pImpl->m_names.find(name);
    if (it != pImpl->m_names.cend())
    {
        return it->second;
    }

    return uint32_t(-1);
}

bool WaveBankReader::IsPrepared()
{
    if (pImpl->m_prepared)
        return true;

    return pImpl->UpdatePrepared();
}

void WaveBankReader::WaitOnPrepare()
{
    if (pImpl->m_prepared)
        return;

    if (pImpl->m_request.hEvent != 0)
    {
        WaitForSingleObjectEx(pImpl->m_request.hEvent, INFINITE, FALSE);

        pImpl->UpdatePrepared();
    }
}

bool WaveBankReader::HasNames() const
{
    return !pImpl->m_names.empty();
}

bool WaveBankReader::IsStreamingBank() const
{
    return (pImpl->m_data.dwFlags  & BANKDATA::TYPE_STREAMING) != 0;
}

#if defined(_XBOX_ONE) && defined(_TITLE)
bool WaveBankReader::HasXMA() const
{
    return (pImpl->m_xmaMemory != 0);
}
#endif

const char* WaveBankReader::BankName() const
{
    return pImpl->m_data.szBankName;
}

uint32_t WaveBankReader::Count() const
{
    return pImpl->m_data.dwEntryCount;
}

uint32_t WaveBankReader::BankAudioSize() const
{
    return pImpl->m_header.Segments[HEADER::SEGIDX_ENTRYWAVEDATA].dwLength;
}

_Use_decl_annotations_
HRESULT WaveBankReader::GetFormat(uint32_t index, WAVEFORMATEX* pFormat, size_t maxsize) const
{
    return pImpl->GetFormat(index, pFormat, maxsize);
}

_Use_decl_annotations_
HRESULT WaveBankReader::GetWaveData(uint32_t index, const uint8_t** pData, uint32_t& dataSize) const
{
    return pImpl->GetWaveData(index, pData, dataSize);
}

_Use_decl_annotations_
HRESULT WaveBankReader::GetSeekTable(uint32_t index, const uint32_t** pData, uint32_t& dataCount, uint32_t& tag) const
{
    return pImpl->GetSeekTable(index, pData, dataCount, tag);
}

_Use_decl_annotations_
HRESULT WaveBankReader::GetMetadata(uint32_t index, Metadata& metadata) const
{
    return pImpl->GetMetadata(index, metadata);
}

HANDLE WaveBankReader::GetAsyncHandle() const
{
    return (pImpl->m_data.dwFlags & BANKDATA::TYPE_STREAMING) ? pImpl->m_async : INVALID_HANDLE_VALUE;
}


text:
@implementation SecondVC

- (void)test1 {
    //[self test1];
//    NSURL *url;
//    SFSafariViewController *sfVC = [[SFSafariViewController alloc]initWithURL:url];
}

@end

redpajama_set_name: RedPajamaGithub


text:
package com.google.gwt.todomvc.client;

import com.google.gwt.angular.client.Angular;
import com.google.gwt.angular.client.Filter;
import com.google.gwt.angular.client.NgInject;
import elemental.js.util.JsArrayOf;
import elemental.util.ArrayOf;

/**
 * Injectable filter.
 */
@NgInject(name = "todoFilter")
public class TodoFilter implements Filter<Todo> {
  public ArrayOf<Todo> filter(ArrayOf<Todo> todos, Todo todoFilter) {
    ArrayOf<Todo> result = JsArrayOf.create();
    for (Todo todo : Angular.iterable(todos)) {
      boolean allMatch = true;
      for (String key : todoFilter.json().keys()) {
        allMatch = allMatch && todo.json().get(key) == todoFilter.json().get(key);
      }
      if (allMatch) {
        result.push(todo);
      }
    }
    return result;
  }
}


text:
package net.liftweb {
package wizard {

import _root_.net.liftweb._
import http._

object HtmlRenderer {
  def apply(in: Wizard): DispatchSnippet = null
}

}
}


text:
package io.cattle.platform.token;

import org.bouncycastle.openssl.jcajce.JcaPEMWriter;

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class CertSet {
    X509Certificate cert;
    X509Certificate ca;
    PrivateKey key;

    public CertSet(X509Certificate ca, X509Certificate cert, PrivateKey key) {
        super();
        this.cert = cert;
        this.ca = ca;
        this.key = key;
    }

    public X509Certificate getCert() {
        return cert;
    }

    public X509Certificate getCa() {
        return ca;
    }

    public PrivateKey getKey() {
        return key;
    }

    public void writeZip(OutputStream output) throws IOException {
        ZipOutputStream zos = new ZipOutputStream(output);
        write(zos, "ca.pem", ca);
        write(zos, "cert.pem", cert);
        write(zos, "key.pem", key);
        zos.close();
    }

    protected void write(ZipOutputStream zos, String name, Object obj) throws IOException {
        ZipEntry ze = new ZipEntry(name);
        zos.putNextEntry(ze);
        JcaPEMWriter writer = new JcaPEMWriter(new OutputStreamWriter(zos));
        writer.writeObject(obj);
        writer.flush();
        zos.closeEntry();
    }

}


text:
package wint.mvc.servlet.mock;

import java.util.Collections;
import java.util.Enumeration;
import java.util.Map;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;

import wint.lang.magic.MagicMap;
import wint.lang.utils.MapUtil;

public class ServletConfigMock implements ServletConfig {

	private MagicMap initParameters = MagicMap.newMagicMap();

	private ServletContext servletContext;

	public ServletConfigMock(MagicMap initConfigParameters, MagicMap servletContextInitParameters) {
		super();
		this.initParameters = initConfigParameters;
		servletContext = new ServletContextMock(toStringMap(servletContextInitParameters));
	}

	private static Map<String, String> toStringMap(Map<String, Object> m) {
		Map<String, String> ret = MapUtil.newHashMap();
		for (Map.Entry<String, Object> entry : m.entrySet()) {
			Object v = entry.getValue();
			if (v == null) {
				continue;
			}
			ret.put(entry.getKey(), v.toString());
		}
		return ret;
	}

	public ServletConfigMock() {
		super();
	}

	public String getInitParameter(String name) {
		return initParameters.getString(name);
	}

	public Enumeration<?> getInitParameterNames() {
		return Collections.enumeration(initParameters.keySet());
	}

	public ServletContext getServletContext() {
		return servletContext;
	}

	public void setServletContext(ServletContext servletContext) {
		this.servletContext = servletContext;
	}

	public void addParameter(String name, String value) {
		initParameters.put(name, value);
	}

	public String getServletName() {
		return "MockServlet";
	}

}


text:
package com.asakusafw.spark.runtime.fragment
package user

import com.asakusafw.runtime.core.Result
import com.asakusafw.runtime.model.DataModel

abstract class SplitOperatorFragment[T <: DataModel[T], L <: DataModel[L], R <: DataModel[R]](
  left: L, right: R, l: Fragment[L], r: Fragment[R])
  extends Fragment[T] {

  override def doAdd(result: T): Unit = {
    left.reset()
    right.reset()
    split(result, left, right)
    l.add(left)
    r.add(right)
  }

  def split(input: T, left: L, right: R): Unit

  override def doReset(): Unit = {
    l.reset()
    r.reset()
  }
}


text:
require "test_helper"

# Name type is deprecated test.
class AcraIsDeprecatedTest < ActiveSupport::TestCase
  test "acra is a deprecated name type" do
    assert_equal true,
                 NameType.find_by(name: "acra").deprecated,
                 "ACRA should be a deprecated name type"
  end
end


text:
name             'devpi'
maintainer       'Dave Shawley'
maintainer_email 'daveshawley@gmail.com'
license          'Apache 2.0'
description      'Installs/Configures a devpi server'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version          '1.0.5'

depends 'nginx'
depends 'python'
depends 'runit'
depends 'supervisor'
['ubuntu', 'centos'].each do |platform|
  supports platform
end

recipe 'devpi::server', 'Installs the devpi-server package.'
recipe 'devpi::supervisor', 'Manage the devpi-server daemon with supervisord.'
recipe 'devpi::nginx', 'Configure nginx as an HTTP front-end.'


text:
package com.microsoft.azure.management.appplatform.v2019_05_01_preview.implementation;

import com.microsoft.azure.management.appplatform.v2019_05_01_preview.OperationDetail;
import com.microsoft.azure.arm.model.implementation.WrapperImpl;
import com.microsoft.azure.management.appplatform.v2019_05_01_preview.OperationDisplay;
import com.microsoft.azure.management.appplatform.v2019_05_01_preview.OperationProperties;

class OperationDetailImpl extends WrapperImpl<OperationDetailInner> implements OperationDetail {
    private final AppPlatformManager manager;
    OperationDetailImpl(OperationDetailInner inner, AppPlatformManager manager) {
        super(inner);
        this.manager = manager;
    }

    @Override
    public AppPlatformManager manager() {
        return this.manager;
    }

    @Override
    public Boolean dataAction() {
        return this.inner().dataAction();
    }

    @Override
    public OperationDisplay display() {
        return this.inner().display();
    }

    @Override
    public String name() {
        return this.inner().name();
    }

    @Override
    public String origin() {
        return this.inner().origin();
    }

    @Override
    public OperationProperties properties() {
        return this.inner().properties();
    }

}


text:
package no.ntnu.okse.clients.stomp;

import asia.stampy.server.message.message.MessageMessage;

public class StompCallback {

    public void messageReceived(MessageMessage message) {
        String topic = message.getHeader().getDestination();
        String content = message.getBody().toString();
        System.out.println(String.format("[%s] %s", topic, content));
    }
}


text:
'''
Created on Aug 30, 2013

@author: James Anderson
'''

import glob
import os

from ez_setup import use_setuptools

# This if test prevents an infinite recursion running tests from "python setup.py test"
if __name__ == '__main__':

    use_setuptools()

    from setuptools import setup, find_packages

    packages = find_packages()

    install_requires = ["pdf2text"]

    provides = ["copy_catcher"]

    classifiers = ['Programming Language :: Python :: 3.4',
                   'Programming Language :: Python :: 2.7']

    dependency_links = ["git+http://github.com/jamesra/copycatcher#egg=copy_catcher-1.0.0"]

    package_dir = {'copy_catcher' : 'copy_catcher'}

    scripts = glob.glob(os.path.join('scripts', 'main.py'))

    entry_points = {'console_scripts': ['copycatcher = copy_catcher.main:Execute']}

    setup(name='copy_catcher',
          zip_safe=True,
          version='1.0.0',
          scripts=scripts,
          classifiers=classifiers,
          description="Find matching text blocks in files",
          author="James Anderson",
          author_email="James.R.Anderson@utah.edu",
          url="http://jamesra.github.com/copy_catcher",
          packages=packages,
          entry_points=entry_points,
          install_requires=install_requires,
          provides=provides,
          test_suite="test",
          dependency_links=dependency_links)


text:
"use strict";
var VMs = $.views.viewModels,
  counter = 0;

// Background color helper function
function bgColor(index) {
  return this.selectedIndex() === index
    ? "yellow"
    : (index%2 ? "#fdfdfe" : "#efeff2");
}

bgColor.depends = "selectedIndex()";

// Compile View Models
VMs({
MovieApp: {
  getters: [
    "selectedIndex",
    { getter: "movies", type: "Movie", parentRef: "movieApp" }
  ],
  extend: {
    addMovie: function() {
      // Instantiate new movie with a movie.movieApp 'parentRef' property
      var newMovie = VMs.Movie("NewTitle" + counter, [], "movieApp", this);
      newMovie.addLanguage(),
      $.observable(this.movies()).insert(newMovie); // Insert the new movie
      this.select($.view(".movies tr:last").index); // Set selection on the added item
    },
    removeMovie: function(index) {
      this.select(); // unselect
      $.observable(this.movies()).remove(index);
      return false;
    },
    select: function(index) {
      if (this.selectedIndex() !== index) {
        this.selectedIndex(index);
      }
    },
    deleteLast: function() { // Example of action using View Model hierarchy
      var moviesCount = this.movies().length;
      if (moviesCount) {
        var lastMovie = this.movies()[moviesCount-1];
        var languagesCount = lastMovie.languages().length;
        if (languagesCount) {
          lastMovie.removeLanguage(languagesCount-1);
        }
      }
    },
    showData: function() { // Get the current data, and display in 'console'
      $("#console").append($("#showData").render(this.unmap()));
    },
    bgColor: bgColor // Helper for background color rendering
  }
},
Movie: {
  getters: [
    "title",
    { getter: "languages", type: "Language", parentRef: "movie" }
  ],
  extend: {
    addLanguage: function() {
      // Instantiate new language with a language.movie 'parentRef' property
      var newLanguage = VMs.Language("NewLanguage" + counter++, "movie", this);
      $.observable(this.languages()).insert(newLanguage); // Insert the new language
    },
    removeLanguage: function(index) {
      $.observable(this.languages()).remove(index);
      return false;
    }
  }
},
Language: {
  getters: ["name"]
}
});

// Initial data
var app = {
  selectedIndex: null,
  movies: [
    {
      title:"Meet Joe Black",
      languages: [
        {name: "English"},
        {name: "French"}
      ]
    },
    {
      title:"Eyes Wide Shut",
      languages: [
        {name: "German"},
        {name: "French"},
        {name: "Spanish"}
      ]
    }
  ]
};

// Instantiate View Models
var appVm = $.views.viewModels.MovieApp.map(app);

// Top level data-linking - bind content to View Models
$.link(true, ".linkedContent", appVm);


text:
package org.ringojs.test;

import junit.framework.TestCase;
import org.ringojs.util.CaseInsensitiveMap;

import java.util.Map;
import java.util.HashMap;

public class CaseInsensitiveMapTest extends TestCase {

    private static final Map<String, Boolean> fixture = new HashMap<String, Boolean>();

    static {
        fixture.put("AAA", true);
        fixture.put("Bbb", true);
        fixture.put("cCC", true);
    }

    public void testAddRemove() {
        Map<String, Boolean> map = new CaseInsensitiveMap<Boolean>();
        map.put("AAA", true);
        map.put("Bbb", true);
        map.put("cCC", true);
        map.put("ZZtop", true);
        map.remove("zzTOP");
        assertEquals(fixture, map);
    }

    public void testOverwrite() {
        Map<String, Boolean> map = new CaseInsensitiveMap<Boolean>();
        map.put("AAA", true);
        map.put("Bbb", true);
        map.put("CCC", false);
        // NOTE: fixture.equals(map) will return true because of
        // the specifics of AbstractMap.equals() implementation
        assertFalse(map.equals(fixture));
        map.put("cCC", true);
        assertEquals(fixture, map);
    }

}


text:
/* Code generated by IfcQuery EXPRESS generator, www.ifcquery.com */
#pragma once
#include <vector>
#include <map>
#include <sstream>
#include <string>
#include "ifcpp/model/GlobalDefines.h"
#include "ifcpp/model/BasicTypes.h"
#include "ifcpp/model/BuildingObject.h"
#include "IfcExtendedProperties.h"
class IFCQUERY_EXPORT IfcMaterialDefinition;
//ENTITY
class IFCQUERY_EXPORT IfcMaterialProperties : public IfcExtendedProperties
{
public:
	IfcMaterialProperties() = default;
	IfcMaterialProperties( int id );
	~IfcMaterialProperties() = default;
	virtual shared_ptr<BuildingObject> getDeepCopy( BuildingCopyOptions& options );
	virtual void getStepLine( std::stringstream& stream ) const;
	virtual void getStepParameter( std::stringstream& stream, bool is_select_type = false ) const;
	virtual void readStepArguments( const std::vector<std::wstring>& args, const std::map<int,shared_ptr<BuildingEntity> >& map );
	virtual void setInverseCounterparts( shared_ptr<BuildingEntity> ptr_self );
	virtual size_t getNumAttributes() { return 4; }
	virtual void getAttributes( std::vector<std::pair<std::string, shared_ptr<BuildingObject> > >& vec_attributes ) const;
	virtual void getAttributesInverse( std::vector<std::pair<std::string, shared_ptr<BuildingObject> > >& vec_attributes ) const;
	virtual void unlinkFromInverseCounterparts();
	virtual const char* className() const { return "IfcMaterialProperties"; }
	virtual const std::wstring toString() const;

	// IfcPropertyAbstraction -----------------------------------------------------------
	// inverse attributes:
	//  std::vector<weak_ptr<IfcExternalReferenceRelationship> >	m_HasExternalReferences_inverse;

	// IfcExtendedProperties -----------------------------------------------------------
	// attributes:
	//  shared_ptr<IfcIdentifier>									m_Name;						//optional
	//  shared_ptr<IfcText>											m_Description;				//optional
	//  std::vector<shared_ptr<IfcProperty> >						m_Properties;

	// IfcMaterialProperties -----------------------------------------------------------
	// attributes:
	shared_ptr<IfcMaterialDefinition>							m_Material;
};


text:
CREATE TABLE [SecurityModule].[SystemAccount]
(
	[SystemAccountKey] UNIQUEIDENTIFIER NOT NULL,
	[OrganizationKey] UNIQUEIDENTIFIER NOT NULL,
	[StaffKey] UNIQUEIDENTIFIER NULL,
	[PatientKey] UNIQUEIDENTIFIER NULL,
	[Identifier] NVARCHAR(100) NOT NULL,
	[Email] NVARCHAR(100) NOT NULL,
	PRIMARY KEY CLUSTERED([SystemAccountKey] ASC),
);
GO
CREATE NONCLUSTERED INDEX [SystemAccount_OrganizationKey_IDX]
	ON [SecurityModule].[SystemAccount]([OrganizationKey] ASC);


text:
<?php

namespace Ublaboo\DataGrid\DataSource;

use Nette\Utils\Strings;
use Nextras\Orm\Collection\ICollection;
use Nextras\Orm\Mapper\Dbal\DbalCollection;
use Ublaboo\DataGrid\Exception\DataGridDateTimeHelperException;
use Ublaboo\DataGrid\Filter;
use Ublaboo\DataGrid\Utils\ArraysHelper;
use Ublaboo\DataGrid\Utils\DateTimeHelper;
use Ublaboo\DataGrid\Utils\Sorting;

class NextrasDataSource extends FilterableDataSource implements IDataSource
{

	/**
	 * @var DbalCollection
	 */
	protected $data_source;

	/**
	 * @var array
	 */
	protected $data = [];

	/**
	 * @var string
	 */
	protected $primary_key;

	/**
	 * @param ICollection  $data_source
	 * @param string       $primary_key
	 */
	public function __construct(ICollection $data_source, $primary_key)
	{
		$this->data_source = $data_source;
		$this->primary_key = $primary_key;
	}

	/********************************************************************************
	 *                          IDataSource implementation                          *
	 ********************************************************************************/

	/**
	 * Get count of data
	 * @return int
	 */
	public function getCount()
	{
		return $this->data_source->countStored();
	}

	/**
	 * Get the data
	 * @return array
	 */
	public function getData()
	{
		/**
		 * Paginator is better if the query uses ManyToMany associations
		 */
		return $this->data ?: $this->data_source->fetchAll();
	}

	/**
	 * Filter data - get one row
	 * @param array $condition
	 * @return static
	 */
	public function filterOne(array $condition)
	{
		$cond = [];
		foreach ($condition as $key => $value) {
			$cond[$this->prepareColumn($key)] = $value;
		}
		$this->data_source = $this->data_source->findBy($cond);

		return $this;
	}

	/**
	 * Filter by date
	 * @param  Filter\FilterDate $filter
	 * @return static
	 */
	public function applyFilterDate(Filter\FilterDate $filter)
	{
		foreach ($filter->getCondition() as $column => $value) {
			try {
				$date = DateTimeHelper::tryConvertToDateTime($value, [$filter->getPhpFormat()]);
				$date_end = clone $date;

				$this->data_source = $this->data_source->findBy([
					$this->prepareColumn($column) . '>=' => $date->setTime(0, 0, 0),
					$this->prepareColumn($column) . '<=' => $date_end->setTime(23, 59, 59),
				]);
			} catch (DataGridDateTimeHelperException $ex) {
				// ignore the invalid filter value
			}
		}

		return $this;
	}

	/**
	 * Filter by date range
	 * @param  Filter\FilterDateRange $filter
	 * @return void
	 */
	public function applyFilterDateRange(Filter\FilterDateRange $filter)
	{
		$conditions = $filter->getCondition();

		$value_from = $conditions[$filter->getColumn()]['from'];
		$value_to = $conditions[$filter->getColumn()]['to'];

		$dataCondition = [];
		if ($value_from) {
			try {
				$date_from = DateTimeHelper::tryConvertToDateTime($value_from, [$filter->getPhpFormat()]);
				$dataCondition[$this->prepareColumn($filter->getColumn()) . '>='] = $date_from->setTime(0, 0, 0);
			} catch (DataGridDateTimeHelperException $ex) {
				// ignore the invalid filter value
			}
		}

		if ($value_to) {
			try {
				$date_to = DateTimeHelper::tryConvertToDateTime($value_to, [$filter->getPhpFormat()]);
				$dataCondition[$this->prepareColumn($filter->getColumn()) . '<='] = $date_to->setTime(23, 59, 59);
			} catch (DataGridDateTimeHelperException $ex) {
				// ignore the invalid filter value
			}
		}

		if (!empty($dataCondition)) {
			$this->data_source = $this->data_source->findBy($dataCondition);
		}
	}

	/**
	 * Filter by range
	 * @param  Filter\FilterRange $filter
	 * @return void
	 */
	public function applyFilterRange(Filter\FilterRange $filter)
	{
		$conditions = $filter->getCondition();

		$value_from = $conditions[$filter->getColumn()]['from'];
		$value_to = $conditions[$filter->getColumn()]['to'];

		$dataCondition = [];

		if ($value_from) {
			$dataCondition[$this->prepareColumn($filter->getColumn()) . '>='] = $value_from;
		}

		if ($value_to) {
			$dataCondition[$this->prepareColumn($filter->getColumn()) . '<='] = $value_to;
		}

		if (!empty($dataCondition)) {
			$this->data_source = $this->data_source->findBy($dataCondition);
		}
	}

	/**
	 * Filter by keyword
	 * @param  Filter\FilterText $filter
	 * @return void
	 */
	public function applyFilterText(Filter\FilterText $filter)
	{
		$condition = $filter->getCondition();
		$expr = '(';
		$params = [];

		foreach ($condition as $column => $value) {
			if ($filter->isExactSearch()) {
				$expr .= '%column = %s OR ';
				$params[] = $column;
				$params[] = "$value";
				continue;
			}

			if ($filter->hasSplitWordsSearch() === false) {
				$words = [$value];
			} else {
				$words = explode(' ', $value);
			}

			foreach ($words as $word) {
				$expr .= '%column LIKE %s OR ';
				$params[] = $column;
				$params[] = "%$word%";
			}
		}

		$expr = preg_replace('/ OR $/', ')', $expr);

		array_unshift($params, $expr);

		call_user_func_array([$this->data_source->getQueryBuilder(), 'andWhere'], $params);
	}

	/**
	 * Filter by multi select value
	 * @param  Filter\FilterMultiSelect $filter
	 * @return void
	 */
	public function applyFilterMultiSelect(Filter\FilterMultiSelect $filter)
	{
		$this->data_source = $this->data_source->findBy([$this->prepareColumn($filter->getColumn()) => $filter->getValue()]);
	}

	/**
	 * Filter by select value
	 * @param  Filter\FilterSelect $filter
	 * @return void
	 */
	public function applyFilterSelect(Filter\FilterSelect $filter)
	{
		$this->data_source = $this->data_source->findBy([$this->prepareColumn($filter->getColumn()) => $filter->getValue()]);
	}

	/**
	 * Apply limit and offset on data
	 * @param int $offset
	 * @param int $limit
	 * @return static
	 */
	public function limit($offset, $limit)
	{
		$this->data_source = $this->data_source->limitBy($limit, $offset);

		return $this;
	}

	/**
	 * Sort data
	 * @param  Sorting $sorting
	 * @return static
	 */
	public function sort(Sorting $sorting)
	{
		if (is_callable($sorting->getSortCallback())) {
			call_user_func(
				$sorting->getSortCallback(),
				$this->data_source,
				$sorting->getSort()
			);

			return $this;
		}

		$sort = $sorting->getSort();

		if (!empty($sort)) {
			foreach ($sort as $column => $order) {
				$this->data_source = $this->data_source->orderBy($this->prepareColumn($column), $order);
			}
		} else {
			/**
			 * Has the statement already a order by clause?
			 */
			$order = $this->data_source->getQueryBuilder()->getClause('order');

			if (ArraysHelper::testEmpty($order)) {
				$this->data_source = $this->data_source->orderBy($this->prepareColumn($this->primary_key));
			}
		}

		return $this;
	}

		/**
		 * Adjust column from DataGrid 'foreignKey.column' to Nextras 'this->foreignKey->column'
		 * @param string $column
		 * @return string
		 */
		private function prepareColumn($column)
		{
			if (Strings::contains($column, '.')) {
				return 'this->' . str_replace('.', '->', $column);
			}
			return $column;
		}
}


text:
'use strict';

// ECMAScript 5.1: 15.12 The JSON Object

function JSON_parse(thisValue, argumentsList) {
	var text = argumentsList[0];
	var reviver = argumentsList[1];
	var JText = ToString(text);
	var unfiltered = theJSONParser.readJSONText(JText);
	if (IsCallable(reviver) === true) {
		var root = Object_Construct([]);
		root.DefineOwnProperty("", PropertyDescriptor({
			Value : unfiltered,
			Writable : true,
			Enumerable : true,
			Configurable : true
		}), false);
		return Walk(root, "");
	}
	else return unfiltered;

	function Walk(holder, name) {
		var val = holder.Get(name);
		if (Type(val) === "Object") {
			if (val.Class === "Array") {
				var I = 0;
				var len = val.Get("length");
				while (I < len) {
					var newElement = Walk(val, ToString(I));
					if (newElement === undefined) {
						val.Delete(ToString(I), false);
					}
					else {
						val.DefineOwnProperty(ToString(I), PropertyDescriptor({
							Value : newElement,
							Writable : true,
							Enumerable : true,
							Configurable : true
						}), false);
					}
					I++;
				}
			}
			else {
				var keys = [];
				var next = val.enumerator(true, true);
				var P;
				while ((P = next()) !== undefined) {
					keys.push(P);
				}
				for (var i = 0; i < keys.length; i++) {
					var P = keys[i];
					var newElement = Walk(val, P);
					if (newElement === undefined) {
						val.Delete(P, false);
					}
					else {
						val.DefineOwnProperty(P, PropertyDescriptor({
							Value : newElement,
							Writable : true,
							Enumerable : true,
							Configurable : true
						}), false);
					}
				}
			}
		}
		return reviver.Call(holder, [ name, val ]);
	}
}

var theJSONParser = JSONParser();

function JSONParser() {
	return {
		readJSONText : readJSONText,
	};

	var source;
	var current;
	var currentPos;

	function readJSONText(text) {
		source = text;
		currentPos = 0;
		current = source[0];
		skipJSONWhiteSpaces();
		var value = readJSONValue();
		skipJSONWhiteSpaces();
		if (current !== undefined) throw VMSyntaxError();
		return value;
	}

	function readJSONValue() {
		if (current === 'n') return readJSONNullLiteral();
		else if (current === 't' || current === 'f') return readJSONBooleanLiteral();
		else if (current === '{') return readJSONObject();
		else if (current === '[') return readJSONArray();
		else if (current === '"') return readJSONString();
		return readJSONNumber();
	}

	function readJSONObject() {
		var obj = Object_Construct([]);
		expecting('{');
		skipJSONWhiteSpaces();
		if (current == '}') {
			proceed();
			return obj;
		}
		while (true) {
			skipJSONWhiteSpaces();
			var key = readJSONString();
			skipJSONWhiteSpaces();
			expecting(':');
			skipJSONWhiteSpaces();
			var value = readJSONValue();
			var desc = PropertyDescriptor({
				Value : value,
				Writable : true,
				Enumerable : true,
				Configurable : true
			});
			obj.DefineOwnProperty(key, desc, false);
			skipJSONWhiteSpaces();
			if (current == '}') {
				proceed();
				return obj;
			}
			expecting(',');
		}
	}

	function readJSONArray() {
		var obj = Array_Construct([]);
		expecting('[');
		skipJSONWhiteSpaces();
		if (current == ']') {
			proceed();
			return obj;
		}
		var index = 0;
		while (true) {
			skipJSONWhiteSpaces();
			var value = readJSONValue();
			var desc = PropertyDescriptor({
				Value : value,
				Writable : true,
				Enumerable : true,
				Configurable : true
			});
			obj.DefineOwnProperty(ToString(index), desc, false);
			index++;
			skipJSONWhiteSpaces();
			if (current == ']') {
				proceed();
				return obj;
			}
			expecting(',');
		}
	}

	function readJSONString() {
		expecting('"');
		var buffer = [];
		while (true) {
			if (current == undefined) throw VMSyntaxError();
			else if (current == '"') {
				proceed();
				return join(buffer);
			}
			else if (current == '\\') {
				var c = readJSONEscapeSequence();
				buffer.push(c);
			}
			else if (toCharCode(current) <= 0x001F) throw VMSyntaxError();
			else {
				buffer.push(current);
				proceed();
			}
		}
	}

	function readJSONEscapeSequence() {
		expecting('\\');
		var c = proceed();
		switch (c) {
		case '"':
		case '/':
		case '\\':
			return c;
		case 'b':
			return '\u0008';
		case 'f':
			return '\u000C';
		case 'n':
			return '\u000A';
		case 'r':
			return '\u000D';
		case 't':
			return '\u0009';
		case 'u':
			var x = 0;
			for (var i = 0; i < 4; i++) {
				if (!isHexDigitChar(current)) throw VMSyntaxError();
				x = (x << 4) + mvDigitChar(current);
				proceed();
			}
			return fromCharCode(x);
		}
		throw VMSyntaxError();
	}

	function readJSONNumber() {
		var startPos = currentPos;
		if (current === '-') {
			proceed();
		}
		if (current === '0') {
			proceed();
			if (isDecimalDigitChar(current)) throw VMSyntaxError();
		}
		else {
			if (!isDecimalDigitChar(current)) throw VMSyntaxError();
			while (isDecimalDigitChar(current)) {
				proceed();
			}
		}
		if (current === '.') {
			proceed();
			while (isDecimalDigitChar(current)) {
				proceed();
			}
		}
		if (current === 'E' || current === 'e') {
			proceed();
			if (current === '+' || current === '-') {
				proceed();
			}
			if (!isDecimalDigitChar(current)) throw VMSyntaxError();
			while (isDecimalDigitChar(current)) {
				proceed();
			}
		}
		if (startPos === currentPos) throw VMSyntaxError();
		return ToNumber(source.substring(startPos, currentPos));
	}

	function readJSONNullLiteral() {
		if (source.substring(currentPos, currentPos + 4) === "null") {
			proceed(4);
			return null;
		}
		throw VMSyntaxError();
	}

	function readJSONBooleanLiteral() {
		if (source.substring(currentPos, currentPos + 4) === "true") {
			proceed(4);
			return true;
		}
		if (source.substring(currentPos, currentPos + 5) === "false") {
			proceed(5);
			return false;
		}
		throw VMSyntaxError();
	}

	function skipJSONWhiteSpaces() {
		while (true) {
			switch (current) {
			case '\u0009': // <TAB>
			case '\u000D': // <CR>
			case '\u000A': // <LF>
			case '\u0020': // <SP>
				proceed();
				break;
			default:
				return;
			}
		}
	}

	function expecting(c) {
		if (c !== current) throw VMSyntaxError();
		proceed();
	}

	function proceed(count) {
		var c = current;
		if (count === undefined) {
			count = 1;
		}
		for (var i = 0; i < count; i++) {
			if (current === undefined) throw VMSyntaxError();
			current = source[++currentPos];
		}
		return c;
	}
}

function JSON_stringify(thisValue, argumentsList) {
	var value = argumentsList[0];
	var replacer = argumentsList[1];
	var space = argumentsList[2];
	var stack = [];
	var indent = "";
	var PropertyList = undefined;
	var ReplacerFunction = undefined;
	if (Type(replacer) === "Object") {
		if (IsCallable(replacer) === true) {
			var ReplacerFunction = replacer;
		}
		else if (replacer.Class === "Array") {
			var PropertyList = [];
			var length = replacer.Get("length");
			for (var i = 0; i < length; i++) {
				if (replacer.HasOwnProperty(ToString(i)) === false) {
					continue;
				}
				var v = replacer.Get(ToString(i));
				var item = undefined;
				if (Type(v) === "String") {
					var item = v;
				}
				else if (Type(v) === "Number") {
					var item = ToString(v);
				}
				else if (Type(v) === "Object") {
					if (v.Class === "String" || v.Class === "Number") {
						var item = ToString(v);
					}
				}
				if (item !== undefined && isIncluded(item, PropertyList) === false) {
					PropertyList.push(item);
				}
			}
		}
	}
	if (Type(space) === "Object") {
		if (space.Class === "Number") {
			var space = ToNumber(space);
		}
		else if (space.Class === "String") {
			var space = ToString(space);
		}
	}
	if (Type(space) === "Number") {
		var space = min(10, ToInteger(space));
		var gap = "";
		for (var i = 0; i < space; i++) {
			gap = gap + " ";
		}
	}
	else if (Type(space) === "String") {
		if (space.length <= 10) {
			var gap = space

		}
		else {
			var gap = space.substring(0, 10);
		}
	}
	else {
		var gap = "";
	}
	var wrapper = Object_Construct([]);
	wrapper.DefineOwnProperty("", PropertyDescriptor({
		Value : value,
		Writable : true,
		Enumerable : true,
		Configurable : true
	}), false);
	return Str("", wrapper);

	function Str(key, holder) {
		var value = holder.Get(key);
		if (Type(value) === "Object") {
			var toJSON = value.Get("toJSON");
			if (IsCallable(toJSON) === true) {
				var value = toJSON.Call(value, [ key ]);
			}
		}
		if (ReplacerFunction !== undefined) {
			var value = ReplacerFunction.Call(holder, [ key, value ]);
		}
		if (Type(value) === "Object") {
			if (value.Class === "Number") {
				var value = ToNumber(value);
			}
			else if (value.Class === "String") {
				var value = ToString(value);
			}
			else if (value.Class === "Boolean") {
				var value = value.PrimitiveValue;
			}
		}
		if (value === null) return "null";
		if (value === true) return "true";
		if (value === false) return "false";
		if (Type(value) === "String") return Quote(value);
		if (Type(value) === "Number") {
			if (isFinite(value)) return ToString(value);
			else return "null";
		}
		if (Type(value) === "Object" && IsCallable(value) === false) {
			if (value.Class === "Array") return JA(value);
			else return JO(value);
		}
		return undefined;
	}

	function Quote(value) {
		var product = [];
		product.push('"');
		for (var i = 0; i < value.length; i++) {
			var C = value[i];
			if (C === '"') {
				product.push('\\"');
			}
			else if (C === '\\') {
				product.push('\\\\');
			}
			else if (C === '\b') {
				product.push('\\b');
			}
			else if (C === '\f') {
				product.push('\\f');
			}
			else if (C === '\n') {
				product.push('\\n');
			}
			else if (C === '\r') {
				product.push('\\r');
			}
			else if (C === '\t') {
				product.push('\\t');
			}
			else if (toCharCode(C) < 0x20) {
				var x = toCharCode(C);
				var hex = toDigitChar(x >> 12) + toDigitChar(15 & (x >> 8)) + toDigitChar(15 & (x >> 4)) + toDigitChar(15 & x);
				product.push('\\u' + hex);
			}
			else {
				product.push(C);
			}
		}
		product.push('"');
		return join(product);
	}

	function JO(value) {
		if (isIncluded(value, stack)) throw VMTypeError();
		stack.push(value);
		var stepback = indent;
		indent = indent + gap;
		if (PropertyList !== undefined) {
			var K = PropertyList;
		}
		else {
			var K = [];
			var next = value.enumerator(true, true);
			var P;
			while ((P = next()) !== undefined) {
				K.push(P);
			}
		}
		var partial = [];
		for (var i = 0; i < K.length; i++) {
			var P = K[i];
			var strP = Str(P, value);
			if (strP !== undefined) {
				var member = Quote(P);
				var member = member + ':';
				if (gap !== "") {
					var member = member + ' ';
				}
				var member = member + strP;
			}
			partial.push(member);
		}
		if (partial === empty) {
			var final = "{}";
		}
		else if (gap === "") {
			var properties = partial.join(',');
			var final = "{" + properties + "}";
		}
		else {
			var separator = ',' + '\n' + indent;
			var properties = partial.join(separator);
			var final = "{" + '\n' + indent + properties + '\n' + stepback + "}";
		}
		stack.pop();
		indent = stepback;
		return final;
	}

	function JA(value) {
		if (isIncluded(value, stack)) throw VMTypeError();
		stack.push(value);
		var stepback = indent;
		indent = indent + gap;
		var partial = [];
		var len = value.Get("length");
		var index = 0;
		while (index < len) {
			var strP = Str(ToString(index), value);
			if (strP === undefined) {
				partial.push("null");
			}
			else {
				partial.push(strP);
			}
			index++;
		}
		if (partial === empty) {
			var final = "[]";
		}
		else if (gap === "") {
			var properties = partial.join(',');
			var final = "[" + properties + "]";
		}
		else {
			var separator = ',' + '\n' + indent;
			var properties = partial.join(separator);
			var final = "[" + '\n' + indent + properties + '\n' + stepback + "]";
		}
		stack.pop();
		indent = stepback;
		return final;
	}

}


text:
/**
 * Reflect CSS value: takes rule's value under caret and pastes it for the same
 * rules with vendor prefixes
 */
if (typeof module === 'object' && typeof define !== 'function') {
	var define = function (factory) {
		module.exports = factory(require, exports, module);
	};
}

define(function(require, exports, module) {
	var handlerList = require('../assets/handlerList');
	var prefs = require('../assets/preferences');
	var cssResolver = require('../resolver/css');
	var cssEditTree = require('../editTree/css');
	var utils = require('../utils/common');
	var actionUtils = require('../utils/action');
	var editorUtils = require('../utils/editor');
	var cssGradient = require('../resolver/cssGradient');

	prefs.define('css.reflect.oldIEOpacity', false, 'Support IE6/7/8 opacity notation, e.g. filter:alpha(opacity=...).\
		Note that CSS3 and SVG also provides filter property so this option is disabled by default.')

	/**
	 * @type HandlerList List of registered handlers
	 */
	var handlers = handlerList.create();

	function doCSSReflection(editor) {
		var outputInfo = editorUtils.outputInfo(editor);
		var caretPos = editor.getCaretPos();

		var cssRule = cssEditTree.parseFromPosition(outputInfo.content, caretPos);
		if (!cssRule) return;

		var property = cssRule.itemFromPosition(caretPos, true);
		// no property under cursor, nothing to reflect
		if (!property) return;

		var oldRule = cssRule.source;
		var offset = cssRule.options.offset;
		var caretDelta = caretPos - offset - property.range().start;

		handlers.exec(false, [property]);

		if (oldRule !== cssRule.source) {
			return {
				data:  cssRule.source,
				start: offset,
				end:   offset + oldRule.length,
				caret: offset + property.range().start + caretDelta
			};
		}
	}

	/**
	 * Returns regexp that should match reflected CSS property names
	 * @param {String} name Current CSS property name
	 * @return {RegExp}
	 */
	function getReflectedCSSName(name) {
		name = cssEditTree.baseName(name);
		var vendorPrefix = '^(?:\\-\\w+\\-)?', m;

		if ((name == 'opacity' || name == 'filter') && prefs.get('css.reflect.oldIEOpacity')) {
			return new RegExp(vendorPrefix + '(?:opacity|filter)$');
		} else if ((m = name.match(/^border-radius-(top|bottom)(left|right)/))) {
			// Mozilla-style border radius
			return new RegExp(vendorPrefix + '(?:' + name + '|border-' + m[1] + '-' + m[2] + '-radius)$');
		} else if ((m = name.match(/^border-(top|bottom)-(left|right)-radius/))) {
			return new RegExp(vendorPrefix + '(?:' + name + '|border-radius-' + m[1] + m[2] + ')$');
		}

		return new RegExp(vendorPrefix + name + '$');
	}

	/**
	 * Reflects inner CSS properites in given value
	 * agains name's vendor prefix. In other words, it tries
	 * to modify `transform 0.2s linear` value for `-webkit-transition`
	 * property
	 * @param  {String} name  Reciever CSS property name
	 * @param  {String} value New property value
	 * @return {String}
	 */
	function reflectValueParts(name, value) {
		// detects and updates vendor-specific properties in value,
		// e.g. -webkit-transition: -webkit-transform

		var reVendor = /^\-(\w+)\-/;
		var propPrefix = reVendor.test(name) ? RegExp.$1.toLowerCase() : '';
		var parts = cssEditTree.findParts(value);

		parts.reverse();
		parts.forEach(function(part) {
			var partValue = part.substring(value).replace(reVendor, '');
			var prefixes = cssResolver.vendorPrefixes(partValue);
			if (prefixes) {
				// if prefixes are not null then given value can
				// be resolved against Can I Use database and may or
				// may not contain prefixed variant
				if (propPrefix && ~prefixes.indexOf(propPrefix)) {
					partValue = '-' + propPrefix + '-' + partValue;
				}

				value = utils.replaceSubstring(value, partValue, part);
			}
		});

		return value;
	}

	/**
	 * Reflects value from donor into receiver
	 * @param {CSSProperty} donor Donor CSS property from which value should
	 * be reflected
	 * @param {CSSProperty} receiver Property that should receive reflected
	 * value from donor
	 */
	function reflectValue(donor, receiver) {
		var value = getReflectedValue(donor.name(), donor.value(),
				receiver.name(), receiver.value());

		value = reflectValueParts(receiver.name(), value);
		receiver.value(value);
	}

	/**
	 * Returns value that should be reflected for refName CSS property
	 * from curName property. This function is used for special cases,
	 * when the same result must be achieved with different properties for different
	 * browsers. For example: opаcity:0.5; → filter:alpha(opacity=50);

	 *
	 * This function does value conversion between different CSS properties
	 *
	 * @param {String} curName Current CSS property name
	 * @param {String} curValue Current CSS property value
	 * @param {String} refName Receiver CSS property's name
	 * @param {String} refValue Receiver CSS property's value
	 * @return {String} New value for receiver property
	 */
	function getReflectedValue(curName, curValue, refName, refValue) {
		curName = cssEditTree.baseName(curName);
		refName = cssEditTree.baseName(refName);

		if (curName == 'opacity' && refName == 'filter') {
			return refValue.replace(/opacity=[^)]*/i, 'opacity=' + Math.floor(parseFloat(curValue) * 100));
		} else if (curName == 'filter' && refName == 'opacity') {
			var m = curValue.match(/opacity=([^)]*)/i);
			return m ? utils.prettifyNumber(parseInt(m[1], 10) / 100) : refValue;
		}

		return curValue;
	}

	module = module || {};
	module.exports = {
		reflectCSSValueAction: function(editor) {
			if (editor.getSyntax() != 'css') {
				return false;
			}

			return actionUtils.compoundUpdate(editor, doCSSReflection(editor));
		},

		_defaultHandler: function(property) {
			var reName = getReflectedCSSName(property.name());
			property.parent.list().forEach(function(p) {
				if (reName.test(p.name())) {
					reflectValue(property, p);
				}
			});
		},

		/**
		 * Adds custom reflect handler. The passed function will receive matched
		 * CSS property (as CSSEditElement object) and should
		 * return true if it was performed successfully (handled
		 * reflection), false otherwise.
		 * @param {Function} fn
		 * @param {Object} options
		 */
		addHandler: function(fn, options) {
			handlers.add(fn, options);
		},

		/**
		 * Removes registered handler
		 * @returns
		 */
		removeHandler: function(fn) {
			handlers.remove(fn);
		}
	};

	// XXX add default handlers
	handlers.add(module.exports._defaultHandler.bind(module.exports), {order: -1});
	handlers.add(cssGradient.reflectValueHandler.bind(cssGradient));

	return module.exports;
});


text:
{{projectName}} {{sprintName}}

Loading..

Loading..

Issues by Issue Type

					<d3-pie-chart data="issuesByTypes" label="name"></d3-pie-chart>

Issues by Components

					<d3-pie-chart data="issuesByComponents" label="name"></d3-pie-chart>

Fixed Issues by Issue Type

					<d3-pie-chart data="closedIssuesByTypes" label="name"></d3-pie-chart>

Fixed Issues by Components

					<d3-pie-chart data="closedIssuesByComponents" label="name"></d3-pie-chart>


text:
// Copyright (c) 2012 Ecma International.  All rights reserved.
// Ecma International makes this code available under the terms and conditions set
// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
// "Use Terms").   Any redistribution of this code must retain the above
// copyright and this notice and otherwise comply with the Use Terms.

/*---
es5id: 15.2.3.5-4-191
description: >
    Object.create - one property in 'Properties' is a Function object
    which implements its own [[Get]] method to access the 'writable'
    property (8.10.5 step 6.a)
includes: [runTestCase.js]
---*/

function testcase() {

        var Func = function (a, b) {
            return a + b;
        };

        var fun = new Func();
        fun.writable = true;

        var newObj = Object.create({}, {
            prop: fun
        });

        var beforeWrite = (newObj.hasOwnProperty("prop") && typeof (newObj.prop) === "undefined");

        newObj.prop = "isWritable";

        var afterWrite = (newObj.prop === "isWritable");

        return beforeWrite === true && afterWrite === true;
    }
runTestCase(testcase);


text:
.class synthetic Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;
.super Ljava/lang/Object;
.source "SimCardAuthenticationService.java"

# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/orange/authentication/simcard/SimCardAuthenticationService;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x1008
    name = null
.end annotation

# static fields
.field static final synthetic $SwitchMap$com$android$internal$telephony$IccCardApplication$AppType:[I

.field static final synthetic $SwitchMap$com$android$internal$telephony$IccCardStatus$CardState:[I

.field static final synthetic $SwitchMap$com$orange$authentication$simcard$SimCardAuthenticationManager$SimCardType:[I

# direct methods
.method static constructor <clinit>()V
    .locals 3

    .prologue
    .line 693
    invoke-static {}, Lcom/android/internal/telephony/IccCardStatus$CardState;->values()[Lcom/android/internal/telephony/IccCardStatus$CardState;

    move-result-object v0

    array-length v0, v0

    new-array v0, v0, [I

    sput-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$android$internal$telephony$IccCardStatus$CardState:[I

    :try_start_0
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$android$internal$telephony$IccCardStatus$CardState:[I

    sget-object v1, Lcom/android/internal/telephony/IccCardStatus$CardState;->CARDSTATE_ABSENT:Lcom/android/internal/telephony/IccCardStatus$CardState;

    invoke-virtual {v1}, Lcom/android/internal/telephony/IccCardStatus$CardState;->ordinal()I

    move-result v1

    const/4 v2, 0x1

    aput v2, v0, v1
    :try_end_0
    .catch Ljava/lang/NoSuchFieldError; {:try_start_0 .. :try_end_0} :catch_e

    :goto_0
    :try_start_1
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$android$internal$telephony$IccCardStatus$CardState:[I

    sget-object v1, Lcom/android/internal/telephony/IccCardStatus$CardState;->CARDSTATE_ERROR:Lcom/android/internal/telephony/IccCardStatus$CardState;

    invoke-virtual {v1}, Lcom/android/internal/telephony/IccCardStatus$CardState;->ordinal()I

    move-result v1

    const/4 v2, 0x2

    aput v2, v0, v1
    :try_end_1
    .catch Ljava/lang/NoSuchFieldError; {:try_start_1 .. :try_end_1} :catch_d

    :goto_1
    :try_start_2
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$android$internal$telephony$IccCardStatus$CardState:[I

    sget-object v1, Lcom/android/internal/telephony/IccCardStatus$CardState;->CARDSTATE_PRESENT:Lcom/android/internal/telephony/IccCardStatus$CardState;

    invoke-virtual {v1}, Lcom/android/internal/telephony/IccCardStatus$CardState;->ordinal()I

    move-result v1

    const/4 v2, 0x3

    aput v2, v0, v1
    :try_end_2
    .catch Ljava/lang/NoSuchFieldError; {:try_start_2 .. :try_end_2} :catch_c

    .line 713
    :goto_2
    invoke-static {}, Lcom/android/internal/telephony/IccCardApplication$AppType;->values()[Lcom/android/internal/telephony/IccCardApplication$AppType;

    move-result-object v0

    array-length v0, v0

    new-array v0, v0, [I

    sput-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$android$internal$telephony$IccCardApplication$AppType:[I

    :try_start_3
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$android$internal$telephony$IccCardApplication$AppType:[I

    sget-object v1, Lcom/android/internal/telephony/IccCardApplication$AppType;->APPTYPE_CSIM:Lcom/android/internal/telephony/IccCardApplication$AppType;

    invoke-virtual {v1}, Lcom/android/internal/telephony/IccCardApplication$AppType;->ordinal()I

    move-result v1

    const/4 v2, 0x1

    aput v2, v0, v1
    :try_end_3
    .catch Ljava/lang/NoSuchFieldError; {:try_start_3 .. :try_end_3} :catch_b

    :goto_3
    :try_start_4
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$android$internal$telephony$IccCardApplication$AppType:[I

    sget-object v1, Lcom/android/internal/telephony/IccCardApplication$AppType;->APPTYPE_RUIM:Lcom/android/internal/telephony/IccCardApplication$AppType;

    invoke-virtual {v1}, Lcom/android/internal/telephony/IccCardApplication$AppType;->ordinal()I

    move-result v1

    const/4 v2, 0x2

    aput v2, v0, v1
    :try_end_4
    .catch Ljava/lang/NoSuchFieldError; {:try_start_4 .. :try_end_4} :catch_a

    :goto_4
    :try_start_5
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$android$internal$telephony$IccCardApplication$AppType:[I

    sget-object v1, Lcom/android/internal/telephony/IccCardApplication$AppType;->APPTYPE_SIM:Lcom/android/internal/telephony/IccCardApplication$AppType;

    invoke-virtual {v1}, Lcom/android/internal/telephony/IccCardApplication$AppType;->ordinal()I

    move-result v1

    const/4 v2, 0x3

    aput v2, v0, v1
    :try_end_5
    .catch Ljava/lang/NoSuchFieldError; {:try_start_5 .. :try_end_5} :catch_9

    :goto_5
    :try_start_6
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$android$internal$telephony$IccCardApplication$AppType:[I

    sget-object v1, Lcom/android/internal/telephony/IccCardApplication$AppType;->APPTYPE_UNKNOWN:Lcom/android/internal/telephony/IccCardApplication$AppType;

    invoke-virtual {v1}, Lcom/android/internal/telephony/IccCardApplication$AppType;->ordinal()I

    move-result v1

    const/4 v2, 0x4

    aput v2, v0, v1
    :try_end_6
    .catch Ljava/lang/NoSuchFieldError; {:try_start_6 .. :try_end_6} :catch_8

    :goto_6
    :try_start_7
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$android$internal$telephony$IccCardApplication$AppType:[I

    sget-object v1, Lcom/android/internal/telephony/IccCardApplication$AppType;->APPTYPE_USIM:Lcom/android/internal/telephony/IccCardApplication$AppType;

    invoke-virtual {v1}, Lcom/android/internal/telephony/IccCardApplication$AppType;->ordinal()I

    move-result v1

    const/4 v2, 0x5

    aput v2, v0, v1
    :try_end_7
    .catch Ljava/lang/NoSuchFieldError; {:try_start_7 .. :try_end_7} :catch_7

    .line 484
    :goto_7
    invoke-static {}, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->values()[Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;

    move-result-object v0

    array-length v0, v0

    new-array v0, v0, [I

    sput-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$orange$authentication$simcard$SimCardAuthenticationManager$SimCardType:[I

    :try_start_8
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$orange$authentication$simcard$SimCardAuthenticationManager$SimCardType:[I

    sget-object v1, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->USIM:Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;

    invoke-virtual {v1}, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->ordinal()I

    move-result v1

    const/4 v2, 0x1

    aput v2, v0, v1
    :try_end_8
    .catch Ljava/lang/NoSuchFieldError; {:try_start_8 .. :try_end_8} :catch_6

    :goto_8
    :try_start_9
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$orange$authentication$simcard$SimCardAuthenticationManager$SimCardType:[I

    sget-object v1, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->CSIM:Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;

    invoke-virtual {v1}, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->ordinal()I

    move-result v1

    const/4 v2, 0x2

    aput v2, v0, v1
    :try_end_9
    .catch Ljava/lang/NoSuchFieldError; {:try_start_9 .. :try_end_9} :catch_5

    :goto_9
    :try_start_a
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$orange$authentication$simcard$SimCardAuthenticationManager$SimCardType:[I

    sget-object v1, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->RUIM:Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;

    invoke-virtual {v1}, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->ordinal()I

    move-result v1

    const/4 v2, 0x3

    aput v2, v0, v1
    :try_end_a
    .catch Ljava/lang/NoSuchFieldError; {:try_start_a .. :try_end_a} :catch_4

    :goto_a
    :try_start_b
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$orange$authentication$simcard$SimCardAuthenticationManager$SimCardType:[I

    sget-object v1, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->SIM:Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;

    invoke-virtual {v1}, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->ordinal()I

    move-result v1

    const/4 v2, 0x4

    aput v2, v0, v1
    :try_end_b
    .catch Ljava/lang/NoSuchFieldError; {:try_start_b .. :try_end_b} :catch_3

    :goto_b
    :try_start_c
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$orange$authentication$simcard$SimCardAuthenticationManager$SimCardType:[I

    sget-object v1, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->ABSENT:Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;

    invoke-virtual {v1}, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->ordinal()I

    move-result v1

    const/4 v2, 0x5

    aput v2, v0, v1
    :try_end_c
    .catch Ljava/lang/NoSuchFieldError; {:try_start_c .. :try_end_c} :catch_2

    :goto_c
    :try_start_d
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$orange$authentication$simcard$SimCardAuthenticationManager$SimCardType:[I

    sget-object v1, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->UNKNOWN:Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;

    invoke-virtual {v1}, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->ordinal()I

    move-result v1

    const/4 v2, 0x6

    aput v2, v0, v1
    :try_end_d
    .catch Ljava/lang/NoSuchFieldError; {:try_start_d .. :try_end_d} :catch_1

    :goto_d
    :try_start_e
    sget-object v0, Lcom/orange/authentication/simcard/SimCardAuthenticationService$1;->$SwitchMap$com$orange$authentication$simcard$SimCardAuthenticationManager$SimCardType:[I

    sget-object v1, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->ERROR:Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;

    invoke-virtual {v1}, Lcom/orange/authentication/simcard/SimCardAuthenticationManager$SimCardType;->ordinal()I

    move-result v1

    const/4 v2, 0x7

    aput v2, v0, v1
    :try_end_e
    .catch Ljava/lang/NoSuchFieldError; {:try_start_e .. :try_end_e} :catch_0

    :goto_e
    return-void

    :catch_0
    move-exception v0

    goto :goto_e

    :catch_1
    move-exception v0

    goto :goto_d

    :catch_2
    move-exception v0

    goto :goto_c

    :catch_3
    move-exception v0

    goto :goto_b

    :catch_4
    move-exception v0

    goto :goto_a

    :catch_5
    move-exception v0

    goto :goto_9

    :catch_6
    move-exception v0

    goto :goto_8

    .line 713
    :catch_7
    move-exception v0

    goto :goto_7

    :catch_8
    move-exception v0

    goto :goto_6

    :catch_9
    move-exception v0

    goto :goto_5

    :catch_a
    move-exception v0

    goto/16 :goto_4

    :catch_b
    move-exception v0

    goto/16 :goto_3

    .line 693
    :catch_c
    move-exception v0

    goto/16 :goto_2

    :catch_d
    move-exception v0

    goto/16 :goto_1

    :catch_e
    move-exception v0

    goto/16 :goto_0
.end method


text:
package EDU.purdue.cs.bloat.reflect;

/**
 * Modifiers is an interface containing constants used as modifiers of classes,
 * fields, and methods.
 *
 * @author Nate Nystrom (<a
 *         href="mailto:nystrom@cs.purdue.edu">nystrom@cs.purdue.edu</a>)
 */
public interface Modifiers {
	/**
	 * The class, field, or method is declared public.
	 */
	public static final short PUBLIC = 0x0001;

	/**
	 * The class, field, or method is declared private.
	 */
	public static final short PRIVATE = 0x0002;

	/**
	 * The class, field, or method is declared protected.
	 */
	public static final short PROTECTED = 0x0004;

	/**
	 * The field or method is declared static.
	 */
	public static final short STATIC = 0x0008;

	/**
	 * The class, field, or method is declared final.
	 */
	public static final short FINAL = 0x0010;

	/**
	 * The class calls methods in the superclass.
	 */
	public static final short SUPER = 0x0020;

	/**
	 * The method is declared synchronized.
	 */
	public static final short SYNCHRONIZED = 0x0020;

	/**
	 * The field is declared volatile.
	 */
	public static final short VOLATILE = 0x0040;

	/**
	 * The field is declared transient.
	 */
	public static final short TRANSIENT = 0x0080;

	/**
	 * The method is declared native.
	 */
	public static final short NATIVE = 0x0100;

	/**
	 * The class is an interface.
	 */
	public static final short INTERFACE = 0x0200;

	/**
	 * The class or method is declared abstract.
	 */
	public static final short ABSTRACT = 0x0400;
}