本文整理汇总了C++中PushValue函数的典型用法代码示例。如果您正苦于以下问题:C++ PushValue函数的具体用法?C++ PushValue怎么用?C++ PushValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PushValue函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:asraniel,项目名称:rocket,代码行数:30,代码来源:Lua.cpp
示例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!");
}
}
开发者ID:mrdooz,项目名称:bristol,代码行数:14,代码来源:evaluator.cpp
示例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);
}
}
开发者ID:sanyaade-iot,项目名称:core-XToolbox,代码行数:15,代码来源:VJSValue.cpp
示例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]);
}
开发者ID:mrdooz,项目名称:bristol,代码行数:16,代码来源:evaluator.cpp
示例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 );
}
开发者ID:awakegod,项目名称:NETMF-LPC,代码行数:7,代码来源:CLR_RT_StackFrame.cpp
示例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);
}
开发者ID:artyyouth,项目名称:SpiderMonkey_JSON,代码行数:29,代码来源:json.cpp
示例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;
}
开发者ID:artyyouth,项目名称:SpiderMonkey_JSON,代码行数:28,代码来源:json.cpp
示例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;
}
开发者ID:artyyouth,项目名称:SpiderMonkey_JSON,代码行数:32,代码来源:json.cpp
示例9: PushValue
void CLR_RT_StackFrame::SetResult_U8( CLR_UINT64& val )
{
CLR_RT_HeapBlock& top = PushValue();
top.SetInteger( val );
}
开发者ID:awakegod,项目名称:NETMF-LPC,代码行数:7,代码来源:CLR_RT_StackFrame.cpp
示例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;
}
开发者ID:Arpit007,项目名称:projectanarchy,代码行数:59,代码来源:VRSDLuaImplementation.cpp
示例11: KeyExists
bool LuaTable::KeyExists(const string& key) const
{
if (!PushValue(key)) {
return false;
}
lua_pop(L, 1);
return true;
}
开发者ID:Dmytry,项目名称:spring,代码行数:8,代码来源:LuaParser.cpp
示例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());
}
开发者ID:SirGoodsmoke,项目名称:GTALua,代码行数:12,代码来源:ScriptHookV.cpp
示例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;
}
开发者ID:Caoxuyang,项目名称:klcommon,代码行数:9,代码来源:table_bind.cpp
示例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;
}
开发者ID:Dmytry,项目名称:spring,代码行数:9,代码来源:LuaParser.cpp
示例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;
}
开发者ID:Dmytry,项目名称:spring,代码行数:9,代码来源:LuaParser.cpp
示例16: exit
// methods
void IntegerClass::Abs(Value &self, Value* execution_stack, size_t &execution_stack_pos, INT_T arg_count) {
if(self.type != INT_TYPE || arg_count != 0) {
wcerr << L">>> expected integer type <<<" << endl;
exit(1);
}
Value value(INT_TYPE);
value.value.int_value = labs(self.value.int_value);
PushValue(value, execution_stack, execution_stack_pos);
}
开发者ID:objeck,项目名称:substance-lang,代码行数:11,代码来源:classes.cpp
示例17: HandleString
static JSBool
HandleString(JSContext *cx, JSONParser *jp, const jschar *buf, uint32 len)
{
JSObject *obj = GetTopOfObjectStack(cx, jp);
JSString *str = js_NewStringCopyN(cx, buf, len);
if (!obj || !str)
return JS_FALSE;
return PushValue(cx, jp, obj, STRING_TO_JSVAL(str));
}
开发者ID:georgi,项目名称:jsmad,代码行数:10,代码来源:json.cpp
示例18: VASSERT
bool VRSDClientLuaImplementation::UpdateDynamicProperty(const void* pUserDataParent,
const char* szVarName,
const char* szNewValue)
{
VASSERT(m_pLuaState);
lua_State* L = m_pLuaState;
VLuaStackCleaner stackCleaner(L);
VTypedObject* pTypedObject = LUA_ExtractFromUserData(L, pUserDataParent);
if (pTypedObject == NULL)
{
return false;
}
LUA_LookupObjectProxy(L, pTypedObject); // proxy or nil, TOP
if (lua_isnil(L, -1))
{
return false;
}
LUA_FetchDynPropertyTable(L); // proxy, dynproptable or nil, TOP
if (lua_isnil(L, -1))
{
return false;
}
lua_pushstring(L, szVarName); // proxy, dynproptable, key, TOP
lua_pushvalue(L, -1); // proxy, dynproptable, key, key, TOP
lua_rawget(L, -3); // proxy, dynproptable, key, value, TOP
if (lua_isnil(L, -1))
{
return false;
}
int iType = lua_type(L, -1); // proxy, dynproptable, key, value, TOP
lua_pop(L, 1); // proxy, dynproptable, key, TOP
if (!PushValue(iType, szNewValue)) // proxy, dynproptable, key, newvalue, TOP
{
return false;
}
lua_rawset(L, -3);
return true;
}
开发者ID:Arpit007,项目名称:projectanarchy,代码行数:53,代码来源:VRSDLuaImplementation.cpp
示例19: GetString
string LuaTable::GetString(int key, const string& def) const
{
if (!PushValue(key)) {
return def;
}
if (!lua_isstring(L, -1)) {
lua_pop(L, 1);
return def;
}
const string value = lua_tostring(L, -1);
lua_pop(L, 1);
return value;
}
开发者ID:Dmytry,项目名称:spring,代码行数:13,代码来源:LuaParser.cpp
示例20:
float3 LuaTable::GetFloat3(int key, const float3& def) const
{
if (!PushValue(key)) {
return def;
}
float3 value;
if (!ParseFloat3(L, -1, value)) {
lua_pop(L, 1);
return def;
}
lua_pop(L, 1);
return value;
}
开发者ID:Dmytry,项目名称:spring,代码行数:13,代码来源:LuaParser.cpp
注:本文中的PushValue函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论