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

C++ setobj函数代码示例

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

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



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

示例1: addk

static int addk(FuncState *fs, Tvalue *key, Tvalue *v)
{
	Tvalue *idx = ktapc_table_set(fs->h, key);
	Proto *f = fs->f;
	int k, oldsize;

	if (ttisnumber(idx)) {
		ktap_Number n = nvalue(idx);
		ktap_number2int(k, n);
		if (ktapc_equalobj(&f->k[k], v))
			return k;
		/* else may be a collision (e.g., between 0.0 and "\0\0\0\0\0\0\0\0");
			go through and create a new entry for this value */
	}
	/* constant not found; create a new entry */
	oldsize = f->sizek;
	k = fs->nk;
	/* numerical value does not need GC barrier;
	   table has no metatable, so it does not need to invalidate cache */
	setnvalue(idx, (ktap_Number)(k));
	ktapc_growvector(f->k, k, f->sizek, Tvalue, MAXARG_Ax, "constants");
	while (oldsize < f->sizek)
		setnilvalue(&f->k[oldsize++]);
	setobj(NULL, &f->k[k], v);
	fs->nk++;
	return k;
}
开发者ID:WeiY,项目名称:ktap,代码行数:27,代码来源:code.c


示例2: addk

static int addk (FuncState *fs, TValue *key, TValue *v) {
  lua_State *L = fs->ls->L;
  TValue *idx = luaH_set(L, fs->h, key);
  Proto *f = fs->f;
  int k, oldsize;
  if (ttisnumber(idx)) {
    lua_Number n = nvalue(idx);
    lua_number2int(k, n);
    if (luaV_rawequalobj(&f->k[k], v))
      return k;
    /* else may be a collision (e.g., between 0.0 and "\0\0\0\0\0\0\0\0");
       go through and create a new entry for this value */
  }
  /* constant not found; create a new entry */
  oldsize = f->sizek;
  k = fs->nk;
  /* numerical value does not need GC barrier;
     table has no metatable, so it does not need to invalidate cache */
  setnvalue(idx, cast_num(k));
  luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants");
  while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
  setobj(L, &f->k[k], v);
  fs->nk++;
  luaC_barrier(L, f, v);
  return k;
}
开发者ID:KatrinaHoffert,项目名称:megaglest-source,代码行数:26,代码来源:lcode.c


示例3: addk

static int addk (FuncState *fs, TValue *k, TValue *v) {
  lua_State *L = fs->L;
  TValue *idx = luaH_set(L, fs->h, k);
  Proto *f = fs->f;
  int oldsize = f->sizek;
  if (ttisnumber(idx)) {
    lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
    return cast_int(nvalue(idx));
  }
  else {  /* constant not found; create a new entry */
    setnvalue(idx, cast_num(fs->nk));
#if LUA_MEMORY_STATS
    luaM_setname(L, "lua.parser.constants");
#endif /* LUA_MEMORY_STATS */
    luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
                    MAXARG_Bx, "constant table overflow");
#if LUA_MEMORY_STATS
    luaM_setname(L, 0);
#endif /* LUA_MEMORY_STATS */
#if LUA_REFCOUNT
    while (oldsize < f->sizek) setnilvalue2n(L, &f->k[oldsize++]);
#else
    while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
#endif /* LUA_REFCOUNT */
    setobj(L, &f->k[fs->nk], v);
    luaC_barrier(L, f, v);
    return fs->nk++;
  }
}
开发者ID:henryfung01,项目名称:GameCode4,代码行数:29,代码来源:lcode.c


示例4: mainposition

static Tvalue *table_newkey(ktap_State *ks, Table *t, const Tvalue *key)
{
	Node *mp;

	mp = mainposition(t, key);
	if (!isnil(gval(mp)) || isdummy(mp)) {  /* main position is taken? */
		Node *othern;
		Node *n = getfreepos(t);  /* get a free place */
		if (n == NULL) {  /* cannot find a free place? */
			rehash(ks, t, key);  /* grow table */
			/* whatever called 'newkey' take care of TM cache and GC barrier */
			return kp_table_set(ks, t, key);  /* insert key into grown table */
		}

		othern = mainposition(t, gkey(mp));
		if (othern != mp) {  /* is colliding node out of its main position? */
			/* yes; move colliding node into free position */
			while (gnext(othern) != mp)
				othern = gnext(othern);  /* find previous */
			gnext(othern) = n;  /* redo the chain with `n' in place of `mp' */
			*n = *mp;  /* copy colliding node into free pos. (mp->next also goes) */
			gnext(mp) = NULL;  /* now `mp' is free */
			setnilvalue(gval(mp));
		} else {  /* colliding node is in its own main position */
			/* new node will go into free position */
			gnext(n) = gnext(mp);  /* chain new position */
			gnext(mp) = n;
			mp = n;
		}
	}
	setobj(ks, gkey(mp), key);
	return gval(mp);
}
开发者ID:eric-zhu,项目名称:ktap,代码行数:33,代码来源:table.c


