This commit is contained in:
FluorescentCIAAfricanAmerican
2020-04-22 12:56:21 -04:00
commit 3bf9df6b27
15370 changed files with 5489726 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef VSTDLIB_IKEYVALUESSYSTEM_H
#define VSTDLIB_IKEYVALUESSYSTEM_H
#ifdef _WIN32
#pragma once
#endif
#include "vstdlib/vstdlib.h"
// handle to a KeyValues key name symbol
typedef int HKeySymbol;
#define INVALID_KEY_SYMBOL (-1)
class IBaseFileSystem;
class KeyValues;
//-----------------------------------------------------------------------------
// Purpose: Interface to shared data repository for KeyValues (included in vgui_controls.lib)
// allows for central data storage point of KeyValues symbol table
//-----------------------------------------------------------------------------
class IKeyValuesSystem
{
public:
// registers the size of the KeyValues in the specified instance
// so it can build a properly sized memory pool for the KeyValues objects
// the sizes will usually never differ but this is for versioning safety
virtual void RegisterSizeofKeyValues(int size) = 0;
// allocates/frees a KeyValues object from the shared mempool
virtual void *AllocKeyValuesMemory(int size) = 0;
virtual void FreeKeyValuesMemory(void *pMem) = 0;
// symbol table access (used for key names)
virtual HKeySymbol GetSymbolForString( const char *name, bool bCreate = true ) = 0;
virtual const char *GetStringForSymbol(HKeySymbol symbol) = 0;
// for debugging, adds KeyValues record into global list so we can track memory leaks
virtual void AddKeyValuesToMemoryLeakList(void *pMem, HKeySymbol name) = 0;
virtual void RemoveKeyValuesFromMemoryLeakList(void *pMem) = 0;
// maintain a cache of KeyValues we load from disk. This saves us quite a lot of time on app startup.
virtual void AddFileKeyValuesToCache( const KeyValues* _kv, const char *resourceName, const char *pathID ) = 0;
virtual bool LoadFileKeyValuesFromCache( KeyValues* _outKv, const char *resourceName, const char *pathID, IBaseFileSystem *filesystem ) const = 0;
virtual void InvalidateCache( ) = 0;
virtual void InvalidateCacheForFile( const char *resourceName, const char *pathID ) = 0;
};
VSTDLIB_INTERFACE IKeyValuesSystem *KeyValuesSystem();
// #define KEYVALUESSYSTEM_INTERFACE_VERSION "KeyValuesSystem002"
#endif // VSTDLIB_IKEYVALUESSYSTEM_H

View File

@@ -0,0 +1,69 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: setjmp/longjmp based cooperative multitasking system
//
//=============================================================================
#ifndef COROUTINE_H
#define COROUTINE_H
#pragma once
#include "vstdlib/vstdlib.h"
// enable this to do coroutine tracing
// this will tell coroutine API users to set coroutine names
// #define COROUTINE_TRACE
//-----------------------------------------------------------------------------
// Purpose: handles running coroutines
// setjmp/longjmp based cooperative multitasking system
//-----------------------------------------------------------------------------
// coroutine callback
typedef void (__cdecl *CoroutineFunc_t )(void *);
// handle to a coroutine
typedef int32 HCoroutine;
// creates a new coroutine
// no coroutine code is executed until Coroutine_Continue() is called
VSTDLIB_INTERFACE HCoroutine Coroutine_Create( CoroutineFunc_t pFunc, void *pvParam );
// continues the specified coroutine
// returns true if the coroutine is still running, false otherwise
VSTDLIB_INTERFACE bool Coroutine_Continue( HCoroutine hCoroutine, const char *pchName = NULL );
// cancels a currently running coroutine
VSTDLIB_INTERFACE void Coroutine_Cancel( HCoroutine hCoroutine );
// 'load' a coroutine only to debug it - immediately breaks into debugger
// when continued, pops back to the prior coroutine
VSTDLIB_INTERFACE void Coroutine_DebugBreak( HCoroutine hCoroutine );
// Load a coroutine and generate an assert. Used to get a minidump of a job
VSTDLIB_INTERFACE void Coroutine_DebugAssert( HCoroutine hCoroutine, const char *pchMsg );
// called from the coroutine to return control to the main thread
VSTDLIB_INTERFACE void Coroutine_YieldToMain();
// returns true if the code is currently running inside of a coroutine
VSTDLIB_INTERFACE bool Coroutine_IsActive();
// returns a handle the currently active coroutine
VSTDLIB_INTERFACE HCoroutine Coroutine_GetCurrentlyActive();
// call when a thread is quiting to release any per-thread memory
VSTDLIB_INTERFACE void Coroutine_ReleaseThreadMemory();
// runs a self-test of the coroutine system
VSTDLIB_INTERFACE bool Coroutine_Test();
// memory validation
VSTDLIB_INTERFACE void Coroutine_ValidateGlobals( class CValidator &validator );
// for debugging purposes - returns stack depth of current coroutine
VSTDLIB_INTERFACE size_t Coroutine_GetStackDepth();
#endif // COROUTINE_H

