本文整理汇总了C++中PushValue函数的典型用法代码示例。如果您正苦于以下问题:C++ PushValue函数的具体用法?C++ PushValue怎么用?C++ PushValue使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PushValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lua_getupvalue
const char* lua_getupvalue(lua_State *L, int funcIndex, int n)
{
const Value* func = GetValueForIndex(L, funcIndex);
luai_apicheck(L, Value_GetIsClosure(func) );
Closure* closure = func->closure;
if (closure->c)
{
if (n >= 1 && n <= closure->cclosure.numUpValues)
{
PushValue(L, &closure->cclosure.upValue[n - 1]);
// Up values to a C function are unnamed.
return "";
}
}
else
{
if (n >= 1 && n <= closure->lclosure.numUpValues)
{
PushValue(L, closure->lclosure.upValue[n - 1]->value);
// Get the name of the up value from the prototype.
String* name = closure->lclosure.prototype->upValue[n - 1];
return String_GetData(name);
}
}
return NULL;
}
示例2: PopValue
//------------------------------------------------------------------------------
void Evaluator::ApplyBinOp(Token::BinOp op)
{
float b = PopValue();
float a = PopValue();
switch (op)
{
case Token::BinOpAdd: PushValue(a + b); break;
case Token::BinOpSub: PushValue(a - b); break;
case Token::BinOpMul: PushValue(a * b); break;
case Token::BinOpDiv: PushValue(a / b); break;
default: LOG_WARN("Unknown bin-op!");
}
}
示例3: xval
void VJSArray::PushValues( const std::vector<const XBOX::VValueSingle*> inValues, JS4D::ExceptionRef *outException) const
{
for (std::vector<const XBOX::VValueSingle*>::const_iterator cur = inValues.begin(), end = inValues.end(); cur != end; cur++)
{
const VValueSingle* val = *cur;
if (val == NULL)
{
VJSValue xval(fContext);
xval.SetNull();
PushValue(xval, outException);
}
else
PushValue(*val, outException);
}
}
示例4: PushValue
//------------------------------------------------------------------------------
void Evaluator::LookupVar(const Token& t, const Environment* env)
{
const string& name = t.name;
if (env)
{
auto it = env->constants.find(name);
if (it != env->constants.end())
{
PushValue(it->second);
return;
}
}
assert(constants.count(name));
PushValue(constants[name]);
}
示例5: NATIVE_PROFILE_CLR_CORE
void CLR_RT_StackFrame::SetResult( CLR_INT32 val, CLR_DataType dataType )
{
NATIVE_PROFILE_CLR_CORE();
CLR_RT_HeapBlock& top = PushValue();
top.SetInteger( val, dataType );
}
示例6: HandleKeyword
static JSBool
HandleKeyword(JSContext *cx, JSONParser *jp, const jschar *buf, uint32 len)
{
jsval keyword;
JSTokenType tt = js_CheckKeyword(buf, len);
if (tt != TOK_PRIMARY)
return JS_FALSE;
if (buf[0] == 'n')
keyword = JSVAL_NULL;
else if (buf[0] == 't')
keyword = JSVAL_TRUE;
else if (buf[0] == 'f')
keyword = JSVAL_FALSE;
else
return JS_FALSE;
jsuint length;
if (!JS_GetArrayLength(cx, jp->objectStack, &length))
return JS_FALSE;
jsval o;
if (!JS_GetElement(cx, jp->objectStack, length - 1, &o))
return JS_FALSE;
JS_ASSERT(JSVAL_IS_OBJECT(o));
JSObject *obj = JSVAL_TO_OBJECT(o);
return PushValue(cx, jp, obj, keyword);
}
示例7: HandleNumber
static JSBool
HandleNumber(JSContext *cx, JSONParser *jp, const jschar *buf, uint32 len)
{
JSBool ok;
jsuint length;
if (!JS_GetArrayLength(cx, jp->objectStack, &length))
return JS_FALSE;
jsval o;
if (!JS_GetElement(cx, jp->objectStack, length - 1, &o))
return JS_FALSE;
JS_ASSERT(JSVAL_IS_OBJECT(o));
JSObject *obj = JSVAL_TO_OBJECT(o);
const jschar *ep;
double val;
// if (!js_strtod(cx, buf, buf + len, &ep, &val) || ep != buf + len)
if (!js_strtod(cx, buf, &ep, &val) || ep != buf + len)
return JS_FALSE;
jsval numVal;
if (JS_NewNumberValue(cx, val, &numVal))
ok = PushValue(cx, jp, obj, numVal);
else
ok = JS_FALSE; // decode error
return ok;
}
示例8: PushObject
static JSBool
PushObject(JSContext *cx, JSONParser *jp, JSObject *obj)
{
jsuint len;
if (!JS_GetArrayLength(cx, jp->objectStack, &len))
return JS_FALSE;
if (len >= JSON_MAX_DEPTH)
return JS_FALSE; // decoding error
jsval v = OBJECT_TO_JSVAL(obj);
// Check if this is the root object
if (len == 0) {
*jp->rootVal = v;
if (!JS_SetElement(cx, jp->objectStack, 0, jp->rootVal))
return JS_FALSE;
return JS_TRUE;
}
jsval p;
if (!JS_GetElement(cx, jp->objectStack, len - 1, &p))
return JS_FALSE;
JS_ASSERT(JSVAL_IS_OBJECT(p));
JSObject *parent = JSVAL_TO_OBJECT(p);
if (!PushValue(cx, jp, parent, OBJECT_TO_JSVAL(obj)))
return JS_FALSE;
if (!JS_SetElement(cx, jp->objectStack, len, &v))
return JS_FALSE;
return JS_TRUE;
}
示例9: PushValue
void CLR_RT_StackFrame::SetResult_U8( CLR_UINT64& val )
{
CLR_RT_HeapBlock& top = PushValue();
top.SetInteger( val );
}
示例10: copyBuffer
bool VRSDClientLuaImplementation::UpdateGlobalVariable(const char* szVarName, const char* szNewValue)
{
if(!szVarName || !szNewValue || szVarName[0]==0)
return false;
// we can only get global symbols without a crash if we are really in a Lua code execution path
if(strcmp(m_pActivationRecord->what, "Lua"))
return true;
VMemoryTempBuffer<512> copyBuffer(szVarName); // operate on a copy string in the tokenizer
VLuaStackCleaner stackCleaner(m_pLuaState);
ScopedBooleanToTrue disableDebugHook(m_bDebuggerRetrievingValues);
VStringTokenizerInPlace Tokenizer(copyBuffer.AsChar(), '.');
const char* pCurrent = Tokenizer.Next();
unsigned int i = 0;
const char* pLastField = NULL;
lua_getfield(m_pLuaState, LUA_GLOBALSINDEX, pCurrent);
if(lua_isnil(m_pLuaState, -1))
return false;
if(LookupPath(Tokenizer, &pLastField) != HKV_SUCCESS)
return false;
// now the variable is at the top of the stack, update its value
int iLuaType = lua_type(m_pLuaState, -1);
lua_pop(m_pLuaState, 1);
bool bIsIntegerKey = false;
if(pLastField && VStringUtil::IsIntegerString(pLastField))
{
bIsIntegerKey = true;
lua_pushnumber(m_pLuaState, (LUA_NUMBER)atoi(pLastField));
}
if (!PushValue(iLuaType, szNewValue))
return false;
if( Tokenizer.GetTokenCount() > 1 )
{
VASSERT(pLastField != NULL);
if(bIsIntegerKey)
{
lua_settable(m_pLuaState, -3);
}
else
{
lua_setfield(m_pLuaState, -2, pLastField);
}
}
else
{
lua_setglobal(m_pLuaState, szVarName);
}
return true;
}
示例11: KeyExists
bool LuaTable::KeyExists(const string& key) const
{
if (!PushValue(key)) {
return false;
}
lua_pop(L, 1);
return true;
}
示例12: PushValue
// =================================================================================
// Push Memory
// =================================================================================
void ScriptHook::PushMemory(ScriptBinds::Memory::MemoryBlock* pMemBlock)
{
if (pMemBlock == NULL || !pMemBlock->IsValid())
{
lua->PushString("ScriptHook::PushMemory failed! Invalid CMemoryBlock passed!");
throw luabind::error(lua->State());
}
PushValue(pMemBlock->GetMemoryPointer());
}
示例13: PT_Get
int PT_Get (lua_State *L) {
ParamTable *pt = check_PT (L, 1);
const char *key = luaL_checkstring (L, 2);
luaL_argcheck (L, key, 2, "a valid string expected");
DEBUG ("PT_Get: %s\n", key);
const Value *val = pt->Get (key);
PushValue (L, val);
return 1;
}
示例14: GetLength
int LuaTable::GetLength(const string& key) const
{
if (!PushValue(key)) {
return 0;
}
const int len = lua_objlen(L, -1);
lua_pop(L, 1);
return len;
}
示例15: GetType
int LuaTable::GetType(const string& key) const
{
if (!PushValue(key)) {
return -1;
}
const int type = lua_type(L, -1);
lua_pop(L, 1);
return type;
}