• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PyObject_ClearWeakRefs函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PyObject_ClearWeakRefs函数的典型用法代码示例。如果您正苦于以下问题:C++ PyObject_ClearWeakRefs函数的具体用法?C++ PyObject_ClearWeakRefs怎么用?C++ PyObject_ClearWeakRefs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PyObject_ClearWeakRefs函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Aeternam,项目名称:server_status,代码行数:26,代码来源:Generator.c


示例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);
}
开发者ID:1st1,项目名称:cpython,代码行数:26,代码来源:mmapmodule.c


示例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);
}
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:35,代码来源:codeobject.c


示例4: Params_clear

static int Params_clear(ParamsObject *self) {
    if (self->weakreflist != NULL) {
        PyObject_ClearWeakRefs((PyObject*)self);
    }
    Py_CLEAR(self->py_lp);
    return 0;
}
开发者ID:aa755,项目名称:scene_labelling,代码行数:7,代码来源:params.c


示例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);
}
开发者ID:gencer,项目名称:psycopg2,代码行数:34,代码来源:connection_type.c


示例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);
}
开发者ID:JoneXiong,项目名称:pyuv,代码行数:29,代码来源:handle.c


示例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
};
开发者ID:akonneker,项目名称:blensor,代码行数:38,代码来源:PyObjectPlus.cpp


示例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);
}
开发者ID:newerthcom,项目名称:savagerebirth,代码行数:28,代码来源:taskletobject.c


示例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);
}
开发者ID:RagnarDanneskjold,项目名称:tuke,代码行数:7,代码来源:weakset.c


示例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;
}
开发者ID:ajakubek,项目名称:python-llist,代码行数:26,代码来源:sllist.c


示例11: Bar_clear

static int Bar_clear(BarObject *self) {
  if (self->weakreflist != NULL) {
    PyObject_ClearWeakRefs((PyObject*)self);
  }
  Py_CLEAR(self->py_bc);
  return 0;
}
开发者ID:CyanoFactory,项目名称:CyanoFactoryKB,代码行数:7,代码来源:bar.c


示例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);
}
开发者ID:vietlq,项目名称:cython,代码行数:25,代码来源:Generator.c


示例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);
}
开发者ID:blep,项目名称:weightless-core,代码行数:9,代码来源:_compose.c


示例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);
}
开发者ID:BananaSamurai,项目名称:Enigma2,代码行数:9,代码来源:console.cpp


示例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);
}
开发者ID:leishen,项目名称:Pybag,代码行数:9,代码来源:debugbreakpoint.cpp


示例16: CapObject_dealloc

static void
CapObject_dealloc(CapObject* self) {

    if (self->__weakref__ != NULL)
        PyObject_ClearWeakRefs((PyObject *) self);

    CapObject_clear(self);
    self->ob_type->tp_free((PyObject*)self);

}
开发者ID:enyst,项目名称:plexnet,代码行数:10,代码来源:.capbase.c


示例17: func_dealloc

static void
func_dealloc(PyFunctionObject *op)
{
    _PyObject_GC_UNTRACK(op);
    if (op->func_weakreflist != NULL) {
        PyObject_ClearWeakRefs((PyObject *) op);
    }
    (void)func_clear(op);
    PyObject_GC_Del(op);
}
开发者ID:tiran,项目名称:cpython,代码行数:10,代码来源:funcobject.c


示例18: TDI_SoupEncoderType_clear

static int
TDI_SoupEncoderType_clear(tdi_soup_encoder_t *self)
{
    if (self->weakreflist)
        PyObject_ClearWeakRefs((PyObject *)self);

    Py_CLEAR(self->encoding);

    return 0;
}
开发者ID:giorgil,项目名称:tdi,代码行数:10,代码来源:soup_encoder.c


示例19: Bar_dealloc

static void Bar_dealloc(BarObject *self) {
#ifdef USE_BAR_GC
  Bar_clear(self);
#else
  if (self->weakreflist != NULL) {
    PyObject_ClearWeakRefs((PyObject*)self);
  }
  Py_DECREF(self->py_bc);
#endif
  Py_TYPE(self)->tp_free((PyObject*)self);
}
开发者ID:CyanoFactory,项目名称:CyanoFactoryKB,代码行数:11,代码来源:bar.c


示例20: igraphmodule_VertexSeq_dealloc

/**
 * \ingroup python_interface_vertexseq
 * \brief Deallocates a Python representation of a given vertex sequence object
 */
void igraphmodule_VertexSeq_dealloc(igraphmodule_VertexSeqObject* self) {
  if (self->weakreflist != NULL)
    PyObject_ClearWeakRefs((PyObject *) self);
  if (self->gref) {
    igraph_vs_destroy(&self->vs);
    Py_DECREF(self->gref);
    self->gref=0;
  }
  Py_TYPE(self)->tp_free((PyObject*)self);
  RC_DEALLOC("VertexSeq", self);
}
开发者ID:bravery,项目名称:python-igraph,代码行数:15,代码来源:vertexseqobject.c



注:本文中的PyObject_ClearWeakRefs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PyObject_DEL函数代码示例发布时间:2022-05-30
下一篇:
C++ PyObject_CallObject函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap