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

C++ LUA_ASSERT函数代码示例

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

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



在下文中一共展示了LUA_ASSERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: aux_stackedfunction

static const char *getobjname (lua_State *L, StkId obj, const char **name) {
  StkId func = aux_stackedfunction(L, 0, obj);
  if (!isLmark(func))
    return NULL;  /* not an active Lua function */
  else {
    Proto *p = infovalue(func)->func->f.l;
    int pc = currentpc(func);
    int stackpos = obj - (func+1);  /* func+1 == function base */
    Instruction i = luaG_symbexec(p, pc, stackpos);
    LUA_ASSERT(pc != -1, "function must be active");
    switch (GET_OPCODE(i)) {
      case OP_GETGLOBAL: {
        *name = p->kstr[GETARG_U(i)]->str;
        return "global";
      }
      case OP_GETLOCAL: {
        *name = luaF_getlocalname(p, GETARG_U(i)+1, pc);
        LUA_ASSERT(*name, "local must exist");
        return "local";
      }
      case OP_PUSHSELF:
      case OP_GETDOTTED: {
        *name = p->kstr[GETARG_U(i)]->str;
        return "field";
      }
      default:
        return NULL;  /* no useful name found */
    }
  }
}
开发者ID:rparet,项目名称:darkpawns,代码行数:30,代码来源:ldebug.c


示例2: luaG_getline

/* copied from ldebug.c */
int luaG_getline (int *lineinfo, int pc, int refline, int *prefi) {
  int refi;
  if (lineinfo == NULL || pc == -1)
    return -1;  /* no line info or function is not active */
  refi = prefi ? *prefi : 0;
  if (lineinfo[refi] < 0)
    refline += -lineinfo[refi++]; 
  LUA_ASSERT(lineinfo[refi] >= 0, "invalid line info");
  while (lineinfo[refi] > pc) {
    refline--;
    refi--;
    if (lineinfo[refi] < 0)
      refline -= -lineinfo[refi--]; 
    LUA_ASSERT(lineinfo[refi] >= 0, "invalid line info");
  }
  for (;;) {
    int nextline = refline + 1;
    int nextref = refi + 1;
    if (lineinfo[nextref] < 0)
      nextline += -lineinfo[nextref++]; 
    LUA_ASSERT(lineinfo[nextref] >= 0, "invalid line info");
    if (lineinfo[nextref] > pc)
      break;
    refline = nextline;
    refi = nextref;
  }
  if (prefi) *prefi = refi;
  return refline;
}
开发者ID:jessicah,项目名称:Vision,代码行数:30,代码来源:stubs.c


示例3: Vector2_New

static int Vector2_New(lua_State* aLuaState)
{
	float x = 0.f;
	float y = 0.f;
	int nrOfArguments = lua_gettop(aLuaState)-1;
	if(nrOfArguments == 0 || nrOfArguments == 2)
	{
		if(nrOfArguments == 2)
		{
			x = (float)(lua_tonumber(aLuaState,-2));
			y = (float)(lua_tonumber(aLuaState,-1));
		}
	}
	else
	{
		LUA_ASSERT(aLuaState,"Too many or too few arguments in Vector declaration");
	}
	lua_pop(aLuaState,3);
	lua_newtable(aLuaState);
	lua_pushstring(aLuaState,"x");
	lua_pushnumber(aLuaState,x);
	lua_settable(aLuaState,-3);
	lua_pushstring(aLuaState,"y");
	lua_pushnumber(aLuaState,y);
	lua_settable(aLuaState,-3);
	luaL_getmetatable(aLuaState,"Vector2");
	lua_setmetatable(aLuaState,-2);
	return 1;
}
开发者ID:TricycleCavalry,项目名称:CodeWars,代码行数:29,代码来源:MathLib.c


示例4: switch