示例5: luaV_gettable

void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {
  int loop;
  TValue temp;
  for (loop = 0; loop < MAXTAGLOOP; loop++) {
    const TValue *tm;
    if (ttistable(t) || ttisrotable(t)) {  /* `t' is a table? */
      void *h = ttistable(t) ? hvalue(t) : rvalue(t);
      const TValue *res = ttistable(t) ? luaH_get((Table*)h, key) : luaH_get_ro(h, key); /* do a primitive get */
      if (!ttisnil(res) ||  /* result is no nil? */
          (tm = fasttm(L, ttistable(t) ? ((Table*)h)->metatable : (Table*)luaR_getmeta(h), TM_INDEX)) == NULL) { /* or no TM? */
        setobj2s(L, val, res);
        return;
      }      
      /* else will try the tag method */
    }
    else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
        luaG_typeerror(L, t, "index");
    if (ttisfunction(tm) || ttislightfunction(tm)) {
      callTMres(L, val, tm, t, key);
      return;
    }
    /* else repeat with `tm' */
    setobj(L, &temp, tm);  /* avoid pointing inside table (may rehash) */
    t = &temp;
  }
  luaG_runerror(L, "loop in gettable");
}
开发者ID:Dxploto,项目名称:nodemcu-firmware,代码行数:27,代码来源:lvm.c


示例6: lua_replace

/* weet:
 * 1. 将idx所在位置设置为当前栈顶元素
 * 2. 栈顶指针下移一个
 * */
LUA_API void lua_replace (lua_State *L, int idx) {
  lua_lock(L);
  api_checknelems(L, 1);
  setobj(luaA_index(L, idx), L->top - 1);  /* write barrier */
  L->top--;
  lua_unlock(L);
}
开发者ID:TheWaWaR,项目名称:my-lua5.0,代码行数:11,代码来源:lapi.c


示例7: luaV_settable

void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
  int loop;
  TValue temp;
  for (loop = 0; loop < MAXTAGLOOP; loop++) {
    const TValue *tm;
    if (ttistable(t)) {  /* `t' is a table? */
      Table *h = hvalue(t);
      TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
      if (!ttisnil(oldval) ||  /* result is no nil? */
          (tm = fasttm(L, h->metatable, TM_NEWINDEX)) == NULL) { /* or no TM? */
        setobj2t(L, oldval, val);
        luaC_barriert(L, h, val);
        return;
      }
      /* else will try the tag method */
    }
    else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
      luaG_typeerror(L, t, "index");
    if (ttisfunction(tm)) {
      callTM(L, tm, t, key, val);
      return;
    }
    /* else repeat with `tm' */
    setobj(L, &temp, tm);  /* avoid pointing inside table (may rehash) */
    t = &temp;
  }
  luaG_runerror(L, "loop in settable");
}
开发者ID:angryzor,项目名称:luajit-tilepro64,代码行数:28,代码来源:lvm.c


示例8: addk

/*
** Add constant 'v' to prototype's list of constants (field 'k').
** Use scanner's table to cache position of constants in constant list
** and try to reuse constants. Because some values should not be used
** as keys (nil cannot be a key, integer keys can collapse with float
** keys), the caller must provide a useful 'key' for indexing the cache.
*/
static int addk (FuncState *fs, TValue *key, TValue *v) {
  lua_State *L = fs->ls->L;
  Proto *f = fs->f;
  TValue *idx = luaH_set(L, fs->ls->h, key);  /* index scanner table */
  int k, oldsize;
  if (ttisinteger(idx)) {  /* is there an index there? */
    k = cast_int(ivalue(idx));
    /* correct value? (warning: must distinguish floats from integers!) */
    if (k < fs->nk && ttype(&f->k[k]) == ttype(v) &&
                      luaV_rawequalobj(&f->k[k], v))
      return k;  /* reuse index */
  }
  /* constant not found; create a new entry */
  oldsize = f->sizek;
  k = fs->nk;
  /* numerical value does not need GC barrier;
     table has no metatable, so it does not need to invalidate cache */
  setivalue(idx, k);
  luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Ax, "constants");
  while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
  setobj(L, &f->k[k], v);
  fs->nk++;
  luaC_barrier(L, f, v);
  return k;
}
开发者ID:celskeggs,项目名称:selkie,代码行数:32,代码来源:lcode.c


