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

C++ sethvalue函数代码示例

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

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



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

示例1: ktap_init_registry

static void ktap_init_registry(ktap_state *ks)
{
	ktap_value mt;
	ktap_table *registry = kp_table_new(ks);

	sethvalue(&G(ks)->registry, registry);
	kp_table_resize(ks, registry, KTAP_RIDX_LAST, 0);
	setthvalue(ks, &mt, ks);
	kp_table_setint(ks, registry, KTAP_RIDX_MAINTHREAD, &mt);
	sethvalue(&mt, kp_table_new(ks));
	kp_table_setint(ks, registry, KTAP_RIDX_GLOBALS, &mt);
}
开发者ID:joelagnel,项目名称:ktap,代码行数:12,代码来源:vm.c


示例2: init_registry

/*
** Create registry table and its predefined values
*/
static void init_registry (lua_State *L, global_State *g) {
  TValue temp;
  /* create registry */
  Table *registry = luaH_new(L);
  sethvalue(L, &g->l_registry, registry);
  luaH_resize(L, registry, LUA_RIDX_LAST, 0);
  /* registry[LUA_RIDX_MAINTHREAD] = L */
  setthvalue(L, &temp, L);  /* temp = L */
  luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &temp);
  /* registry[LUA_RIDX_GLOBALS] = table of globals */
  sethvalue(L, &temp, luaH_new(L));  /* temp = new table (global table) */
  luaH_setint(L, registry, LUA_RIDX_GLOBALS, &temp);
}
开发者ID:duchuan123,项目名称:ravi,代码行数:16,代码来源:lstate.c


示例3: init_registry

/*
** Create registry table and its predefined values
*/
static void init_registry (LUA_State *L, global_State *g) {
  TValue mt;
  /* create registry */
  Table *registry = LUAH_new(L);
  sethvalue(L, &g->l_registry, registry);
  LUAH_resize(L, registry, LUA_RIDX_LAST, 0);
  /* registry[LUA_RIDX_MAINTHREAD] = L */
  setthvalue(L, &mt, L);
  LUAH_setint(L, registry, LUA_RIDX_MAINTHREAD, &mt);
  /* registry[LUA_RIDX_GLOBALS] = table of globals */
  sethvalue(L, &mt, LUAH_new(L));
  LUAH_setint(L, registry, LUA_RIDX_GLOBALS, &mt);
}
开发者ID:mniip,项目名称:LUA,代码行数:16,代码来源:Lstate.c


示例4: lua_newtable

LUA_API void lua_newtable (lua_State *L) {
  lua_lock(L);
  luaC_checkGC(L);
  sethvalue(L->top, luaH_new(L, 0, 0));
  api_incr_top(L);
  lua_unlock(L);
}
开发者ID:TheWaWaR,项目名称:my-lua5.0,代码行数:7,代码来源:lapi.c


示例5: lua_getmetatable

LUA_API int lua_getmetatable (lua_State *L, int objindex) {
  const TObject *obj;
  Table *mt = NULL;
  int res;
  lua_lock(L);
  obj = luaA_indexAcceptable(L, objindex);
  if (obj != NULL) {
    switch (ttype(obj)) {
      case LUA_TTABLE:
        mt = hvalue(obj)->metatable;
        break;
      case LUA_TUSERDATA:
        mt = uvalue(obj)->uv.metatable;
        break;
    }
  }
  if (mt == NULL || mt == hvalue(defaultmeta(L)))
    res = 0;
  else {
    sethvalue(L->top, mt);
    api_incr_top(L);
    res = 1;
  }
  lua_unlock(L);
  return res;
}
开发者ID:TheWaWaR,项目名称:my-lua5.0,代码行数:26,代码来源:lapi.c


示例6: nilK

/*
** Add nil to list of constants and return its index.
*/
static int nilK (FuncState *fs) {
  TValue k, v;
  setnilvalue(&v);
  /* cannot use nil as key; instead use table itself to represent nil */
  sethvalue(fs->ls->L, &k, fs->ls->h);
  return addk(fs, &k, &v);
}
开发者ID:celskeggs,项目名称:selkie,代码行数:10,代码来源:lcode.c


示例7: ktap_lib_pairs

