Пример #1
0
void NativePlayerWnd::StreamGetURLNotify(	const char* url,
        const char* window,
        void*		notifyData )
{
    // The quick and easy solution - support for file loading only. But, in order
    // to bring some aura of respectability to this demo, it will be implemented
    // on a thread and simulating a network connection.

    // Remove the file: prefix
    const char* fname;
    char* cmd = SkipPrefix( (char*) url, "file://");
    if ( cmd )
        fname = cmd;
    else
        fname = url;

    // We now have an fname that may or may not be a valid file. Try to open it:
    FILE* fp = fopen( url, "rb" );
    if ( fp )
    {
#ifdef SIMULATE_STREAMING
        DWORD id;
        ThreadData* data = new ThreadData;

        data->fp = fp;
        data->notifyData = notifyData;
        data->hwnd = hwnd;
        data->url = CreateStr( (char*)url );

        CreateThread( 0, 0, StreamThread, data, 0, &id );
#else
        StreamData streamData;
        char block[256];
        int  read;

        StreamInNew( &streamData, (char*) url, notifyData );
        while ( read = fread( block, 1, 256, fp ) )
        {
            StreamInWrite( &streamData, &block, read );
        }
        StreamInDestroy( &streamData );
#endif
    }
}
Пример #2
0
bool MainVisitor::MatchType(const string& type, const char* source, const char** pSourceEnd)
{
    // try match type in source directly (clang "bool" type is "_Bool")
    if (SkipPrefix(source, type) || (type == "_Bool" && SkipPrefix(source, "bool")))
    {
        *pSourceEnd = source;
        return true;
    }

    const char* p = type.c_str();
    while (*p && *source)
    {
        if (SkipSpace(p) || SkipSpace(source))
        {
            continue;
        }

#define SKIP_EITHER_PREFIX(prefix) \
            (SkipPrefix(p, prefix) || SkipPrefix(source, prefix))
        if (SKIP_EITHER_PREFIX("const ") ||
            SKIP_EITHER_PREFIX("class ") ||
            SKIP_EITHER_PREFIX("struct ") ||
            SKIP_EITHER_PREFIX("union ") ||
            SKIP_EITHER_PREFIX("enum "))
        {
            continue;
        }
#undef SKIP_EITHER_PREFIX

        // type may contain [...] array specifier, while source has it after field name
        if (*p == '[')
        {
            while (*p && *p++ != ']');
            continue;
        }

        // skip <...> in both
        if (SkipTemplateParameters(p) || SkipTemplateParameters(source))
        {
            continue;
        }

        // type may contain fully qualified name but source may or may not
        const char* pSkipScopeType = strstr(p, "::");
        if (pSkipScopeType && !memchr(p, ' ', pSkipScopeType - p))
        {
            pSkipScopeType += 2;
            if (strncmp(source, p, pSkipScopeType - p) == 0)
            {
                source += pSkipScopeType - p;
            }
            p = pSkipScopeType;
            continue;
        }

        if (*p == *source)
        {
            while (*p && *source && *p == *source && !strchr("<>", *p))
            {
                ++p, ++source;
            }
            continue;
        }

        if (*p != *source)
        {
            return false;  // mismatch
        }
    }

    if (!*p && *source)  // type match completed and having remaining source
    {
        while (*(source - 1) == ' ') --source; // try to stop after a non-space char
        *pSourceEnd = source;
        return true;
    }

    return false;
}
Пример #3
0
bool SkipAlgPrefix(TStringBuf& keytext)
{
    return SkipPrefix(keytext, GetAlgPrefix());
}
Пример #4
0
bool SkipTomitaPrefix(TStringBuf& keytext)
{
    return SkipPrefix(keytext, GetTomitaPrefix());
}