当前位置: 首页>>代码示例>>C++>>正文


C++ setobj函数代码示例

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


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


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