//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============// // // Purpose: VPC // //=====================================================================================// #include "vpc.h" void CVPC::SetMacro( const char *pName, const char *pValue, bool bSetupDefineInProjectFile ) { // Setup the macro. VPCStatus( false, "Set Macro: $%s = %s", pName, pValue ); macro_t *pMacro = FindOrCreateMacro( pName, true, pValue ); pMacro->m_bSetupDefineInProjectFile = bSetupDefineInProjectFile; pMacro->m_bInternalCreatedMacro = true; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- macro_t *CVPC::FindOrCreateMacro( const char *pName, bool bCreate, const char *pValue ) { for ( int i = 0; i < m_Macros.Count(); i++ ) { if ( !V_stricmp( pName, m_Macros[i].name.String() ) ) { if ( pValue && V_stricmp( pValue, m_Macros[i].value.String() ) ) { // update m_Macros[i].value = pValue; } return &m_Macros[i]; } } if ( !bCreate ) { return NULL; } int index = m_Macros.AddToTail(); m_Macros[index].name = pName; m_Macros[index].value = pValue; return &m_Macros[index]; } int CVPC::GetMacrosMarkedForCompilerDefines( CUtlVector< macro_t* > ¯oDefines ) { macroDefines.Purge(); for ( int i = 0; i < m_Macros.Count(); i++ ) { if ( m_Macros[i].m_bSetupDefineInProjectFile ) { macroDefines.AddToTail( &m_Macros[i] ); } } return macroDefines.Count(); } void CVPC::ResolveMacrosInString( char const *pString, char *pOutBuff, int outBuffSize ) { char macroName[MAX_SYSTOKENCHARS]; char buffer1[MAX_SYSTOKENCHARS]; char buffer2[MAX_SYSTOKENCHARS]; int i; // iterate and resolve user macros until all macros resolved strcpy( buffer1, pString ); bool bDone; do { bDone = true; for ( i=0; i