25
public/vstdlib/cvar.h Normal file
View File

@@ -0,0 +1,25 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#if !defined( CVAR_H )
#define CVAR_H
#ifdef _WIN32
#pragma once
#endif
#include "vstdlib/vstdlib.h"
#include "icvar.h"
//-----------------------------------------------------------------------------
// Returns a CVar dictionary for tool usage
//-----------------------------------------------------------------------------
VSTDLIB_INTERFACE CreateInterfaceFn VStdLib_GetICVarFactory();
#endif // CVAR_H

View File

@@ -0,0 +1,64 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//===========================================================================//
#ifndef IPROCESSUTILS_H
#define IPROCESSUTILS_H
#ifdef _WIN32
#pragma once
#endif
#include "appframework/IAppSystem.h"
//-----------------------------------------------------------------------------
// Handle to a process
//-----------------------------------------------------------------------------
typedef int ProcessHandle_t;
enum
{
PROCESS_HANDLE_INVALID = 0,
};
//-----------------------------------------------------------------------------
// Interface version
//-----------------------------------------------------------------------------
#define PROCESS_UTILS_INTERFACE_VERSION "VProcessUtils001"
//-----------------------------------------------------------------------------
// Interface for makefiles to build differently depending on where they are run from
//-----------------------------------------------------------------------------
abstract_class IProcessUtils : public IAppSystem
{
public:
// Starts, stops a process
virtual ProcessHandle_t StartProcess( const char *pCommandLine, bool bConnectStdPipes ) = 0;
virtual ProcessHandle_t StartProcess( int argc, const char **argv, bool bConnectStdPipes ) = 0;
virtual void CloseProcess( ProcessHandle_t hProcess ) = 0;
virtual void AbortProcess( ProcessHandle_t hProcess ) = 0;
// Returns true if a process is complete
virtual bool IsProcessComplete( ProcessHandle_t hProcess ) = 0;
// Waits until a process is complete
virtual void WaitUntilProcessCompletes( ProcessHandle_t hProcess ) = 0;
// Methods used to write input into a process
virtual int SendProcessInput( ProcessHandle_t hProcess, char *pBuf, int nBufLen ) = 0;
// Methods used to read output back from a process
virtual int GetProcessOutputSize( ProcessHandle_t hProcess ) = 0;
virtual int GetProcessOutput( ProcessHandle_t hProcess, char *pBuf, int nBufLen ) = 0;
// Returns the exit code for the process. Doesn't work unless the process is complete
virtual int GetProcessExitCode( ProcessHandle_t hProcess ) = 0;
};
#endif // IPROCESSUTILS_H

1344
public/vstdlib/jobthread.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,60 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $Workfile: $
// $Date: $
//
//-----------------------------------------------------------------------------
// $Log: $
//
// $NoKeywords: $
//=============================================================================//
#ifndef OSVERSION_H
#define OSVERSION_H
#pragma once
#include "vstdlib/vstdlib.h"
// OS types we know about
// Must be in ascending capability order, we use this for min OS requirements
enum EOSType
{
k_eOSUnknown = -1,
k_eMacOSUnknown = -102,
k_eMacOS104 = -101,
k_eMacOS105 = -100,
k_eMacOS1058 = -99,
k_eMacOS106 = -95,
k_eMacOS1063 = -94,
k_eMacOS107 = -90,
// k_eMacOSMax = -1
k_eLinuxUnknown = -203,
k_eLinux22 = -202,
k_eLinux24 = -201,
k_eLinux26 = -200,
// k_eLinuxMax = -103
k_eWinUnknown = 0,
k_eWin311 = 1,
k_eWin95,
k_eWin98,
k_eWinME,
k_eWinNT,
k_eWin2000,
k_eWinXP,
k_eWin2003,
k_eWinVista,
k_eWindows7,
k_eWin2008,
k_eWinMAX,
k_eOSTypeMax = k_eWinMAX + 11 // win types + other ifdef'd types
};
VSTDLIB_INTERFACE const char *GetNameFromOSType( EOSType eOSType );
VSTDLIB_INTERFACE const char *GetOSDetailString( char *pchOutBuf, int cchOutBuf );
VSTDLIB_INTERFACE EOSType GetOSType();
VSTDLIB_INTERFACE bool OSTypesAreCompatible( EOSType eOSTypeDetected, EOSType eOSTypeRequired );
VSTDLIB_INTERFACE const char *GetPlatformName( bool *pbIs64Bit );
#endif // OSVERSION_H