示例9: o_face

int
o_face(		/* print out a polygon */
	char	*mod,
	char	*typ,
	char	*id,
	FUNARGS	*fa
)
{
	char	entbuf[2048], *linestart;
	register char	*cp;
	register int	i;

	if ((fa->nfargs < 9) | (fa->nfargs % 3))
		return(-1);
	setmat(mod);
	setobj(id);
	cp = linestart = entbuf;
	*cp++ = 'f';
	for (i = 0; i < fa->nfargs; i += 3) {
		*cp++ = ' ';
		if (cp - linestart > 72) {
			*cp++ = '\\'; *cp++ = '\n';
			linestart = cp;
			*cp++ = ' '; *cp++ = ' ';
		}
		getvertid(cp, fa->farg + i);
		while (*cp)
			cp++;
	}
	puts(entbuf);
	return(0);
}
开发者ID:Pizookies,项目名称:Radiance,代码行数:32,代码来源:rad2mgf.c


示例10: luaM_new

static UpVal *makeupval(lua_State *L, int stackpos) {
	UpVal *uv = luaM_new(L, UpVal);
	uv->tt = LUA_TUPVAL;
	uv->v = &uv->value;
	setobj(uv->v, getobject(L, stackpos));
	luaC_link(L, valtogco(uv), LUA_TUPVAL);
	return uv;
}
开发者ID:CeRiAl,项目名称:DreamZZT,代码行数:8,代码来源:pluto.c


示例11: reverse

/*
** Reverse the stack segment from 'from' to 'to'
** (auxiliary to 'lua_rotate')
*/
static void reverse (lua_State *L, StkId from, StkId to) {
  for (; from < to; from++, to--) {
    TValue temp;
    setobj(L, &temp, from);
    setobjs2s(L, from, to);
    setobj2s(L, to, &temp);
  }
}
开发者ID:1414648814,项目名称:ejoy2d,代码行数:12,代码来源:lapi.c


示例12: lua_pushtobject

LUAPLUS_API void lua_pushtobject(lua_State *L, void* tobject)
{
	TValue* tobj = (TValue*)tobject;
	lua_lock(L);
	setobj(L, L->top, tobj);
	api_incr_top(L);
	lua_unlock(L);
}
开发者ID:mentaldease,项目名称:bastionlandscape,代码行数:8,代码来源:LuaPlus.cpp


示例13: moveto

static void moveto (lua_State *L, TValue *fr, int idx) {
  TValue *to = index2addr(L, idx);
  api_checkvalidindex(L, to);
  setobj(L, to, fr);
  if (idx < LUA_REGISTRYINDEX)  /* function upvalue? */
    luaC_barrier(L, clCvalue(L->ci->func), fr);
  /* LUA_REGISTRYINDEX does not need gc barrier
     (collector revisits it before finishing collection) */
}
开发者ID:AdunSG,项目名称:Pktgen-DPDK,代码行数:9,代码来源:lapi.c


示例14: gettable

static void gettable(ktap_state *ks, const ktap_value *t, ktap_value *key,
		     StkId val)
{
	if (ttistable(t)) {
		setobj(val, kp_table_get(hvalue(t), key));
	} else if (ttisaggrtable(t)) {
		kp_aggrtable_get(ks, ahvalue(t), key, val);
	} else {
		kp_error(ks, "get key from non-table\n");
	}
}
开发者ID:joelagnel,项目名称:ktap,代码行数:11,代码来源:vm.c


示例15: lua_new

UpVal *makeUpValue(lua_State *luaState, int stackPos) {
	UpVal *uv = lua_new(luaState, UpVal);
	lua_link(luaState, (GCObject *)uv, LUA_TUPVAL);
	uv->tt = LUA_TUPVAL;
	uv->v = &uv->u.value;
	uv->u.l.prev = NULL;
	uv->u.l.next = NULL;

	setobj(luaState, uv->v, getObject(luaState, stackPos));

	return uv;
}
开发者ID:AlbanBedel,项目名称:scummvm,代码行数:12,代码来源:lua_persistence_util.cpp


示例16: lua_replace

