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

C++ setnilvalue函数代码示例

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

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



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

示例1: preinit_state

static void preinit_state (lua_State *L, global_State *g) {
    G(L) = g;
    L->stack = NULL;
    L->stacksize = 0;
    L->errorJmp = NULL;
    L->hook = NULL;
    L->hookmask = 0;
    L->basehookcount = 0;
    L->allowhook = 1;
    resethookcount(L);
    L->openupval = NULL;
    L->size_ci = 0;
    L->nCcalls = L->baseCcalls = 0;
    L->status = 0;
    L->base_ci = L->ci = NULL;
    L->savedpc = NULL;
    L->errfunc = 0;
    setnilvalue(gt(L));
}
开发者ID:Badcreature,项目名称:caffeine-hx,代码行数:19,代码来源:lstate.c


示例2: traversestack

static void traversestack (GCState *st, lua_State *L1) {
  StkId o, lim;
  CallInfo *ci;
  lua_State *L = st->L;
  (void)L;
  markobject(st, gt(L1));
  lim = L1->top;
  for (ci = L1->base_ci; ci <= L1->ci; ci++) {
    lua_assert(ci->top <= L1->stack_last);
    lua_assert(ci->state & (CI_C | CI_HASFRAME | CI_SAVEDPC));
    if (lim < ci->top)
      lim = ci->top;
  }
  for (o = L1->stack; o < L1->top; o++)
    markobject(st, o);
  for (; o <= lim; o++)
    setnilvalue(o);
  checkstacksizes(L1, lim);
}
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:19,代码来源:lgc.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));
    luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
                    MAXARG_Bx, "constant table overflow");
    while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
    setobj(L, &f->k[fs->nk], v);
    luaC_barrier(L, f, v);
    return fs->nk++;
  }
}
开发者ID:dx168b,项目名称:luafltk,代码行数:19,代码来源:lcode.c


示例4: lua_pushcclosure

LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
  Closure *cl;
  lua_lock(L);
  luaC_checkGC(L);
  api_checknelems(L, n);
  cl = luaF_newCclosure(L, n);
  cl->c.f = fn;
  L->top -= n;
  while (n--)
  {
    setobj2n(&cl->c.upvalue[n], L->top+n);
#if LUA_REFCOUNT
	setnilvalue(L->top+n);
#endif LUA_REFCOUNT
  }
  setclvalue(L->top, cl);
  api_incr_top(L);
  lua_unlock(L);
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:19,代码来源:lapi.c


示例5: cleartablevalues

/*
** clear collected values from weaktables
*/
static void cleartablevalues (lua_State *L, GCObject *l) {
  while (l) {
    Table *h = gcotoh(l);
    int i = h->sizearray;
    lua_assert(h->marked & VALUEWEAK);
    while (i--) {
      TObject *o = &h->array[i];
      if (!valismarked(o))  /* value was collected? */
        setnilvalue(o);  /* remove value */
    }
    i = sizenode(h);
    while (i--) {
      Node *n = gnode(h, i);
      if (!valismarked(gval(n)))  /* value was collected? */
        removekey(L, n);  /* remove entry from table */
    }
    l = h->gclist;
  }
}
开发者ID:ueverything,项目名称:mmo-resourse,代码行数:22,代码来源:lgc.c


示例6: addk

static int addk (FuncState *fs, TValue *k, TValue *v) {
  lua_State *L = fs->L;
  TValue *idx = luaH_set(L, fs->h, k);
#ifdef LUA_TINT
  /* Note: Integer-valued LUA_TNUMBER's are handled as in unpatched Lua (below)
  */
  if (ttype(idx)==LUA_TINT) {
    int i;
# ifdef LNUM_INT64
    lua_assert( (int)ivalue(idx) == ivalue(idx) );  /* make sure no data is lost in the casting */
# endif
    i= (int)ivalue(idx);
    lua_assert(luaO_rawequalObj(&fs->f->k[i], v));
    return i;
  }
  else if (ttype(idx)==LUA_TNUMBER) {
#else
  if (ttisnumber(idx)) {
#endif
    int i= cast_int(nvalue_fast(idx));
    lua_assert(luaO_rawequalObj(&fs->f->k[i], v));
    return i;
  }
  else {  /* constant not found; create a new entry */
    Proto *f = fs->f;
    int oldsize = f->sizek;
    setivalue(idx, fs->nk);
    luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
                    MAXARG_Bx, "constant table overflow");
    while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
    setobj(L, &f->k[fs->nk], v);
    luaC_barrier(L, f, v);
    return fs->nk++;
  }
}