View File

@@ -0,0 +1,51 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// The copyright to the contents herein is the property of Valve, L.L.C.
// The contents may be used and/or copied only with the written permission of
// Valve, L.L.C., or in accordance with the terms and conditions stipulated in
// the agreement/contract under which the contents have been supplied.
//
// Purpose:
//
// $Workfile: $
// $NoKeywords: $
//=============================================================================
#pragma warning(disable: 4514)
// First include standard libraries
#include <stdio.h>
#include <ctype.h>
#include <math.h>
#include <malloc.h>
#include <memory.h>
#include <ctype.h>
// Next, include public
#include "tier0/basetypes.h"
#include "tier0/dbg.h"
#include "tier0/valobject.h"
// Next, include vstdlib
#include "vstdlib/vstdlib.h"
#include "tier1/strtools.h"
#include "vstdlib/random.h"
#include "tier1/KeyValues.h"
#include "tier1/utlmemory.h"
#include "tier1/utlrbtree.h"
#include "tier1/utlvector.h"
#include "tier1/utllinkedlist.h"
#include "tier1/utlmultilist.h"
#include "tier1/utlsymbol.h"
#include "tier0/icommandline.h"
#include "tier1/netadr.h"
#include "tier1/mempool.h"
#include "tier1/utlbuffer.h"
#include "tier1/utlstring.h"
#include "tier1/utlmap.h"
#include "tier0/memdbgon.h"

123
public/vstdlib/random.h Normal file
View File

@@ -0,0 +1,123 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Random number generator
//
// $Workfile: $
// $NoKeywords: $
//===========================================================================//
#ifndef VSTDLIB_RANDOM_H
#define VSTDLIB_RANDOM_H
#include "vstdlib/vstdlib.h"
#include "tier0/basetypes.h"
#include "tier0/threadtools.h"
#include "tier1/interface.h"
#define NTAB 32
#pragma warning(push)
#pragma warning( disable:4251 )
//-----------------------------------------------------------------------------
// A generator of uniformly distributed random numbers
//-----------------------------------------------------------------------------
class VSTDLIB_CLASS IUniformRandomStream
{
public:
//virtual ~IUniformRandomStream() { }
// Sets the seed of the random number generator
virtual void SetSeed( int iSeed ) = 0;
// Generates random numbers
virtual float RandomFloat( float flMinVal = 0.0f, float flMaxVal = 1.0f ) = 0;
virtual int RandomInt( int iMinVal, int iMaxVal ) = 0;
virtual float RandomFloatExp( float flMinVal = 0.0f, float flMaxVal = 1.0f, float flExponent = 1.0f ) = 0;
};
//-----------------------------------------------------------------------------
// The standard generator of uniformly distributed random numbers
//-----------------------------------------------------------------------------
class VSTDLIB_CLASS CUniformRandomStream : public IUniformRandomStream
{
public:
CUniformRandomStream();
// Sets the seed of the random number generator
virtual void SetSeed( int iSeed );
// Generates random numbers
virtual float RandomFloat( float flMinVal = 0.0f, float flMaxVal = 1.0f );
virtual int RandomInt( int iMinVal, int iMaxVal );
virtual float RandomFloatExp( float flMinVal = 0.0f, float flMaxVal = 1.0f, float flExponent = 1.0f );
private:
int GenerateRandomNumber();
int m_idum;
int m_iy;
int m_iv[NTAB];
CThreadFastMutex m_mutex;
};
//-----------------------------------------------------------------------------
// A generator of gaussian distributed random numbers
//-----------------------------------------------------------------------------
class VSTDLIB_CLASS CGaussianRandomStream
{
public:
// Passing in NULL will cause the gaussian stream to use the
// installed global random number generator
CGaussianRandomStream( IUniformRandomStream *pUniformStream = NULL );
// Attaches to a random uniform stream
void AttachToStream( IUniformRandomStream *pUniformStream = NULL );
// Generates random numbers
float RandomFloat( float flMean = 0.0f, float flStdDev = 1.0f );
private:
IUniformRandomStream *m_pUniformStream;
bool m_bHaveValue;
float m_flRandomValue;
CThreadFastMutex m_mutex;
};
//-----------------------------------------------------------------------------
// A couple of convenience functions to access the library's global uniform stream
//-----------------------------------------------------------------------------
VSTDLIB_INTERFACE void RandomSeed( int iSeed );
VSTDLIB_INTERFACE float RandomFloat( float flMinVal = 0.0f, float flMaxVal = 1.0f );
VSTDLIB_INTERFACE float RandomFloatExp( float flMinVal = 0.0f, float flMaxVal = 1.0f, float flExponent = 1.0f );
VSTDLIB_INTERFACE int RandomInt( int iMinVal, int iMaxVal );
VSTDLIB_INTERFACE float RandomGaussianFloat( float flMean = 0.0f, float flStdDev = 1.0f );
//-----------------------------------------------------------------------------
// IUniformRandomStream interface for free functions
//-----------------------------------------------------------------------------
class VSTDLIB_CLASS CDefaultUniformRandomStream : public IUniformRandomStream
{
public:
virtual void SetSeed( int iSeed ) OVERRIDE { RandomSeed( iSeed ); }
virtual float RandomFloat( float flMinVal, float flMaxVal ) OVERRIDE { return ::RandomFloat( flMinVal, flMaxVal ); }
virtual int RandomInt( int iMinVal, int iMaxVal ) OVERRIDE { return ::RandomInt( iMinVal, iMaxVal ); }
virtual float RandomFloatExp( float flMinVal, float flMaxVal, float flExponent ) OVERRIDE { return ::RandomFloatExp( flMinVal, flMaxVal, flExponent ); }
};
//-----------------------------------------------------------------------------
// Installs a global random number generator, which will affect the Random functions above
//-----------------------------------------------------------------------------
VSTDLIB_INTERFACE void InstallUniformRandomStream( IUniformRandomStream *pStream );
#pragma warning(pop)
#endif // VSTDLIB_RANDOM_H

