• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ FOUNDATION_ASSERT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中FOUNDATION_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ FOUNDATION_ASSERT函数的具体用法?C++ FOUNDATION_ASSERT怎么用?C++ FOUNDATION_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了FOUNDATION_ASSERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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, &paramSize, &paramType, nullptr);
			FOUNDATION_ASSERT(paramSize > 0);
		}

    	case ShaderParamType_UniformBlock:
    	{
    		paramIndex = glGetUniformBlockIndex(program->program, name);
    		glGetActiveUniformBlockiv(program->program, paramIndex, GL_UNIFORM_BLOCK_DATA_SIZE, &paramSize);
    		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;
}
开发者ID:johanster,项目名称:mint,代码行数:33,代码来源:osxRenderResource.cpp


示例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);
}
开发者ID:rampantpixels,项目名称:network_lib,代码行数:7,代码来源:stream.c


示例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) */
}
开发者ID:Jasper-Bekkers,项目名称:ProDBG,代码行数:35,代码来源:objectmap.c


示例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;
}
开发者ID:rampantpixels,项目名称:network_lib,代码行数:7,代码来源:stream.c


示例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);
}
开发者ID:rampantpixels,项目名称:network_lib,代码行数:7,代码来源:stream.c


示例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 );
}
开发者ID:sunfirefox,项目名称:foundation_lib,代码行数:9,代码来源:stream.c


示例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 );
}
开发者ID:sunfirefox,项目名称:foundation_lib,代码行数:9,代码来源:stream.c


示例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 };
}
开发者ID:haifenghuang,项目名称:foundation_lib,代码行数:56,代码来源:stream.c


示例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 );
}
开发者ID:sunfirefox,项目名称:foundation_lib,代码行数:10,代码来源:stream.c


示例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;
}
开发者ID:apprisi,项目名称:foundation_lib,代码行数:10,代码来源:objectmap.c


示例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;
}
开发者ID:rampantpixels,项目名称:network_lib,代码行数:13,代码来源:stream.c


示例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;
}
开发者ID:sunfirefox,项目名称:foundation_lib,代码行数:51,代码来源:stream.c


示例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) */
}
开发者ID:apprisi,项目名称:foundation_lib,代码行数:14,代码来源:objectmap.c


示例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 );
	}
}
开发者ID:HardlyHaki,项目名称:ProDBG,代码行数:50,代码来源:profile.c


示例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;
}
开发者ID:sunfirefox,项目名称:foundation_lib,代码行数:49,代码来源:stream.c


示例16: shader_create

shader_t* shader_create(const char* data, const int64_t dataSize, ShaderType type)
{
	GLuint shaderHandle = glCreateShader(type == VertexShader ? GL_VERTEX_SHADER : GL_FRAGMENT_SHADER);
	mint_CHECKFORGLERROR;
	{
		//Shader source should never exceed 4Gb anyway, riiight? 
		FOUNDATION_ASSERT(dataSize < 0xffffffff);
		int32_t shaderSourceSize = (int32_t) dataSize;
		glShaderSource(shaderHandle, 1, &data, &shaderSourceSize);
		mint_CHECKFORGLERROR;
		glCompileShader(shaderHandle);
		mint_CHECKFORGLERROR;

		int32_t logLength = 0, success;
		glGetShaderiv(shaderHandle, GL_COMPILE_STATUS, &success);
		glGetShaderiv(shaderHandle, GL_INFO_LOG_LENGTH, &logLength);
		if (success != GL_TRUE && logLength > 1)
		{
			int32_t charsWritten;
			GLchar* log = (GLchar*) memory_allocate(sizeof(GLchar) * (logLength + 1), 4, MEMORY_TEMPORARY);
			glGetShaderInfoLog(shaderHandle, logLength + 1, &charsWritten, log);
			log_errorf(ERROR_NONE, "Compiler results: %s", (char*) log);
			memory_deallocate(log);
		}
	}

	shader_t* shader = (shader_t*) memory_allocate(sizeof(shader_t), 4, MEMORY_PERSISTENT);
	shader->buffer = shaderHandle;
	return shader;
}
开发者ID:johanster,项目名称:mint,代码行数:30,代码来源:osxRenderResource.cpp


示例17: stream_available_read

