本文整理汇总了C#中TValue类的典型用法代码示例。如果您正苦于以下问题:C# TValue类的具体用法?C# TValue怎么用?C# TValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TValue类属于命名空间,在下文中一共展示了TValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: T_GetTMByObj
private StkId T_GetTMByObj( ref TValue o, TMS tm )
{
LuaTable mt = null;
switch( o.Tt )
{
case (int)LuaType.LUA_TTABLE:
{
var tbl = o.HValue();
mt = tbl.MetaTable;
break;
}
case (int)LuaType.LUA_TUSERDATA:
{
var ud = o.RawUValue();
mt = ud.MetaTable;
break;
}
default:
{
mt = G.MetaTables[o.Tt];
break;
}
}
return (mt != null)
? mt.GetStr( GetTagMethodName( tm ) )
: TheNilValue;
}
开发者ID:Jornason,项目名称:UniLua,代码行数:28,代码来源:TagMethod.cs
示例2: luaV_tonumber
public static TValue luaV_tonumber (TValue obj, TValue n) {
lua_Number num;
if (ttisnumber(obj)) return obj;
if (ttisstring(obj) && (luaO_str2d(svalue(obj), out num)!=0)) {
setnvalue(n, num);
return n;
}
else
return null;
}
开发者ID:mlnlover11,项目名称:KopiLua-v5.1.5,代码行数:10,代码来源:lvm.cs
示例3: luaV_tonumber
public static TValue luaV_tonumber (TValue obj, TValue n) {
lua_Number num;
if (TTIsNumber(obj)) return obj;
if (TTIsString(obj) && (LuaOStr2d(SValue(obj), out num)!=0)) {
SetNValue(n, num);
return n;
}
else
return null;
}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:10,代码来源:lvm.cs
示例4: callTMres
private static void callTMres (lua_State L, StkId res, TValue f,
TValue p1, TValue p2) {
ptrdiff_t result = savestack(L, res);
setobj2s(L, L.top, f); /* push function */
setobj2s(L, L.top+1, p1); /* 1st argument */
setobj2s(L, L.top+2, p2); /* 2nd argument */
luaD_checkstack(L, 3);
L.top += 3;
luaD_call(L, L.top-3, 1);
res = restorestack(L, result);
StkId.dec(ref L.top);
setobjs2s(L, res, L.top);
}
开发者ID:mlnlover11,项目名称:KopiLua-v5.1.5,代码行数:13,代码来源:lvm.cs
示例5: Main
public static unsafe int Main ()
{
TValue[] values = new TValue[10];
values[0] = new TValue (0L);
values[1] = new TValue (1000L);
values[2] = new TValue (1L);
Console.WriteLine ("values: {0} {1} {2}", values[0], values[1], values[2]);
fixed (TValue* vals = values) {
Console.WriteLine ("fixed: {0} {1} {2}", vals[0], vals[1], vals[2]);
if (vals[0].ToString () != "0")
return 1;
if (vals[1].ToString() != "1000")
return 2;
if (vals[2].ToString() != "1")
return 3;
}
Console.WriteLine ("ok");
return 0;
}
开发者ID:carrie901,项目名称:mono,代码行数:22,代码来源:test-740.cs
示例6: lua_setfield
public static void lua_setfield(LuaState L, int idx, CharPtr k)
{
StkId t;
TValue key = new TValue();
lua_lock(L);
api_checknelems(L, 1);
t = index2adr(L, idx);
api_checkvalidindex(L, t);
setsvalue(L, key, luaS_new(L, k));
luaV_settable(L, t, key, L.top - 1);
StkId.dec(ref L.top); /* pop value */
lua_unlock(L);
}
开发者ID:chenzuo,项目名称:SharpLua,代码行数:13,代码来源:lapi.cs
示例7: lua_tointeger
public static lua_Integer lua_tointeger(LuaState L, int idx)
{
TValue n = new TValue();
TValue o = index2adr(L, idx);
if (tonumber(ref o, n) != 0)
{
lua_Integer res;
lua_Number num = nvalue(o);
lua_number2integer(out res, num);
return res;
}
else
return 0;
}
开发者ID:chenzuo,项目名称:SharpLua,代码行数:14,代码来源:lapi.cs
示例8: lua_isnumber
public static int lua_isnumber(LuaState L, int idx)
{
TValue n = new TValue();
TValue o = index2adr(L, idx);
return tonumber(ref o, n);
}
开发者ID:chenzuo,项目名称:SharpLua,代码行数:6,代码来源:lapi.cs
示例9: lua_getupvalue
public static CharPtr lua_getupvalue(LuaState L, int funcindex, int n)
{
CharPtr name;
TValue val = new TValue();
lua_lock(L);
name = aux_upvalue(index2adr(L, funcindex), n, ref val);
if (name != null)
{
setobj2s(L, L.top, val);
api_incr_top(L);
}
lua_unlock(L);
return name;
}
开发者ID:chenzuo,项目名称:SharpLua,代码行数:14,代码来源:lapi.cs
示例10: AddK
private static int AddK (FuncState fs, TValue k, TValue v) {
LuaState L = fs.L;
TValue idx = luaH_set(L, fs.h, k);
Proto f = fs.f;
int oldsize = f.sizek;
if (TTIsNumber(idx)) {
LuaAssert(LuaORawEqualObj(fs.f.k[CastInt(NValue(idx))], v));
return CastInt(NValue(idx));
}
else { /* constant not found; create a new entry */
SetNValue(idx, CastNum(fs.nk));
LuaMGrowVector(L, ref f.k, fs.nk, ref f.sizek,
MAXARG_Bx, "constant table overflow");
while (oldsize < f.sizek) SetNilValue(f.k[oldsize++]);
SetObj(L, f.k[fs.nk], v);
LuaCBarrier(L, f, v);
return fs.nk++;
}
}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:19,代码来源:lcode.cs
示例11: boolK
private static int boolK (FuncState fs, int b) {
TValue o = new TValue();
setbvalue(o, b);
return addk(fs, o, o);
}
开发者ID:mlnlover11,项目名称:KopiLua-v5.1.5,代码行数:5,代码来源:lcode.cs
示例12: countint
private static int countint (TValue key, int[] nums) {
int k = arrayindex(key);
if (0 < k && k <= MAXASIZE) { /* is `key' an appropriate array index? */
nums[CeilLog2(k)]++; /* count as such */
return 1;
}
else
return 0;
}
开发者ID:oathx,项目名称:Six,代码行数:9,代码来源:ltable.cs
示例13: arrayindex
/*
** returns the index for `key' if `key' is an appropriate key to live in
** the array part of the table, -1 otherwise.
*/
private static int arrayindex (TValue key) {
if (TTIsNumber(key)) {
lua_Number n = NValue(key);
int k;
lua_number2int(out k, n);
if (luai_numeq(CastNum(k), n))
return k;
}
return -1; /* `key' did not match some condition */
}
开发者ID:oathx,项目名称:Six,代码行数:14,代码来源:ltable.cs
示例14: LuaGOrderError
public static int LuaGOrderError (LuaState L, TValue p1, TValue p2) {
CharPtr t1 = luaT_typenames[TType(p1)];
CharPtr t2 = luaT_typenames[TType(p2)];
if (t1[2] == t2[2])
LuaGRunError(L, "attempt to compare two %s values", t1);
else
LuaGRunError(L, "attempt to compare %s with %s", t1, t2);
return 0;
}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:9,代码来源:ldebug.cs
示例15: LuaGArithError
public static void LuaGArithError (LuaState L, TValue p1, TValue p2) {
TValue temp = new LuaTypeValue();
if (luaV_tonumber(p1, temp) == null)
p2 = p1; /* first operand is wrong */
LuaGTypeError(L, p2, "perform arithmetic on");
}
开发者ID:ZoneBeat,项目名称:FAForeverMapEditor,代码行数:6,代码来源:ldebug.cs
示例16: luaK_stringK
public static int luaK_stringK (FuncState fs, TString s) {
TValue o = new TValue();
setsvalue(fs.L, o, s);
return addk(fs, o, o);
}
开发者ID:mlnlover11,项目名称:KopiLua-v5.1.5,代码行数:5,代码来源:lcode.cs
示例17: luaK_numberK
public static int luaK_numberK (FuncState fs, lua_Number r) {
TValue o = new TValue();
setnvalue(o, r);
return addk(fs, o, o);
}
开发者ID:mlnlover11,项目名称:KopiLua-v5.1.5,代码行数:5,代码来源:lcode.cs
示例18: rehash
private static void rehash (LuaState L, Table t, TValue ek) {
int nasize, na;
int[] nums = new int[MAXBITS+1]; /* nums[i] = number of keys between 2^(i-1) and 2^i */
int i;
int totaluse;
for (i=0; i<=MAXBITS; i++) nums[i] = 0; /* reset counts */
nasize = numusearray(t, nums); /* count keys in array part */
totaluse = nasize; /* all those keys are integer keys */
totaluse += numusehash(t, nums, ref nasize); /* count keys in hash part */
/* count extra key */
nasize += countint(ek, nums);
totaluse++;
/* compute new size for array part */
na = computesizes(nums, ref nasize);
/* resize the table to new computed sizes */
resize(L, t, nasize, totaluse - na);
}
开发者ID:oathx,项目名称:Six,代码行数:17,代码来源:ltable.cs
示例19: nilK
private static int nilK (FuncState fs) {
TValue k = new TValue(), v = new TValue();
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);
}
开发者ID:mlnlover11,项目名称:KopiLua-v5.1.5,代码行数:7,代码来源:lcode.cs
示例20: newkey
/*
** inserts a new key into a hash table; first, check whether key's main
** position is free. If not, check whether colliding node is in its main
** position or not: if it is not, move colliding node to an empty place and
** put new key in its main position; otherwise (colliding node is in its main
** position), new key goes to an empty position.
*/
private static TValue newkey (LuaState L, Table t, TValue key) {
Node mp = mainposition(t, key);
if (!TTIsNil(gval(mp)) || mp == dummynode) {
Node othern;
Node n = getfreepos(t); /* get a free place */
if (n == null) { /* cannot find a free place? */
rehash(L, t, key); /* grow table */
return luaH_set(L, t, key); /* re-insert key into grown table */
}
LuaAssert(n != dummynode);
othern = mainposition(t, key2tval(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_set(othern, n); /* redo the chain with `n' in place of `mp' */
n.i_val = new LuaTypeValue(mp.i_val); /* copy colliding node into free pos. (mp.next also goes) */
n.i_key = new TKey(mp.i_key);
gnext_set(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_set(n, gnext(mp)); /* chain new position */
gnext_set(mp, n);
mp = n;
}
}
gkey(mp).value.Copy(key.value); gkey(mp).tt = key.tt;
LuaCBarrierT(L, t, key);
LuaAssert(TTIsNil(gval(mp)));
return gval(mp);
}
开发者ID:oathx,项目名称:Six,代码行数:39,代码来源:ltable.cs
注:本文中的TValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论