本文整理汇总了C++中pushValue函数的典型用法代码示例。如果您正苦于以下问题:C++ pushValue函数的具体用法?C++ pushValue怎么用?C++ pushValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pushValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void
StyledStreamWriter::writeValue( const Value &value )
{
switch ( value.type() )
{
case nullValue:
pushValue( "null" );
break;
case intValue:
pushValue( valueToString( value.asInt() ) );
break;
case uintValue:
pushValue( valueToString( value.asUInt() ) );
break;
case realValue:
pushValue( valueToString( value.asDouble() ) );
break;
case stringValue:
pushValue( valueToQuotedString( value.asCString() ) );
break;
case booleanValue:
pushValue( valueToString( value.asBool() ) );
break;
case arrayValue:
writeArrayValue( value);
break;
case objectValue:
{
Value::Members members( value.getMemberNames() );
if ( members.empty() )
pushValue( "{}" );
else
{
writeWithIndent( "{" );
indent();
Value::Members::iterator it = members.begin();
while ( true )
{
const std::string &name = *it;
const Value &childValue = value[name];
writeCommentBeforeValue( childValue );
writeWithIndent( valueToQuotedString( name.c_str() ) );
*document_ << " : ";
writeValue( childValue );
if ( ++it == members.end() )
{
writeCommentAfterValueOnSameLine( childValue );
break;
}
*document_ << ",";
writeCommentAfterValueOnSameLine( childValue );
}
unindent();
writeWithIndent( "}" );
}
}
break;
}
}
示例2: pushValue
void
StyledStreamWriter::writeArrayValue ( const Value& value )
{
unsigned size = value.size ();
if ( size == 0 )
pushValue ( "[]" );
else
{
bool isArrayMultiLine = isMultineArray ( value );
if ( isArrayMultiLine )
{
writeWithIndent ( "[" );
indent ();
bool hasChildValue = !childValues_.empty ();
unsigned index = 0;
while ( true )
{
const Value& childValue = value[index];
if ( hasChildValue )
writeWithIndent ( childValues_[index] );
else
{
writeIndent ();
writeValue ( childValue );
}
if ( ++index == size )
break;
*document_ << ",";
}
unindent ();
writeWithIndent ( "]" );
}
else // output on a single line
{
assert ( childValues_.size () == size );
*document_ << "[ ";
for ( unsigned index = 0; index < size; ++index )
{
if ( index > 0 )
*document_ << ", ";
*document_ << childValues_[index];
}
*document_ << " ]";
}
}
}
示例3: draw
void draw()
{
background(0);
drawGrid();
val = getValue();
if (val != -1) {
pushValue(val);
}
drawLines();
}
开发者ID:AndyFiore,项目名称:Random-Nerd-Tutorials,代码行数:10,代码来源:Arduino_Poor_mans_oscilloscope_processing_code.c
示例4: VALIDATE
bool VariableRef::readUInt32( uint32& out ) const
{
VALIDATE();
pushValue();
out = (uint32)lua_tonumber(m_ownerContext->getPimpl()->L, -1);
popValue();
return true;
}
示例5: setupListener
//// Listener settings ////
void setupListener()
{
auto listener_node = *m_dev->emplace(m_dev->children().cend(), "listener");
auto listener_pos_node = *listener_node->emplace(listener_node->children().cend(), "pos");
add_position(listener_pos_node,
make_parameter(
[&] () { return m_scene.listener().Position(); },
[&] (const auto& elt) { m_scene.listener().Position(elt); }));
auto listener_orient_node = *listener_node->emplace(listener_node->children().cend(), "orientation");
auto listener_orient_addr = listener_orient_node->createAddress(OSSIA::Value::Type::TUPLE); // [ at_x at_y at_z up_x at_y at_z ]
auto tupl = new OSSIA::Tuple;
const auto& orient = m_scene.listener().Orientation();
tupl->value.push_back(new OSSIA::Float(orient.At()[0]));
tupl->value.push_back(new OSSIA::Float(orient.At()[1]));
tupl->value.push_back(new OSSIA::Float(orient.At()[2]));
tupl->value.push_back(new OSSIA::Float(orient.Up()[0]));
tupl->value.push_back(new OSSIA::Float(orient.Up()[1]));
tupl->value.push_back(new OSSIA::Float(orient.Up()[2]));
listener_orient_addr->pushValue(tupl);
listener_orient_addr->addCallback([&] (const OSSIA::Value* val) {
auto tpl = dynamic_cast<const OSSIA::Tuple*>(val);
if(tpl->value.size() != 6)
return;
auto at_x = dynamic_cast<const OSSIA::Float*>(tpl->value[0]);
auto at_y = dynamic_cast<const OSSIA::Float*>(tpl->value[1]);
auto at_z = dynamic_cast<const OSSIA::Float*>(tpl->value[2]);
auto up_x = dynamic_cast<const OSSIA::Float*>(tpl->value[3]);
auto up_y = dynamic_cast<const OSSIA::Float*>(tpl->value[4]);
auto up_z = dynamic_cast<const OSSIA::Float*>(tpl->value[5]);
if(!at_x || !at_y || !at_z || !up_x || !up_y || !up_z)
return;
m_scene.listener().Orientation(at_x->value, at_y->value, at_z->value, up_x->value, up_y->value, up_z->value);
});
auto listener_orient_at_node = *listener_orient_node->emplace(listener_orient_node->children().cend(), "at");
add_position(listener_orient_at_node,
make_parameter(
[&] () { return m_scene.listener().OrientationAt(); },
[&] (const auto& elt) { m_scene.listener().Orientation(elt, m_scene.listener().OrientationUp()); }
));
auto listener_orient_up_node = *listener_orient_node->emplace(listener_orient_node->children().cend(), "up");
add_position(listener_orient_up_node,
make_parameter(
[&] () { return m_scene.listener().OrientationUp(); },
[&] (const auto& elt) { m_scene.listener().Orientation(m_scene.listener().OrientationAt(), elt); }
));
}
示例6: luaopen_input
int luaopen_input(lua_State* L)
{
luaL_register(L, "input", inputlib_f);
// event table
lua_pushstring(L, "event");
lua_newtable(L);
lua_pushstring(L, "key");
pushValue(L, W_INPUT.KeyEvent);
lua_settable(L, -3);
lua_pushstring(L, "mouseButton");
pushValue(L, W_INPUT.MouseButtonEvent);
lua_settable(L, -3);
lua_pushstring(L, "cursorPos");
pushValue(L, W_INPUT.CursorPositionEvent);
lua_settable(L, -3);
lua_settable(L, -3);
// end event table
lua_pushstring(L, "action");
push_action_constants(L);
lua_settable(L, -3);
lua_pushstring(L, "key");
push_keyboard_constants(L);
lua_settable(L, -3);
lua_pushstring(L, "mouse");
push_mouse_constants(L);
lua_settable(L, -3);
lua_pushstring(L, "cursorMode");
push_cursor_mode_constants(L);
lua_settable(L, -3);
return 1;
}
示例7: pushValue
int pushValue(lua_State* state, const std::vector<T>& vec)
{
lua_createtable(state, vec.size(), 0);
for(std::size_t i = 0; i < vec.size(); i++)
{
pushValue(state, vec[i]);
lua_rawseti(state, -2, i + 1);
}
return 1;
}
示例8: pushArray
//------------------------------------------------------------------------------
void SN_API pushArray(HSQUIRRELVM vm, const Variant::Array & a)
{
sq_newarray(vm, a.size());
for (size_t i = 0; i < a.size(); ++i)
{
sq_pushinteger(vm, i);
pushValue(vm, a[i]);
if (SQ_FAILED(sq_set(vm, -3)))
{
SN_WARNING("Variant => Squirrel: failed to set array index " << i);
}
}
}
示例9: pushValue
void
StyledWriter::writeArrayValue( const Value &value )
{
unsigned size = value.size();
if ( size == 0 )
pushValue( "[]" );
else
{
bool isArrayMultiLine = isMultineArray( value );
if ( isArrayMultiLine )
{
writeWithIndent( "[" );
indent();
bool hasChildValue = !childValues_.empty();
unsigned index =0;
for (;;)
{
const Value &childValue = value[index];
writeCommentBeforeValue( childValue );
if ( hasChildValue )
writeWithIndent( childValues_[index] );
else
{
writeIndent();
writeValue( childValue );
}
if ( ++index == size )
{
writeCommentAfterValueOnSameLine( childValue );
break;
}
document_ += ",";
writeCommentAfterValueOnSameLine( childValue );
}
unindent();
writeWithIndent( "]" );
}
else // output on a single line
{
assert( childValues_.size() == size );
document_ += "[ ";
for ( unsigned index =0; index < size; ++index )
{
if ( index > 0 )
document_ += ", ";
document_ += childValues_[index];
}
document_ += " ]";
}
}
}
示例10: s_implementation
static void s_implementation(gnative_Object *obj, gnative_Function *function, gnative_Value *parameters)
{
if (L == NULL)
return;
gnative_Class *cls = gnative_ObjectGetClass(obj);
lua_pushlightuserdata(L, &keyClasses);
lua_gettable(L, LUA_REGISTRYINDEX);
lua_pushlightuserdata(L, cls);
lua_gettable(L, -2);
lua_remove(L, -2);
lua_pushstring(L, "__functions");
lua_rawget(L, -2);
lua_pushlightuserdata(L, function);
lua_gettable(L, -2);
gnative_Value v;
v.obj = obj;
pushValue(L, v, GNATIVE_TYPE_OBJECT, false);
int parameterCount = gnative_FunctionGetParameterCount(function);
gnative_Type *parameterTypes = gnative_FunctionGetParameterTypes(function);
for (int i = 0; i < parameterCount; ++i)
pushValue(L, parameters[i], parameterTypes[i], false);
lua_call(L, 1 + parameterCount, 0);
lua_pop(L, 2);
}
示例11: switch
void BuiltStyledStreamWriter::writeValue(Value const& value) {
switch (value.type()) {
case nullValue:
pushValue(nullSymbol_);
break;
case intValue:
pushValue(valueToString(value.asLargestInt()));
break;
case uintValue:
pushValue(valueToString(value.asLargestUInt()));
break;
case realValue:
pushValue(valueToString(value.asDouble()));
break;
case stringValue:
pushValue(valueToQuotedString(value.asCString()));
break;
case booleanValue:
pushValue(valueToString(value.asBool()));
break;
case arrayValue:
writeArrayValue(value);
break;
case objectValue: {
Value::Members members(value.getMemberNames());
if (members.empty())
pushValue("{}");
else {
writeWithIndent("{");
indent();
Value::Members::iterator it = members.begin();
for (;;) {
std::string const& name = *it;
Value const& childValue = value[name];
writeCommentBeforeValue(childValue);
writeWithIndent(valueToQuotedString(name.c_str()));
sout_ << colonSymbol_;
writeValue(childValue);
if (++it == members.end()) {
writeCommentAfterValueOnSameLine(childValue);
break;
}
sout_ << ",";
writeCommentAfterValueOnSameLine(childValue);
}
unindent();
writeWithIndent("}");
}
} break;
}
}
示例12: pushKey
void LuaModule::pushJsonScalarValue(const Json::Value &key,
const Json::Value &val, lua_State * stack) {
if (val.isObject() || val.isArray()) {
throw std::runtime_error("Not a scalar value");
}
if (key.isString()) {
pushKey(key, stack);
}
pushValue(val, stack);
if (key.isNumeric()) {
lua_rawseti(stack, -2, key.asInt() + 1);
} else if (key.isString()) {
lua_settable(stack, -3);
}
}
示例13: pushValue
void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
unsigned size = value.size();
if (size == 0)
pushValue("[]");
else {
bool isMultiLine = (cs_ == CommentStyle::All) || isMultineArray(value);
if (isMultiLine) {
writeWithIndent("[");
indent();
bool hasChildValue = !childValues_.empty();
unsigned index = 0;
for (;;) {
Value const& childValue = value[index];
writeCommentBeforeValue(childValue);
if (hasChildValue)
writeWithIndent(childValues_[index]);
else {
if (!indented_) writeIndent();
indented_ = true;
writeValue(childValue);
indented_ = false;
}
if (++index == size) {
writeCommentAfterValueOnSameLine(childValue);
break;
}
sout_ << ",";
writeCommentAfterValueOnSameLine(childValue);
}
unindent();
writeWithIndent("]");
} else // output on a single line
{
assert(childValues_.size() == size);
sout_ << "[";
if (!indentation_.empty()) sout_ << " ";
for (unsigned index = 0; index < size; ++index) {
if (index > 0)
sout_ << ", ";
sout_ << childValues_[index];
}
if (!indentation_.empty()) sout_ << " ";
sout_ << "]";
}
}
}
示例14: pushGlobalVariable
void Lua::callFunction(const char* name, const std::vector<Data>& args, std::vector<Data>* result) {
pushGlobalVariable(name);
for (const auto& arg: args) {
pushValue(arg);
}
std::size_t numReturn = result ? result->size() : 0;
handleError(lua_pcall(handle, args.size(), numReturn, 0));
if (result) {
std::size_t stackSize = lua_gettop(handle);
assert(stackSize >= numReturn);
for (std::size_t i = 0; i < numReturn; ++i) {
(*result)[i] = getValue(stackSize - numReturn + i + 1);
}
pop(numReturn);
}
}
示例15: pushTable
//------------------------------------------------------------------------------
void SN_API pushTable(HSQUIRRELVM vm, const Variant::Dictionary & d)
{
sq_newtable(vm);
for (auto it = d.begin(); it != d.end(); ++it)
{
// Push key
const std::string & key = it->first;
sq_pushstring(vm, key.c_str(), key.size());
// Push value
const Variant & value = it->second;
pushValue(vm, value);
// Set or create
if (SQ_FAILED(sq_newslot(vm, -3, SQFalse)))
{
SN_WARNING("Variant => Squirrel: failed to set key " << key);
}
}
}