LUA_API void lua_replace (lua_State *L, int idx)
{
    lua_lock(L);

    /* explicit test for incompatible code */
    if ( idx == LUA_ENVIRONINDEX && !hascallingenv( L ) )
    {
        luaG_runerror(L, "no calling environment");
    }

    api_checknelems(L, 1);
    {
        rtStack_t& rtStack = L->rtStack;

        rtStack.Lock( L );

        StkId stackTop = L->GetCurrentStackFrame().TopMutable( L, L->rtStack );

        if ( idx == LUA_ENVIRONINDEX )
        {
            Closure *func = curr_func(L);
            const TValue *val = stackTop;

            func->env = gcvalue(val);
            luaC_barrier(L, func, val);
        }
        else if ( idx == LUA_STORAGEINDEX )
        {
            const TValue *val = stackTop;

            setgcvalue( L, &L->storage, gcvalue( val ) );
            luaC_barrier( L, L, val );
        }
        else
        {
            ValueAddress o = index2adr(L, idx);
            api_checkvalidindex(L, o);

            setobj( L, o, stackTop );

            if ( idx < LUA_GLOBALSINDEX )  /* function upvalue? */
            {
                luaC_barrier(L, curr_func(L), stackTop);
            }
        }

        popstack( L, 1 );

        rtStack.Unlock( L );
    }
    lua_unlock(L);
}
开发者ID:qaisjp,项目名称:green-candy,代码行数:52,代码来源:lapi.stack.c


示例17: luaF_close

void luaF_close (lua_State *L, StkId level) {
  UpVal *uv;
  while (L->openupval != NULL &&
        (uv = L->openupval, uplevel(uv) >= level)) {
    TValue *slot = &uv->u.value;  /* new position for value */
    luaF_unlinkupval(uv);
    setobj(L, slot, uv->v);  /* move value to upvalue slot */
    uv->v = slot;  /* now current value lives here */
    if (!iswhite(uv))
      gray2black(uv);  /* closed upvalues cannot be gray */
    luaC_barrier(L, uv, slot);
  }
}
开发者ID:luciouskami,项目名称:YDWE,代码行数:13,代码来源:lfunc.c


示例18: lua_copy

LUA_API void lua_copy (lua_State *L, int fromidx, int toidx) {
  TValue *fr, *to;
  lua_lock(L);
  fr = index2addr(L, fromidx);
  to = index2addr(L, toidx);
  api_checkvalidindex(to);
  setobj(L, to, fr);
  if (isupvalue(toidx))  /* function upvalue? */
    luaC_barrier(L, clCvalue(L->ci->func), fr);
  /* LUA_REGISTRYINDEX does not need gc barrier
     (collector revisits it before finishing collection) */
  lua_unlock(L);
}
开发者ID:1414648814,项目名称:ejoy2d,代码行数:13,代码来源:lapi.c


示例19: kp_table_next

int kp_table_next(ktap_State *ks, Table *t, StkId key)
{
	int i = findindex(ks, t, key);  /* find original element */

	for (i++; i < t->sizearray; i++) {  /* try first array part */
	        if (!ttisnil(&t->array[i])) {  /* a non-nil value? */
			setnvalue(key, i+1);
			setobj(ks, key+1, &t->array[i]);
			return 1;
		}
	}

	for (i -= t->sizearray; i < sizenode(t); i++) {  /* then hash part */
		if (!ttisnil(gval(gnode(t, i)))) {  /* a non-nil value? */
			setobj(ks, key, gkey(gnode(t, i)));
			setobj(ks, key+1, gval(gnode(t, i)));
			return 1;
		}
	}

	return 0;  /* no more elements */
}
开发者ID:eric-zhu,项目名称:ktap,代码行数:22,代码来源:table.c


示例20: luaF_close

void luaF_close (lua_State *L, StkId level) {
  UpVal *uv;
  while (L->openupval != NULL && (uv = L->openupval)->v >= level) {
    lua_assert(upisopen(uv));
    L->openupval = uv->u.open.next;  /* remove from 'open' list */
    if (uv->refcount == 0)  /* no references? */
      luaM_free(L, uv);  /* free upvalue */
    else {
      setobj(L, &uv->u.value, uv->v);  /* move value to upvalue slot */
      uv->v = &uv->u.value;  /* now current value lives here */
      luaC_upvalbarrier(L, uv);
    }
  }
}
开发者ID:141141,项目名称:nodemcu-firmware-lua5.3.0,代码行数:14,代码来源:lfunc.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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