本文整理汇总了C++中PyObject_CallMethodObjArgs函数的典型用法代码示例。如果您正苦于以下问题:C++ PyObject_CallMethodObjArgs函数的具体用法?C++ PyObject_CallMethodObjArgs怎么用?C++ PyObject_CallMethodObjArgs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyObject_CallMethodObjArgs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pickle___reduce__
static PyObject *
pickle___reduce__(PyObject *self)
{
PyObject *args=NULL, *bargs=0, *state=NULL;
int l, i;
bargs = PyObject_CallMethodObjArgs(self, str__getnewargs__, NULL);
if (bargs == NULL)
return NULL;
l = PyTuple_Size(bargs);
if (l < 0)
goto end;
args = PyTuple_New(l+1);
if (args == NULL)
goto end;
Py_INCREF(self->ob_type);
PyTuple_SET_ITEM(args, 0, (PyObject*)(self->ob_type));
for (i = 0; i < l; i++)
{
Py_INCREF(PyTuple_GET_ITEM(bargs, i));
PyTuple_SET_ITEM(args, i+1, PyTuple_GET_ITEM(bargs, i));
}
state = PyObject_CallMethodObjArgs(self, str__getstate__, NULL);
if (state == NULL)
goto end;
state = Py_BuildValue("(OON)", __newobj__, args, state);
end:
Py_XDECREF(bargs);
Py_XDECREF(args);
return state;
}
示例2: rpy_MetricInfo
static void rpy_MetricInfo(int c, const pGEcontext gc,
double* ascent, double* descent, double *width,
pDevDesc dd)
{
PyObject *result;
/* Restore the Python handler */
/* FIXME */
/* PyOS_setsig(SIGINT, python_sighandler); */
PyObject *self = (PyObject *)dd->deviceSpecific;
/* FIXME optimize ? */
#ifdef RPY_DEBUG_GRDEV
printf("FIXME: MetricInfo.\n");
#endif
#if (PY_VERSION_HEX < 0x03010000)
PyObject *py_c = PyInt_FromLong((long)c);
#else
PyObject *py_c = PyLong_FromLong((long)c);
#endif
//PyObject *py_ascent = PyFloat_FromDouble(*ascent);
//PyObject *py_descent = PyFloat_FromDouble(*descent);
//PyObject *py_width = PyFloat_FromDouble(*width);
/* FIXME pass gc ? */
result = PyObject_CallMethodObjArgs(self, GrDev_metricinfo_name,
py_c,
//py_ascent, py_descent, py_width,
NULL);
rpy_printandclear_error();
if (! PyTuple_Check(result) ) {
PyErr_Format(PyExc_ValueError, "Callback 'size' should return a tuple.");
rpy_printandclear_error();
} else if (PyTuple_Size(result) != 3) {
PyErr_Format(PyExc_ValueError, "Callback 'metricinfo' should return a tuple of length 3.");
rpy_printandclear_error();
} else {
*ascent = PyFloat_AsDouble(PyTuple_GetItem(result, 0));
*descent = PyFloat_AsDouble(PyTuple_GetItem(result, 1));
*width = PyFloat_AsDouble(PyTuple_GetItem(result, 2));
}
Py_DECREF(py_c);
//Py_DECREF(py_ascent);
//Py_DECREF(py_descent);
//Py_DECREF(py_width);
Py_DECREF(result);
}
示例3: PyObject_Call
static PyObject *_prepareValue(t_set *self, PyObject *value)
{
PyObject *item = PyObject_Call(self->itemvalue.owner, Empty_TUPLE, NULL);
if (!item)
return NULL;
value = PyObject_CallMethodObjArgs((PyObject *) self, prepareValue_NAME,
item, self->itemvalue.attribute, value,
Py_False, NULL);
Py_DECREF(item);
return value;
}
示例4: GetHash
static PyObject* GetHash(PyObject* p)
{
if (hashlib)
{
Object hash(PyObject_CallMethod(hashlib, "new", "s", "sha1"));
if (!hash.IsValid())
return 0;
PyObject_CallMethodObjArgs(hash, update, p, 0);
return PyObject_CallMethod(hash, "hexdigest", 0);
}
if (sha)
{
Object hash(PyObject_CallMethod(sha, "new", 0));
if (!hash.IsValid())
return 0;
PyObject_CallMethodObjArgs(hash, update, p, 0);
return PyObject_CallMethod(hash, "hexdigest", 0);
}
return 0;
}
示例5: iobase_iternext
static PyObject *
iobase_iternext(PyObject *self)
{
PyObject *line = PyObject_CallMethodObjArgs(self, _PyIO_str_readline, NULL);
if (line == NULL)
return NULL;
if (PyObject_Size(line) == 0) {
Py_DECREF(line);
return NULL;
}
return line;
}
示例6: rpy_GrDev_CallBack
/* evaluate a call to a Python callback for the device */
static inline void rpy_GrDev_CallBack(pDevDesc dd, PyObject *name)
{
PyObject *result;
/* Restore the Python handler */
/* FIXME */
/* PyOS_setsig(SIGINT, python_sighandler); */
PyObject *self = (PyObject *)dd->deviceSpecific;
result = PyObject_CallMethodObjArgs(self, name, NULL);
rpy_printandclear_error();
Py_XDECREF(result);
}
示例7: HostRef
HostRef* PythonHostEnvironment::getCallableFrom(HostRef* ref, string& name)
{
JPCleaner cleaner;
PyObject* pname = JPyString::fromString(name.c_str());
cleaner.add(new HostRef(pname, false));
PyObject* mname = JPyString::fromString("getCallable");
cleaner.add(new HostRef(mname, false));
PyObject* call = PyObject_CallMethodObjArgs(UNWRAP(ref), mname, pname, NULL);
JPyErr::check();
return new HostRef(call, false);
}
示例8: _PyIOBase_check_writable
/* May be called with any object */
PyObject *
_PyIOBase_check_writable(PyObject *self, PyObject *args)
{
PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_writable, NULL);
if (res == NULL)
return NULL;
if (res != Py_True) {
Py_CLEAR(res);
iobase_unsupported("File or stream is not writable.");
return NULL;
}
if (args == Py_True) {
Py_DECREF(res);
}
return res;
}
示例9: iobase_close
static PyObject *
iobase_close(PyObject *self, PyObject *args)
{
PyObject *res;
if (IS_CLOSED(self))
Py_RETURN_NONE;
res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
PyObject_SetAttrString(self, "__IOBase_closed", Py_True);
if (res == NULL) {
return NULL;
}
Py_XDECREF(res);
Py_RETURN_NONE;
}
示例10: getGlyphAdvance
virtual void getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) const
{
PyObject *name = PyString_FromString("getGlyphAdvance");
PyObject *g = PyInt_FromLong(LE_GET_GLYPH(glyph));
PyObject *result =
PyObject_CallMethodObjArgs((PyObject *) self, name, g, NULL);
Py_DECREF(g);
Py_DECREF(name);
if (result != NULL)
{
PyArg_ParseTuple(result, "ff", &advance.fX, &advance.fY);
Py_DECREF(result);
}
}
示例11: rpy_NewPage
static void rpy_NewPage(const pGEcontext gc, pDevDesc dd)
{
PyObject *result;
/* Restore the Python handler */
/* FIXME */
/* PyOS_setsig(SIGINT, python_sighandler); */
/* FIXME give the callback access to gc */
PyObject *self = (PyObject *)dd->deviceSpecific;
result = PyObject_CallMethodObjArgs(self, GrDev_newpage_name, NULL);
rpy_printandclear_error();
Py_XDECREF(result);
}
示例12: _PyIOBase_check_writable
/* May be called with any object */
PyObject *
_PyIOBase_check_writable(PyObject *self, PyObject *args)
{
PyObject *res = PyObject_CallMethodObjArgs(self, _PyIO_str_writable, NULL);
if (res == NULL)
return NULL;
if (res != Py_True) {
Py_CLEAR(res);
PyErr_SetString(PyExc_IOError, "File or stream is not writable.");
return NULL;
}
if (args == Py_True) {
Py_DECREF(res);
}
return res;
}
示例13: rpy_Locator
static Rboolean rpy_Locator(double *x, double *y, pDevDesc dd)
{
PyObject *result;
/* Restore the Python handler */
/* FIXME */
/* PyOS_setsig(SIGINT, python_sighandler); */
PyObject *self = (PyObject *)dd->deviceSpecific;
/* FIXME optimize ? */
#ifdef RPY_DEBUG_GRDEV
printf("FIXME: Locator.\n");
#endif
//PyObject *py_x = PyList_New(0);
//PyObject *py_y = PyList_New(0);
/* FIXME: pass gc ? */
/* FIXME: test !dd->dev->locator before proceed ? */
result = PyObject_CallMethodObjArgs(self, GrDev_locator_name,
//py_x, py_y,
NULL);
rpy_printandclear_error();
if (! PyTuple_Check(result) ) {
PyErr_Format(PyExc_ValueError, "Callback 'size' should return a tuple.");
rpy_printandclear_error();
} else if (PyTuple_Size(result) != 2) {
PyErr_Format(PyExc_ValueError, "Callback 'size' should return a tuple of length 2.");
rpy_printandclear_error();
} else {
x[0] = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 0));
y[0] = PyFloat_AsDouble(PyTuple_GET_ITEM(result, 1));
//int i;
//for (i = 0; i < n; i++) {
//x[i] = PyFloat_AsDouble(PyList_GET_ITEM(py_x, (Py_ssize_t)i));
//y[i] = PyFloat_AsDouble(PyList_GET_ITEM(py_y, (Py_ssize_t)i));
//}
}
Rboolean res_r = TRUE;
printf("FIXME: return TRUE or FALSE");
//Py_DECREF(py_x);
//Py_DECREF(py_y);
Py_DECREF(result);
return res_r;
}
示例14: pickle___reduce__
static PyObject *
pickle___reduce__(PyObject *self)
{
PyObject *args=NULL, *bargs=NULL, *state=NULL, *getnewargs=NULL;
int l, i;
getnewargs = PyObject_GetAttr(self, py___getnewargs__);
if (getnewargs)
{
bargs = PyObject_CallFunctionObjArgs(getnewargs, NULL);
Py_DECREF(getnewargs);
if (!bargs)
return NULL;
l = PyTuple_Size(bargs);
if (l < 0)
goto end;
}
else
{
PyErr_Clear();
l = 0;
}
args = PyTuple_New(l+1);
if (args == NULL)
goto end;
Py_INCREF(Py_TYPE(self));
PyTuple_SET_ITEM(args, 0, (PyObject*)(Py_TYPE(self)));
for (i = 0; i < l; i++)
{
Py_INCREF(PyTuple_GET_ITEM(bargs, i));
PyTuple_SET_ITEM(args, i+1, PyTuple_GET_ITEM(bargs, i));
}
state = PyObject_CallMethodObjArgs(self, py___getstate__, NULL);
if (!state)
goto end;
state = Py_BuildValue("(OON)", __newobj__, args, state);
end:
Py_XDECREF(bargs);
Py_XDECREF(args);
return state;
}
示例15: pickle___reduce__
static PyObject *
pickle___reduce__(PyObject *self)
{
PyObject *args=NULL, *bargs=0, *state=NULL;
int l, i;
/* we no longer require '__getnewargs__' to be defined but use it if it is */
PyObject *getnewargs=NULL;
getnewargs = PyObject_GetAttr(self, str__getnewargs__);
if (getnewargs)
bargs = PyEval_CallObject(getnewargs, (PyObject *)NULL);
else {
PyErr_Clear();
bargs = PyTuple_New(0);
}
l = PyTuple_Size(bargs);
if (l < 0)
goto end;
args = PyTuple_New(l+1);
if (args == NULL)
goto end;
Py_INCREF(self->ob_type);
PyTuple_SET_ITEM(args, 0, (PyObject*)(self->ob_type));
for (i = 0; i < l; i++)
{
Py_INCREF(PyTuple_GET_ITEM(bargs, i));
PyTuple_SET_ITEM(args, i+1, PyTuple_GET_ITEM(bargs, i));
}
state = PyObject_CallMethodObjArgs(self, str__getstate__, NULL);
if (state == NULL)
goto end;
state = Py_BuildValue("(OON)", __newobj__, args, state);
end:
Py_XDECREF(bargs);
Py_XDECREF(args);
Py_XDECREF(getnewargs);
return state;
}