本文整理汇总了C++中pushInt函数的典型用法代码示例。如果您正苦于以下问题:C++ pushInt函数的具体用法?C++ pushInt怎么用?C++ pushInt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pushInt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test1
void test1() {
printf("Test 1: Objects on stack are preserved.\n");
VM* vm = newVM();
pushInt(vm, 1);
pushInt(vm, 2);
gc(vm);
assert(vm->numObjects == 2, "Should have preserved objects.");
freeVM(vm);
}
示例2: test2
void test2() {
printf("Test 2: Unreached objects are collected.\n");
VM* vm = newVM();
pushInt(vm, 1);
pushInt(vm, 2);
pop(vm);
pop(vm);
gc(vm);
assert(vm->numObjects == 0, "Should have collected objects.");
freeVM(vm);
}
示例3: CCLOG
void GameNetDelegate::onMessageReceived(const char *data, unsigned short size)
{
CCLOG("onMessageReceived, size is %d %d", size, size - sizeof(CMD_Head));
CMD_Command Command = ((CMD_Head *)data)->CommandInfo;
auto stack = LuaEngine::getInstance()->getLuaStack();
stack->pushInt(Command.wMainCmdID);
stack->pushInt(Command.wSubCmdID);
stack->pushString(data + sizeof(CMD_Head), size - sizeof(CMD_Head));
auto it = m_callBacks.find("onReceived");
stack->executeFunctionByHandler(it->second, 3);
stack->clean();
}
示例4: luaopen_int64
LUALIB_API int luaopen_int64(lua_State *L)
{
if (sizeof(Int)<8) luaL_error(L,"int64 cannot work with %d-byte values",sizeof(Int));
luaL_newmetatable(L,MYTYPE);
luaL_setfuncs(L,R,0);
lua_pushliteral(L,"version"); /** version */
lua_pushliteral(L,MYVERSION);
lua_settable(L,-3);
pushInt(L,LLONG_MIN);
lua_setfield(L,-2,"min"); /** min */
pushInt(L,LLONG_MAX);
lua_setfield(L,-2,"max"); /** max */
return 1;
}
示例5: pushInt
void BenchmarkTcpClient::buildWriteChunk() {
if (writeBuffer.empty()) {
if (server) {
if (answerSizeRemain > 0) {
int size = std::min(answerSizeRemain, 1024);
writeBuffer.reserve(size);
for(char *c = (char*)writeBuffer.end(), *end = c + size; c != end; ++c)
*c = (int)random(currentSeed)%256 - 128;
writeBuffer.push(size);
answerSizeRemain -= size;
eventWrite.setTimeRelativeNow();
if (answerSizeRemain <= 0) {
requestSize = -1;
answerSize = -1;
}
}
} else {
int size = std::min(requestSize + 3*(int)sizeof(int), 1024);
writeBuffer.reserve(size);
if (requestsCountRemain == requestsCount) {
pushInt(requestsCount);
requestSizeRemain = requestSize;
}
if (requestSizeRemain == requestSize) {
if (requestsCountRemain <= 0 || requestSize <= 0 || answerSize <= 0)
{ formatError(); return; }
pushInt(requestSize);
pushInt(answerSize);
--requestsCountRemain;
}
if (requestSizeRemain > 0) {
size -= writeBuffer.size();
size = std::min(requestSizeRemain, size);
if (size > 0) {
for(char *c = (char*)writeBuffer.end(), *end = c + size; c != end; ++c)
*c = (int)random(currentSeed)%256 - 128;
currentCrc32 = Packet::crc32(writeBuffer.end(), size, currentCrc32);
writeBuffer.push(size);
requestSizeRemain -= size;
}
if (requestSizeRemain <= 0) {
answerSizeRemain = answerSize;
currentSeed = currentCrc32;
currentCrc32 = 0;
}
eventWrite.setTimeRelativeNow();
}
}
}
}
示例6: test3
void test3() {
printf("Test 3: Reach nested objects.\n");
VM* vm = newVM();
pushInt(vm, 1);
pushInt(vm, 2);
pushPair(vm);
pushInt(vm, 3);
pushInt(vm, 4);
pushPair(vm);
pushPair(vm);
gc(vm);
assert(vm->numObjects == 7, "Should have reached objects.");
freeVM(vm);
}
示例7: popInt
void Interpreter::divInts() {
int64_t right = popInt();
int64_t left = popInt();
//cout << "Dividing " << left << " " << right << endl;
pushInt(left / right);
}
示例8: topContext
void Interpreter::loadCtxInt() {
FunctionContext* ctx = topContext();
uint16_t ctxId = getNext2Bytes();
uint16_t id = getNext2Bytes();
pushInt(ctx->readInt(ctxId, id));
}
示例9: LANDRU_DECL_FN
LANDRU_DECL_FN(ColorVarObj, getInt)
{
ColorVarObj* o = (ColorVarObj*) p->vo.get();
p->stack->pop();
pushInt(p, (int) o->c);
}
示例10: pushInt
int CCLuaEngine::pushCCLuaValue(const CCLuaValue& value)
{
const CCLuaValueType type = value.getType();
if (type == CCLuaValueTypeInt)
{
return pushInt(value.intValue());
}
else if (type == CCLuaValueTypeFloat)
{
return pushFloat(value.floatValue());
}
else if (type == CCLuaValueTypeBoolean)
{
return pushBoolean(value.booleanValue());
}
else if (type == CCLuaValueTypeString)
{
return pushString(value.stringValue().c_str());
}
else if (type == CCLuaValueTypeDict)
{
pushCCLuaValueDict(value.dictValue());
}
else if (type == CCLuaValueTypeArray)
{
pushCCLuaValueArray(value.arrayValue());
}
else if (type == CCLuaValueTypeCCObject)
{
pushCCObject(value.ccobjectValue(), value.getCCObjectTypename().c_str());
}
return lua_gettop(m_state);
}
示例11: unregisterMovementEventHandler
void DBCCArmatureNode::registerMovementEventHandler(cocos2d::LUA_FUNCTION func)
{
unregisterMovementEventHandler();
_movementEventHandler = func;
auto dispatcher = getCCEventDispatcher();
auto f = [this](cocos2d::EventCustom *event)
{
auto eventData = (dragonBones::EventData*)(event->getUserData());
auto type = (int) eventData->getType();
auto movementId = eventData->animationState->name;
auto lastState = eventData->armature->getAnimation()->getLastAnimationState();
auto stack = cocos2d::LuaEngine::getInstance()->getLuaStack();
stack->pushObject(this, "db.DBCCArmatureNode");
stack->pushInt(type);
stack->pushString(movementId.c_str(), movementId.size());
stack->pushBoolean(lastState == eventData->animationState);
stack->executeFunctionByHandler(_movementEventHandler, 4);
};
dispatcher->addCustomEventListener(dragonBones::EventData::COMPLETE, f);
dispatcher->addCustomEventListener(dragonBones::EventData::LOOP_COMPLETE, f);
}
示例12: pushInt
void LuaStack::pushLuaValue(const LuaValue& value)
{
const LuaValueType type = value.getType();
if (type == LuaValueTypeInt)
{
return pushInt(value.intValue());
}
else if (type == LuaValueTypeFloat)
{
return pushFloat(value.floatValue());
}
else if (type == LuaValueTypeBoolean)
{
return pushBoolean(value.booleanValue());
}
else if (type == LuaValueTypeString)
{
return pushString(value.stringValue().c_str());
}
else if (type == LuaValueTypeDict)
{
pushLuaValueDict(value.dictValue());
}
else if (type == LuaValueTypeArray)
{
pushLuaValueArray(value.arrayValue());
}
else if (type == LuaValueTypeObject)
{
pushObject(value.ccobjectValue(), value.getObjectTypename().c_str());
}
}
示例13: autoMatchResponse
void autoMatchResponse(const boids::MatchResponse& response)
{
auto stack = cocos2d::LuaEngine::getInstance()->getLuaStack();
stack->pushInt(response.ret_value());
stack->pushString(response.ret_info().c_str());
if (response.ret_value() == boids::MatchResponse_Value_Success)
{
cocos2d::log("autoMatch success. ip: %s, port: %d", response.game_server_ip().c_str(), response.game_server_port());
if (NetworkAdapter::getInstance()->init(response.game_server_ip(), response.game_server_port()))
{
processGameInit(response.game_init_data(), stack);
stack->executeFunctionByHandler(autoMatchCallback, 3);
}
else
{
cocos2d::log("[ERROR] udp init failed !");
}
}
else
{
cocos2d::log("autoMatch error: %d %s", response.ret_value(), response.ret_info().c_str());
stack->executeFunctionByHandler(autoMatchCallback, 2);
}
}
示例14: op_aload_0
//--------------------------------------------------------------------------------
// aload_0
int op_aload_0( unsigned char **opCode, StackFrame *stack, SimpleConstantPool *p ) {
pushInt(stack, 0);
#if SIMPLE_JVM_DEBUG
printf("push 0 into stack\n");
#endif
*opCode = *opCode + 1;
return 0;
}
示例15: op_iconst_5
// iconst_5
int op_iconst_5( unsigned char **opCode, StackFrame *stack, SimpleConstantPool *p ) {
pushInt(stack, 5);
#if SIMPLE_JVM_DEBUG
printf("iconst_5: push 5 into stack\n");
#endif
*opCode = *opCode + 1;
return 0;
}