本文整理汇总了C++中PRINTMARK函数的典型用法代码示例。如果您正苦于以下问题:C++ PRINTMARK函数的具体用法?C++ PRINTMARK怎么用?C++ PRINTMARK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PRINTMARK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PyErr_Format
PyObject *Client_connect(PyClient *self, PyObject *args)
{
if (self->desc.prv == NULL)
{
return PyErr_Format(PyExc_RuntimeError, "Client can not be reconnected");
}
if (!self->client->connect (PyString_AS_STRING(self->host), self->port))
{
PRINTMARK();
return NULL;
}
Py_RETURN_NONE;
}
示例2: Client_init
int Client_init(PyClient *self, PyObject *args)
{
/* Args:
def __init__(self, address, protocol = "text", codec = "default"):
*/
self->client = NULL;
self->host = NULL;
char *address;
PRINTMARK();
if (!PyArg_ParseTuple (args, "s", &address))
{
PRINTMARK();
return -1;
}
PRINTMARK();
char *offset = strchr (address, ':');
if (offset == NULL)
{
PyErr_Format(PyExc_RuntimeError, "Invalid argument for address");
return -1;
}
char *port = address + (offset - address) + 1;
self->host = PyString_FromStringAndSize(address, (offset - address));
self->port = atoi(port);
Py_INCREF(self->host);
PRINTMARK();
self->sock = (PyObject *) API_createSocket(AF_INET, SOCK_STREAM, 0);
PRINTMARK();
self->sockfd = API_getSocketFD(self->sock);
self->desc.prv = self;
self->desc.connect = API_connect;
self->desc.destroy = API_destroy;
self->desc.recv = API_recv;
self->desc.send = API_send;
PRINTMARK();
self->client = new Client(&self->desc);
PRINTMARK();
return 0;
}
示例3: API_recv
int API_recv(SOCKETDESC *desc, void *data, size_t cbMaxData)
{
PyClient *client = (PyClient *) desc->prv;
if (client == NULL)
{
PyErr_Format(PyExc_IOError, "No client object");
PRINTMARK();
return -1;
}
int result;
while (true)
{
result = recv ( client->sockfd, (char *) data, cbMaxData, MSG_NOSIGNAL);
if (result == 0)
{
PRINTMARK();
PyErr_Format(PyExc_IOError, "Connection reset by peer while reading on socket");
return -1;
}
if (result > 0)
{
PRINTMARK();
break;
}
PRINTMARK();
if (!SocketWouldBlock(client->sockfd))
{
PyErr_Format(PyExc_IOError, "Socket error %d when reading", SocketGetLastError());
return -1;
}
PRINTMARK();
if (API_wouldBlock_gevent(client->sock, client->sockfd, 1, 10) == 0)
{
PRINTMARK();
return -1;
}
PRINTMARK();
}
return result;
}
示例4: Dir_iterEnd
void Dir_iterEnd(JSOBJ obj, JSONTypeContext *tc)
{
if (GET_TC(tc)->itemValue)
{
Py_DECREF(GET_TC(tc)->itemValue);
GET_TC(tc)->itemValue = NULL;
}
if (GET_TC(tc)->itemName)
{
Py_DECREF(GET_TC(tc)->itemName);
GET_TC(tc)->itemName = NULL;
}
Py_DECREF( (PyObject *) GET_TC(tc)->attrList);
PRINTMARK();
}
示例5: PyString_FromString
PyObject *Client_set_timeout(PyClient *self, PyObject *args)
{
PyObject *timeout;
if (!PyArg_ParseTuple (args, "O", &timeout))
{
return NULL;
}
PyObject *method = PyString_FromString("settimeout");
PyObject *res = PyObject_CallMethodObjArgs(self->sock, method, timeout, NULL);
PRINTMARK();
Py_DECREF(method);
return res;
}
示例6: Object_npyNewArray
JSOBJ Object_npyNewArray(void *prv, void* _decoder)
{
NpyArrContext* npyarr;
PyObjectDecoder* decoder = (PyObjectDecoder*) _decoder;
PRINTMARK();
if (decoder->curdim <= 0)
{
// start of array - initialise the context buffer
npyarr = decoder->npyarr = PyObject_Malloc(sizeof(NpyArrContext));
decoder->npyarr_addr = npyarr;
if (!npyarr)
{
PyErr_NoMemory();
return NULL;
}
npyarr->dec = decoder;
npyarr->labels[0] = npyarr->labels[1] = NULL;
npyarr->shape.ptr = PyObject_Malloc(sizeof(npy_intp)*NPY_MAXDIMS);
npyarr->shape.len = 1;
npyarr->ret = NULL;
npyarr->elsize = 0;
npyarr->elcount = 4;
npyarr->i = 0;
}
else
{
// starting a new dimension continue the current array (and reshape after)
npyarr = (NpyArrContext*) decoder->npyarr;
if (decoder->curdim >= npyarr->shape.len)
{
npyarr->shape.len++;
}
}
npyarr->shape.ptr[decoder->curdim] = 0;
decoder->curdim++;
return npyarr;
}
示例7: Npy_releaseContext
// free the numpy context buffer
void Npy_releaseContext(NpyArrContext* npyarr)
{
PRINTMARK();
if (npyarr)
{
if (npyarr->shape.ptr)
{
PyObject_Free(npyarr->shape.ptr);
}
if (npyarr->dec)
{
npyarr->dec->npyarr = NULL;
npyarr->dec->curdim = 0;
}
Py_XDECREF(npyarr->labels[0]);
Py_XDECREF(npyarr->labels[1]);
Py_XDECREF(npyarr->ret);
PyObject_Free(npyarr);
}
}
示例8: Object_npyEndObject
JSOBJ Object_npyEndObject(void *prv, JSOBJ obj)
{
PyObject *list;
npy_intp labelidx;
NpyArrContext* npyarr = (NpyArrContext*) obj;
PRINTMARK();
if (!npyarr)
{
return NULL;
}
labelidx = npyarr->dec->curdim-1;
list = npyarr->labels[labelidx];
if (list)
{
npyarr->labels[labelidx] = PyArray_FROM_O(list);
Py_DECREF(list);
}
return (PyObject*) ((JSONObjectDecoder*)npyarr->dec)->endArray(prv, obj);
}
示例9: Object_npyEndArrayList
JSOBJ Object_npyEndArrayList(void *prv, JSOBJ obj)
{
PyObject *list, *ret;
NpyArrContext* npyarr = (NpyArrContext*) obj;
PRINTMARK();
if (!npyarr)
{
return NULL;
}
// convert decoded list to numpy array
list = (PyObject *) npyarr->ret;
npyarr->ret = PyArray_FROM_O(list);
ret = Npy_returnLabelled(npyarr);
npyarr->ret = list;
((JSONObjectDecoder*)npyarr->dec)->newArray = Object_npyNewArray;
((JSONObjectDecoder*)npyarr->dec)->arrayAddItem = Object_npyArrayAddItem;
((JSONObjectDecoder*)npyarr->dec)->endArray = Object_npyEndArray;
Npy_releaseContext(npyarr);
return ret;
}
示例10: API_connect
int API_connect(SOCKETDESC *desc, const char *address, int port)
{
PyClient *client = (PyClient *) desc->prv;
char strTemp[256 + 1];
PRINTMARK();
snprintf (strTemp, 256, "%s:%d", address, port);
PRINTMARK();
PRINTMARK();
PyObject *args = PyTuple_New(2);
//Increment client->host before dropping into tuple
Py_INCREF(client->host);
PyTuple_SET_ITEM(args, 0, client->host);
PyTuple_SET_ITEM(args, 1, PyInt_FromLong(client->port));
PyObject *method = PyString_FromString("connect");
PyObject *res = PyObject_CallMethodObjArgs(client->sock, method, args, NULL);
PRINTMARK();
//PyTuple_SET_ITEM doesn't increment ref counter
//Py_DECREF(PyTuple_GET_ITEM(args, 1));
Py_DECREF(args);
Py_DECREF(method);
if (res == NULL)
{
PRINTMARK();
return 0;
}
Py_DECREF(res);
PRINTMARK();
return 1;
}
示例11: objToJSON
PyObject* objToJSON(PyObject* self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "obj", "ensure_ascii", NULL};
char buffer[65536];
char *ret;
PyObject *newobj;
PyObject *oinput = NULL;
PyObject *oensureAscii = NULL;
JSONObjectEncoder encoder =
{
Object_beginTypeContext, //void (*beginTypeContext)(JSOBJ obj, JSONTypeContext *tc);
Object_endTypeContext, //void (*endTypeContext)(JSOBJ obj, JSONTypeContext *tc);
Object_getStringValue, //const char *(*getStringValue)(JSOBJ obj, JSONTypeContext *tc, size_t *_outLen);
Object_getLongValue, //JSLONG (*getLongValue)(JSOBJ obj, JSONTypeContext *tc);
Object_getIntValue, //JSLONG (*getLongValue)(JSOBJ obj, JSONTypeContext *tc);
Object_getDoubleValue, //double (*getDoubleValue)(JSOBJ obj, JSONTypeContext *tc);
Object_iterBegin, //JSPFN_ITERBEGIN iterBegin;
Object_iterNext, //JSPFN_ITERNEXT iterNext;
Object_iterEnd, //JSPFN_ITEREND iterEnd;
Object_iterGetValue, //JSPFN_ITERGETVALUE iterGetValue;
Object_iterGetName, //JSPFN_ITERGETNAME iterGetName;
Object_releaseObject, //void (*releaseValue)(JSONTypeContext *ti);
PyObject_Malloc, //JSPFN_MALLOC malloc;
PyObject_Realloc, //JSPFN_REALLOC realloc;
PyObject_Free, //JSPFN_FREE free;
-1, //recursionMax
5, //default decimal precision
1, //forceAscii
};
PRINTMARK();
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", kwlist, &oinput, &oensureAscii))
{
return NULL;
}
if (oensureAscii != NULL && !PyObject_IsTrue(oensureAscii))
{
encoder.forceASCII = 0;
}
PRINTMARK();
ret = JSON_EncodeObject (oinput, &encoder, buffer, sizeof (buffer));
PRINTMARK();
if (PyErr_Occurred())
{
return NULL;
}
if (encoder.errorMsg)
{
if (ret != buffer)
{
encoder.free (ret);
}
PyErr_Format (PyExc_OverflowError, "%s", encoder.errorMsg);
return NULL;
}
newobj = PyString_FromString (ret);
if (ret != buffer)
{
encoder.free (ret);
}
PRINTMARK();
return newobj;
}
示例12: Object_beginTypeContext
void Object_beginTypeContext (PyObject *obj, JSONTypeContext *tc)
{
TypeContext *pc = (TypeContext *) tc->prv;
PyObject *toDictFunc;
tc->prv[0] = 0;
tc->prv[1] = 0;
tc->prv[2] = 0;
tc->prv[3] = 0;
tc->prv[4] = 0;
tc->prv[5] = 0;
tc->prv[6] = 0;
tc->prv[7] = 0;
tc->prv[8] = 0;
tc->prv[9] = 0;
tc->prv[10] = 0;
tc->prv[11] = 0;
tc->prv[12] = 0;
tc->prv[13] = 0;
tc->prv[14] = 0;
if (PyIter_Check(obj))
{
goto ISITERABLE;
}
if (PyBool_Check(obj))
{
PRINTMARK();
tc->type = (obj == Py_True) ? JT_TRUE : JT_FALSE;
return;
}
else
if (PyInt_Check(obj))
{
PRINTMARK();
#ifdef _LP64
pc->PyTypeToJSON = PyIntToINT64; tc->type = JT_LONG;
#else
pc->PyTypeToJSON = PyIntToINT32; tc->type = JT_INT;
#endif
return;
}
else
if (PyLong_Check(obj))
{
PyObject *exc;
PRINTMARK();
pc->PyTypeToJSON = PyLongToINT64;
tc->type = JT_LONG;
GET_TC(tc)->longValue = PyLong_AsLongLong(obj);
exc = PyErr_Occurred();
if (exc && PyErr_ExceptionMatches(PyExc_OverflowError))
{
PRINTMARK();
tc->type = JT_INVALID;
return;
}
return;
}
else
if (PyString_Check(obj))
{
PRINTMARK();
pc->PyTypeToJSON = PyStringToUTF8; tc->type = JT_UTF8;
return;
}
else
if (PyUnicode_Check(obj))
{
PRINTMARK();
pc->PyTypeToJSON = PyUnicodeToUTF8; tc->type = JT_UTF8;
return;
}
else
if (PyFloat_Check(obj))
{
PRINTMARK();
pc->PyTypeToJSON = PyFloatToDOUBLE; tc->type = JT_DOUBLE;
return;
}
else
if (PyDateTime_Check(obj))
{
PRINTMARK();
pc->PyTypeToJSON = PyDateTimeToINT64; tc->type = JT_LONG;
return;
}
else
if (PyDate_Check(obj))
{
PRINTMARK();
pc->PyTypeToJSON = PyDateToINT64; tc->type = JT_LONG;
return;
}
else
//.........这里部分代码省略.........
示例13: Object_beginTypeContext
void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc)
{
PyObject *obj, *exc, *toDictFunc, *iter;
TypeContext *pc;
PRINTMARK();
if (!_obj) {
tc->type = JT_INVALID;
return;
}
obj = (PyObject*) _obj;
pc = (TypeContext *) tc->prv;
if (!pc)
{
tc->type = JT_INVALID;
PyErr_NoMemory();
return;
}
pc->newObj = NULL;
pc->dictObj = NULL;
pc->itemValue = NULL;
pc->itemName = NULL;
pc->iterator = NULL;
pc->attrList = NULL;
pc->index = 0;
pc->size = 0;
pc->longValue = 0;
if (PyIter_Check(obj))
{
PRINTMARK();
goto ISITERABLE;
}
if (PyBool_Check(obj))
{
PRINTMARK();
tc->type = (obj == Py_True) ? JT_TRUE : JT_FALSE;
return;
}
else
if (PyLong_Check(obj))
{
PRINTMARK();
pc->PyTypeToJSON = PyLongToINT64;
tc->type = JT_LONG;
GET_TC(tc)->longValue = PyLong_AsLongLong(obj);
exc = PyErr_Occurred();
if (exc && PyErr_ExceptionMatches(PyExc_OverflowError))
{
PRINTMARK();
goto INVALID;
}
return;
}
else
if (PyInt_Check(obj))
{
PRINTMARK();
#ifdef _LP64
pc->PyTypeToJSON = PyIntToINT64; tc->type = JT_LONG;
#else
pc->PyTypeToJSON = PyIntToINT32; tc->type = JT_INT;
#endif
return;
}
else
if (PyString_Check(obj))
{
PRINTMARK();
pc->PyTypeToJSON = PyStringToUTF8; tc->type = JT_UTF8;
return;
}
else
if (PyUnicode_Check(obj))
{
PRINTMARK();
pc->PyTypeToJSON = PyUnicodeToUTF8; tc->type = JT_UTF8;
return;
}
else
if (PyFloat_Check(obj) || (type_decimal && PyObject_IsInstance(obj, type_decimal)))
{
PRINTMARK();
pc->PyTypeToJSON = PyFloatToDOUBLE; tc->type = JT_DOUBLE;
return;
}
else
if (PyDateTime_Check(obj))
{
PRINTMARK();
pc->PyTypeToJSON = PyDateTimeToINT64; tc->type = JT_LONG;
return;
}
else
if (PyDate_Check(obj))
//.........这里部分代码省略.........
示例14: AppendEscapedArg
int AppendEscapedArg (Connection *self, char *start, char *end, PyObject *obj)
{
int ret;
PyObject *strobj;
/*
FIXME: Surround strings with '' could be performed in this function to avoid extra logic in AppendAndEscapeString */
PRINTMARK();
if (PyString_Check(obj))
{
PRINTMARK();
return AppendAndEscapeString(start, end, PyString_AS_STRING(obj), PyString_AS_STRING(obj) + PyString_GET_SIZE(obj), TRUE);
}
else
if (PyUnicode_Check(obj))
{
PRINTMARK();
strobj = self->PFN_PyUnicode_Encode(PyUnicode_AS_UNICODE(obj), PyUnicode_GET_SIZE(obj), NULL);
if (strobj == NULL)
{
if (PyErr_Occurred())
{
return -1;
}
PyErr_SetObject (PyExc_ValueError, obj);
return -1;
}
ret = AppendAndEscapeString(start, end, PyString_AS_STRING(strobj), PyString_AS_STRING(strobj) + PyString_GET_SIZE(strobj), TRUE);
Py_DECREF(strobj);
return ret;
}
else
if (obj == Py_None)
{
(*start++) = 'n';
(*start++) = 'u';
(*start++) = 'l';
(*start++) = 'l';
return 4;
}
else
if (PyDateTime_Check(obj))
{
int len = sprintf (start, "'%04d-%02d-%02d %02d:%02d:%02d'",
PyDateTime_GET_YEAR(obj),
PyDateTime_GET_MONTH(obj),
PyDateTime_GET_DAY(obj),
PyDateTime_DATE_GET_HOUR(obj),
PyDateTime_DATE_GET_MINUTE(obj),
PyDateTime_DATE_GET_SECOND(obj));
return len;
}
else
if (PyDate_Check(obj))
{
int len = sprintf (start, "'%04d:%02d:%02d'",
PyDateTime_GET_YEAR(obj),
PyDateTime_GET_MONTH(obj),
PyDateTime_GET_DAY(obj));
return len;
}
//FIXME: Might possible to avoid this?
PRINTMARK();
strobj = PyObject_Str(obj);
ret = AppendAndEscapeString(start, end, PyString_AS_STRING(strobj), PyString_AS_STRING(strobj) + PyString_GET_SIZE(strobj), FALSE);
Py_DECREF(strobj);
return ret;
}
示例15: AppendAndEscapeString
int AppendAndEscapeString(char *buffStart, char *buffEnd, const char *strStart, const char *strEnd, int quote)
{
//{'\0': '\\0', '\n': '\\n', '\r': '\\r', '\\': '\\\\', "'": "\\'", '"': '\\"', '\x1a': '\\Z'}):
char *buffOffset = buffStart;
if (quote)
{
(*buffOffset++) = '\'';
}
while (strStart < strEnd)
{
switch (*strStart)
{
case '\0': // NULL
PRINTMARK();
(*buffOffset++) = '\\';
(*buffOffset++) = '0';
break;
case '\n': // LF
PRINTMARK();
(*buffOffset++) = '\\';
(*buffOffset++) = 'n';
break;
case '\r': // CR
PRINTMARK();
(*buffOffset++) = '\\';
(*buffOffset++) = 'r';
break;
case '\\': // BACKSLASH
PRINTMARK();
(*buffOffset++) = '\\';
(*buffOffset++) = '\\';
break;
case '\'': // SINGLE QUOTE
PRINTMARK();
(*buffOffset++) = '\\';
(*buffOffset++) = '\'';
break;
case '\"': // DOUBLE QUOTE
PRINTMARK();
(*buffOffset++) = '\\';
(*buffOffset++) = '\"';
break;
case '\x1a': // SUBSTITUTE CONTROL CHARACTER
PRINTMARK();
(*buffOffset++) = '\\';
(*buffOffset++) = 'Z';
break;
default:
(*buffOffset++) = (*strStart);
break;
}
strStart ++;
}
if (quote)
{
(*buffOffset++) = '\'';
}
return (int) (buffOffset - buffStart);
}