/*
** returns the `main' position of an element in a table (that is, the index
** of its hash value)
*/
Node *luaH_mainposition (const Hash *t, const TObject *key) {
  unsigned h;
  switch (ttype(key)) {
    case LUA_TNUMBER:
      h = (unsigned)(int)nvalue(key);
      break;
    case LUA_TSTRING:
      h = tsvalue(key)->u.s.hash;
      break;
    case LUA_TUSERDATA:
      h = IntPoint(tsvalue(key));
      break;
    case LUA_TTABLE:
      h = IntPoint(hvalue(key));
      break;
    case LUA_TFUNCTION:
      h = IntPoint(clvalue(key));
      break;
    default:
      return NULL;  /* invalid key */
  }
  LUA_ASSERT(h%(unsigned int)t->size == (h&((unsigned int)t->size-1)),
            "a&(x-1) == a%x, for x power of 2");
  return &t->node[h&(t->size-1)];
}
开发者ID:Djent-,项目名称:GBALua,代码行数:29,代码来源:ltable.c


示例5: invalidaterefs

static void invalidaterefs (lua_State *L) {
  int n = L->refSize;
  int i;
  for (i=0; i<n; i++) {
    struct Ref *r = &L->refArray[i];
    if (r->st == HOLD && !hasmark(&r->o))
      r->st = COLLECTED;
    LUA_ASSERT((r->st == LOCK && hasmark(&r->o)) ||
               (r->st == HOLD && hasmark(&r->o)) ||
                r->st == COLLECTED ||
                r->st == NONEXT ||
               (r->st < n && VALIDLINK(L, L->refArray[r->st].st, n)),
               "inconsistent ref table");
  }
  LUA_ASSERT(VALIDLINK(L, L->refFree, n), "inconsistent ref table");
}
开发者ID:Akagi201,项目名称:learning-lua,代码行数:16,代码来源:lgc.c


示例6: lua_unref

LUA_API void lua_unref (lua_State *L, int ref) {
  if (ref >= 0) {
    LUA_ASSERT(ref < L->refSize && L->refArray[ref].st < 0, "invalid ref");
    L->refArray[ref].st = L->refFree;
    L->refFree = ref;
  }
}
开发者ID:XeanoRRR,项目名称:mmo-resourse,代码行数:7,代码来源:lapi.c


示例7: luaK_testgo

static void luaK_testgo (FuncState *fs, expdesc *v, int invert, OpCode jump) {
  int prevpos;  /* position of last instruction */
  Instruction *previous;
  int *golist, *exitlist;
  if (!invert) {
    golist = &v->u.l.f;    /* go if false */
    exitlist = &v->u.l.t;  /* exit if true */
  }
  else {
    golist = &v->u.l.t;    /* go if true */
    exitlist = &v->u.l.f;  /* exit if false */
  }
  discharge1(fs, v);
  prevpos = fs->pc-1;
  previous = &fs->f->code[prevpos];
  LUA_ASSERT(*previous==previous_instruction(fs), "no jump allowed here");
  if (!ISJUMP(GET_OPCODE(*previous)))
    prevpos = luaK_code1(fs, jump, NO_JUMP);
  else {  /* last instruction is already a jump */
    if (invert)
      SET_OPCODE(*previous, invertjump(GET_OPCODE(*previous)));
  }
  luaK_concat(fs, exitlist, prevpos);  /* insert last jump in `exitlist' */
  luaK_patchlist(fs, *golist, luaK_getlabel(fs));
  *golist = NO_JUMP;
}
开发者ID:xiaobinshe,项目名称:multitv,代码行数:26,代码来源:lcode.c


示例8: Vector2_Normalize

static int Vector2_Normalize(lua_State* aLuaState)
{
	int nrOfArguments = lua_gettop(aLuaState)-1;
	float length;
	float x;
	float y;
	if(nrOfArguments > 0)
	{
		LUA_ASSERT(aLuaState,"Vector2.Normalize should not take any arguments");
	}

	Vector2_Length(aLuaState);
	length = (float)lua_tonumber(aLuaState,-1);

	lua_getfield(aLuaState,-2,"x");
	x = (float)lua_tonumber(aLuaState,-1);
	lua_getfield(aLuaState,-3,"y");
	y = (float)lua_tonumber(aLuaState,-1);

	lua_pop(aLuaState,3);

	lua_pushstring(aLuaState,"x");
	lua_pushnumber(aLuaState,x/length);
	lua_settable(aLuaState,-3);

	lua_pushstring(aLuaState,"y");
	lua_pushnumber(aLuaState,y/length);
	lua_settable(aLuaState,-3);

	return 0;
}
开发者ID:TricycleCavalry,项目名称:CodeWars,代码行数:31,代码来源:MathLib.c


