本文整理汇总了C++中PyObject_CallFunctionObjArgs函数的典型用法代码示例。如果您正苦于以下问题:C++ PyObject_CallFunctionObjArgs函数的具体用法?C++ PyObject_CallFunctionObjArgs怎么用?C++ PyObject_CallFunctionObjArgs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyObject_CallFunctionObjArgs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:bedwards,项目名称:lampy,代码行数:20,代码来源:_zope_interface_coptimizations.c
示例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;
}
开发者ID:244xiao,项目名称:blender,代码行数:41,代码来源:bpy_internal_import.c
示例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;
}
开发者ID:ZachBeta,项目名称:znc,代码行数:41,代码来源:modpython.cpp
示例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;
}
开发者ID:KennethNielsen,项目名称:llvmpy,代码行数:41,代码来源:capsule.cpp
示例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;
}
开发者ID:krichter722,项目名称:binutils-gdb,代码行数:41,代码来源:py-prettyprint.c
示例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;
}
}
}
开发者ID:aRkadeFR,项目名称:dotVim,代码行数:21,代码来源:cext.c
示例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;
}
开发者ID:Distrotech,项目名称:rpm,代码行数:21,代码来源:rpmfd-py.c
示例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;
}
开发者ID:psycopg,项目名称:psycopg2,代码行数:21,代码来源:xid_type.c
示例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;
}
开发者ID:chenbk85,项目名称:jega,代码行数:21,代码来源:locks.c
示例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;
}
开发者ID:Claruarius,项目名称:stblinux-2.6.37,代码行数:40,代码来源:py-event.c
示例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;
}
开发者ID:pombredanne,项目名称:lazy_python,代码行数:42,代码来源:_thunk.c
示例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;
}
}
开发者ID:kikin,项目名称:watchlrsite,代码行数:30,代码来源:green.c
示例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;
}
开发者ID:mureinik,项目名称:cthreading,代码行数:22,代码来源:_cthreading.c
示例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);
}
开发者ID:Highstaker,项目名称:antimony,代码行数:22,代码来源:control.cpp
示例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);
}
开发者ID:ayanamist,项目名称:pyuv,代码行数:39,代码来源:pipe.c
示例16: on_body
static int on_body(http_parser* parser, const char *at, size_t length)
{
int fail = 0;
PyObject* self = (PyObject*)parser->data;
if (PyObject_HasAttrString(self, "_on_body")) {
PyObject* callable = PyObject_GetAttrString(self, "_on_body");
PyObject* bytearray = PyByteArray_FromStringAndSize(at, length);
PyObject* result = PyObject_CallFunctionObjArgs(
callable, bytearray, NULL);
PyObject* exception = PyErr_Occurred();
if (exception != NULL) {
fail = 1;
} else {
if (PyObject_IsTrue(result))
fail = 1;
}
Py_XDECREF(result);
Py_DECREF(callable);
Py_DECREF(bytearray);
}
return fail;
}
开发者ID:lucidfrontier45,项目名称:geventhttpclient,代码行数:22,代码来源:_parser.c
示例17: on_timer_callback
static void
on_timer_callback(uv_timer_t *handle)
{
PyGILState_STATE gstate = PyGILState_Ensure();
Timer *self;
PyObject *result;
ASSERT(handle);
self = PYUV_CONTAINER_OF(handle, Timer, timer_h);
/* Object could go out of scope in the callback, increase refcount to avoid it */
Py_INCREF(self);
result = PyObject_CallFunctionObjArgs(self->callback, self, NULL);
if (result == NULL) {
handle_uncaught_exception(HANDLE(self)->loop);
}
Py_XDECREF(result);
Py_DECREF(self);
PyGILState_Release(gstate);
}
开发者ID:iyedb,项目名称:pyuv,代码行数:22,代码来源:timer.c
示例18: execPycContent
void execPycContent(PyObject* pyc_content)
{
PyObject* py_marshal = NULL;
PyObject* py_marshal_loads = NULL;
PyObject* pyc_content_wo_magic = NULL;
PyObject* py_code = NULL;
PyObject* global = PyDict_New();
PyObject* local = PyDict_New();
Py_ssize_t content_size = 0;
char* content = NULL;
#if PY_MAJOR_VERSION >= 3
PyObject* main_name = PyUnicode_FromString("__main__");
#else
PyObject* main_name = PyBytes_FromString("__main__");
#endif
// load compiled source from .pyc content
py_marshal = PyImport_ImportModule("marshal");
py_marshal_loads = PyObject_GetAttrString(py_marshal, "loads");
content = PyBytes_AS_STRING(pyc_content);
content_size = PyBytes_Size(pyc_content);
pyc_content_wo_magic = PyBytes_FromStringAndSize(content+MAGIC_OFFSET, content_size-MAGIC_OFFSET);
py_code = PyObject_CallFunctionObjArgs(py_marshal_loads, pyc_content_wo_magic, NULL);
// setup global and exec loaded py_code
PyDict_SetItemString(global, "__name__", main_name);
PyDict_SetItemString(global, "__builtins__", PyEval_GetBuiltins());
PyEval_EvalCode((PyCodeObject*)py_code, global, local);
Py_DECREF(py_code);
Py_DECREF(global);
Py_DECREF(local);
Py_DECREF(pyc_content_wo_magic);
Py_DECREF(py_marshal_loads);
Py_DECREF(py_marshal);
}
开发者ID:holitics,项目名称:pyconcrete,代码行数:38,代码来源:pyconcrete_exe.c
示例19: atom
PyObject * atom(PyObject *obj) {
PyObject *moddict = NULL;
PyObject *mod = NULL;
PyObject *fun = NULL;
PyObject *res = NULL;
moddict = PyImport_GetModuleDict();
if (!moddict) goto error;
mod = PyMapping_GetItemString(moddict,
"toy");
if (!mod) goto error;
fprintf(stderr, "Found toy module\n");
fun = PyObject_GetAttrString(mod,
"atom");
if (!fun) goto error;
fprintf(stderr, "Found atom there\n");
res = PyObject_CallFunctionObjArgs(fun,
obj,
NULL);
if (!res) goto error;
fprintf(stderr, "Called atom\n");
success:
Py_XDECREF(fun);
Py_XDECREF(mod);
fprintf(stderr, "Returning from atom\n");
return res;
error:
Py_XDECREF(fun);
Py_XDECREF(mod);
Py_XDECREF(res);
return NULL;
}
开发者ID:mabragor,项目名称:ibcl,代码行数:38,代码来源:atom.c
示例20: scheduler_Scheduler
/* Scheduler scheduler callback */
static double
scheduler_Scheduler(ev_periodic *periodic, double now)
{
PyGILState_STATE gstate = PyGILState_Ensure();
double result;
Scheduler *self = periodic->data;
PyObject *pynow, *pyresult = NULL;
pynow = PyFloat_FromDouble(now);
if (!pynow) {
self->err_fatal = 1;
goto error;
}
pyresult = PyObject_CallFunctionObjArgs(self->scheduler, self, pynow, NULL);
if (!pyresult) {
goto error;
}
result = PyFloat_AsDouble(pyresult);
if (result == -1 && PyErr_Occurred()) {
goto error;
}
if (result < now) {
PyErr_SetString(Error, "returned value must be >= 'now' param");
goto error;
}
goto finish;
error:
PyErr_Fetch(&self->err_type, &self->err_value, &self->err_traceback);
ev_prepare_start(((Watcher *)self)->loop->loop, &self->prepare);
result = now + 1e30;
finish:
Py_XDECREF(pyresult);
Py_XDECREF(pynow);
PyGILState_Release(gstate);
return result;
}
开发者ID:CZ-NIC,项目名称:dionaea,代码行数:39,代码来源:Scheduler.c
注:本文中的PyObject_CallFunctionObjArgs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论