Exemple #1
0
BOOL CLang::ChangeLang(UINT langID)
{
	if(langID == m_activeLang || langID >= m_langCount)//
	{
		return FALSE;
	}

	CString strLangFile;

	strLangFile.Format(theApp.ConvertAbsolutePath(_T("lang\\%s.txt")), m_langName[langID]);
	if(LoadStringFromFile(strLangFile))//加载
	{
		m_activeLang = langID;//
	}
	else
	{
		if(langID < 2)//
		{
			LoadDefaultString(langID==0);//
			m_activeLang = langID;
		}
		else
		{
			return FALSE;
		}
	}
	
	return TRUE;
}
    //
    // CreateShaders
    //
    void CSample03::CreateShaders()
    {
        Ptr<GL::CCgShader> VS, FS;
       
        string SourceStr = LoadStringFromFile( "../MEDIA/Cg/WVP.cg" );

        VS = new GL::CCgVertexShader( CG_SOURCE, SourceStr, CG_PROFILE_ARBVP1, "VS" );
        FS = new GL::CCgFragmentShader( CG_SOURCE, SourceStr, CG_PROFILE_ARBFP1, "FS" );

        m_CgWVP = new GL::CCgShadingProgram();
        m_CgWVP->AttachShader( VS );
        m_CgWVP->AttachShader( FS );
        m_CgWVP->Link();
        m_CgWVP->GetUniform( "WorldViewProj", &m_UWorldViewProj );
        m_CgWVP->GetUniform( "Color", &m_UColor );
    }