int luaK_stringK (FuncState *fs, TString *s) {
  TValue o;
  setsvalue(fs->L, &o, s);
  return addk(fs, &o, &o);
}
开发者ID:7568168,项目名称:cheat-engine,代码行数:42,代码来源:lcode.c


示例7: nilK

static int nilK (FuncState *fs) {
  TValue k, v;
#if LUA_REFCOUNT
  lua_State *L = fs->L;
  int ret;
  setnilvalue2n(L, &v);
  luarc_newvalue(&k);
  /* cannot use nil as key; instead use table itself to represent nil */
  sethvalue(fs->L, &k, fs->h);
  ret = addk(fs, &k, &v);
  luarc_cleanvalue(&k);
  luarc_cleanvalue(&v);
  return ret;
#else
  setnilvalue(&v);
  /* cannot use nil as key; instead use table itself to represent nil */
  sethvalue(fs->L, &k, fs->h);
  return addk(fs, &k, &v);
#endif /* LUA_REFCOUNT */
}
开发者ID:henryfung01,项目名称:GameCode4,代码行数:20,代码来源:lcode.c


示例8: traversestack

static lu_mem traversestack (global_State *g, lua_State *th) {
	int n = 0;
	StkId o = th->stack;
	if (o == NULL)
	return 1;  /* stack not completely built yet */
	for (; o < th->top; o++)  /* mark live elements in the stack */
	markvalue(g, o);
	if (g->gcstate == GCSatomic) {  /* final traversal? */
	StkId lim = th->stack + th->stacksize;  /* real end of stack */
	for (; o < lim; o++)  /* clear not-marked stack slice */
		setnilvalue(o);
	}
	else {  /* count call infos to compute size */
	CallInfo *ci;
	for (ci = &th->base_ci; ci != th->ci; ci = ci->next)
		n++;
	}
	return sizeof(lua_State) + sizeof(TValue) * th->stacksize +
			sizeof(CallInfo) * n;
}
开发者ID:crazii,项目名称:mameplus,代码行数:20,代码来源:lgc.c


示例9: php_deserialize

int php_deserialize( rabbit * r, rawbuffer * buf, TValue * tv )
{
	if(!buf || !tv) {
		return -1;
	}
	setnilvalue(tv);

	int c = decode_read_byte( buf );

	switch( c ) {
		case PHP_NULL:
	//		kLOG(r, 0,"php decode nil\n");
			return decode_null( r, buf, tv );

		case PHP_INT:
	//		kLOG(r, 0,"php decode int\n");
			return decode_int( r, buf, tv );

		case PHP_DOUBLE:
	//		kLOG(r, 0,"php decode double\n");
			return decode_double(r, buf, tv);

		case PHP_STRING:
	//		kLOG(r, 0,"php decode string\n");
			return decode_string(r, buf, tv);

		case PHP_ARRAY:
	//		kLOG(r, 0,"php decode array\n");
			return decode_array(r, buf, tv);

		case PHP_BOOL:
			return decode_bool(r, buf, tv);

		default:
			kLOG(r, 0, "php decode unknow:%c\n",c);
			break;
	}

	return -1;
}
开发者ID:wobushizhanghua,项目名称:SmartRabbitServer,代码行数:40,代码来源:php_deserialize.c


示例10: vm_OP_VARARG

void vm_OP_VARARG(lua_State *L, LClosure *cl, int a, int b) {
  TValue *base = L->base;
  TValue *ra = base + a;
  int j;
  CallInfo *ci = L->ci;
  int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1;
  b -= 1;
  if (b == LUA_MULTRET) {
    Protect(luaD_checkstack(L, n));
    ra = base + a;  /* previous call may change the stack */
    b = n;
    L->top = ra + n;
  }
  for (j = 0; j < b; j++) {
    if (j < n) {
      setobjs2s(L, ra + j, ci->base - n + j);
    }
    else {
      setnilvalue(ra + j);
    }
  }
}
开发者ID:GranPC,项目名称:llvm-lua,代码行数:22,代码来源:lua_vm_ops_static.c


示例11: luaV_settable

void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {
  int loop;
  TValue temp;
  setnilvalue(L->top);
  L->top++;
  fixedstack(L);
  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);
      TValue *oldval = ttistable(t) ? luaH_set(L, (Table*)h, key) : NULL; /* do a primitive set */
      if ((oldval && !ttisnil(oldval)) ||  /* result is no nil? */
          (tm = fasttm(L, ttistable(t) ? ((Table*)h)->metatable : (Table*)luaR_getmeta(h), TM_NEWINDEX)) == NULL) { /* or no TM? */
        if(oldval) {
          L->top--;
          unfixedstack(L);
          setobj2t(L, oldval, val);
          ((Table *)h)->flags = 0;
          luaC_barriert(L, (Table*)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) || ttislightfunction(tm)) {
      L->top--;
      unfixedstack(L);
      callTM(L, tm, t, key, val);
      return;
    }
    /* else repeat with `tm' */
    setobj(L, &temp, tm);  /* avoid pointing inside table (may rehash) */
    t = &temp;
    setobj2s(L, L->top-1, t);  /* need to protect value from EGC. */
  }
  luaG_runerror(L, "loop in settable");
}
开发者ID:Dxploto,项目名称:nodemcu-firmware,代码行数:39,代码来源:lvm.c


