本文整理匯總了C++中GM_ASSERT函數的典型用法代碼示例。如果您正苦於以下問題:C++ GM_ASSERT函數的具體用法?C++ GM_ASSERT怎麽用?C++ GM_ASSERT使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GM_ASSERT函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: GM_ASSERT
bool gmCodeGenPrivate::GenDeclVariable(const gmCodeTreeNode * a_node, gmByteCodeGen * a_byteCode)
{
GM_ASSERT(a_node->m_type == CTNT_DECLARATION && a_node->m_subType == CTNDT_VARIABLE);
GM_ASSERT(m_currentFunction);
m_currentFunction->SetVariableType(a_node->m_children[0]->m_data.m_string, (gmCodeTreeVariableType) a_node->m_subTypeType);
return true;
}
示例2: DestructPersistantObjects
void gmGCColorSet::DestructAll()
{
int count = 0;
DestructPersistantObjects();
// Black and Gray
gmGCObjBase* curGrayOrBlack = m_gray->GetNext();
while(curGrayOrBlack != m_free)
{
gmGCObjBase* objToRecycle = curGrayOrBlack;
curGrayOrBlack = curGrayOrBlack->GetNext();
#if GM_GC_KEEP_PERSISTANT_SEPARATE
GM_ASSERT(!objToRecycle->GetPersist());
#endif //GM_GC_KEEP_PERSISTANT_SEPARATE
objToRecycle->Destruct(m_gc->GetVM());
#if GM_GC_STATS
--m_numAllocated;
#endif //GM_GC_STATS
++count;
}
// Whites
gmGCObjBase* curWhite = m_white->GetNext();
while(curWhite != m_tail)
{
gmGCObjBase* objToRecycle = curWhite;
curWhite = curWhite->GetNext();
#if GM_GC_KEEP_PERSISTANT_SEPARATE
GM_ASSERT(!objToRecycle->GetPersist());
#endif //GM_GC_KEEP_PERSISTANT_SEPARATE
objToRecycle->Destruct(m_gc->GetVM());
#if GM_GC_STATS
--m_numAllocated;
#endif //GM_GC_STATS
++count;
}
// Free list
gmGCObjBase* curFree = m_free;
while(curFree != m_white)
{
gmGCObjBase* objToRecycle = curFree;
curFree = curFree->GetNext();
{
#if GM_GC_KEEP_PERSISTANT_SEPARATE
GM_ASSERT(!objToRecycle->GetPersist());
#endif //GM_GC_KEEP_PERSISTANT_SEPARATE
objToRecycle->Destruct(m_gc->GetVM());
#if GM_GC_STATS
--m_numAllocated;
#endif //GM_GC_STATS
++count;
}
}
Init(m_gc);
}
示例3: GM_ASSERT
void ScriptSys::SetTableGameObj(const char* a_memberName, GameObj* a_gameObj, gmTableObject* a_table)
{
GM_ASSERT(a_table);
GM_ASSERT(a_gameObj);
gmTableObject* table = a_table;
gmVariable newVar;
newVar.SetUser(a_gameObj->GetScriptObj()->GetUserObject());
table->Set(m_machine, a_memberName, newVar);
}
示例4: while
int gmGCColorSet::DestructSomeFreeObjects(int a_maxToDestruct)
{
int numDestructed = 0;
// Go through the free list (perhaps over multiple installments in future) and call Destruct() on them.
if(m_free != m_white)
{
gmGCObjBase* beforeFree = m_free->GetPrev(); // Save previous node so we can relink after removing some
bool fixScan = false;
if(m_scan == m_free) // Will need to fix the scan ptr later if this is so.
{
fixScan = true;
}
while(m_free != m_white)
{
gmGCObjBase* objToRecycle = m_free;
m_free = m_free->GetNext();
#if GM_GC_DEBUG
//GM_ASSERT(objToRecycle->m_curPosColor == GM_GC_DEBUG_COL_WHITE);
GM_ASSERT(objToRecycle->m_curPosColor == GM_GC_DEBUG_COL_FREE);
objToRecycle->m_curPosColor = GM_GC_DEBUG_COL_INVALID;
#endif //GM_GC_DEBUG
#if GM_GC_KEEP_PERSISTANT_SEPARATE
GM_ASSERT(!objToRecycle->GetPersist());
#endif //GM_GC_KEEP_PERSISTANT_SEPARATE
#if GM_GC_STATS
--m_numAllocated;
#endif //GM_GC_STATS
objToRecycle->Destruct(m_gc->GetVM());
++numDestructed;
--a_maxToDestruct;
if(a_maxToDestruct <= 0)
{
// Relink since we removed elements
beforeFree->SetNext(m_free);
m_free->SetPrev(beforeFree);
if(fixScan)
{
m_scan = m_free;
}
return numDestructed; // Work is done for now.
}
}
// Relink since we removed elements
beforeFree->SetNext(m_free);
m_free->SetPrev(beforeFree);
if(fixScan)
{
m_scan = m_free;
}
}
return numDestructed;
}
示例5: gmFileInfoOpGetDot
static void GM_CDECL gmFileInfoOpGetDot(gmThread * a_thread, gmVariable * a_operands)
{
gmUserObject * user = (gmUserObject *) GM_OBJECT(a_operands->m_value.m_ref);
if(user && user->m_user)
{
gmFileInfoUser * fileInfo = (gmFileInfoUser *) user->m_user;
gmStringObject * member = (gmStringObject *) GM_OBJECT(a_operands[1].m_value.m_ref);
GM_ASSERT(sizeof(fileInfo->m_creationTime) <= sizeof(gmint));
// NOTE: Not valid or tested for 64bit target
if(strcmp(member->GetString(), "creationTime") == 0)
a_operands->SetInt((gmint) fileInfo->m_creationTime);
else if(strcmp(member->GetString(), "accessedTime") == 0)
a_operands->SetInt((gmint) fileInfo->m_accessedTime);
else if(strcmp(member->GetString(), "modifiedTime") == 0)
a_operands->SetInt((gmint) fileInfo->m_modifiedTime);
else if(strcmp(member->GetString(), "size") == 0)
a_operands->SetInt((gmint) fileInfo->m_size);
else
{
a_operands->Nullify();
return;
}
return;
}
a_operands->Nullify();
}
示例6: gmfTime
static int GM_CDECL gmfTime(gmThread * a_thread)
{
#ifdef IS64BIT // Compatible with 64bit OS
__time32_t t;
_time32(&t);
GM_ASSERT(sizeof(t) <= sizeof(gmint));
a_thread->PushInt(t);
return GM_OK;
#else
time_t t;
time(&t);
GM_ASSERT(sizeof(time_t) <= sizeof(gmptr));
a_thread->PushInt(t);
return GM_OK;
#endif
}
示例7: gmfSystem
static int GM_CDECL gmfSystem(gmThread * a_thread)
{
const int bufferSize = 256;
int len = 0, size = 0, i, ret = -1;
char * str = NULL, buffer[bufferSize];
// build the string
for(i = 0; i < a_thread->GetNumParams(); ++i)
{
gmConcat(a_thread->GetMachine(), str, len, size, a_thread->Param(i).AsString(a_thread->GetMachine(), buffer, bufferSize), 64);
if(str)
{
GM_ASSERT(len < size);
str[len++] = ' ';
str[len] = '\0';
}
}
// print the string
if(str)
{
ret = system(str);
a_thread->GetMachine()->Sys_Free(str);
}
a_thread->PushInt(ret);
return GM_OK;
}
示例8: gmfFileSeek
static int GM_CDECL gmfFileSeek(gmThread * a_thread) // return false on error
{
gmUserObject * fileObject = a_thread->ThisUserObject();
GM_ASSERT(fileObject->m_userType == s_gmFileType);
GM_CHECK_NUM_PARAMS(2);
GM_CHECK_INT_PARAM(offset, 0);
GM_CHECK_INT_PARAM(origin, 1);
if( origin != SEEK_CUR
&& origin != SEEK_END
&& origin != SEEK_SET )
{
return GM_EXCEPTION;
}
int result = fseek((FILE*)fileObject->m_user, offset, origin);
if(result != 0)
{
a_thread->PushInt(false);
}
a_thread->PushInt(true);
return GM_OK;
}
示例9: gmfFileIsOpen
static int GM_CDECL gmfFileIsOpen(gmThread * a_thread) // return 1 if open, else 0
{
gmUserObject * fileObject = a_thread->ThisUserObject();
GM_ASSERT(fileObject->m_userType == s_gmFileType);
a_thread->PushInt((fileObject->m_user) ? 1 : 0);
return GM_OK;
}
示例10: gmfStringSpanExcluding
static int GM_CDECL gmfStringSpanExcluding(gmThread * a_thread)
{
GM_CHECK_NUM_PARAMS(1);
if(a_thread->ParamType(0) == GM_STRING)
{
const gmVariable * var = a_thread->GetThis();
GM_ASSERT(var->m_type == GM_STRING);
gmStringObject * strObj = (gmStringObject *) GM_OBJECT(var->m_value.m_ref);
const char * thisStr = (const char *) *strObj;
const char * otherStr = a_thread->ParamString(0);
int offset = strcspn(thisStr, otherStr);
char * buffer = (char *) alloca(offset + 1);
memcpy(buffer, thisStr, offset);
buffer[offset] = 0;
a_thread->PushNewString(buffer, offset);
return GM_OK;
}
return GM_EXCEPTION;
}
示例11: gmStringTrimRight
static int GM_CDECL gmStringTrimRight(gmThread * a_thread)
{
GM_STRING_PARAM(trim, 0, GM_WHITE_SPACE);
const gmVariable * var = a_thread->GetThis();
GM_ASSERT(var->m_type == GM_STRING);
gmStringObject * strObj = (gmStringObject *) GM_OBJECT(var->m_value.m_ref);
const char * str = (const char *) *strObj;
int strLength = strObj->GetLength();
if(strLength > 0)
{
char * buffer = (char *) alloca(strLength + 1);
memcpy(buffer, str, strLength + 1); //Copy old string
// Find beginning of trailing matches by starting at end
char *lpsz = buffer + strLength;
while (--lpsz >= buffer && strchr(trim, *lpsz) != NULL) {}
++lpsz;
*lpsz = '\0';
a_thread->PushNewString(buffer);
}
else
{
a_thread->PushString(strObj);
}
return GM_OK;
}
示例12: while
bool gmThread::Touch(int a_extra)
{
// Grow stack if necessary. NOTE: Use better growth metric if needed.
bool reAlloc = false;
while((m_top + a_extra + GMTHREAD_SLACKSPACE) >= m_size)
{
if(sizeof(gmVariable) * m_size > GMTHREAD_MAXBYTESIZE)
{
GM_ASSERT(!"GMTHREAD_MAXBYTESIZE exceeded");
return false;
}
m_size *= 2;
reAlloc = true;
}
if(reAlloc)
{
gmVariable * stack = new gmVariable[m_size];
//memset(stack, 0, sizeof(gmVariable) * m_size);
memcpy(stack, m_stack, m_top * sizeof(gmVariable));
if(m_stack)
delete[] m_stack;
m_stack = stack;
}
return true;
}
示例13: GM_ASSERT
void gmGCColorSet::Allocate(gmGCObjBase* a_obj)
{
#if GM_GC_STATS
++m_numAllocated;
#endif //GM_GC_STATS
a_obj->SetPersist(false);
a_obj->SetColor(m_gc->GetCurShadeColor());
#if GM_GC_DEBUG
GM_ASSERT(a_obj->m_curPosColor == GM_GC_DEBUG_COL_INVALID);
a_obj->m_curPosColor = GM_GC_DEBUG_COL_BLACK;
#endif //GM_GC_DEBUG
//Insert at the end of black list
a_obj->SetNext(m_free); //Next is first Free
a_obj->SetPrev(m_free->GetPrev()); //Prev is last Black
m_free->GetPrev()->SetNext(a_obj); //Last Black next is now this
m_free->SetPrev(a_obj); //Free prev is now this
//If there were no blacks, move scan forward to prevent scanning this new black
if(m_scan == m_free)
{
m_scan = a_obj;
}
}
示例14: gmStringGetPath
static int GM_CDECL gmStringGetPath(gmThread * a_thread)
{
GM_INT_PARAM(keepSlash, 0, 0);
const gmVariable * var = a_thread->GetThis();
GM_ASSERT(var->m_type == GM_STRING);
gmStringObject * strObj = (gmStringObject *) GM_OBJECT(var->m_value.m_ref);
const char * str = (const char *) *strObj;
int strLength = strObj->GetLength();
char * buffer = (char *) alloca(strLength + 1);
memcpy(buffer, str, strLength + 1); //Copy old string
char *lpsz = buffer + strLength;
while (--lpsz >= buffer && *lpsz != '\\' && *lpsz != '/') {}
if(*lpsz == '\\' || *lpsz == '/')
{
if(keepSlash)
lpsz[1] = 0;
else
lpsz[0] = 0;
a_thread->PushNewString(buffer);
}
else
{
a_thread->PushNewString("");
}
return GM_OK;
}
示例15: gmStringGetExtension
static int GM_CDECL gmStringGetExtension(gmThread * a_thread)
{
GM_INT_PARAM(keepDot, 0, 0);
const gmVariable * var = a_thread->GetThis();
GM_ASSERT(var->m_type == GM_STRING);
gmStringObject * strObj = (gmStringObject *) GM_OBJECT(var->m_value.m_ref);
const char * str = (const char *) *strObj;
int strLength = strObj->GetLength();
const char *lpsz = str + strLength;
while (--lpsz >= str && *lpsz != '.') {}
if(*lpsz == '.')
{
if(!keepDot)
{
++lpsz;
}
a_thread->PushNewString(lpsz);
}
else
{
a_thread->PushNewString("");
}
return GM_OK;
}