本文整理汇总了C++中PyObject_CallMethodObjArgs函数的典型用法代码示例。如果您正苦于以下问题:C++ PyObject_CallMethodObjArgs函数的具体用法?C++ PyObject_CallMethodObjArgs怎么用?C++ PyObject_CallMethodObjArgs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyObject_CallMethodObjArgs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:newhollandpress,项目名称:phpzope,代码行数:38,代码来源:pickle.c
示例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);
}
开发者ID:ktargows,项目名称:rpy2,代码行数:50,代码来源:_rpy_device.c
示例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;
}
开发者ID:HackLinux,项目名称:chandler,代码行数:14,代码来源:set.c
示例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;
}
开发者ID:JordanReiter,项目名称:pyodbc,代码行数:24,代码来源:cnxninfo.cpp
示例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;
}
开发者ID:GINK03,项目名称:StaticPython,代码行数:15,代码来源:iobase.c
示例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);
}
开发者ID:ktargows,项目名称:rpy2,代码行数:16,代码来源:_rpy_device.c
示例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);
}
开发者ID:baztian,项目名称:jpype,代码行数:15,代码来源:py_hostenv.cpp
示例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;
}
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:17,代码来源:iobase.c
示例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;
}
开发者ID:GINK03,项目名称:StaticPython,代码行数:16,代码来源:iobase.c
示例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);
}
}
开发者ID:moyogo,项目名称:pyicu,代码行数:16,代码来源:layoutengine.cpp
示例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);
}
开发者ID:ktargows,项目名称:rpy2,代码行数:16,代码来源:_rpy_device.c
示例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;
}
开发者ID:GINK03,项目名称:StaticPython,代码行数:17,代码来源:iobase.c
示例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;
}
开发者ID:ktargows,项目名称:rpy2,代码行数:47,代码来源:_rpy_device.c
示例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;
}
开发者ID:zopefoundation,项目名称:persistent,代码行数:47,代码来源:cPersistence.c
示例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;
}
开发者ID:goschtl,项目名称:zope,代码行数:46,代码来源:pickle.c
示例16: iobase_close
static PyObject *
iobase_close(PyObject *self, PyObject *args)
{
PyObject *res;
_Py_IDENTIFIER(__IOBase_closed);
if (IS_CLOSED(self))
Py_RETURN_NONE;
res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
_PyObject_SetAttrId(self, &PyId___IOBase_closed, Py_True);
if (res == NULL) {
return NULL;
}
Py_XDECREF(res);
Py_RETURN_NONE;
}
开发者ID:524777134,项目名称:cpython,代码行数:17,代码来源:iobase.c
示例17: __call__
/*
def __call__(self, obj, alternate=_marker):
conform = getattr(obj, '__conform__', None)
if conform is not None:
adapter = self._call_conform(conform)
if adapter is not None:
return adapter
adapter = self.__adapt__(obj)
if adapter is not None:
return adapter
elif alternate is not _marker:
return alternate
else:
raise TypeError("Could not adapt", obj, self)
*/
static PyObject *
ib_call(PyObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *conform, *obj, *alternate=NULL, *adapter;
static char *kwlist[] = {"obj", "alternate", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O", kwlist,
&obj, &alternate))
return NULL;
conform = PyObject_GetAttr(obj, str__conform__);
if (conform != NULL)
{
adapter = PyObject_CallMethodObjArgs(self, str_call_conform,
conform, NULL);
Py_DECREF(conform);
if (adapter == NULL || adapter != Py_None)
return adapter;
Py_DECREF(adapter);
}
else
PyErr_Clear();
adapter = __adapt__(self, obj);
if (adapter == NULL || adapter != Py_None)
return adapter;
Py_DECREF(adapter);
if (alternate != NULL)
{
Py_INCREF(alternate);
return alternate;
}
adapter = Py_BuildValue("sOO", "Could not adapt", obj, self);
if (adapter != NULL)
{
PyErr_SetObject(PyExc_TypeError, adapter);
Py_DECREF(adapter);
}
return NULL;
}
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:60,代码来源:_zope_interface_coptimizations.c
示例18: iobase_finalize
static void
iobase_finalize(PyObject *self)
{
PyObject *res;
PyObject *error_type, *error_value, *error_traceback;
int closed;
_Py_IDENTIFIER(_finalizing);
/* Save the current exception, if any. */
PyErr_Fetch(&error_type, &error_value, &error_traceback);
/* If `closed` doesn't exist or can't be evaluated as bool, then the
object is probably in an unusable state, so ignore. */
res = PyObject_GetAttr(self, _PyIO_str_closed);
if (res == NULL) {
PyErr_Clear();
closed = -1;
}
else {
closed = PyObject_IsTrue(res);
Py_DECREF(res);
if (closed == -1)
PyErr_Clear();
}
if (closed == 0) {
/* Signal close() that it was called as part of the object
finalization process. */
if (_PyObject_SetAttrId(self, &PyId__finalizing, Py_True))
PyErr_Clear();
res = PyObject_CallMethodObjArgs((PyObject *) self, _PyIO_str_close,
NULL);
/* Silencing I/O errors is bad, but printing spurious tracebacks is
equally as bad, and potentially more frequent (because of
shutdown issues). */
if (res == NULL)
PyErr_Clear();
else
Py_DECREF(res);
}
/* Restore the saved exception. */
PyErr_Restore(error_type, error_value, error_traceback);
}
开发者ID:Alkalit,项目名称:cpython,代码行数:43,代码来源:iobase.c
示例19: t_descriptor___delete__
static int t_descriptor___delete__(t_descriptor *self, t_item *item)
{
t_attribute *attr = self->attr;
if (attr)
{
t_values *attrDict = get_attrdict(item, attr->flags);
PyObject *value = PyObject_CallMethodObjArgs((PyObject *) item, removeAttributeValue_NAME, self->name, attrDict ? (PyObject *) attrDict : Py_None, attr->attrID, NULL);
if (!value)
return -1;
Py_DECREF(value);
return 0;
}
PyErr_SetObject(PyExc_AttributeError, self->name);
return -1;
}
开发者ID:HackLinux,项目名称:chandler,代码行数:19,代码来源:descriptor.c
示例20: subscriptions
/*
def subscriptions(self, required, provided):
cache = self._scache.get(provided)
if cache is None:
cache = {}
self._scache[provided] = cache
required = tuple(required)
result = cache.get(required, _not_in_mapping)
if result is _not_in_mapping:
result = self._uncached_subscriptions(required, provided)
cache[required] = result
return result
*/
static PyObject *
_subscriptions(lookup *self, PyObject *required, PyObject *provided)
{
PyObject *cache, *result;
ASSURE_DICT(self->_scache);
cache = _subcache(self->_scache, provided);
if (cache == NULL)
return NULL;
required = tuplefy(required);
if (required == NULL)
return NULL;
result = PyDict_GetItem(cache, required);
if (result == NULL)
{
int status;
result = PyObject_CallMethodObjArgs(
OBJECT(self), str_uncached_subscriptions,
required, provided, NULL);
if (result == NULL)
{
Py_DECREF(required);
return NULL;
}
status = PyDict_SetItem(cache, required, result);
Py_DECREF(required);
if (status < 0)
{
Py_DECREF(result);
return NULL;
}
}
else
{
Py_INCREF(result);
Py_DECREF(required);
}
return result;
}
开发者ID:JohnDoes95,项目名称:project_parser,代码行数:58,代码来源:_zope_interface_coptimizations.c
注:本文中的PyObject_CallMethodObjArgs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论