mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-07-27 07:31:49 +03:00
Update sqdbg
This commit is contained in:
parent
985ebc0dbb
commit
ab03538347
@ -106,6 +106,7 @@
|
||||
} while(0)
|
||||
#endif
|
||||
#define Verify( x ) Assert(x)
|
||||
#define STATIC_ASSERT( x ) static_assert( x, #x )
|
||||
#else
|
||||
#define DebuggerBreak() ((void)0)
|
||||
#define Assert( x ) ((void)0)
|
||||
@ -113,12 +114,15 @@
|
||||
#define AssertMsg1( x, msg, a1 ) ((void)0)
|
||||
#define AssertMsg2( x, msg, a1, a2 ) ((void)0)
|
||||
#define Verify( x ) x
|
||||
#define STATIC_ASSERT( x )
|
||||
#endif // _DEBUG
|
||||
|
||||
#endif
|
||||
|
||||
#include <tier0/dbg.h>
|
||||
|
||||
#define STATIC_ASSERT COMPILE_TIME_ASSERT
|
||||
|
||||
// Misdefined for GCC in platform.h
|
||||
#undef UNREACHABLE
|
||||
|
||||
|
@ -275,9 +275,13 @@ static inline void PutStr( CBuffer *buffer, const string_t &str )
|
||||
#ifdef SQDBG_VALIDATE_SENT_MSG
|
||||
for ( unsigned int i = 0; i < str.len; i++ )
|
||||
{
|
||||
AssertMsg( IN_RANGE_CHAR( str.ptr[i], 0x20, 0x7E ) &&
|
||||
( ( str.ptr[i] != '\\' && str.ptr[i] != '\"' ) || ( i && str.ptr[i-1] == '\\' ) ),
|
||||
"control char in json string" );
|
||||
if ( str.ptr[i] == '\\' && ( str.ptr[i+1] == '\\' || str.ptr[i+1] == '\"' ) )
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
AssertMsg( str.ptr[i] != '\\' && IN_RANGE_CHAR( str.ptr[i], 0x20, 0x7E ), "control char in json string" );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -433,7 +437,7 @@ static inline void PutStr( CBuffer *buffer, const string_t &str, bool quote )
|
||||
idx += printhex< true, false >(
|
||||
mem + idx,
|
||||
buffer->Capacity() - idx,
|
||||
(SQChar)*(unsigned char*)c );
|
||||
(SQUnsignedChar)*(unsigned char*)c );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -503,6 +507,7 @@ static inline void PutInt( CBuffer *buffer, I val )
|
||||
template < bool padding, typename I >
|
||||
static inline void PutHex( CBuffer *buffer, I val )
|
||||
{
|
||||
STATIC_ASSERT( IS_UNSIGNED( I ) );
|
||||
buffer->base.Ensure( buffer->Size() + countdigits<16>( val ) + 1 );
|
||||
int len = printhex< padding >( buffer->Base() + buffer->Size(), buffer->Capacity() - buffer->Size(), val );
|
||||
buffer->size += len;
|
||||
@ -699,7 +704,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
PutHex< false >( m_pBuffer, val );
|
||||
PutHex< false >( m_pBuffer, cast_unsigned( I, val ) );
|
||||
}
|
||||
PutChar( m_pBuffer, ']' );
|
||||
PutChar( m_pBuffer, '\"' );
|
||||
@ -850,7 +855,7 @@ private:
|
||||
else
|
||||
{
|
||||
buf = m_Allocator->Alloc(5);
|
||||
int i = printhex< true, true, false >( buf, 5, token );
|
||||
int i = printhex< true, true, false >( buf, 5, (unsigned char)token );
|
||||
Assert( i == 4 );
|
||||
buf[i] = 0;
|
||||
}
|
||||
@ -877,6 +882,24 @@ private:
|
||||
m_error[len] = 0;
|
||||
}
|
||||
|
||||
bool IsValue( char token )
|
||||
{
|
||||
switch ( token )
|
||||
{
|
||||
case Token_String:
|
||||
case Token_Integer:
|
||||
case Token_Float:
|
||||
case Token_False:
|
||||
case Token_True:
|
||||
case Token_Null:
|
||||
case Token_Table:
|
||||
case Token_Array:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
char NextToken( string_t &token )
|
||||
{
|
||||
while ( m_cur < m_end )
|
||||
@ -1206,7 +1229,7 @@ err_eof:
|
||||
type = NextToken( token );
|
||||
type = ParseValue( type, token, &kv->val );
|
||||
|
||||
if ( type == Token_Error )
|
||||
if ( !IsValue( type ) )
|
||||
{
|
||||
SetError( "invalid token %s @ %i", Char(type), Index() );
|
||||
return Token_Error;
|
||||
@ -1239,7 +1262,7 @@ err_eof:
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if ( type == Token_Error )
|
||||
if ( !IsValue( type ) )
|
||||
{
|
||||
SetError( "expected '%c', got %s @ %i", ']', Char(type), Index() );
|
||||
return Token_Error;
|
||||
@ -1315,7 +1338,7 @@ err_eof:
|
||||
value->type = JSON_NULL;
|
||||
return type;
|
||||
default:
|
||||
return type;
|
||||
return Token_Error;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -842,7 +842,7 @@ public:
|
||||
m_pRecvBufPtr( m_pRecvBuf ),
|
||||
m_bWSAInit( false )
|
||||
{
|
||||
Assert( sizeof(m_pRecvBuf) <= ( 1 << ( sizeof(CMessagePool::message_t::len) * 8 ) ) );
|
||||
STATIC_ASSERT( sizeof(m_pRecvBuf) <= ( 1 << ( sizeof(CMessagePool::message_t::len) * 8 ) ) );
|
||||
}
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -75,6 +75,21 @@ bool atox( string_t str, I *out );
|
||||
template < typename I >
|
||||
bool atoo( string_t str, I *out );
|
||||
|
||||
template < typename I >
|
||||
struct _as_unsigned { typedef I T; };
|
||||
|
||||
template <>
|
||||
struct _as_unsigned< int > { typedef unsigned int T; };
|
||||
|
||||
#ifdef _SQ64
|
||||
template <>
|
||||
struct _as_unsigned< SQInteger > { typedef SQUnsignedInteger T; };
|
||||
#endif
|
||||
|
||||
#define as_unsigned_type( I ) typename _as_unsigned<I>::T
|
||||
#define cast_unsigned( I, v ) (as_unsigned_type(I)(v))
|
||||
#define IS_UNSIGNED( I ) ((I)0 < (I)-1)
|
||||
|
||||
|
||||
#define _isdigit( c ) \
|
||||
IN_RANGE_CHAR( c, '0', '9' )
|
||||
@ -403,9 +418,10 @@ struct sqstring_t
|
||||
unsigned int i = 0;
|
||||
do
|
||||
{
|
||||
if ( ptr[i] > 0x7E || other.ptr[i] != (char)ptr[i] )
|
||||
if ( (SQUnsignedChar)ptr[i] > 0x7E || other.ptr[i] != (char)ptr[i] )
|
||||
{
|
||||
AssertMsg( ptr[i] <= 0x7E, "not implemented" );
|
||||
// > 0x7E can be reached through completions request
|
||||
// unicode identifiers are not supported, ignore them
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -556,6 +572,8 @@ struct stringbufbase_t
|
||||
template < typename I >
|
||||
void PutHex( I value, bool padding = true )
|
||||
{
|
||||
STATIC_ASSERT( IS_UNSIGNED( I ) );
|
||||
|
||||
int space = BytesLeft();
|
||||
|
||||
if ( space < 3 )
|
||||
@ -590,9 +608,9 @@ bool string_t::IsEqualTo( const sqstring_t &other ) const
|
||||
{
|
||||
// Used for comparing against locals and outers,
|
||||
// implement unicode conversion if locals can have unicode characters
|
||||
if ( other.ptr[i] > 0x7E || (char)other.ptr[i] != ptr[i] )
|
||||
if ( (SQUnsignedChar)other.ptr[i] > 0x7E || (char)other.ptr[i] != ptr[i] )
|
||||
{
|
||||
AssertMsg( other.ptr[i] <= 0x7E, "not implemented" );
|
||||
AssertMsg( (SQUnsignedChar)other.ptr[i] <= 0x7E, "not implemented" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -675,7 +693,7 @@ inline int printint( C *buf, int size, I value )
|
||||
value /= 10;
|
||||
buf[i--] = !neg ? ( '0' + c ) : ( '0' - c );
|
||||
}
|
||||
while ( value && i >= 0 );
|
||||
while ( value );
|
||||
|
||||
return len;
|
||||
}
|
||||
@ -683,10 +701,11 @@ inline int printint( C *buf, int size, I value )
|
||||
template < bool padding, bool prefix, bool uppercase, typename C, typename I >
|
||||
inline int printhex( C *buf, int size, I value )
|
||||
{
|
||||
STATIC_ASSERT( IS_UNSIGNED( as_unsigned_type( I ) ) );
|
||||
Assert( buf );
|
||||
Assert( size > 0 );
|
||||
|
||||
int len = ( prefix ? 2 : 0 ) + ( padding ? sizeof(I) * 2 : countdigits<16>( value ) );
|
||||
int len = ( prefix ? 2 : 0 ) + ( padding ? sizeof(I) * 2 : countdigits<16>( cast_unsigned( I, value ) ) );
|
||||
|
||||
if ( len > size )
|
||||
len = size;
|
||||
@ -695,11 +714,11 @@ inline int printhex( C *buf, int size, I value )
|
||||
|
||||
do
|
||||
{
|
||||
C c = value & 0xf;
|
||||
value >>= 4;
|
||||
C c = cast_unsigned( I, value ) & 0xf;
|
||||
*(as_unsigned_type(I)*)&value >>= 4;
|
||||
buf[i--] = c + ( ( c < 10 ) ? '0' : ( ( uppercase ? 'A' : 'a' ) - 10 ) );
|
||||
}
|
||||
while ( value && i >= 0 );
|
||||
while ( value );
|
||||
|
||||
if ( padding )
|
||||
{
|
||||
@ -725,6 +744,7 @@ inline int printhex( C *buf, int size, I value )
|
||||
template < typename C, typename I >
|
||||
inline int printoct( C *buf, int size, I value )
|
||||
{
|
||||
STATIC_ASSERT( IS_UNSIGNED( I ) );
|
||||
Assert( buf );
|
||||
Assert( size > 0 );
|
||||
|
||||
@ -741,7 +761,7 @@ inline int printoct( C *buf, int size, I value )
|
||||
value >>= 3;
|
||||
buf[i--] = '0' + c;
|
||||
}
|
||||
while ( value && i >= 0 );
|
||||
while ( value );
|
||||
|
||||
if ( i >= 0 )
|
||||
buf[i--] = '0';
|
||||
@ -1302,7 +1322,7 @@ doescape:
|
||||
else
|
||||
{
|
||||
mbc[bytes++] = 'x';
|
||||
bytes += printhex< true, false >( mbc + bytes, sizeof(mbc) - bytes, (SQChar)cp );
|
||||
bytes += printhex< true, false >( mbc + bytes, sizeof(mbc) - bytes, (SQUnsignedChar)cp );
|
||||
}
|
||||
|
||||
goto write;
|
||||
@ -1339,7 +1359,7 @@ x7ff:
|
||||
|
||||
mbc[bytes++] = '\\';
|
||||
mbc[bytes++] = 'x';
|
||||
bytes = bytes + printhex< true, false >( mbc + bytes, sizeof(mbc) - bytes, (SQChar)cp );
|
||||
bytes = bytes + printhex< true, false >( mbc + bytes, sizeof(mbc) - bytes, (SQUnsignedChar)cp );
|
||||
goto write;
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ public:
|
||||
|
||||
void Free( void *ptr )
|
||||
{
|
||||
Assert( !SEQUENTIAL );
|
||||
STATIC_ASSERT( !SEQUENTIAL );
|
||||
Assert( m_Memory );
|
||||
Assert( ptr );
|
||||
|
||||
@ -364,7 +364,7 @@ public:
|
||||
|
||||
void ReleaseShrink()
|
||||
{
|
||||
Assert( SEQUENTIAL );
|
||||
STATIC_ASSERT( SEQUENTIAL );
|
||||
|
||||
if ( !m_Memory )
|
||||
return;
|
||||
@ -412,7 +412,7 @@ public:
|
||||
|
||||
void Release()
|
||||
{
|
||||
Assert( SEQUENTIAL );
|
||||
STATIC_ASSERT( SEQUENTIAL );
|
||||
|
||||
if ( !m_Memory || ( !m.LastFreeChunk() && !m.LastFreeIndex() ) )
|
||||
return;
|
||||
@ -437,7 +437,7 @@ public:
|
||||
|
||||
void ReleaseTop()
|
||||
{
|
||||
Assert( SEQUENTIAL );
|
||||
STATIC_ASSERT( SEQUENTIAL );
|
||||
|
||||
m.SetLastFreeChunk( m.PrevChunk() );
|
||||
m.SetLastFreeIndex( m.PrevIndex() );
|
||||
@ -455,23 +455,23 @@ public:
|
||||
|
||||
vector() : base(), size(0)
|
||||
{
|
||||
Assert( !bExternalMem );
|
||||
STATIC_ASSERT( !bExternalMem );
|
||||
}
|
||||
|
||||
vector( CAllocator &a ) : base(a), size(0)
|
||||
{
|
||||
Assert( bExternalMem );
|
||||
STATIC_ASSERT( bExternalMem );
|
||||
}
|
||||
|
||||
vector( I count ) : base(), size(0)
|
||||
{
|
||||
Assert( !bExternalMem );
|
||||
STATIC_ASSERT( !bExternalMem );
|
||||
base.Alloc( count * sizeof(T) );
|
||||
}
|
||||
|
||||
vector( const vector< T > &src ) : base()
|
||||
{
|
||||
Assert( !bExternalMem );
|
||||
STATIC_ASSERT( !bExternalMem );
|
||||
base.Alloc( src.base.Size() );
|
||||
size = src.size;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user