本文整理汇总了C++中CCLuaStack::pushNil方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLuaStack::pushNil方法的具体用法?C++ CCLuaStack::pushNil怎么用?C++ CCLuaStack::pushNil使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLuaStack
的用法示例。
在下文中一共展示了CCLuaStack::pushNil方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}