本文整理汇总了C++中PyObject_CallFunctionObjArgs函数的典型用法代码示例。如果您正苦于以下问题:C++ PyObject_CallFunctionObjArgs函数的具体用法?C++ PyObject_CallFunctionObjArgs怎么用?C++ PyObject_CallFunctionObjArgs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyObject_CallFunctionObjArgs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Spec_providedBy
static PyObject *
Spec_providedBy(PyObject *self, PyObject *ob)
{
PyObject *decl, *item;
decl = providedBy(NULL, ob);
if (decl == NULL)
return NULL;
if (PyObject_TypeCheck(decl, &SpecType))
item = Spec_extends(decl, self);
else
/* decl is probably a security proxy. We have to go the long way
around.
*/
item = PyObject_CallFunctionObjArgs(decl, self, NULL);
Py_DECREF(decl);
return item;
}
示例2: PyObject_CallFunctionObjArgs
static PyObject *blender_reload(PyObject *UNUSED(self), PyObject *module)
{
PyObject *exception, *err, *tb;
PyObject *newmodule = NULL;
int found = 0;
/* try reimporting from file */
/* in Py3.3 this just calls imp.reload() which we overwrite, causing recursive calls */
//newmodule = PyImport_ReloadModule(module);
newmodule = PyObject_CallFunctionObjArgs(imp_reload_orig, module, NULL);
if (newmodule)
return newmodule;
/* no file, try importing from memory */
PyErr_Fetch(&exception, &err, &tb); /*restore for probable later use */
newmodule = bpy_text_reimport(module, &found);
if (newmodule) { /* found module as blender text, ignore above exception */
PyErr_Clear();
Py_XDECREF(exception);
Py_XDECREF(err);
Py_XDECREF(tb);
/* printf("imported from text buffer...\n"); */
}
else if (found == 1) { /* blender text module failed to execute but was found, use its error message */
Py_XDECREF(exception);
Py_XDECREF(err);
Py_XDECREF(tb);
return NULL;
}
else {
/* no blender text was found that could import the module
* reuse the original error from PyImport_ImportModuleEx */
PyErr_Restore(exception, err, tb);
}
return newmodule;
}
示例3: GetPyExceptionStr
CString GetPyExceptionStr() {
PyObject* ptype;
PyObject* pvalue;
PyObject* ptraceback;
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
CString result;
if (!pvalue) {
Py_INCREF(Py_None);
pvalue = Py_None;
}
if (!ptraceback) {
Py_INCREF(Py_None);
ptraceback = Py_None;
}
PyErr_NormalizeException(&ptype, &pvalue, &ptraceback);
PyObject* strlist = PyObject_CallFunctionObjArgs(m_PyFormatException, ptype, pvalue, ptraceback, NULL);
Py_CLEAR(ptype);
Py_CLEAR(pvalue);
Py_CLEAR(ptraceback);
if (!strlist) {
return "Couldn't get exact error message";
}
if (PySequence_Check(strlist)) {
PyObject* strlist_fast = PySequence_Fast(strlist, "Shouldn't happen (1)");
PyObject** items = PySequence_Fast_ITEMS(strlist_fast);
Py_ssize_t L = PySequence_Fast_GET_SIZE(strlist_fast);
for (Py_ssize_t i = 0; i < L; ++i) {
PyObject* utf8 = PyUnicode_AsUTF8String(items[i]);
result += PyBytes_AsString(utf8);
Py_CLEAR(utf8);
}
Py_CLEAR(strlist_fast);
} else {
result = "Can't get exact error message";
}
Py_CLEAR(strlist);
return result;
}
示例4: WrapCore
static
PyObject* WrapCore(PyObject *oldCap, bool owned) {
auto_pyobject cap = PyObject_CallFunctionObjArgs(GetCapsuleClass(), oldCap,
NULL);
auto_pyobject cls = PyObject_CallMethod(*cap, "get_class", "");
auto_pyobject addr = GetPointer(oldCap);
// look up cached object
auto_pyobject cache_cls = PyObject_GetItem(GetCache(), *cls);
Assert(*cache_cls);
PyObject* obj = NULL;
obj = PyObject_GetItem(*cache_cls, *addr);
if (obj) {
/* cache hit */
}
else {
if (!PyErr_ExceptionMatches(PyExc_KeyError))
return NULL;
/* cache miss */
PyErr_Clear();
if (!owned) {
auto_pyobject hasDtor = PyObject_CallMethod(*cls, "_has_dtor", "");
if (PyObject_IsTrue(*hasDtor)) {
auto_pyobject name = GetName(oldCap);
auto_pyobject key = PyTuple_Pack(2, *name, *addr);
auto_pyobject val = PyObject_GetAttrString(*cls, "_delete_");
int ok = PyDict_SetItem(GetAddrDtorDict(), *key, *val);
Assert(ok != -1);
}
}
obj = PyObject_CallMethod(*cap, "instantiate", "");
int ok = PyObject_SetItem(*cache_cls, *addr, obj);
Assert(ok != -1);
}
Assert(obj);
return obj;
}
示例5: search_pp_list
static PyObject *
search_pp_list (PyObject *list, PyObject *value)
{
Py_ssize_t pp_list_size, list_index;
PyObject *function, *printer = NULL;
pp_list_size = PyList_Size (list);
for (list_index = 0; list_index < pp_list_size; list_index++)
{
function = PyList_GetItem (list, list_index);
if (! function)
return NULL;
/* Skip if disabled. */
if (PyObject_HasAttr (function, gdbpy_enabled_cst))
{
PyObject *attr = PyObject_GetAttr (function, gdbpy_enabled_cst);
int cmp;
if (!attr)
return NULL;
cmp = PyObject_IsTrue (attr);
Py_DECREF (attr);
if (cmp == -1)
return NULL;
if (!cmp)
continue;
}
printer = PyObject_CallFunctionObjArgs (function, value, NULL);
if (! printer)
return NULL;
else if (printer != Py_None)
return printer;
Py_DECREF (printer);
}
Py_RETURN_NONE;
}
示例6: PyObject_CallFunctionObjArgs
static PyObject *Proxy__ensure_wrapped(ProxyObject *self)
{
PyObject *wrapped;
if (self->wrapped) {
return self->wrapped;
} else {
if (self->factory) {
wrapped = PyObject_CallFunctionObjArgs(self->factory, NULL);
if (wrapped) {
self->wrapped = wrapped;
return wrapped;
} else {
return NULL;
}
} else {
PyErr_SetString(PyExc_ValueError, "Proxy hasn't been initiated: __factory__ is missing.");
return NULL;
}
}
}
示例7: rpmfdFromPyObject
int rpmfdFromPyObject(PyObject *obj, rpmfdObject **fdop)
{
rpmfdObject *fdo = NULL;
if (rpmfdObject_Check(obj)) {
Py_INCREF(obj);
fdo = (rpmfdObject *) obj;
} else {
fdo = (rpmfdObject *) PyObject_CallFunctionObjArgs((PyObject *)&rpmfd_Type,
obj, NULL);
}
if (fdo == NULL) return 0;
if (Ferror(fdo->fd)) {
PyErr_SetString(PyExc_IOError, Fstrerror(fdo->fd));
Py_DECREF(fdo);
return 0;
}
*fdop = fdo;
return 1;
}
示例8: _xid_base64_enc_dec
static PyObject *
_xid_base64_enc_dec(const char *funcname, PyObject *s)
{
PyObject *base64 = NULL;
PyObject *func = NULL;
PyObject *rv = NULL;
if (!(base64 = PyImport_ImportModule("base64"))) { goto exit; }
if (!(func = PyObject_GetAttrString(base64, funcname))) { goto exit; }
Py_INCREF(s);
if (!(s = psyco_ensure_bytes(s))) { goto exit; }
rv = psyco_ensure_text(PyObject_CallFunctionObjArgs(func, s, NULL));
Py_DECREF(s);
exit:
Py_XDECREF(func);
Py_XDECREF(base64);
return rv;
}
示例9: RLockObject_init
static int
RLockObject_init(RLockObject *self, PyObject *args, PyObject *kwargs)
{
PyObject *s;
DEBUG("self:%p", self);
s = PyObject_CallFunctionObjArgs((PyObject*)&SemaphoreObjectType, NULL);
if (s == NULL) {
return -1;
}
Py_CLEAR(self->block);
Py_CLEAR(self->owner);
self->block = s;
self->count = 0;
self->owner = Py_None;
Py_INCREF(self->owner);
return 1;
}
示例10: evpy_emit_event
int
evpy_emit_event (PyObject *event,
eventregistry_object *registry)
{
PyObject *callback_list_copy = NULL;
Py_ssize_t i;
/* Create a copy of call back list and use that for
notifying listeners to avoid skipping callbacks
in the case of a callback being disconnected during
a notification. */
callback_list_copy = PySequence_List (registry->callbacks);
if (!callback_list_copy)
goto fail;
for (i = 0; i < PyList_Size (callback_list_copy); i++)
{
PyObject *func = PyList_GetItem (callback_list_copy, i);
if (func == NULL)
goto fail;
if (!PyObject_CallFunctionObjArgs (func, event, NULL))
{
/* Print the trace here, but keep going -- we want to try to
call all of the callbacks even if one is broken. */
gdbpy_print_stack ();
}
}
Py_XDECREF (callback_list_copy);
Py_XDECREF (event);
return 0;
fail:
gdbpy_print_stack ();
Py_XDECREF (callback_list_copy);
Py_XDECREF (event);
return -1;
}
示例11: strict_eval
/* Strictly evaluate a thunk.
return: A new reference. */
static PyObject *
strict_eval(PyObject *th)
{
static PyObject *strict_name;
PyObject *normal;
PyObject *strict_method = NULL;
if (PyObject_IsInstance(th, (PyObject*) &thunk_type)) {
if (!(th = _strict_eval_borrowed(th))) {
return NULL;
}
}
if (!(strict_name ||
(strict_name = PyUnicode_FromString("__strict__")))) {
return NULL;
}
if (!(strict_method = PyObject_GetAttr((PyObject*) Py_TYPE(th),
strict_name))) {
if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
PyErr_Clear();
normal = th;
}
else {
return NULL;
}
}
else if (!(normal = PyObject_CallFunctionObjArgs(strict_method,
th,
NULL))) {
Py_DECREF(strict_method);
return NULL;
}
else {
Py_XDECREF(strict_method);
}
Py_INCREF(normal);
return normal;
}
示例12: psyco_wait
/* Block waiting for data available in an async connection.
*
* This function assumes `wait_callback` to be available:
* raise `InterfaceError` if it is not. Use `psyco_green()` to check if
* the function is to be called.
*
* Return 0 on success, else nonzero and set a Python exception.
*/
int
psyco_wait(connectionObject *conn)
{
PyObject *rv;
PyObject *cb;
Dprintf("psyco_wait");
if (!(cb = have_wait_callback())) {
return -1;
}
rv = PyObject_CallFunctionObjArgs(cb, conn, NULL);
Py_DECREF(cb);
if (NULL != rv) {
Py_DECREF(rv);
return 0;
} else {
Dprintf("psyco_wait: error in wait callback");
return -1;
}
}
示例13: Condition_wait_released
static acquire_result
Condition_wait_released(Condition *self, struct waiter *waiter, double timeout)
{
PyObject *saved_state = NULL;
PyObject *r = NULL;
acquire_result res;
saved_state = PyObject_CallObject(self->release_save, NULL);
if (saved_state == NULL)
return ACQUIRE_ERROR;
res = acquire_lock(&waiter->sem, timeout);
r = PyObject_CallFunctionObjArgs(self->acquire_restore, saved_state, NULL);
if (r == NULL)
res = ACQUIRE_ERROR;
Py_CLEAR(saved_state);
Py_CLEAR(r);
return res;
}
示例14: PyFloat_FromDouble
void Control::drag(QVector3D center, QVector3D diff)
{
auto p = node->mutableProxy();
auto x = PyFloat_FromDouble(relative ? diff.x() : center.x());
auto y = PyFloat_FromDouble(relative ? diff.y() : center.y());
auto z = PyFloat_FromDouble(relative ? diff.z() : center.z());
if (drag_func)
{
PyObject_CallFunctionObjArgs(drag_func, p, x, y, z, NULL);
if (PyErr_Occurred())
{
PyErr_Print();
PyErr_Clear();
}
}
Py_DECREF(p);
Py_DECREF(x);
Py_DECREF(y);
Py_DECREF(z);
}
示例15: on_pipe_read2
static void
on_pipe_read2(uv_pipe_t* handle, int nread, uv_buf_t buf, uv_handle_type pending)
{
PyGILState_STATE gstate = PyGILState_Ensure();
uv_err_t err;
Stream *self;
PyObject *result, *data, *py_errorno, *py_pending;
ASSERT(handle);
self = (Stream *)handle->data;
ASSERT(self);
/* Object could go out of scope in the callback, increase refcount to avoid it */
Py_INCREF(self);
py_pending = PyInt_FromLong((long)pending);
if (nread >= 0) {
data = PyBytes_FromStringAndSize(buf.base, nread);
py_errorno = Py_None;
Py_INCREF(Py_None);
} else {
data = Py_None;
Py_INCREF(Py_None);
err = uv_last_error(UV_HANDLE_LOOP(self));
py_errorno = PyInt_FromLong((long)err.code);
}
result = PyObject_CallFunctionObjArgs(self->on_read_cb, self, data, py_pending, py_errorno, NULL);
if (result == NULL) {
handle_uncaught_exception(HANDLE(self)->loop);
}
Py_XDECREF(result);
Py_DECREF(data);
Py_DECREF(py_pending);
Py_DECREF(py_errorno);
Py_DECREF(self);
PyGILState_Release(gstate);
}