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

C++ GM_ASSERT函数代码示例

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

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



在下文中一共展示了GM_ASSERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:7,代码来源:gmCodeGen.cpp


示例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);
}
开发者ID:arajar,项目名称:funk,代码行数:59,代码来源:gmIncGC.cpp


示例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);
}
开发者ID:joechenq,项目名称:multi-script,代码行数:9,代码来源:ScriptSys.cpp


示例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;
}
开发者ID:CJFocke,项目名称:vsxu,代码行数:56,代码来源:gmIncGC.cpp


示例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();
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:29,代码来源:gmSystemLib.cpp


示例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
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:16,代码来源:gmSystemLib.cpp


示例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;
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:30,代码来源:gmSystemLib.cpp


示例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;
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:25,代码来源:gmSystemLib.cpp


示例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;
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:7,代码来源:gmSystemLib.cpp


示例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;
}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:26,代码来源:gmStringLib.cpp


示例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;
}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:28,代码来源:gmStringLib.cpp


示例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;
}
开发者ID:cgbystrom,项目名称:scriptorium,代码行数:26,代码来源:gmThread.cpp


示例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;
  }
}
开发者ID:arajar,项目名称:funk,代码行数:27,代码来源:gmIncGC.cpp


示例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;
}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:30,代码来源:gmStringLib.cpp


示例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;
}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:27,代码来源:gmStringLib.cpp


示例16: while

bool gmGCColorSet::VerifyIntegrity()
{
  // Scan through list make sure all pointers are in valid positions and all objects are colored correctly
  gmGCObjBase* curObj = m_gray->GetNext();
  int curCol = GM_GC_DEBUG_COL_GRAY;
  while(curObj != m_tail)
  {
    if(curObj == m_scan)
    {
      curCol = GM_GC_DEBUG_COL_BLACK;
    }
    if(curObj == m_free)
    {
      curCol = GM_GC_DEBUG_COL_FREE;
    }
    if(curObj == m_white)
    {
      curCol = GM_GC_DEBUG_COL_WHITE;
    }
    if(curObj != &m_separatorObject)
    {
      GM_ASSERT(curObj->m_curPosColor == curCol);
    }

    curObj = curObj->GetNext();
  }
  
  return true;
}
开发者ID:arajar,项目名称:funk,代码行数:29,代码来源:gmIncGC.cpp


示例17: gmStringSetAt

// string string.SetAt(int a_index, int a_char);
// Returns string with modified character at offset, or original string if index out of range.
static int GM_CDECL gmStringSetAt(gmThread * a_thread)
{
  GM_CHECK_NUM_PARAMS(1);
  GM_CHECK_INT_PARAM(index, 0);
  GM_CHECK_INT_PARAM(newChar, 1);

  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(index < 0 || index >= strLength)
  {
    a_thread->PushString(strObj); //Return original string if index out of range
    return GM_OK;
  }

  char * buffer = (char *) alloca(strLength + 1); 
  memcpy(buffer, str, strLength + 1); //Copy old string
  buffer[index] = (char)newChar; //Set character in string

  a_thread->PushNewString(buffer, strLength);
  return GM_OK;
}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:29,代码来源:gmStringLib.cpp


示例18: gmStringReverseFind

// int string.ReverseFind(char/string a_charOrStringToFind);
// Find the last instance of a specific character in a string.
// Returns character offset or -1 if not found.
static int GM_CDECL gmStringReverseFind(gmThread * a_thread)
{
  GM_CHECK_NUM_PARAMS(1);

  const char* retCharPtr = NULL;
  const gmVariable * var = a_thread->GetThis();
  GM_ASSERT(var->m_type == GM_STRING);
  gmStringObject * thisStrObj = (gmStringObject *) GM_OBJECT(var->m_value.m_ref);
  const char* thisStr = (const char *) *thisStrObj;
  
  if(a_thread->ParamType(0) == GM_INT)
  {
    const char otherChar = (char)a_thread->ParamInt(0);
    
    //Find character
    retCharPtr = strrchr(thisStr, otherChar);
  }
  else if(a_thread->ParamType(0) == GM_STRING)
  {
    gmStringObject * otherStrObj = a_thread->ParamStringObject(0);
    const char* otherStr = a_thread->ParamString(0);

    //Find string
    const char* lastFoundPtr = NULL;
    const char* newTestPtr = NULL;
    const char* curTestPtr = thisStr;
    const char* endThisStr = thisStr + thisStrObj->GetLength();
    int searchStrLength = otherStrObj->GetLength();

    //Search through string for last occurence
    //Not very efficient, but very rarely used.
    for(;;)
    {
      newTestPtr = strstr(curTestPtr, otherStr);
      if(!newTestPtr)
      {
        break;
      }
      lastFoundPtr = newTestPtr;
      curTestPtr = newTestPtr + searchStrLength;
      if(curTestPtr > endThisStr)
      {
        break;
      }
    };

    retCharPtr = lastFoundPtr;
  }
  else
  {
    return GM_EXCEPTION;
  }

  // return -1 for not found, distance from beginning otherwise
  int retOffset = (retCharPtr == NULL) ? -1 : (int)(retCharPtr - thisStr);
  a_thread->PushInt(retOffset);

  return GM_OK;
}
开发者ID:Sylica2013,项目名称:Antrix,代码行数:62,代码来源:gmStringLib.cpp


示例19: Cross

  static void Cross(const gmVector3& a_vec1, const gmVector3& a_vec2, gmVector3& a_result)
  {
    GM_ASSERT( (&a_result != &a_vec1) && (&a_result != &a_vec2) );

    a_result.m_x = (a_vec1.m_y * a_vec2.m_z) - (a_vec1.m_z * a_vec2.m_y);
    a_result.m_y = (a_vec1.m_z * a_vec2.m_x) - (a_vec1.m_x * a_vec2.m_z);
    a_result.m_z = (a_vec1.m_x * a_vec2.m_y) - (a_vec1.m_y * a_vec2.m_x);
  }
开发者ID:joechenq,项目名称:multi-script,代码行数:8,代码来源:gmVector3Lib.cpp


示例20: gmfFileClose

static int GM_CDECL gmfFileClose(gmThread * a_thread)
{
  gmUserObject * fileObject = a_thread->ThisUserObject();
  GM_ASSERT(fileObject->m_userType == s_gmFileType);
  if(fileObject->m_user) fclose((FILE *) fileObject->m_user);
  fileObject->m_user = NULL;
  return GM_OK;
}
开发者ID:Guthius,项目名称:gs2emu-googlecode,代码行数:8,代码来源:gmSystemLib.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ GM_CHECK_NUM_PARAMS函数代码示例发布时间:2022-05-30
下一篇:
C++ GMX_RELEASE_ASSERT函数代码示例发布时间: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