示例12: traversethread

static lu_mem traversethread (global_State *g, lua_State *th) {
  StkId o = th->stack;
  if (o == NULL)
    return 1;  /* stack not completely built yet */
  lua_assert(g->gcstate == GCSinsideatomic ||
             th->openupval == NULL || isintwups(th));
  for (; o < th->top; o++)  /* mark live elements in the stack */
    markvalue(g, o);
  if (g->gcstate == GCSinsideatomic) {  /* final traversal? */
    StkId lim = th->stack + th->stacksize;  /* real end of stack */
    for (; o < lim; o++)  /* clear not-marked stack slice */
      setnilvalue(o);
    /* 'remarkupvals' may have removed thread from 'twups' list */ 
    if (!isintwups(th) && th->openupval != NULL) {
      th->twups = g->twups;  /* link it back to the list */
      g->twups = th;
    }
  }
  else if (g->gckind != KGC_EMERGENCY)
    luaD_shrinkstack(th); /* do not change stack in emergency cycle */
  return (sizeof(lua_State) + sizeof(TValue) * th->stacksize);
}
开发者ID:charleeli,项目名称:srpc,代码行数:22,代码来源:lgc.c


示例13: lua_getinfo

LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar)
{
    int status;
    Closure *f = NULL;
    CallInfo *ci = NULL;
    void *plight = NULL;
    lua_lock(L);
    if (*what == '>') {
        StkId func = L->top - 1;
        luai_apicheck(L, ttisfunction(func) || ttislightfunction(func));
        what++;  /* skip the '>' */
        if (ttisfunction(func))
            f = clvalue(func);
        else
            plight = fvalue(func);
        L->top--;  /* pop function */
    } else if (ar->i_ci != 0) { /* no tail call? */
        ci = L->base_ci + ar->i_ci;
        lua_assert(ttisfunction(ci->func) || ttislightfunction(ci->func));
        if (ttisfunction(ci->func))
            f = clvalue(ci->func);
        else
            plight = fvalue(ci->func);
    }
    status = auxgetinfo(L, what, ar, f, plight, ci);
    if (strchr(what, 'f')) {
        if (f != NULL)
            setclvalue(L, L->top, f)
            else if (plight != NULL)
                setfvalue(L->top, plight)
                else
                    setnilvalue(L->top);
        incr_top(L);
    }
    if (strchr(what, 'L'))
        collectvalidlines(L, f);
    lua_unlock(L);
    return status;
}
开发者ID:autosportlabs,项目名称:RaceCapture-Pro-firmware-mk1,代码行数:39,代码来源:ldebug.c


示例14: lua_setmetatable

