本文整理汇总了C++中PyObject_ClearWeakRefs函数的典型用法代码示例。如果您正苦于以下问题:C++ PyObject_ClearWeakRefs函数的具体用法?C++ PyObject_ClearWeakRefs怎么用?C++ PyObject_ClearWeakRefs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyObject_ClearWeakRefs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __Pyx_Generator_dealloc
static void __Pyx_Generator_dealloc(PyObject *self) {
__pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
PyObject_GC_UnTrack(gen);
if (gen->gi_weakreflist != NULL)
PyObject_ClearWeakRefs(self);
if (gen->resume_label > 0) {
// Generator is paused, so we need to close
PyObject_GC_Track(self);
#if PY_VERSION_HEX >= 0x030400a1
if (PyObject_CallFinalizerFromDealloc(self))
#else
Py_TYPE(gen)->tp_del(self);
if (self->ob_refcnt > 0)
#endif
{
// resurrected. :(
return;
}
PyObject_GC_UnTrack(self);
}
__Pyx_Generator_clear(self);
PyObject_GC_Del(gen);
}
示例2: mmap_object_dealloc
static void
mmap_object_dealloc(mmap_object *m_obj)
{
#ifdef MS_WINDOWS
if (m_obj->data != NULL)
UnmapViewOfFile (m_obj->data);
if (m_obj->map_handle != NULL)
CloseHandle (m_obj->map_handle);
if (m_obj->file_handle != INVALID_HANDLE_VALUE)
CloseHandle (m_obj->file_handle);
if (m_obj->tagname)
PyMem_Free(m_obj->tagname);
#endif /* MS_WINDOWS */
#ifdef UNIX
if (m_obj->fd >= 0)
(void) close(m_obj->fd);
if (m_obj->data!=NULL) {
munmap(m_obj->data, m_obj->size);
}
#endif /* UNIX */
if (m_obj->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) m_obj);
Py_TYPE(m_obj)->tp_free((PyObject*)m_obj);
}
示例3: code_dealloc
static void
code_dealloc(PyCodeObject *co)
{
if (co->co_extra != NULL) {
PyInterpreterState *interp = PyThreadState_Get()->interp;
_PyCodeObjectExtra *co_extra = co->co_extra;
for (Py_ssize_t i = 0; i < co_extra->ce_size; i++) {
freefunc free_extra = interp->co_extra_freefuncs[i];
if (free_extra != NULL) {
free_extra(co_extra->ce_extras[i]);
}
}
PyMem_Free(co_extra);
}
Py_XDECREF(co->co_code);
Py_XDECREF(co->co_consts);
Py_XDECREF(co->co_names);
Py_XDECREF(co->co_varnames);
Py_XDECREF(co->co_freevars);
Py_XDECREF(co->co_cellvars);
Py_XDECREF(co->co_filename);
Py_XDECREF(co->co_name);
Py_XDECREF(co->co_lnotab);
if (co->co_cell2arg != NULL)
PyMem_FREE(co->co_cell2arg);
if (co->co_zombieframe != NULL)
PyObject_GC_Del(co->co_zombieframe);
if (co->co_weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject*)co);
PyObject_DEL(co);
}
示例4: Params_clear
static int Params_clear(ParamsObject *self) {
if (self->weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject*)self);
}
Py_CLEAR(self->py_lp);
return 0;
}
示例5: connection_dealloc
static void
connection_dealloc(PyObject* obj)
{
connectionObject *self = (connectionObject *)obj;
/* Make sure to untrack the connection before calling conn_close, which may
* allow a different thread to try and dealloc the connection again,
* resulting in a double-free segfault (ticket #166). */
PyObject_GC_UnTrack(self);
conn_close(self);
if (self->weakreflist) {
PyObject_ClearWeakRefs(obj);
}
conn_notice_clean(self);
PyMem_Free(self->dsn);
PyMem_Free(self->encoding);
if (self->critical) free(self->critical);
if (self->cancel) PQfreeCancel(self->cancel);
connection_clear(self);
pthread_mutex_destroy(&(self->lock));
Dprintf("connection_dealloc: deleted connection object at %p, refcnt = "
FORMAT_CODE_PY_SSIZE_T,
obj, Py_REFCNT(obj)
);
Py_TYPE(obj)->tp_free(obj);
}
示例6: Handle_tp_dealloc
static void
Handle_tp_dealloc(Handle *self)
{
ASSERT(self->uv_handle);
if (self->initialized && !uv_is_closing(self->uv_handle)) {
uv_close(self->uv_handle, on_handle_dealloc_close);
ASSERT(uv_is_closing(self->uv_handle));
/* resurrect the Python object until the close callback is called */
Py_INCREF(self);
resurrect_object((PyObject *)self);
return;
} else {
/* There are a few cases why the code will take this path:
* - A subclass of a handle didn't call it's parent's __init__
* - Aclosed handle is deallocated. Refcount is increased in close(),
* so it's guaranteed that if we arrived here and the user had called close(),
* the callback was already executed.
* - A handle goes out of scope and it's closed here in tp_dealloc and resurrected.
* Once it's deallocated again it will take this path because the handle is now
* closed.
*/
;
}
if (self->weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject *)self);
}
Py_TYPE(self)->tp_clear((PyObject *)self);
Py_TYPE(self)->tp_free((PyObject *)self);
}
示例7: PyObject_ClearWeakRefs
/**
* \param self A PyObjectPlus_Proxy
*/
void PyObjectPlus::py_base_dealloc(PyObject *self) // python wrapper
{
#ifdef USE_WEAKREFS
if (BGE_PROXY_WKREF(self) != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
#endif
if (BGE_PROXY_PYREF(self)) {
PyObjectPlus *self_plus= BGE_PROXY_REF(self);
if (self_plus) {
if (BGE_PROXY_PYOWNS(self)) { /* Does python own this?, then delete it */
self_plus->m_proxy = NULL; /* Need this to stop ~PyObjectPlus from decrefing m_proxy otherwise its decref'd twice and py-debug crashes */
delete self_plus;
}
BGE_PROXY_REF(self)= NULL; // not really needed
}
// the generic pointer is not deleted directly, only through self_plus
BGE_PROXY_PTR(self)= NULL; // not really needed
} else {
void *ptr= BGE_PROXY_PTR(self);
if (ptr) {
if (BGE_PROXY_PYOWNS(self)) { /* Does python own this?, then delete it */
// generic structure owned by python MUST be created though MEM_alloc
MEM_freeN(ptr);
}
BGE_PROXY_PTR(self)= NULL; // not really needed
}
}
#if 0
/* is ok normally but not for subtyping, use tp_free instead. */
PyObject_DEL( self );
#else
Py_TYPE(self)->tp_free(self);
#endif
};
示例8: tasklet_dealloc
static void
tasklet_dealloc(PyTaskletObject *t)
{
if (tasklet_has_c_stack(t)) {
/*
* we want to cleanly kill the tasklet in the case it
* was forgotten. One way would be to resurrect it,
* but this is quite ugly with many ifdefs, see
* classobject/typeobject.
* Well, we do it.
*/
if (slp_resurrect_and_kill((PyObject *) t, kill_finally)) {
/* the beast has grown new references */
return;
}
}
tasklet_clear_frames(t);
if (t->tsk_weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *)t);
if (t->cstate != NULL) {
assert(t->cstate->task != t || t->cstate->ob_size == 0);
Py_DECREF(t->cstate);
}
Py_DECREF(t->tempval);
Py_XDECREF(t->def_globals);
t->ob_type->tp_free((PyObject*)t);
}
示例9: WeakSet_dealloc
void WeakSet_dealloc(WeakSet *self){
if (self->in_weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
Py_XDECREF(self->set);
Py_XDECREF(self->selfref);
self->ob_type->tp_free((PyObject*)self);
}
示例10: sllist_clear_refs
static int sllist_clear_refs(SLListObject* self)
{
PyObject* node = self->first;
if (self->weakref_list != NULL)
PyObject_ClearWeakRefs((PyObject*)self);
self->first = NULL;
self->last = NULL;
self->weakref_list = NULL;
if (node != NULL)
{
while (node != Py_None)
{
PyObject* next_node = ((SLListNodeObject*)node)->next;
((SLListNodeObject*)node)->next = Py_None;
Py_DECREF(node);
node = next_node;
}
}
Py_DECREF(Py_None);
return 0;
}
示例11: Bar_clear
static int Bar_clear(BarObject *self) {
if (self->weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject*)self);
}
Py_CLEAR(self->py_bc);
return 0;
}
示例12: __Pyx_Generator_dealloc
static void
__Pyx_Generator_dealloc(PyObject *self)
{
__pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
PyObject_GC_UnTrack(gen);
if (gen->gi_weakreflist != NULL)
PyObject_ClearWeakRefs(self);
PyObject_GC_Track(self);
if (gen->resume_label > 0) {
/* Generator is paused, so we need to close */
Py_TYPE(gen)->tp_del(self);
if (self->ob_refcnt > 0)
return; /* resurrected. :( */
}
PyObject_GC_UnTrack(self);
Py_CLEAR(gen->closure);
Py_CLEAR(gen->classobj);
Py_CLEAR(gen->exc_type);
Py_CLEAR(gen->exc_value);
Py_CLEAR(gen->exc_traceback);
PyObject_GC_Del(gen);
}
示例13: compose_dealloc
static void compose_dealloc(PyComposeObject* self) {
PyObject_GC_UnTrack(self);
if(self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject*)self);
compose_clear(self);
PyObject_GC_Del(self);
}
示例14: eConsolePy_dealloc
static void
eConsolePy_dealloc(eConsolePy* self)
{
if (self->in_weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
eConsolePy_clear(self);
self->cont->Release();
self->ob_type->tp_free((PyObject*)self);
}
示例15: dbgbp_dealloc
static void
dbgbp_dealloc(PyDebugBreakpointObject *self)
{
if (self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *)self);
if (self->bp)
self->bp = NULL;
Py_TYPE(self)->tp_free((PyObject *)self);
}