示例9: world_load_level

static int world_load_level(lua_State* L)
{
	LuaStack stack(L);
	StringId64 name = stack.get_resource_id(2);
	LUA_ASSERT(device()->resource_manager()->can_get(LEVEL_TYPE, name), stack, "Level not found");
	stack.get_world(1)->load_level(name);
	return 0;
}
开发者ID:batitous,项目名称:crown,代码行数:8,代码来源:lua_world.cpp


示例10: currentpc

static int currentpc (StkId f) {
  CallInfo *ci = infovalue(f);
  LUA_ASSERT(isLmark(f), "function has no pc");
  if (ci->pc)
    return (*ci->pc - ci->func->f.l->code) - 1;
  else
    return -1;  /* function is not active */
}
开发者ID:rparet,项目名称:darkpawns,代码行数:8,代码来源:ldebug.c


示例11: lua_rawseti

LUA_API void lua_rawseti (lua_State *L, int index, int n) {
  StkId o = Index(L, index);
  LUA_ASSERT(ttype(o) == LUA_TTABLE, "table expected");
  *luaH_setint(L, hvalue(o), n) = *(L->top-1);

  markobject(L->top - 1, L, 0);

  L->top--;
}
开发者ID:zig,项目名称:dcplaya,代码行数:9,代码来源:lapi.c


示例12: lua_rawset

LUA_API void lua_rawset (lua_State *L, int index) {
  StkId t = Index(L, index);
  LUA_ASSERT(ttype(t) == LUA_TTABLE, "table expected");
  *luaH_set(L, hvalue(t), L->top-2) = *(L->top-1);

  markobject(L->top - 1, L, 0);
  markobject(L->top - 2, L, 0);

  L->top -= 2;
}
开发者ID:zig,项目名称:dcplaya,代码行数:10,代码来源:lapi.c


示例13: tolua_region_get_resource

static int tolua_region_get_resource(lua_State * L)
{
    region *r;
    const char *type;
    const resource_type *rtype;
    int result = 0;
    void * match;
    critbit_tree * cb = special_resources();

    r = (region *)tolua_tousertype(L, 1, 0);
    LUA_ASSERT(r != NULL, "invalid parameter");
    type = tolua_tostring(L, 2, 0);
    LUA_ASSERT(type != NULL, "invalid parameter");

    if (cb_find_prefix(cb, type, strlen(type) + 1, &match, 1, 0)) {
        cb_get_kv(match, &result, sizeof(result));
        switch (result) {
        case 0:
        case 1:
        case 2:
            result = rtrees(r, result);
            break;
        case 3:
            result = deathcount(r);
            break;
        case 4:
            result = get_chaoscount(r);
            break;
        }
    }
    else {
        rtype = rt_find(type);
        if (rtype) {
            result = region_getresource(r, rtype);
        }
        else {
            result = -1;
        }
    }

    lua_pushinteger(L, result);
    return 1;
}
开发者ID:stm2,项目名称:server,代码行数:43,代码来源:bind_region.c


示例14: globalmark

static void globalmark (void)
{
  TaggedString *g;
  for (g=(TaggedString *)L->rootglobal.next; g; g=(TaggedString *)g->head.next){
    LUA_ASSERT(g->constindex >= 0, "userdata in global list");
    if (g->u.s.globalval.ttype != LUA_T_NIL) {
      markobject(&g->u.s.globalval);
      strmark(g);  /* cannot collect non nil global variables */
    }
  }
}
开发者ID:Botje,项目名称:residualvm-tools,代码行数:11,代码来源:lgc.cpp


示例15: dohook

