本文整理汇总了C++中pvalue函数的典型用法代码示例。如果您正苦于以下问题:C++ pvalue函数的具体用法?C++ pvalue怎么用?C++ pvalue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pvalue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: kp_equalobjv
/*
* equality of ktap values. ks == NULL means raw equality
*/
int kp_equalobjv(ktap_State *ks, const Tvalue *t1, const Tvalue *t2)
{
switch (ttype(t1)) {
case KTAP_TNIL:
return 1;
case KTAP_TNUMBER:
return nvalue(t1) == nvalue(t2);
case KTAP_TBOOLEAN:
return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
case KTAP_TLIGHTUSERDATA:
return pvalue(t1) == pvalue(t2);
case KTAP_TLCF:
return fvalue(t1) == fvalue(t2);
case KTAP_TSHRSTR:
return eqshrstr(rawtsvalue(t1), rawtsvalue(t2));
case KTAP_TLNGSTR:
return kp_tstring_eqlngstr(rawtsvalue(t1), rawtsvalue(t2));
case KTAP_TUSERDATA:
if (uvalue(t1) == uvalue(t2))
return 1;
else if (ks == NULL)
return 0;
case KTAP_TTABLE:
if (hvalue(t1) == hvalue(t2))
return 1;
else if (ks == NULL)
return 0;
default:
return gcvalue(t1) == gcvalue(t2);
}
return 0;
}
示例2: kp_obj_equal
/*
* equality of ktap values. ks == NULL means raw equality
*/
int kp_obj_equal(ktap_state *ks, const ktap_value *t1, const ktap_value *t2)
{
switch (ttype(t1)) {
case KTAP_TYPE_NIL:
return 1;
case KTAP_TYPE_NUMBER:
return nvalue(t1) == nvalue(t2);
case KTAP_TYPE_BOOLEAN:
return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
case KTAP_TYPE_LIGHTUSERDATA:
return pvalue(t1) == pvalue(t2);
case KTAP_TYPE_CFUNCTION:
return fvalue(t1) == fvalue(t2);
case KTAP_TYPE_SHRSTR:
return eqshrstr(rawtsvalue(t1), rawtsvalue(t2));
case KTAP_TYPE_LNGSTR:
return kp_str_eqlng(rawtsvalue(t1), rawtsvalue(t2));
case KTAP_TYPE_TABLE:
if (hvalue(t1) == hvalue(t2))
return 1;
else if (ks == NULL)
return 0;
case KTAP_TYPE_BTRACE:
return btrace_equal(btvalue(t1), btvalue(t2));
default:
return gcvalue(t1) == gcvalue(t2);
}
return 0;
}
示例3: luaV_equalval
/* Note: 'luaV_equalval()' and 'luaO_rawequalObj()' have largely overlapping
* implementation.
*/
int luaV_equalval (lua_State *L, const TValue *l, const TValue *r) {
const TValue *tm;
lua_assert( ttype_ext(l) == ttype_ext(r) );
switch (ttype(l)) {
case LUA_TNIL: return 1;
#ifdef LUA_TINT
case LUA_TINT:
#endif
case LUA_TNUMBER: return luaO_rawequalObj(l,r);
case LUA_TBOOLEAN: return bvalue(l) == bvalue(r); /* true must be 1 !! */
case LUA_TLIGHTUSERDATA: return pvalue(l) == pvalue(r);
case LUA_TUSERDATA: {
if (uvalue(l) == uvalue(r)) return 1;
tm = get_compTM(L, uvalue(l)->metatable, uvalue(r)->metatable, TM_EQ);
break; /* will try TM */
}
case LUA_TTABLE: {
if (hvalue(l) == hvalue(r)) return 1;
tm = get_compTM(L, hvalue(l)->metatable, hvalue(r)->metatable, TM_EQ);
break; /* will try TM */
}
default: return gcvalue(l) == gcvalue(r);
}
if (tm == NULL) return 0; /* no TM? */
callTMres(L, L->top, tm, l, r); /* call TM */
return !l_isfalse(L->top);
}
示例4: luaV_equalval
int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
const TValue *tm;
lua_assert(ttype(t1) == ttype(t2));
switch (ttype(t1)) {
case LUA_TNIL: return 1;
case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
case LUA_TUSERDATA: {
if (uvalue(t1) == uvalue(t2)) return 1;
tm = get_compTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable,
TM_EQ);
break; /* will try TM */
}
case LUA_TTABLE: {
if (hvalue(t1) == hvalue(t2)) return 1;
tm = get_compTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
break; /* will try TM */
}
default: return gcvalue(t1) == gcvalue(t2);
}
if (tm == NULL) return 0; /* no TM? */
callTMres(L, L->top, tm, t1, t2); /* call TM */
return !l_isfalse(L->top);
}
示例5: kp_equalobjv
/*
* equality of ktap values. ks == NULL means raw equality
*/
int kp_equalobjv(ktap_state *ks, const ktap_value *t1, const ktap_value *t2)
{
switch (ttype(t1)) {
case KTAP_TNIL:
return 1;
case KTAP_TNUMBER:
return nvalue(t1) == nvalue(t2);
case KTAP_TBOOLEAN:
return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
case KTAP_TLIGHTUSERDATA:
return pvalue(t1) == pvalue(t2);
case KTAP_TLCF:
return fvalue(t1) == fvalue(t2);
case KTAP_TSHRSTR:
return eqshrstr(rawtsvalue(t1), rawtsvalue(t2));
case KTAP_TLNGSTR:
return kp_tstring_eqlngstr(rawtsvalue(t1), rawtsvalue(t2));
case KTAP_TTABLE:
if (hvalue(t1) == hvalue(t2))
return 1;
else if (ks == NULL)
return 0;
#ifdef __KERNEL__
case KTAP_TBTRACE:
return kp_btrace_equal(btvalue(t1), btvalue(t2));
#endif
default:
return gcvalue(t1) == gcvalue(t2);
}
return 0;
}
示例6: luaV_equalobj_
/*
** equality of Lua values. L == NULL means raw equality (no metamethods)
*/
int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2) {
const TValue *tm;
lua_assert(ttisequal(t1, t2));
switch (ttype(t1)) {
case LUA_TNIL: return 1;
case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));
case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
case LUA_TLCF: return fvalue(t1) == fvalue(t2);
case LUA_TSTRING: return eqstr(rawtsvalue(t1), rawtsvalue(t2));
case LUA_TUSERDATA: {
if (uvalue(t1) == uvalue(t2)) return 1;
else if (L == NULL) return 0;
tm = get_equalTM(L, uvalue(t1)->metatable, uvalue(t2)->metatable, TM_EQ);
break; /* will try TM */
}
case LUA_TTABLE: {
if (hvalue(t1) == hvalue(t2)) return 1;
else if (L == NULL) return 0;
tm = get_equalTM(L, hvalue(t1)->metatable, hvalue(t2)->metatable, TM_EQ);
break; /* will try TM */
}
default:
lua_assert(iscollectable(t1));
return gcvalue(t1) == gcvalue(t2);
}
if (tm == NULL) return 0; /* no TM? */
callTM(L, tm, t1, t2, L->top, 1); /* call TM */
return !l_isfalse(L->top);
}
示例7: luaV_equalobj
/*
** Main operation for equality of Lua values; return 't1 == t2'.
** L == NULL means raw equality (no metamethods)
*/
int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
const TValue *tm;
if (ttype(t1) != ttype(t2)) { /* not the same variant? */
#ifndef _KERNEL
if (ttnov(t1) != ttnov(t2) || ttnov(t1) != LUA_TNUMBER)
return 0; /* only numbers can be equal with different variants */
else { /* two numbers with different variants */
lua_Integer i1, i2; /* compare them as integers */
return (tointeger(t1, &i1) && tointeger(t2, &i2) && i1 == i2);
}
#else /* _KERNEL */
return 0; /* numbers have only the integer variant */
#endif /* _KERNEL */
}
/* values have same type and same variant */
switch (ttype(t1)) {
case LUA_TNIL: return 1;
case LUA_TNUMINT: return (ivalue(t1) == ivalue(t2));
#ifndef _KERNEL
case LUA_TNUMFLT: return luai_numeq(fltvalue(t1), fltvalue(t2));
#endif /* _KERNEL */
case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */
case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
case LUA_TLCF: return fvalue(t1) == fvalue(t2);
case LUA_TSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2));
case LUA_TLNGSTR: return luaS_eqlngstr(tsvalue(t1), tsvalue(t2));
case LUA_TUSERDATA: {
if (uvalue(t1) == uvalue(t2)) return 1;
else if (L == NULL) return 0;
tm = fasttm(L, uvalue(t1)->metatable, TM_EQ);
if (tm == NULL)
tm = fasttm(L, uvalue(t2)->metatable, TM_EQ);
break; /* will try TM */
}
case LUA_TTABLE: {
if (hvalue(t1) == hvalue(t2)) return 1;
else if (L == NULL) return 0;
tm = fasttm(L, hvalue(t1)->metatable, TM_EQ);
if (tm == NULL)
tm = fasttm(L, hvalue(t2)->metatable, TM_EQ);
break; /* will try TM */
}
default:
return gcvalue(t1) == gcvalue(t2);
}
if (tm == NULL) /* no TM? */
return 0; /* objects are different */
luaT_callTM(L, tm, t1, t2, L->top, 1); /* call TM */
return !l_isfalse(L->top);
}
示例8: switch
static Node *mainposition (const Table *t, const Tvalue *key)
{
switch (ttype(key)) {
case KTAP_TNUMBER:
return hashnum(t, nvalue(key));
case KTAP_TLNGSTR: {
Tstring *s = rawtsvalue(key);
if (s->tsv.extra == 0) { /* no hash? */
s->tsv.hash = kp_string_hash(getstr(s), s->tsv.len, s->tsv.hash);
s->tsv.extra = 1; /* now it has its hash */
}
return hashstr(t, rawtsvalue(key));
}
case KTAP_TSHRSTR:
return hashstr(t, rawtsvalue(key));
case KTAP_TBOOLEAN:
return hashboolean(t, bvalue(key));
case KTAP_TLIGHTUSERDATA:
return hashpointer(t, pvalue(key));
case KTAP_TLCF:
return hashpointer(t, fvalue(key));
default:
return hashpointer(t, gcvalue(key));
}
}
示例9: Cursor_next
static PyObject *
Cursor_next(KyotoCursor *self)
{
std::string key;
std::string value;
bool succeed = self->m_cursor->get(&key, &value, true);
if (succeed) {
switch (self->m_type) {
case KYOTO_VALUE: {
return KyotoDB_load(value, self->m_db->use_pickle);
}
case KYOTO_ITEMS:{
APR pkey(KyotoDB_load(key, self->m_db->use_pickle));
APR pvalue(KyotoDB_load(value, self->m_db->use_pickle));
return PyTuple_Pack(2, (PyObject *)pkey, (PyObject *)pvalue);
}
case KYOTO_KEY:
default:
return KyotoDB_load(key, self->m_db->use_pickle);
}
}
PyErr_SetString(PyExc_StopIteration, "");
return NULL;
}
示例10: switch
/*
** returns the `main' position of an element in a table (that is, the index
** of its hash value)
**
** Floating point numbers with integer value give the hash position of the
** integer (so they use the same table position).
*/
static Node *mainposition (const Table *t, const TValue *key) {
switch (ttype(key)) {
#ifdef LUA_TINT
case LUA_TINT:
return hashint(t,ivalue(key));
#endif
case LUA_TNUMBER: {
#ifdef LUA_TINT
lua_Integer i;
if (tt_integer_valued(key,&i))
return hashint(t, i);
# ifdef LNUM_COMPLEX
/* Complex numbers are hashed by their scalar part. Pure imaginary values
* with scalar 0 or -0 should give same hash.
*/
if (nvalue_img_fast(key)!=0 && luai_numeq(nvalue_fast(key),0))
return gnode(t, 0); /* 0 and -0 to give same hash */
# endif
#else
if (luai_numeq(nvalue(key),0)) return gnode(t, 0); /* 0 and -0 to give same hash */
#endif
return hashnum(t,nvalue_fast(key));
}
case LUA_TSTRING:
return hashstr(t, rawtsvalue(key));
case LUA_TBOOLEAN:
return hashboolean(t, bvalue(key));
case LUA_TLIGHTUSERDATA:
return hashpointer(t, pvalue(key));
default:
return hashpointer(t, gcvalue(key));
}
}
示例11: pvalue
// -------------------------------------------------------------------
// MyOnlineState
// -------------------------------------------------------------------
void SFSBuddyManager::MyOnlineState(bool value)
{
boost::shared_ptr<bool> pvalue (new bool());
*pvalue = value;
boost::shared_ptr<BuddyVariable> variable(new SFSBuddyVariable(ReservedBuddyVariables::BV_ONLINE, pvalue, VARIABLETYPE_BOOL));
SetMyVariable (variable);
}
示例12: kp_obj_dump
void kp_obj_dump(ktap_state_t *ks, const ktap_val_t *v)
{
switch (itype(v)) {
case KTAP_TNIL:
kp_puts(ks, "NIL");
break;
case KTAP_TTRUE:
kp_printf(ks, "true");
break;
case KTAP_TFALSE:
kp_printf(ks, "false");
break;
case KTAP_TNUM:
kp_printf(ks, "NUM %ld", nvalue(v));
break;
case KTAP_TLIGHTUD:
kp_printf(ks, "LIGHTUD 0x%lx", (unsigned long)pvalue(v));
break;
case KTAP_TFUNC:
kp_printf(ks, "FUNCTION 0x%lx", (unsigned long)fvalue(v));
break;
case KTAP_TSTR:
kp_printf(ks, "STR #%s", svalue(v));
break;
case KTAP_TTAB:
kp_printf(ks, "TABLE 0x%lx", (unsigned long)hvalue(v));
break;
default:
kp_printf(ks, "GCVALUE 0x%lx", (unsigned long)gcvalue(v));
break;
}
}
示例13: kp_obj_dump
void kp_obj_dump(ktap_state *ks, const ktap_value *v)
{
switch (ttype(v)) {
case KTAP_TYPE_NIL:
kp_puts(ks, "NIL");
break;
case KTAP_TYPE_NUMBER:
kp_printf(ks, "NUMBER %ld", nvalue(v));
break;
case KTAP_TYPE_BOOLEAN:
kp_printf(ks, "BOOLEAN %d", bvalue(v));
break;
case KTAP_TYPE_LIGHTUSERDATA:
kp_printf(ks, "LIGHTUSERDATA 0x%lx", (unsigned long)pvalue(v));
break;
case KTAP_TYPE_CFUNCTION:
kp_printf(ks, "LIGHTCFCUNTION 0x%lx", (unsigned long)fvalue(v));
break;
case KTAP_TYPE_SHRSTR:
case KTAP_TYPE_LNGSTR:
kp_printf(ks, "SHRSTR #%s", svalue(v));
break;
case KTAP_TYPE_TABLE:
kp_printf(ks, "TABLE 0x%lx", (unsigned long)hvalue(v));
break;
default:
kp_printf(ks, "GCVALUE 0x%lx", (unsigned long)gcvalue(v));
break;
}
}
示例14: kp_obj_dump
void kp_obj_dump(ktap_State *ks, const Tvalue *v)
{
switch (ttype(v)) {
case KTAP_TNIL:
kp_printf(ks, "NIL");
break;
case KTAP_TNUMBER:
kp_printf(ks, "NUMBER %d", nvalue(v));
break;
case KTAP_TBOOLEAN:
kp_printf(ks, "BOOLEAN %d", bvalue(v));
break;
case KTAP_TLIGHTUSERDATA:
kp_printf(ks, "LIGHTUSERDATA %d", pvalue(v));
break;
case KTAP_TLCF:
kp_printf(ks, "LIGHTCFCUNTION 0x%x", fvalue(v));
break;
case KTAP_TSHRSTR:
case KTAP_TLNGSTR:
kp_printf(ks, "SHRSTR #%s", svalue(v));
break;
case KTAP_TUSERDATA:
kp_printf(ks, "USERDATA %d", uvalue(v));
break;
case KTAP_TTABLE:
kp_printf(ks, "TABLE 0x%x", hvalue(v));
break;
default:
kp_printf(ks, "GCVALUE 0x%x", gcvalue(v));
break;
}
}
示例15: luaO_rawequalObj
int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
if (ttype(t1) != ttype(t2)) return 0;
else switch (ttype(t1)) {
case LUA_TNIL:
return 1;
case LUA_TNUMBER:
return luai_numeq(nvalue(t1), nvalue(t2));
case LUA_TBOOLEAN:
return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */
case LUA_TLIGHTUSERDATA:
return pvalue(t1) == pvalue(t2);
default:
lua_assert(iscollectable(t1));
return gcvalue(t1) == gcvalue(t2);
}
}