Exemple #3
0
bool Token::SerializeIn(wxFile* f)
{
    if (!LoadIntFromFile(f, (int*)&m_ParentIndex)) return false;
    if (!LoadStringFromFile(f, m_Type)) return false;
    if (!LoadStringFromFile(f, m_ActualType)) return false;
    if (!LoadStringFromFile(f, m_Name)) return false;
    if (!LoadStringFromFile(f, m_DisplayName)) return false;
    if (!LoadStringFromFile(f, m_Args)) return false;
    if (!LoadStringFromFile(f, m_AncestorsString)) return false;
    if (!LoadStringFromFile(f, m_Filename)) return false;
    if (!LoadIntFromFile(f, (int*)&m_Line)) return false;
    if (!LoadStringFromFile(f, m_ImplFilename)) return false;
    if (!LoadIntFromFile(f, (int*)&m_ImplLine)) return false;
    if (!LoadIntFromFile(f, (int*)&m_Scope)) return false;
    if (!LoadIntFromFile(f, (int*)&m_TokenKind)) return false;
    if (!LoadIntFromFile(f, (int*)&m_IsOperator)) return false;
    if (!LoadIntFromFile(f, (int*)&m_IsLocal)) return false;

    m_AncestorsIndices.Clear();
    int count = 0;
    LoadIntFromFile(f, &count);
    for (int i = 0; i < count; ++i)
    {
        int idx = 0;
        LoadIntFromFile(f, &idx);
        m_AncestorsIndices.Add(idx);
    }

    m_ChildrenIndices.Clear();
    count = 0;
    LoadIntFromFile(f, &count);
    for (int i = 0; i < count; ++i)
    {
        int idx = 0;
        LoadIntFromFile(f, &idx);
        m_ChildrenIndices.Add(idx);
    }
    // parent-child relationship is set in a post-processing step
    return true;
}
Exemple #4
0
bool Token::SerializeIn(std::istream& f)
{
    bool result = true;
    do
    {
        if (!LoadIntFromFile(f, (int*)&m_Self))
        {
            result = false;
            break;
        }
        if (!LoadIntFromFile(f, (int*)&m_ParentIndex))
        {
            result = false;
            break;
        }
        if(m_ParentIndex < 0)
            m_ParentIndex = -1;

        if (!LoadStringFromFile(f, m_Type))
        {
            result = false;
            break;
        }
        if (!LoadStringFromFile(f, m_ActualType))
        {
            result = false;
            break;
        }
        if (!LoadStringFromFile(f, m_Name))
        {
            result = false;
            break;
        }
        if (!LoadStringFromFile(f, m_Args))
        {
            result = false;
            break;
        }
        if (!LoadStringFromFile(f, m_AncestorsString))
        {
            result = false;
            break;
        }
        if (!LoadIntFromFile(f, (int*)&m_FileIdx))
        {
            result = false;
            break;
        }
        if (!LoadIntFromFile(f, (int*)&m_Line))
        {
            result = false;
            break;
        }
        if (!LoadIntFromFile(f, (int*)&m_ImplFile))
        {
            result = false;
            break;
        }
        if (!LoadIntFromFile(f, (int*)&m_ImplLine))
        {
            result = false;
            break;
        }
        if (!LoadIntFromFile(f, (int*)&m_Scope))
        {
            result = false;
            break;
        }
        if (!LoadIntFromFile(f, (int*)&m_TokenKind))
        {
            result = false;
            break;
        }
        if (!LoadIntFromFile(f, (int*)&m_IsOperator))
        {
            result = false;
            break;
        }
        if (!LoadIntFromFile(f, (int*)&m_IsLocal))
        {
            result = false;
            break;
        }
        if(!LoadTokenIdxSetFromFile(f, &m_Ancestors))
        {
            result = false;
            break;
        }
        if(!LoadTokenIdxSetFromFile(f, &m_Children))
        {
            result = false;
            break;
        }
        if(!LoadTokenIdxSetFromFile(f, &m_Descendants))
        {
            result = false;
            break;
        }
    } while(false);
    return result;
}
Exemple #5
0
bool Parser::ReadFromCache(wxInputStream* f)
{
    bool result = false;

    TRACK_THREAD_LOCKER(s_TokensTreeCritical);
    wxCriticalSectionLocker locker(s_TokensTreeCritical);
    THREAD_LOCKER_SUCCESS(s_TokensTreeCritical);

    char CACHE_MAGIC_READ[] = "           ";
    m_TokensTree->clear(); // Clear data

    // File format is like this:
    //
    // CACHE_MAGIC
    // Number of parsed files
    // Number of tokens
    // Parsed files
    // Tokens
    // EOF

//  Begin loading process
    do
    {

        // keep a backup of include dirs
        if (f->Read(CACHE_MAGIC_READ, sizeof(CACHE_MAGIC_READ)).LastRead() != sizeof(CACHE_MAGIC_READ) ||
            strncmp(CACHE_MAGIC, CACHE_MAGIC_READ, sizeof(CACHE_MAGIC_READ) != 0))
            break;
        int fcount = 0, actual_fcount = 0;
        int tcount = 0, actual_tcount = 0;
        int idx;
        if (!LoadIntFromFile(f, &fcount))
            break;
        if (!LoadIntFromFile(f, &tcount))
            break;
        if (fcount < 0)
            break;
        if (tcount < 0)
            break;

        wxString file;
        int nonempty_token = 0;
        Token* token = 0;
        do // do while-false block
        {
            // Filenames
            int i;
            for (i = 0; i < fcount && !f->Eof(); ++i)
            {
                if (!LoadIntFromFile(f,&idx)) // Filename index
                    break;
                if (idx != i)
                    break;
                if (!LoadStringFromFile(f,file)) // Filename data
                    break;
                if (!idx)
                    file.Clear();
                if (file.IsEmpty())
                    idx = 0;
                m_TokensTree->m_FilenamesMap.insert(file);
                actual_fcount++;
            }
            result = (actual_fcount == fcount);
            if (!result)
                break;
            if (tcount)
                m_TokensTree->m_Tokens.resize(tcount,0);
            // Tokens
            for (i = 0; i < tcount && !f->Eof(); ++i)
            {
                token = 0;
                if (!LoadIntFromFile(f, &nonempty_token))
                break;
                if (nonempty_token != 0)
                {
                    token = new Token(wxEmptyString, 0, 0, ++m_TokensTree->m_TokenTicketCount);
                    if (!token->SerializeIn(f))
                    {
                        delete token;
                        --m_TokensTree->m_TokenTicketCount;
                        token = 0;
                        break;
                    }
                    m_TokensTree->insert(i,token);
                }
                ++actual_tcount;
            }
            if (actual_tcount != tcount)
                break;
            m_TokensTree->RecalcFreeList();
            result = true;
        } while(false);

    } while(false);

//  End loading process

    if (result)
        m_UsingCache = true;
    else
        m_TokensTree->clear();

    m_TokensTree->m_Modified = false;

    return result;
}