unsigned int stream_available_read( stream_t* stream )
{
	FOUNDATION_ASSERT( stream );
	if( stream->vtable->available_read )
		return (unsigned int)stream->vtable->available_read( stream );
	return (unsigned int)( stream_size( stream ) - stream_tell( stream ) );
}
开发者ID:sunfirefox,项目名称:foundation_lib,代码行数:7,代码来源:stream.c


示例18: stream_determine_binary_mode

void stream_determine_binary_mode( stream_t* stream, unsigned int num )
{
	char* buf;
	int64_t cur;
	uint64_t actual_read, i;

	FOUNDATION_ASSERT( stream );
	if( !( stream->mode & STREAM_IN ) || stream_is_sequential( stream ) )
		return;

	if( !num )
		num = 8;

	buf = memory_allocate( num, 0, MEMORY_TEMPORARY );
	memset( buf, 32, num );
	
	cur = stream_tell( stream );
	actual_read = stream_read( stream, buf, num );
	stream_seek( stream, cur, STREAM_SEEK_BEGIN );

	stream->mode &= ~STREAM_BINARY;
	
	for( i = 0; i < actual_read; ++i )
	{
		//TODO: What about UTF-8?
		if( ( ( buf[i] < 0x20 ) && ( buf[i] != 0x09 ) && ( buf[i] != 0x0a ) && ( buf[i] != 0x0d ) ) || ( buf[i] > 0x7e ) )
		{
			stream->mode |= STREAM_BINARY;
			break;
		}
	}

	memory_deallocate( buf );
}
开发者ID:sunfirefox,项目名称:foundation_lib,代码行数:34,代码来源:stream.c


示例19: _pipe_stream_write

static uint64_t _pipe_stream_write( stream_t* stream, const void* source, uint64_t num )
{
	stream_pipe_t* pipestream = (stream_pipe_t*)stream;
	FOUNDATION_ASSERT( stream->type == STREAMTYPE_PIPE );
#if FOUNDATION_PLATFORM_WINDOWS
	if( pipestream->handle_write && ( ( pipestream->mode & STREAM_OUT ) != 0 ) )
	{
		uint64_t total_written = 0;
		do
		{
			unsigned long num_written = 0;
			if( !WriteFile( pipestream->handle_write, pointer_offset_const( source, total_written ), (unsigned int)( num - total_written ), &num_written, 0 ) )
				break;
			total_written += num_written;
		} while( total_written < num );
		return total_written;
	}
#elif FOUNDATION_PLATFORM_POSIX
	if( pipestream->fd_write && ( ( pipestream->mode & STREAM_OUT ) != 0 ) )
	{
		uint64_t total_written = 0;
		do
		{
			ssize_t num_written = write( pipestream->fd_write, pointer_offset_const( source, total_written ), (size_t)( num - total_written ) );
			if( num_written < 0 )
				break;
			total_written += num_written;
		} while( total_written < num );
		return total_written;
	}	
#endif

	return 0;
}
开发者ID:DanielTillett,项目名称:foundation_lib,代码行数:34,代码来源:pipe.c


示例20: mutex_lock

bool mutex_lock( mutex_t* mutex )
{
	FOUNDATION_ASSERT( mutex );

#if !BUILD_DEPLOY
	profile_trylock( mutex->name );
#endif

#if FOUNDATION_PLATFORM_WINDOWS
	EnterCriticalSection( (CRITICAL_SECTION*)mutex->csection );
#elif FOUNDATION_PLATFORM_POSIX
	if( pthread_mutex_lock( &mutex->mutex ) != 0 )
	{
		FOUNDATION_ASSERT_FAILFORMAT( "unable to lock mutex %s", mutex->name );
		return false;
	}
#else
#  error mutex_lock not implemented
#endif
#if !BUILD_DEPLOY
	profile_lock( mutex->name );
#endif

	FOUNDATION_ASSERT_MSGFORMAT( !mutex->lockcount || ( thread_id() == mutex->lockedthread ), "Mutex lock acquired with lockcount > 0 (%d) and locked thread not self (%llx != %llx)", mutex->lockcount, mutex->lockedthread, thread_id() );
	if( !mutex->lockcount )
		mutex->lockedthread = thread_id();
	++mutex->lockcount;

	return true;
}
开发者ID:apprisi,项目名称:foundation_lib,代码行数:30,代码来源:mutex.c



注:本文中的FOUNDATION_ASSERT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FOUNDATION_UNUSED函数代码示例发布时间:2022-05-30
下一篇:
C++ FOR_EACH_IMPL函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap