本文整理汇总了C++中CCLuaStack::pushString方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLuaStack::pushString方法的具体用法?C++ CCLuaStack::pushString怎么用?C++ CCLuaStack::pushString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLuaStack
的用法示例。
在下文中一共展示了CCLuaStack::pushString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: malloc
cocos2d::LUA_STRING CCCrypto::cryptAES256Lua(bool isDecrypt,
const char* input,
int inputLength,
const char* key,
int keyLength)
{
CCLuaStack* stack = CCLuaEngine::defaultEngine()->getLuaStack();
stack->clean();
if (getAES256KeyLength() == 0)
{
stack->pushNil();
return 1;
}
int bufferSize = inputLength + getAES256KeyLength();
void* buffer = malloc(bufferSize);
int dataUsed = cryptAES256(isDecrypt, (unsigned char*)input, inputLength, (unsigned char*)buffer, bufferSize, (unsigned char*)key, keyLength);
if (dataUsed > 0)
{
stack->pushString(static_cast<const char*>(buffer), dataUsed);
}
else
{
stack->pushNil();
}
free(buffer);
return 1;
}
示例2: free
LUA_STRING CCCrypto::encodingBase64Lua(bool isDecoding,
const char* input,
int inputLength)
{
CCLuaStack* stack = CCLuaEngine::defaultEngine()->getLuaStack();
stack->clean();
int outputLength = inputLength * 2;
char* output = static_cast<char*>(malloc(outputLength));
int dataUsed = -1;
if (isDecoding)
{
dataUsed = decodeBase64(input, output, outputLength);
}
else
{
dataUsed = encodeBase64((unsigned char*)input, inputLength, output, outputLength);
}
if (dataUsed > 0 && dataUsed < outputLength)
{
stack->pushString(output, dataUsed);
}
else
{
stack->pushNil();
}
free(output);
return 1;
}
示例3: free
LUA_STRING CCCrypto::encodingBase64Lua(bool isDecoding,
const char* input,
int inputLength)
{
CCLuaStack* stack = CCLuaEngine::defaultEngine()->getLuaStack();
stack->clean();
int bufferSize = isDecoding ? Base64decode_len(input) : Base64encode_len(inputLength);
char *buffer = bufferSize ? (char*)malloc(bufferSize) : NULL;
int size = 0;
if (buffer)
{
size = isDecoding ? Base64decode(buffer, input) : (Base64encode(buffer, input, inputLength) - 1);
}
if (size)
{
stack->pushString(buffer, size);
}
else
{
stack->pushNil();
}
if (buffer)
{
free(buffer);
}
return 1;
}
示例4: getResponseDataLua
LUA_STRING CCHTTPRequest::getResponseDataLua(void)
{
CCAssert(m_state == kCCHTTPRequestStateCompleted, "CCHTTPRequest::getResponseDataLua() - request not completed");
CCLuaStack *stack = CCLuaEngine::defaultEngine()->getLuaStack();
stack->clean();
stack->pushString(static_cast<char*>(m_responseBuffer), (int)m_responseDataLength);
return 1;
}
示例5: strlen
LUA_STRING CCCrypto::sha1Lua(char* input, char* key, bool isRawOutput)
{
unsigned char buffer[SHA1_BUFFER_LENGTH];
MD5(static_cast<void*>(input), strlen(input), buffer);
CCLuaStack* stack = CCLuaEngine::defaultEngine()->getLuaStack();
stack->clean();
if (isRawOutput)
{
stack->pushString((char*)buffer, SHA1_BUFFER_LENGTH);
}
else
{
char* hex = bin2hex(buffer, SHA1_BUFFER_LENGTH);
stack->pushString(hex);
delete[] hex;
}
return 1;
}
示例6: getFileData
int CZHelperFunc::getFileData(const char *pPathFile)
{
unsigned long size;
unsigned char* buf = CZHelperFunc::getFileData(pPathFile, "rb", &size);
if (NULL==buf) return 0;
CCLuaStack* stack = CCLuaEngine::defaultEngine()->getLuaStack();
stack->clean();
stack->pushString((const char*)(buf), size);
delete buf;
return 1;
}
示例7: movementEventCallback
void LuaArmatureWrapper::movementEventCallback(CCArmature* armature, MovementEventType type,const char* movementID)
{
if (0 != m_lHandler)
{
CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
CCLuaStack* pStack = pEngine->getLuaStack();
pStack->pushCCObject(armature, "CCArmature");
pStack->pushInt(type);
pStack->pushString(movementID);
pStack->executeFunctionByHandler(m_lHandler, 3);
pStack->clean();
}
}
示例8:
LUA_STRING CCCrypto::MD5FileLua(const char* path)
{
unsigned char buffer[MD5_BUFFER_LENGTH];
MD5File(path, buffer);
CCLuaStack* stack = CCLuaEngine::defaultEngine()->getLuaStack();
stack->clean();
char* hex = bin2hex(buffer, MD5_BUFFER_LENGTH);
stack->pushString(hex);
delete[] hex;
return 1;
}
示例9: frameEventCallback
void LuaArmatureWrapper::frameEventCallback(CCBone* bone, const char* frameEventName, int orginFrameIndex, int currentFrameIndex)
{
if (0 != m_lHandler)
{
CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
CCLuaStack* pStack = pEngine->getLuaStack();
pStack->pushCCObject(bone, "CCBone");
pStack->pushString(frameEventName);
pStack->pushInt(orginFrameIndex);
pStack->pushInt(currentFrameIndex);
pStack->executeFunctionByHandler(m_lHandler, 4);
pStack->clean();
}
}
示例10: getFileDataOrder
void CCZipFile::getFileDataOrder(const char *filename)
{
unsigned long size;
unsigned char* buf = getFileData(filename, &size);
CCLuaStack* stack = CCLuaEngine::defaultEngine()->getLuaStack();
stack->clean();
if (NULL==buf)
{
stack->pushNil();
return;
}
stack->pushString((const char*)buf, size);
delete []buf;
return;
}
示例11: onMessage
virtual void onMessage(WebSocket* ws, const WebSocket::Data& data)
{
LuaWebSocket* luaWs = dynamic_cast<LuaWebSocket*>(ws);
if (NULL != luaWs) {
if (data.isBinary) {
int nHandler = luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerMessage);
if (-1 != nHandler) {
CCLuaStack *pStack = CCLuaEngine::defaultEngine()->getLuaStack();
pStack->pushFunctionByHandler(nHandler);
pStack->pushString(data.bytes, (int)data.len);
pStack->pushInt((int)data.len);
pStack->executeFunction(2);
}
}
else{
int nHandler = luaWs->getScriptHandler(LuaWebSocket::kWebSocketScriptHandlerMessage);
if (-1 != nHandler) {
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeEvent(nHandler,data.bytes);
}
}
}
}