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


C++ sethvalue函数代码示例

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


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


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