本文整理匯總了C++中FOUNDATION_ASSERT函數的典型用法代碼示例。如果您正苦於以下問題:C++ FOUNDATION_ASSERT函數的具體用法?C++ FOUNDATION_ASSERT怎麽用?C++ FOUNDATION_ASSERT使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了FOUNDATION_ASSERT函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: shader_get_param
shaderparameter_t* shader_get_param(shaderprogram_t* program, const char* name, ShaderParamType type)
{
GLint paramIndex = 0;
GLint paramSize = 0;
GLenum paramType;
switch(type)
{
default:
case ShaderParamType_Uniform:
{
GLsizei nameLength;
paramIndex = glGetUniformLocation(program->program, name);
glGetActiveUniform(program->program, paramIndex, 0, &nameLength, ¶mSize, ¶mType, nullptr);
FOUNDATION_ASSERT(paramSize > 0);
}
case ShaderParamType_UniformBlock:
{
paramIndex = glGetUniformBlockIndex(program->program, name);
glGetActiveUniformBlockiv(program->program, paramIndex, GL_UNIFORM_BLOCK_DATA_SIZE, ¶mSize);
FOUNDATION_ASSERT(paramSize > 0);
}
}
shaderparameter_t* param = (shaderparameter_t*) memory_allocate(sizeof(shaderparameter_t), 4, MEMORY_PERSISTENT);
param->index = paramIndex;
param->size = paramSize;
param->gltype = paramType;
param->name = string_clone(name);
param->type = type;
return param;
}
示例2: _socket_stream_truncate
static void
_socket_stream_truncate(stream_t* stream, size_t size) {
FOUNDATION_ASSERT(stream);
FOUNDATION_ASSERT(stream->type == STREAMTYPE_SOCKET);
FOUNDATION_UNUSED(stream);
FOUNDATION_UNUSED(size);
}
示例3: objectmap_reserve
object_t objectmap_reserve( objectmap_t* map )
{
uint64_t idx, next, id;
FOUNDATION_ASSERT( map ); /*lint -esym(613,pool) */
//Reserve spot in array
//TODO: Look into double-ended implementation with allocation from tail and free push to head
do
{
idx = atomic_load64( &map->free );
if( idx >= map->size )
{
log_error( 0, ERROR_OUT_OF_MEMORY, "Pool full, unable to reserve id" );
return 0;
}
next = ((uintptr_t)map->map[idx]) >> 1;
} while( !atomic_cas64( &map->free, next, idx ) );
//Sanity check that slot isn't taken
FOUNDATION_ASSERT_MSG( (intptr_t)(map->map[idx]) & 1, "Map failed sanity check, slot taken after reserve" );
map->map[idx] = 0;
//Allocate ID
id = 0;
do
{
id = atomic_incr64( &map->id ) & map->id_max; //Wrap-around handled by masking
} while( !id );
//Make sure id stays within correct bits (if fails, check objectmap allocation and the mask setup there)
FOUNDATION_ASSERT( ( ( id << map->size_bits ) & map->mask_id ) == ( id << map->size_bits ) );
return ( id << map->size_bits ) | idx; /*lint +esym(613,pool) */
}
示例4: _socket_stream_size
static size_t
_socket_stream_size(stream_t* stream) {
FOUNDATION_ASSERT(stream);
FOUNDATION_ASSERT(stream->type == STREAMTYPE_SOCKET);
FOUNDATION_UNUSED(stream);
return 0;
}
示例5: _socket_stream_flush
static void
_socket_stream_flush(stream_t* stream) {
FOUNDATION_ASSERT(stream);
FOUNDATION_ASSERT(stream->type == STREAMTYPE_SOCKET);
_socket_stream_doflush((socket_stream_t*)stream);
}
示例6: stream_seek
void stream_seek( stream_t* stream, int64_t offset, stream_seek_mode_t direction )
{
FOUNDATION_ASSERT( stream );
if( stream->sequential )
return;
FOUNDATION_ASSERT( stream->vtable->seek );
stream->vtable->seek( stream, offset, direction );
}
示例7: stream_read
uint64_t stream_read( stream_t* stream, void* buffer, uint64_t num_bytes )
{
FOUNDATION_ASSERT( stream );
if( !( stream->mode & STREAM_IN ) )
return 0;
FOUNDATION_ASSERT( stream->vtable->read );
return stream->vtable->read( stream, buffer, num_bytes );
}
示例8: stream_read_line
string_t
stream_read_line(stream_t* stream, char delimiter) {
char buffer[128];
char* outbuffer = 0;
size_t outsize = 0;
size_t cursize = 0;
size_t read, i;
size_t want_read = 128;
if (!(stream->mode & STREAM_IN))
return (string_t) { 0, 0 };
//Need to read one byte at a time since we can't scan back if overreading
if (stream_is_sequential(stream))
want_read = 1;
while (!stream_eos(stream)) {
read = stream->vtable->read(stream, buffer, want_read);
if (!read)
break;
for (i = 0; i < read; ++i) {
if (buffer[i] == delimiter)
break;
}
if (cursize + i > outsize) {
size_t nextsize;
if (!outbuffer) {
nextsize = (i >= 32 ? i + 1 : (i > 1 ? i + 1 : 32));
outbuffer = memory_allocate(0, nextsize, 0, MEMORY_PERSISTENT);
}
else {
nextsize = (outsize < 511 ? 512 : outsize + 513); //Always aligns to 512 multiples
FOUNDATION_ASSERT(!(nextsize % 512));
outbuffer = memory_reallocate(outbuffer, nextsize, 0, outsize + 1);
}
outsize = nextsize - 1;
}
if (i) {
memcpy(outbuffer + cursize, buffer, i); //lint !e613
cursize += i;
}
if (i < read) {
if ((i + 1) < read) {
//Sequential should never end up here reading one byte at a time
FOUNDATION_ASSERT(!stream_is_sequential(stream));
stream_seek(stream, (ssize_t)(1 + i) - (ssize_t)read, STREAM_SEEK_CURRENT);
}
break;
}
}
if (outbuffer)
outbuffer[cursize] = 0;
return (string_t) { outbuffer, cursize };
}
示例9: stream_write
uint64_t stream_write( stream_t* stream, const void* buffer, uint64_t num_bytes )
{
FOUNDATION_ASSERT( stream );
if( !( stream->mode & STREAM_OUT ) )
return 0;
FOUNDATION_ASSERT( stream->vtable->write );
return stream->vtable->write( stream, buffer, num_bytes );
}
示例10: objectmap_raw_lookup
void* objectmap_raw_lookup( const objectmap_t* map, unsigned int idx )
{
uintptr_t ptr;
/*lint --e{613} Performance path (no ptr checks)*/
FOUNDATION_ASSERT( map );
FOUNDATION_ASSERT( idx < map->size );
ptr = (uintptr_t)map->map[idx];
return ( ptr & 1 ) ? 0 : (void*)ptr;
}
示例11: _socket_stream_tell
static size_t
_socket_stream_tell(stream_t* stream) {
socket_stream_t* sockstream;
socket_t* sock;
FOUNDATION_ASSERT(stream);
FOUNDATION_ASSERT(stream->type == STREAMTYPE_SOCKET);
sockstream = (socket_stream_t*)stream;
sock = sockstream->socket;
return sock->bytes_read;
}
示例12: stream_read_line
char* stream_read_line( stream_t* stream, char delimiter )
{
char buffer[128];
char* outbuffer;
int outsize = 32;
int cursize = 0;
int read, i;
int want_read = 128;
FOUNDATION_ASSERT( stream );
if( !( stream->mode & STREAM_IN ) )
return 0;
FOUNDATION_ASSERT( stream->vtable->read );
if( stream_is_sequential( stream ) ) //Need to read one byte at a time since we can't scan back if overreading
want_read = 1;
outbuffer = memory_allocate( outsize + 1, 0, MEMORY_PERSISTENT );
while( !stream_eos( stream ) )
{
read = (int)stream->vtable->read( stream, buffer, want_read );
if( !read )
break;
for( i = 0; i < read; ++i )
{
if( buffer[i] == delimiter )
break;
}
if( cursize + i > outsize )
{
outsize += 512;
outbuffer = memory_reallocate( outbuffer, outsize + 1, 0, cursize );
}
memcpy( outbuffer + cursize, buffer, i );
cursize += i;
if( i < read )
{
if( ( i + 1 ) < read )
{
FOUNDATION_ASSERT( !stream_is_sequential( stream ) ); //Sequential should never end up here reading one byte at a time
stream_seek( stream, 1 + i - read, STREAM_SEEK_CURRENT );
}
break;
}
}
outbuffer[cursize] = 0;
return outbuffer;
}
示例13: objectmap_set
void objectmap_set( objectmap_t* map, object_t id, void* object )
{
uint64_t idx;
FOUNDATION_ASSERT( map ); /*lint -esym(613,pool) */
idx = (int)( id & map->mask_index );
//Sanity check, can't set free slot, and non-free slot should be initialized to 0 in reserve function
FOUNDATION_ASSERT( !(((uintptr_t)map->map[idx]) & 1 ) );
FOUNDATION_ASSERT( !((uintptr_t)map->map[idx]) );
if( !map->map[idx] )
map->map[idx] = object;
/*lint +esym(613,pool) */
}
示例14: profile_end_block
void profile_end_block( void )
{
uint32_t block_index = get_thread_profile_block();
profile_block_t* block;
if( !_profile_enable || !block_index )
return;
block = GET_BLOCK( block_index );
block->data.end = time_current() - _profile_ground_time;
if( block->previous )
{
unsigned int processor;
profile_block_t* current = block;
profile_block_t* previous = GET_BLOCK( block->previous );
profile_block_t* parent;
unsigned int current_index = block_index;
unsigned int parent_index;
while( previous->child != current_index )
{
current_index = current->previous; //Walk sibling list backwards
current = GET_BLOCK( current_index );
previous = GET_BLOCK( current->previous );
#if PROFILE_ENABLE_SANITY_CHECKS
FOUNDATION_ASSERT( current_index != 0 );
FOUNDATION_ASSERT( current->previous != 0 );
#endif
}
parent_index = current->previous; //Previous now points to parent
parent = GET_BLOCK( parent_index );
#if PROFILE_ENABLE_SANITY_CHECKS
FOUNDATION_ASSERT( parent_index != block_index );
#endif
set_thread_profile_block( parent_index );
processor = thread_hardware();
if( parent->data.processor != processor )
{
const char* message = parent->data.name;
//Thread migrated, split into new block
profile_end_block();
profile_begin_block( message );
}
}
else
{
_profile_put_root_block( block_index );
set_thread_profile_block( 0 );
}
}
示例15: stream_read_line_buffer
uint64_t stream_read_line_buffer( stream_t* stream, char* dest, unsigned int count, char delimiter )
{
int i, read, total, limit;
FOUNDATION_ASSERT( stream );
FOUNDATION_ASSERT( dest );
if( !( stream->mode & STREAM_IN ) || ( count < 2 ) )
return 0;
FOUNDATION_ASSERT( stream->vtable->read );
total = 0;
--count;
while( !stream_eos( stream ) )
{
limit = count - total;
if( limit > 128 )
limit = 128;
if( !limit )
break;
if( stream_is_sequential( stream ) ) //Need to read one byte at a time since we can't scan back if overreading
limit = 1;
read = (int)stream->vtable->read( stream, dest + total, limit );
if( !read )
break;
for( i = 0; i < read; ++i )
{
if( dest[total+i] == delimiter )
break;
}
total += i;
if( i < read )
{
if( ( i + 1 ) < read )
{
FOUNDATION_ASSERT( !stream_is_sequential( stream ) ); //Sequential should never end up here reading one byte at a time
stream_seek( stream, 1 + i - read, STREAM_SEEK_CURRENT );
}
break;
}
}
dest[total] = 0;
return total;
}