static int ktap_lib_pairs(ktap_state *ks)
{
	ktap_value *v = kp_arg(ks, 1);
	ktap_table *t;

	if (G(ks)->mainthread != ks) {
		kp_error(ks, "only mainthread can call table pairs\n");
		return -1;
	}

	if (ttistable(v)) {
		t = hvalue(v);
	} else if (ttisaggrtable(v)) {
		t = kp_aggrtable_synthesis(ks, ahvalue(v));
	} else if (isnil(v)) {
		kp_error(ks, "table is nil in pairs\n");
		return 0;
	} else {
		kp_error(ks, "wrong argument for pairs\n");
		return 0;
	}

	setfvalue(ks->top++, ktap_lib_next);
	sethvalue(ks->top++, t);
	setnilvalue(ks->top++);
	return 3;
}
开发者ID:joelagnel,项目名称:ktap,代码行数:27,代码来源:baselib.c


示例8: f_luaopen

/*
** open parts of the state that may cause memory-allocation errors
*/
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, 1, 0));  /* refs */
	setnvalue(&n, 0);
    setobj2t(L, luaH_setnum(L, hvalue(&G(L)->l_refs), LUA_RIDX_FASTREF_FREELIST), &n);

    setnilvalue(&g->fastrefNilValue);
  }
#endif /* LUA_FASTREF_SUPPORT */
  luaS_resize(L, MINSTRTABSIZE);  /* initial size of string table */
  luaT_init(L);
  luaX_init(L);
  /* pre-create memory-error message */
  g->memerrmsg = luaS_newliteral(L, MEMERRMSG);
  luaS_fix(g->memerrmsg);  /* it should never be collected */
  g->gcrunning = 1;  /* allow gc */
  g->version = lua_version(NULL);
  luai_userstateopen(L);
}
开发者ID:arventwei,项目名称:jamplus,代码行数:29,代码来源:lstate.c


示例9: ktap_init_arguments

static void ktap_init_arguments(ktap_state *ks, int argc, char **argv)
{
	const ktap_value *gt = kp_table_getint(hvalue(&G(ks)->registry),
			   KTAP_RIDX_GLOBALS);
	ktap_table *global_tbl = hvalue(gt);
	ktap_table *arg_tbl = kp_table_new(ks);
	ktap_value arg_tblval;
	ktap_value arg_tsval;
	int i;
	
	setsvalue(&arg_tsval, kp_tstring_new(ks, "arg"));
	sethvalue(&arg_tblval, arg_tbl);
	kp_table_setvalue(ks, global_tbl, &arg_tsval, &arg_tblval);

	if (!argc)
		return;

	kp_table_resize(ks, arg_tbl, 100, 100);

	for (i = 0; i < argc; i++) {
		int res;
		ktap_value val;

		if (!kstrtoint(argv[i], 10, &res)) {
			setnvalue(&val, res);
		} else
			setsvalue(&val, kp_tstring_new(ks, argv[i]));

		kp_table_setint(ks, arg_tbl, i, &val);
	}
}
开发者ID:joelagnel,项目名称:ktap,代码行数:31,代码来源:vm.c


示例10: kp_register_lib

/* function for register library */
void kp_register_lib(ktap_state *ks, const char *libname, const ktap_Reg *funcs)
{
	int i;
	ktap_table *target_tbl;
	const ktap_value *gt = kp_table_getint(hvalue(&G(ks)->registry),
					       KTAP_RIDX_GLOBALS);

	/* lib is null when register baselib function */
	if (libname == NULL)
		target_tbl = hvalue(gt);
	else {
		ktap_value key, val;

		target_tbl = kp_table_new(ks);
		kp_table_resize(ks, target_tbl, 0,
				sizeof(*funcs) / sizeof(ktap_Reg));

		setsvalue(&key, kp_tstring_new(ks, libname));
		sethvalue(&val, target_tbl);
		kp_table_setvalue(ks, hvalue(gt), &key, &val);
	}

	for (i = 0; funcs[i].name != NULL; i++) {
		ktap_value func_name, cl;

		setsvalue(&func_name, kp_tstring_new(ks, funcs[i].name));
		setfvalue(&cl, funcs[i].func);
		kp_table_setvalue(ks, target_tbl, &func_name, &cl);

		cfunction_cache_add(ks, &cl);
	}
}
开发者ID:joelagnel,项目名称:ktap,代码行数:33,代码来源:vm.c


示例11: setnilvalue