LUA_API int lua_setmetatable (lua_State *L, int objindex) {
  TObject *obj, *mt;
  int res = 1;
  lua_lock(L);
  api_checknelems(L, 1);
  obj = luaA_index(L, objindex);
  mt = (!ttisnil(L->top - 1)) ? L->top - 1 : defaultmeta(L);
  api_check(L, ttistable(mt));
  switch (ttype(obj)) {
    case LUA_TTABLE: {
#if LUA_REFCOUNT
      __AddRefDirect(hvalue(mt));
      __ReleaseDirect(L, hvalue(obj)->metatable);
#endif LUA_REFCOUNT
	  hvalue(obj)->metatable = hvalue(mt);  /* write barrier */
      break;
    }
    case LUA_TUSERDATA: {
#if LUA_REFCOUNT
      __AddRefDirect(hvalue(mt));
	  __ReleaseDirect(L, &uvalue(obj)->uv.metatable);
#endif LUA_REFCOUNT
      uvalue(obj)->uv.metatable = hvalue(mt);  /* write barrier */
      break;
    }
    default: {
      res = 0;  /* cannot set */
      break;
    }
  }
#if LUA_REFCOUNT
  setnilvalue(--L->top);
#else !LUA_REFCOUNT
  L->top--;
#endif LUA_REFCOUNT
  lua_unlock(L);
  return res;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:38,代码来源:lapi.c


示例15: f_luaopen

/*
** open parts of the state that may cause memory-allocation errors.
** ('g->version' != NULL flags that the state was completely build)
*/
static void f_luaopen (lua_State *L, void *ud) {
  global_State *g = G(L);
  UNUSED(ud);
  stack_init(L, L);  /* init stack */
  init_registry(L, g);
#if LUA_FASTREF_SUPPORT
  {
    TValue n;

    sethvalue(L, &G(L)->l_refs, luaH_new(L));  /* refs */
    setivalue(&n, 0);
    luaH_setint(L, hvalue(&G(L)->l_refs), LUA_RIDX_FASTREF_FREELIST, &n);

    setnilvalue(&g->fastrefNilValue);
  }
#endif /* LUA_FASTREF_SUPPORT */
  luaS_init(L);
  luaT_init(L);
  luaX_init(L);
  g->gcrunning = 1;  /* allow gc */
  g->version = lua_version(NULL);
  luai_userstateopen(L);
}
开发者ID:cjtallman,项目名称:luaplus51-all,代码行数:27,代码来源:lstate.c


示例16: poscall

static int poscall(ktap_state *ks, StkId first_result)
{
	ktap_callinfo *ci;
	StkId res;
	int wanted, i;

	ci = ks->ci;

	res = ci->func;
	wanted = ci->nresults;

	ks->ci = ci = ci->prev;

	for (i = wanted; i != 0 && first_result < ks->top; i--)
		setobj(res++, first_result++);

	while(i-- > 0)
		setnilvalue(res++);

	ks->top = res;

	return (wanted - (-1));
}
开发者ID:joelagnel,项目名称:ktap,代码行数:23,代码来源:vm.c


示例17: 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 (ttype(idx)==LUA_TNUMBER) {
    luai_normalize(idx);
    lua_assert( ttype(idx)==LUA_TINT );     /* had no fraction */
  }
  if (ttisint(idx)) {
    lua_assert(luaO_rawequalObj(&fs->f->k[ivalue(idx)], v));
    return cast_int(ivalue(idx));
  }
  else {  /* constant not found; create a new entry */
    setivalue(idx, fs->nk);
    luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
                    MAXARG_Bx, "constant table overflow");
    while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
    setobj(L, &f->k[fs->nk], v);
    luaC_barrier(L, f, v);
    return fs->nk++;
  }
}
开发者ID:Yui-Qi-Tang,项目名称:openwrtPKG,代码行数:23,代码来源:lcode.c


示例18: traversestack

static void traversestack (global_State *g, lua_State *l) {
  StkId o, lim;
  CallInfo *ci;
  markvalue(g, gt(l));
  lim = l->top;
  for (ci = l->base_ci; ci <= l->ci; ci++) {
    lua_assert(ci->top <= l->stack_last);
    if (lim < ci->top) lim = ci->top;
  }
  for (o = l->stack; o < l->top; o++)
    markvalue(g, o);
#if LUA_REFCOUNT
  for (; o <= lim; o++) {
    if (iscollectable(o))
      o->value.gc->gch.ref--;
    setnilvalue2n(l, o);
  }
#else
  for (; o <= lim; o++)
    setnilvalue(o);
#endif /* LUA_REFCOUNT */
  checkstacksizes(l, lim);
}
开发者ID:zapline,项目名称:zlib,代码行数:23,代码来源:lgc.c


示例19: ktap_concat

static void ktap_concat(ktap_state *ks, int start, int end)
{
	int i, len = 0;
	StkId top = ks->ci->u.l.base;
	ktap_string *ts;
	char *ptr, *buffer;

	for (i = start; i <= end; i++) {
		if (!ttisstring(top + i)) {
			kp_error(ks, "cannot concat non-string\n");
			setnilvalue(top + start);
			return;
		}

		len += rawtsvalue(top + i)->tsv.len;
	}

	if (len >= KTAP_PERCPU_BUFFER_SIZE) {
		kp_error(ks, "Error: too long string concatenation\n");
		return;
	}

	preempt_disable_notrace();

	buffer = kp_percpu_data(KTAP_PERCPU_DATA_BUFFER);
	ptr = buffer;

	for (i = start; i <= end; i++) {
		int len = rawtsvalue(top + i)->tsv.len;
		strncpy(ptr, svalue(top + i), len);
		ptr += len;
	}
	ts = kp_tstring_newlstr(ks, buffer, len);
	setsvalue(top + start, ts);

	preempt_enable_notrace();
}
开发者ID:joelagnel,项目名称:ktap,代码行数:37,代码来源:vm.c


示例20: addk

static int addk (FuncState *fs, TValue *key, TValue *v) {
  lua_State *L = fs->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 (luaO_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;
  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:mascarenhas,项目名称:lua52-in-leave,代码行数:24,代码来源:lcode.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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