这篇教程C++ Assert函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中Assert函数的典型用法代码示例。如果您正苦于以下问题:C++ Assert函数的具体用法?C++ Assert怎么用?C++ Assert使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了Assert函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: Assertvoid ctp2_TextBuffer::Scroll(sint32 numLines){ sint32 errcode; char *buffer; sint32 deltaY = numLines * m_charHeight; errcode = m_surface->Lock(NULL, (LPVOID *)&buffer, 0); Assert(errcode == AUI_ERRCODE_OK); if (errcode != AUI_ERRCODE_OK) return; sint32 x = m_rect.left; sint32 y = m_rect.top; sint32 h = m_rect.bottom - m_rect.top, w = m_rect.right - m_rect.left, copyHeight = h - abs(deltaY); sint32 pitch = m_surface->Pitch(); uint32 *srcPtr, *destPtr; sint32 dy = abs(deltaY); sint32 i,j; sint32 slop; char *scrollBuffer = buffer + (pitch * y + x * 2); if (deltaY) { if (deltaY < 0) { srcPtr = (uint32 *)(scrollBuffer + (pitch * (h - dy - 1))); destPtr = (uint32 *)(scrollBuffer + (pitch * (h - 1))); slop = (pitch / 4) + (w / 2); for (i=0; i<copyHeight; i++) { for (j=0; j<w>>1; j++) { *destPtr++ = *srcPtr++; } srcPtr -= slop; destPtr -= slop; } for (i=0; i<dy; i++) { for (j=0; j<w>>1; j++) { *destPtr++ = 0x00000000; } destPtr -= slop; } } else { srcPtr = (uint32 *)(scrollBuffer + (pitch * dy)); destPtr = (uint32 *)(scrollBuffer); slop = (pitch / 4) - (w / 2); for (i=0; i<copyHeight; i++) { for (j=0; j<w>>1; j++) { *destPtr++ = *srcPtr++; } srcPtr += slop; destPtr += slop; } for (i=0; i<dy; i++) { for (j=0; j<w>>1; j++) { *destPtr++ = 0x00000000; } destPtr += slop; } } } errcode = m_surface->Unlock(buffer); Assert(errcode == AUI_ERRCODE_OK); if (errcode != AUI_ERRCODE_OK) return;}
开发者ID:jleclanche,项目名称:darkdust-ctp2,代码行数:69,
示例2: vcdSymbolTable//.........这里部分代码省略......... int sceneEntryStart = stringPoolStart + stringPool.TellMaxPut(); // then variable sized summaries int sceneSummaryStart = sceneEntryStart + g_SceneFiles.Count() * sizeof( SceneImageEntry_t ); // then variable sized compiled binary scene data int sceneDataStart = 0; // construct header SceneImageHeader_t imageHeader = { 0 }; imageHeader.nId = SCENE_IMAGE_ID; imageHeader.nVersion = SCENE_IMAGE_VERSION; imageHeader.nNumScenes = g_SceneFiles.Count(); imageHeader.nNumStrings = stringOffsets.Count(); imageHeader.nSceneEntryOffset = sceneEntryStart; if ( !bLittleEndian ) { imageHeader.nId = BigLong( imageHeader.nId ); imageHeader.nVersion = BigLong( imageHeader.nVersion ); imageHeader.nNumScenes = BigLong( imageHeader.nNumScenes ); imageHeader.nNumStrings = BigLong( imageHeader.nNumStrings ); imageHeader.nSceneEntryOffset = BigLong( imageHeader.nSceneEntryOffset ); } targetBuffer.Put( &imageHeader, sizeof( imageHeader ) ); // header is immediately followed by string table and pool for ( int i = 0; i < stringOffsets.Count(); i++ ) { unsigned int offset = stringPoolStart + stringOffsets[i]; if ( !bLittleEndian ) { offset = BigLong( offset ); } targetBuffer.PutInt( offset ); } Assert( stringPoolStart == targetBuffer.TellMaxPut() ); targetBuffer.Put( stringPool.Base(), stringPool.TellMaxPut() ); // construct directory CUtlSortVector< SceneImageEntry_t, CSceneImageEntryLessFunc > imageDirectory; imageDirectory.EnsureCapacity( g_SceneFiles.Count() ); // build directory // directory is linear sorted by filename checksum for later binary search for ( int i = 0; i < g_SceneFiles.Count(); i++ ) { SceneImageEntry_t imageEntry = { 0 }; // name needs to be normalized for determinstic later CRC name calc // calc crc based on scenes/anydir/anyscene.vcd char szCleanName[MAX_PATH]; V_strncpy( szCleanName, g_SceneFiles[i].fileName.String(), sizeof( szCleanName ) ); V_strlower( szCleanName ); V_FixSlashes( szCleanName ); char *pName = V_stristr( szCleanName, "scenes//" ); if ( !pName ) { // must have scenes/ in filename Error( "CreateSceneImageFile: Unexpected lack of scenes prefix on %s/n", g_SceneFiles[i].fileName.String() ); } CRC32_t crcFilename = CRC32_ProcessSingleBuffer( pName, strlen( pName ) ); imageEntry.crcFilename = crcFilename; // temp store an index to its file, fixup later, necessary to access post sort imageEntry.nDataOffset = i; if ( imageDirectory.Find( imageEntry ) != imageDirectory.InvalidIndex() ) {
开发者ID:xxauroraxx,项目名称:Source.Python,代码行数:67,
示例3: CclMissile/**** Create a missile.**** @param l Lua state.*/static int CclMissile(lua_State *l){ MissileType *type = NULL; PixelPos position(-1, -1); PixelPos destination(-1, -1); PixelPos source(-1, -1); Missile *missile = NULL; DebugPrint("FIXME: not finished/n"); const int args = lua_gettop(l); for (int j = 0; j < args; ++j) { const char *value = LuaToString(l, j + 1); ++j; if (!strcmp(value, "type")) { type = MissileTypeByIdent(LuaToString(l, j + 1)); } else if (!strcmp(value, "pos")) { CclGetPos(l, &position.x, &position.y, j + 1); } else if (!strcmp(value, "origin-pos")) { CclGetPos(l, &source.x, &source.y, j + 1); } else if (!strcmp(value, "goal")) { CclGetPos(l, &destination.x, &destination.y, j + 1); } else if (!strcmp(value, "local")) { Assert(type); missile = MakeLocalMissile(*type, position, destination); missile->Local = 1; --j; } else if (!strcmp(value, "global")) { Assert(type); missile = MakeMissile(*type, position, destination); missile->position = position; missile->source = source; missile->destination = destination; missile->Local = 0; --j; } else if (!strcmp(value, "frame")) { Assert(missile); missile->SpriteFrame = LuaToNumber(l, j + 1); } else if (!strcmp(value, "state")) { Assert(missile); missile->State = LuaToNumber(l, j + 1); } else if (!strcmp(value, "anim-wait")) { Assert(missile); missile->AnimWait = LuaToNumber(l, j + 1); } else if (!strcmp(value, "wait")) { Assert(missile); missile->Wait = LuaToNumber(l, j + 1); } else if (!strcmp(value, "delay")) { Assert(missile); missile->Delay = LuaToNumber(l, j + 1); } else if (!strcmp(value, "source")) { Assert(missile); lua_pushvalue(l, j + 1); missile->SourceUnit = CclGetUnitFromRef(l); lua_pop(l, 1); } else if (!strcmp(value, "target")) { Assert(missile); lua_pushvalue(l, j + 1); missile->TargetUnit = CclGetUnitFromRef(l); lua_pop(l, 1); } else if (!strcmp(value, "damage")) { Assert(missile); missile->Damage = LuaToNumber(l, j + 1); } else if (!strcmp(value, "ttl")) { Assert(missile); missile->TTL = LuaToNumber(l, j + 1); } else if (!strcmp(value, "hidden")) { Assert(missile); missile->Hidden = 1; --j; } else if (!strcmp(value, "step")) { Assert(missile); if (!lua_istable(l, j + 1) || lua_rawlen(l, j + 1) != 2) { LuaError(l, "incorrect argument"); } missile->CurrentStep = LuaToNumber(l, j + 1, 1); missile->TotalStep = LuaToNumber(l, j + 1, 2); } else { LuaError(l, "Unsupported tag: %s" _C_ value); } } // we need to reinitialize position parameters - that's because of // the way InitMissile() (called from MakeLocalMissile()) computes // them - it works for creating a missile during a game but breaks // loading the missile from a file. missile->position = position; missile->source = source; missile->destination = destination; return 0;}
开发者ID:onkrot,项目名称:stratagus,代码行数:97,
示例4: shm_mq_set_handle/* * Associate a BackgroundWorkerHandle with a shm_mq_handle just as if it had * been passed to shm_mq_attach. */voidshm_mq_set_handle(shm_mq_handle *mqh, BackgroundWorkerHandle *handle){ Assert(mqh->mqh_handle == NULL); mqh->mqh_handle = handle;}
开发者ID:kasoku,项目名称:jpug-doc,代码行数:10,
示例5: shm_mq_receive/* * Receive a message from a shared message queue. * * We set *nbytes to the message length and *data to point to the message * payload. If the entire message exists in the queue as a single, * contiguous chunk, *data will point directly into shared memory; otherwise, * it will point to a temporary buffer. This mostly avoids data copying in * the hoped-for case where messages are short compared to the buffer size, * while still allowing longer messages. In either case, the return value * remains valid until the next receive operation is perfomed on the queue. * * When nowait = false, we'll wait on our process latch when the ring buffer * is empty and we have not yet received a full message. The sender will * set our process latch after more data has been written, and we'll resume * processing. Each call will therefore return a complete message * (unless the sender detaches the queue). * * When nowait = true, we do not manipulate the state of the process latch; * instead, whenever the buffer is empty and we need to read from it, we * return SHM_MQ_WOULD_BLOCK. In this case, the caller should call this * function again after the process latch has been set. */shm_mq_resultshm_mq_receive(shm_mq_handle *mqh, Size *nbytesp, void **datap, bool nowait){ shm_mq *mq = mqh->mqh_queue; shm_mq_result res; Size rb = 0; Size nbytes; void *rawdata; Assert(mq->mq_receiver == MyProc); /* We can't receive data until the sender has attached. */ if (!mqh->mqh_counterparty_attached) { if (nowait) { if (shm_mq_get_sender(mq) == NULL) return SHM_MQ_WOULD_BLOCK; } else if (!shm_mq_wait_internal(mq, &mq->mq_sender, mqh->mqh_handle) && shm_mq_get_sender(mq) == NULL) { mq->mq_detached = true; return SHM_MQ_DETACHED; } mqh->mqh_counterparty_attached = true; } /* Consume any zero-copy data from previous receive operation. */ if (mqh->mqh_consume_pending > 0) { shm_mq_inc_bytes_read(mq, mqh->mqh_consume_pending); mqh->mqh_consume_pending = 0; } /* Try to read, or finish reading, the length word from the buffer. */ while (!mqh->mqh_length_word_complete) { /* Try to receive the message length word. */ Assert(mqh->mqh_partial_bytes < sizeof(Size)); res = shm_mq_receive_bytes(mq, sizeof(Size) - mqh->mqh_partial_bytes, nowait, &rb, &rawdata); if (res != SHM_MQ_SUCCESS) return res; /* * Hopefully, we'll receive the entire message length word at once. * But if sizeof(Size) > MAXIMUM_ALIGNOF, then it might be split over * multiple reads. */ if (mqh->mqh_partial_bytes == 0 && rb >= sizeof(Size)) { Size needed; nbytes = *(Size *) rawdata; /* If we've already got the whole message, we're done. */ needed = MAXALIGN(sizeof(Size)) + MAXALIGN(nbytes); if (rb >= needed) { /* * Technically, we could consume the message length * information at this point, but the extra write to shared * memory wouldn't be free and in most cases we would reap no * benefit. */ mqh->mqh_consume_pending = needed; *nbytesp = nbytes; *datap = ((char *) rawdata) + MAXALIGN(sizeof(Size)); return SHM_MQ_SUCCESS; } /* * We don't have the whole message, but we at least have the whole * length word. */ mqh->mqh_expected_bytes = nbytes; mqh->mqh_length_word_complete = true;//.........这里部分代码省略.........
开发者ID:kasoku,项目名称:jpug-doc,代码行数:101,
示例6: get_object_address/* * Translate an object name and arguments (as passed by the parser) to an * ObjectAddress. * * The returned object will be locked using the specified lockmode. If a * sub-object is looked up, the parent object will be locked instead. * * If the object is a relation or a child object of a relation (e.g. an * attribute or contraint), the relation is also opened and *relp receives * the open relcache entry pointer; otherwise, *relp is set to NULL. This * is a bit grotty but it makes life simpler, since the caller will * typically need the relcache entry too. Caller must close the relcache * entry when done with it. The relation is locked with the specified lockmode * if the target object is the relation itself or an attribute, but for other * child objects, only AccessShareLock is acquired on the relation. * * We don't currently provide a function to release the locks acquired here; * typically, the lock must be held until commit to guard against a concurrent * drop operation. */ObjectAddressget_object_address(ObjectType objtype, List *objname, List *objargs, Relation *relp, LOCKMODE lockmode){ ObjectAddress address; Relation relation = NULL; /* Some kind of lock must be taken. */ Assert(lockmode != NoLock); switch (objtype) { case OBJECT_INDEX: case OBJECT_SEQUENCE: case OBJECT_TABLE: case OBJECT_VIEW: relation = get_relation_by_qualified_name(objtype, objname, lockmode); address.classId = RelationRelationId; address.objectId = RelationGetRelid(relation); address.objectSubId = 0; break; case OBJECT_COLUMN: address = get_object_address_attribute(objtype, objname, &relation, lockmode); break; case OBJECT_RULE: case OBJECT_TRIGGER: case OBJECT_CONSTRAINT: address = get_object_address_relobject(objtype, objname, &relation); break; case OBJECT_DATABASE: case OBJECT_EXTENSION: case OBJECT_TABLESPACE: case OBJECT_ROLE: case OBJECT_SCHEMA: case OBJECT_LANGUAGE: address = get_object_address_unqualified(objtype, objname); break; case OBJECT_TYPE: case OBJECT_DOMAIN: address.classId = TypeRelationId; address.objectId = typenameTypeId(NULL, makeTypeNameFromNameList(objname), NULL); address.objectSubId = 0; break; case OBJECT_AGGREGATE: address.classId = ProcedureRelationId; address.objectId = LookupAggNameTypeNames(objname, objargs, false); address.objectSubId = 0; break; case OBJECT_FUNCTION: address.classId = ProcedureRelationId; address.objectId = LookupFuncNameTypeNames(objname, objargs, false); address.objectSubId = 0; break; case OBJECT_OPERATOR: Assert(list_length(objargs) == 2); address.classId = OperatorRelationId; address.objectId = LookupOperNameTypeNames(NULL, objname, (TypeName *) linitial(objargs), (TypeName *) lsecond(objargs), false, -1); address.objectSubId = 0; break; case OBJECT_OPCLASS: case OBJECT_OPFAMILY: address = get_object_address_opcf(objtype, objname, objargs); break; case OBJECT_CAST: { TypeName *sourcetype = (TypeName *) linitial(objname); TypeName *targettype = (TypeName *) linitial(objargs); Oid sourcetypeid = typenameTypeId(NULL, sourcetype, NULL); Oid targettypeid = typenameTypeId(NULL, targettype, NULL); address.classId = CastRelationId; address.objectId =//.........这里部分代码省略.........
开发者ID:50wu,项目名称:gpdb,代码行数:101,
|