static void dohook (lua_State *L, lua_Debug *ar, lua_Hook hook) {
  StkId old_Cbase = L->Cbase;
  StkId old_top = L->Cbase = L->top;
  luaD_checkstack(L, LUA_MINSTACK);  /* ensure minimum stack size */
  L->allowhooks = 0;  /* cannot call hooks inside a hook */
  (*hook)(L, ar);
  LUA_ASSERT(L->allowhooks == 0, "invalid allow");
  L->allowhooks = 1;
  L->top = old_top;
  L->Cbase = old_Cbase;
}
开发者ID:jcubic,项目名称:ToME,代码行数:11,代码来源:ldo.c


示例16: world_spawn_unit

static int world_spawn_unit(lua_State* L)
{
	LuaStack stack(L);
	World* world = stack.get_world(1);
	const StringId64 name = stack.get_resource_id(2);
	const Vector3& pos = stack.num_args() > 2 ? stack.get_vector3(3) : vector3::ZERO;
	const Quaternion& rot = stack.num_args() > 3 ? stack.get_quaternion(4) : quaternion::IDENTITY;

	LUA_ASSERT(device()->resource_manager()->can_get(UNIT_TYPE, name), stack, "Unit not found");

	UnitId unit = world->spawn_unit(name, pos, rot);
	stack.push_unit(world->get_unit(unit));
	return 1;
}
开发者ID:batitous,项目名称:crown,代码行数:14,代码来源:lua_world.cpp


示例17: blocksize

static void *checkblock (void *block) {
  if (block == NULL)
    return NULL;
  else {
    unsigned long *b = blocksize(block);
    unsigned long size = *b;
    int i;
    for (i=0;i<MARKSIZE;i++)
      LUA_ASSERT(*(((char *)b)+HEADER+size+i) == MARK+i, "corrupted block");
    numblocks--;
    totalmem -= size;
    return b;
  }
}
开发者ID:Akagi201,项目名称:learning-lua,代码行数:14,代码来源:lmem.c


示例18: MapConstant

/*
 * Bytecode optimization
 */
static int MapConstant(Hash* t, int j, const TObject* key)
{
	const TObject* o=luaH_get(compile_lua_state,t,key);
	if (ttype(o)==LUA_TNUMBER)
		return (int) nvalue(o);
	else
	{
		TObject val;
		ttype(&val)=LUA_TNUMBER;
		nvalue(&val)=j;
		*luaH_set(compile_lua_state,t,key)=val;
		LUA_ASSERT(j>=0,"MapConstant returns negative!");
		return j;
	}
}
开发者ID:jcubic,项目名称:ToME,代码行数:18,代码来源:luac.c


示例19: luaO_equalval

int luaO_equalval (const TObject *t1, const TObject *t2) {
  switch (ttype(t1)) {
    case TAG_NUMBER:
      return nvalue(t1) == nvalue(t2);
    case TAG_STRING: case TAG_USERDATA:
      return svalue(t1) == svalue(t2);
    case TAG_TABLE: 
      return avalue(t1) == avalue(t2);
    case TAG_CCLOSURE: case TAG_LCLOSURE:
      return clvalue(t1) == clvalue(t2);
    default:
      LUA_ASSERT(L, ttype(t1) == TAG_NIL, "invalid type");
      return 1; /* TAG_NIL */
  }
}
开发者ID:jeske,项目名称:hz,代码行数:15,代码来源:lobject.c


示例20: lua_next

LUA_API int lua_next (lua_State *L, int index) {
  StkId t = luaA_index(L, index);
  Node *n;
  LUA_ASSERT(ttype(t) == LUA_TTABLE, "table expected");
  n = luaH_next(L, hvalue(t), luaA_index(L, -1));
  if (n) {
    *(L->top-1) = *key(n);
    *L->top = *val(n);
    api_incr_top(L);
    return 1;
  }
  else {  /* no more elements */
    L->top -= 1;  /* remove key */
    return 0;
  }
}
开发者ID:XeanoRRR,项目名称:mmo-resourse,代码行数:16,代码来源:lapi.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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