125
public/vstdlib/vcover.h Normal file
View File

@@ -0,0 +1,125 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: A simple tool for coverage tests
//
//=============================================================================
#ifndef VCOVER_H
#define VCOVER_H
#include "tier1/utlrbtree.h"
#include "vstdlib.h"
#if defined( _WIN32 )
#pragma once
#endif
class CVCoverage
{
public:
CVCoverage() :
m_bActive( false ),
m_depth( 0 ),
m_token( 1 )
{
}
bool IsActive() const
{
return m_bActive;
}
void SetActive( bool bActive )
{
Assert( bActive != m_bActive );
m_bActive = bActive;
if ( bActive )
++m_token;
}
void Begin()
{
++m_depth;
}
void End()
{
--m_depth;
}
void Reset()
{
m_locations.RemoveAll();
}
bool ShouldCover( unsigned token ) const
{
return ( m_bActive && m_depth > 0 && token != m_token );
}
unsigned Cover( const char *pszFile, int line )
{
Location_t location = { pszFile, line };
m_locations.Insert( location );
return m_token;
}
void Report()
{
for ( int i = m_locations.FirstInorder(); i != m_locations.InvalidIndex(); i = m_locations.NextInorder( i ) )
{
Msg( "%s(%d) :\n", m_locations[i].pszFile, m_locations[i].line );
}
}
private:
struct Location_t
{
const char *pszFile;
int line;
};
class CLocationLess
{
public:
CLocationLess( int ignored ) {}
bool operator!() { return false; }
bool operator()( const Location_t &lhs, const Location_t &rhs ) const
{
if ( lhs.line < rhs.line )
{
return true;
}
return CaselessStringLessThan( lhs.pszFile, rhs.pszFile );
}
};
bool m_bActive;
int m_depth;
unsigned m_token;
CUtlRBTree< Location_t, unsigned short, CLocationLess > m_locations;
};
VSTDLIB_INTERFACE CVCoverage g_VCoverage;
#ifdef VCOVER_ENABLED
#define VCOVER() \
do \
{ \
static token; \
if ( g_VCoverage.ShouldCover( token ) ) \
{ \
token = g_VCoverage.Cover( __FILE__, __LINE__ ); \
} \
} while( 0 )
#else
#define VCOVER() ((void)0)
#endif
#endif // VCOVER_H

33
public/vstdlib/vstdlib.h Normal file
View File

@@ -0,0 +1,33 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef VSTDLIB_H
#define VSTDLIB_H
#ifdef _WIN32
#pragma once
#endif
#include "tier0/platform.h"
//-----------------------------------------------------------------------------
// dll export stuff
//-----------------------------------------------------------------------------
#ifdef VSTDLIB_DLL_EXPORT
#define VSTDLIB_INTERFACE DLL_EXPORT
#define VSTDLIB_OVERLOAD DLL_GLOBAL_EXPORT
#define VSTDLIB_CLASS DLL_CLASS_EXPORT
#define VSTDLIB_GLOBAL DLL_GLOBAL_EXPORT
#else
#define VSTDLIB_INTERFACE DLL_IMPORT
#define VSTDLIB_OVERLOAD DLL_GLOBAL_IMPORT
#define VSTDLIB_CLASS DLL_CLASS_IMPORT
#define VSTDLIB_GLOBAL DLL_GLOBAL_IMPORT
#endif
#endif // VSTDLIB_H