/*static*/ int FuncState::nilK (/*FuncState *fs*/) {
	TValue k, v;
	setnilvalue(&v);
	/* cannot use nil as key; instead use table itself to represent nil */
	sethvalue(ls->L, &k, ls->h);
	return addk(&k, &v);
}
开发者ID:swizl,项目名称:lua,代码行数:7,代码来源:lcode.cpp


示例12: lua_getdefaultmetatable

LUA_API void lua_getdefaultmetatable(lua_State *L, int type)
{
  lua_lock(L);
  sethvalue(L->top, hvalue(defaultmetatypes(L, type)));
  api_incr_top(L);
  lua_unlock(L);
}
开发者ID:rvpoochen,项目名称:wxsj2,代码行数:7,代码来源:LuaPlusAddons.c


示例13: lua_getmetatable

LUA_API int lua_getmetatable (lua_State *L, int objindex) {
  const TValue *obj;
  Table *mt = NULL;
  int res;
  lua_lock(L);
  obj = index2addr(L, objindex);
  switch (ttypenv(obj)) {
    case LUA_TTABLE:
      mt = hvalue(obj)->metatable;
      break;
    case LUA_TUSERDATA:
      mt = uvalue(obj)->metatable;
      break;
    default:
      mt = G(L)->mt[ttypenv(obj)];
      break;
  }
  if (mt == NULL)
    res = 0;
  else {
    sethvalue(L, L->top, mt);
    api_incr_top(L);
    res = 1;
  }
  lua_unlock(L);
  return res;
}
开发者ID:AdunSG,项目名称:Pktgen-DPDK,代码行数:27,代码来源:lapi.c


示例14: nilK

static int nilK(ktap_funcstate *fs)
{
	ktap_value k, v;
	setnilvalue(&v);
	/* cannot use nil as key; instead use table itself to represent nil */
	sethvalue(&k, fs->h);
	return addk(fs, &k, &v);
}
开发者ID:unixbhaskar,项目名称:ktap,代码行数:8,代码来源:code.c


示例15: ktap_lib_pairs

static int ktap_lib_pairs(ktap_State *ks)
{
	Table *t = hvalue(GetArg(ks, 1));

	setfvalue(ks->top++, ktap_lib_next);
	sethvalue(ks->top++, t);
	setnilvalue(ks->top++);
	return 3;
}
开发者ID:WeiY,项目名称:ktap,代码行数:9,代码来源:baselib.c


示例16: lua_createtable

LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
  Table *t;
  lua_lock(L);
  luaC_checkGC(L);
  t = luaH_new(L);
  sethvalue(L, L->top, t);
  api_incr_top(L);
  if (narray > 0 || nrec > 0)
    luaH_resize(L, t, narray, nrec);
  lua_unlock(L);
}
开发者ID:AdunSG,项目名称:Pktgen-DPDK,代码行数:11,代码来源:lapi.c


示例17: 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


示例18: LUA_createtable

LUA_API void LUA_createtable (LUA_State *L, int narray, int nrec) {
  Table *t;
  LUA_lock(L);
  LUAC_checkGC(L);
  t = LUAH_new(L);
  sethvalue(L, L->top, t);
  api_incr_top(L);
  if (narray > 0 || nrec > 0)
    LUAH_resize(L, t, narray, nrec);
  LUA_unlock(L);
}
开发者ID:mniip,项目名称:LUA,代码行数:11,代码来源:Lapi.c


示例19: lua_setdefaultmetatable

LUA_API void lua_setdefaultmetatable(lua_State *L, int type)
{
  StkId t;
  lua_lock(L);
  api_checknelems(L, 1);
  t = L->top - 1;
  if (ttype(t) == LUA_TTABLE) {  /* `t' is a table? */
	  sethvalue(defaultmetatypes(L, type), hvalue(t));
  }
  L->top -= 1;
  lua_unlock(L);
}
开发者ID:rvpoochen,项目名称:wxsj2,代码行数:12,代码来源:LuaPlusAddons.c


示例20: lua_getuservalue

LUA_API void lua_getuservalue (lua_State *L, int idx) {
	StkId o;
	lua_lock(L);
	o = index2addr(L, idx);
	api_check(L, ttisuserdata(o), "userdata expected");
	if (uvalue(o)->env) {
	sethvalue(L, L->top, uvalue(o)->env);
	} else
	setnilvalue(L->top);
	api_incr_top(L);
	lua_unlock(L);
}
开发者ID:Ilgrim,项目名称:MAMEHub,代码行数:12,代码来源:lapi.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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