MCPcopy Create free account
hub / github.com/RedisGears/RedisGears / createArgs

Function createArgs

plugins/python/redisgears_python.c:3178–3209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3176}
3177
3178static RedisModuleString** createArgs(PyObject *args){
3179 // Declare and initialize variables for arguments processing.
3180 size_t argLen;
3181 const char* argumentCStr = NULL;
3182 RedisModuleString* argumentRedisStr = NULL;
3183 RedisModuleString** arguments = array_new(RedisModuleString*, 10);
3184 for(int i = 0 ; i < PyTuple_Size(args) ; ++i){
3185 PyObject* argument = PyTuple_GetItem(args, i);
3186 if(PyByteArray_Check(argument)) {
3187 // Argument is bytearray.
3188 argLen = PyByteArray_Size(argument);
3189 argumentCStr = PyByteArray_AsString(argument);
3190 argumentRedisStr = RedisModule_CreateString(NULL, argumentCStr, argLen);
3191 } else if(PyBytes_Check(argument)) {
3192 // Argument is bytes.
3193 argLen = PyBytes_Size(argument);
3194 argumentCStr = PyBytes_AsString(argument);
3195 argumentRedisStr = RedisModule_CreateString(NULL, argumentCStr, argLen);
3196 } else {
3197 // Argument is string.
3198 PyObject* argumentStr = PyObject_Str(argument);
3199 argumentCStr = PyUnicode_AsUTF8AndSize(argumentStr, &argLen);
3200 argumentRedisStr = RedisModule_CreateString(NULL, argumentCStr, argLen);
3201 // Decrease ref-count after done processing the argument.
3202 GearsPyDecRef(argumentStr);
3203 }
3204 arguments = array_append(arguments, argumentRedisStr);
3205 }
3206
3207 GearsPyDecRef(args);
3208 return arguments;
3209}
3210
3211static PyObject* createReply(RedisModuleCallReply *reply){
3212 PyObject* res = NULL;

Callers 2

executeCommandFunction · 0.85
callNextFunction · 0.85

Calls 1

GearsPyDecRefFunction · 0.85

Tested by

no test coverage detected