本文整理汇总了C++中PyObject_GC_Track函数的典型用法代码示例。如果您正苦于以下问题:C++ PyObject_GC_Track函数的具体用法?C++ PyObject_GC_Track怎么用?C++ PyObject_GC_Track使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyObject_GC_Track函数的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);
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
示例2: PyObject_GC_New
static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
__pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
if (op == NULL)
return NULL;
op->flags = flags;
__Pyx_CyFunction_weakreflist(op) = NULL;
op->func.m_ml = ml;
op->func.m_self = (PyObject *) op;
Py_XINCREF(closure);
op->func_closure = closure;
Py_XINCREF(module);
op->func.m_module = module;
op->func_dict = NULL;
op->func_name = NULL;
Py_INCREF(qualname);
op->func_qualname = qualname;
op->func_doc = NULL;
op->func_classobj = NULL;
op->func_globals = globals;
Py_INCREF(op->func_globals);
Py_XINCREF(code);
op->func_code = code;
// Dynamic Default args
op->defaults_pyobjects = 0;
op->defaults = NULL;
op->defaults_tuple = NULL;
op->defaults_kwdict = NULL;
op->defaults_getter = NULL;
op->func_annotations = NULL;
PyObject_GC_Track(op);
return (PyObject *) op;
}
开发者ID:Neilhzy,项目名称:Neutrophils-kinetics,代码行数:33,代码来源:CythonFunction.c
示例3: _gc_track
static PyObject *
_gc_track(PyObject *self, PyObject *ob)
{
PyObject_GC_Track(ob);
Py_INCREF(Py_None);
return Py_None;
}
开发者ID:d11,项目名称:rts,代码行数:7,代码来源:stacklessmodule.c
示例4: compose_new
static PyObject* compose_new(PyObject* type, PyObject* args, PyObject* kwargs) {
static char* argnames[] = {"initial", "stepping"};
PyObject* initial = NULL;
PyObject* stepping = Py_False;
if(!PyArg_ParseTupleAndKeywords( // borrowed refs
args, kwargs, "O|O:compose", argnames,
&initial, &stepping)) return NULL;
if(!is_generator(initial)) {
PyErr_SetString(PyExc_TypeError, "compose() argument 1 must be generator");
return NULL;
}
PyComposeObject* cmps = PyObject_GC_New(PyComposeObject, &PyCompose_Type);
if(cmps == NULL)
return NULL;
_compose_initialize((PyComposeObject*) cmps);
if(stepping)
cmps->stepping = stepping == Py_True;
if(!generators_push(cmps, initial)) return NULL;
PyObject_GC_Track(cmps);
return (PyObject*) cmps;
}
开发者ID:blep,项目名称:weightless-core,代码行数:29,代码来源:_compose.c
示例5: PyObject_GC_New
static PyObject *CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags,
/*PyObject *closure,*/
PyObject *self, PyObject *module, PyObject* code)
{
CyFunctionObject *op = PyObject_GC_New(CyFunctionObject, type);
if (op == NULL)
return NULL;
op->flags = flags;
op->func_weakreflist = NULL;
op->func.m_ml = ml;
/* op->func.m_self = (PyObject *) op;*/
Py_XINCREF(self);
op->func.m_self = self;
/*Py_XINCREF(closure);
op->func_closure = closure;*/
op->func_closure = NULL;
Py_XINCREF(module);
op->func.m_module = module;
op->func_dict = NULL;
op->func_name = NULL;
op->func_doc = NULL;
op->func_classobj = NULL;
Py_XINCREF(code);
op->func_code = code;
/* Dynamic Default args */
op->defaults_pyobjects = 0;
op->defaults = NULL;
op->defaults_tuple = NULL;
op->defaults_getter = NULL;
PyObject_GC_Track(op);
return (PyObject *) op;
}
开发者ID:buguen,项目名称:numba,代码行数:32,代码来源:cyfunction.c
示例6: init_repository
PyObject *
init_repository(PyObject *self, PyObject *args)
{
git_repository *repo;
Repository *py_repo;
const char *path;
unsigned int bare;
int err;
if (!PyArg_ParseTuple(args, "sI", &path, &bare))
return NULL;
err = git_repository_init(&repo, path, bare);
if (err < 0)
return Error_set_str(err, path);
py_repo = PyObject_GC_New(Repository, &RepositoryType);
if (py_repo) {
py_repo->repo = repo;
py_repo->index = NULL;
PyObject_GC_Track(py_repo);
return (PyObject*)py_repo;
}
git_repository_free(repo);
return NULL;
};
开发者ID:delanne,项目名称:pygit2,代码行数:27,代码来源:pygit2.c
示例7: CThunkObject_new
static CThunkObject* CThunkObject_new(Py_ssize_t nArgs)
{
CThunkObject *p;
Py_ssize_t i;
p = PyObject_GC_NewVar(CThunkObject, &PyCThunk_Type, nArgs);
if (p == NULL) {
return NULL;
}
p->pcl_write = NULL;
p->pcl_exec = NULL;
memset(&p->cif, 0, sizeof(p->cif));
p->flags = 0;
p->converters = NULL;
p->callable = NULL;
p->restype = NULL;
p->setfunc = NULL;
p->ffi_restype = NULL;
for (i = 0; i < nArgs + 1; ++i)
p->atypes[i] = NULL;
PyObject_GC_Track((PyObject *)p);
return p;
}
开发者ID:FFMG,项目名称:myoddweb.piger,代码行数:25,代码来源:callbacks.c
示例8: PyErr_SetString
PyObject *SibPair_New(PyObject *head, PyObject *tail) {
// checked
SibPair *self = NULL;
if (! (head && tail)) {
PyErr_SetString(PyExc_TypeError, "pair requires a head and a tail");
return NULL;
}
if (pair_free_list) {
// printf("reusing existing SibPair, count=%i\n", pair_free_count);
self = pair_free_list;
pair_free_list = (SibPair *) SibPair_CDR(self);
pair_free_count--;
Py_INCREF(self);
} else {
// printf("no spare SibPair, allocating fresh\n");
self = PyObject_GC_New(SibPair, &SibPairType);
}
self->position = NULL;
Py_INCREF(head);
self->head = head;
Py_INCREF(tail);
self->tail = tail;
PyObject_GC_Track((PyObject *) self);
return (PyObject *) self;
}
开发者ID:obriencj,项目名称:python-sibilant,代码行数:35,代码来源:pair.c
示例9: __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
示例10: Repository_config__get__
PyObject *
Repository_config__get__(Repository *self, void *closure)
{
int err;
git_config *config;
Config *py_config;
assert(self->repo);
if (self->config == NULL) {
err = git_repository_config(&config, self->repo);
if (err < 0)
return Error_set(err);
py_config = PyObject_GC_New(Config, &ConfigType);
if (!py_config) {
git_config_free(config);
return NULL;
}
Py_INCREF(self);
py_config->repo = self;
py_config->config = config;
PyObject_GC_Track(py_config);
self->config = (PyObject*)py_config;
}
Py_INCREF(self->config);
return self->config;
}
开发者ID:cboos,项目名称:pygit2,代码行数:30,代码来源:repository.c
示例11: PyModule_NewObject
PyObject *
PyModule_NewObject(PyObject *name)
{
PyModuleObject *m;
m = PyObject_GC_New(PyModuleObject, &PyModule_Type);
if (m == NULL)
return NULL;
m->md_def = NULL;
m->md_state = NULL;
m->md_dict = PyDict_New();
if (m->md_dict == NULL)
goto fail;
if (PyDict_SetItemString(m->md_dict, "__name__", name) != 0)
goto fail;
if (PyDict_SetItemString(m->md_dict, "__doc__", Py_None) != 0)
goto fail;
if (PyDict_SetItemString(m->md_dict, "__package__", Py_None) != 0)
goto fail;
PyObject_GC_Track(m);
return (PyObject *)m;
fail:
Py_DECREF(m);
return NULL;
}
开发者ID:IgnusIndia,项目名称:pythonexperiment,代码行数:25,代码来源:moduleobject.c
示例12: Repository_index__get__
PyObject *
Repository_index__get__(Repository *self, void *closure)
{
int err;
git_index *index;
Index *py_index;
assert(self->repo);
if (self->index == NULL) {
err = git_repository_index(&index, self->repo);
if (err < 0)
return Error_set(err);
py_index = PyObject_GC_New(Index, &IndexType);
if (!py_index) {
git_index_free(index);
return NULL;
}
Py_INCREF(self);
py_index->repo = self;
py_index->index = index;
PyObject_GC_Track(py_index);
self->index = (PyObject*)py_index;
}
Py_INCREF(self->index);
return self->index;
}
开发者ID:victorgp,项目名称:pygit2_dup,代码行数:30,代码来源:repository.c
示例13: slpmodule_new
static PyObject *
slpmodule_new(char *name)
{
PySlpModuleObject *m;
PyObject *nameobj;
m = PyObject_GC_New(PySlpModuleObject, PySlpModule_TypePtr);
if (m == NULL)
return NULL;
m->__channel__ = NULL;
m->__tasklet__ = NULL;
nameobj = PyString_FromString(name);
m->md_dict = PyDict_New();
if (m->md_dict == NULL || nameobj == NULL)
goto fail;
if (PyDict_SetItemString(m->md_dict, "__name__", nameobj) != 0)
goto fail;
if (PyDict_SetItemString(m->md_dict, "__doc__", Py_None) != 0)
goto fail;
Py_DECREF(nameobj);
PyObject_GC_Track(m);
return (PyObject *)m;
fail:
Py_XDECREF(nameobj);
Py_DECREF(m);
return NULL;
}
开发者ID:develersrl,项目名称:dspython,代码行数:28,代码来源:stacklessmodule.c
示例14: pygi_resulttuple_new
/**
* pygi_resulttuple_new:
* @subclass: A PyGIResultTuple_Type subclass which will be the type of the
* returned instance.
* @len: Length of the returned tuple
*
* Like PyTuple_New(). Return an uninitialized tuple of the given @length.
*
* Returns: An instance of @subclass or %NULL on error.
*/
PyObject *
pygi_resulttuple_new(PyTypeObject *subclass, Py_ssize_t len) {
PyObject *self;
Py_ssize_t i;
/* Check the free list for a tuple object with the needed size;
* clear it and change the class to ours.
*/
if (len > 0 && len < PyGIResultTuple_MAXSAVESIZE) {
self = free_list[len];
if (self != NULL) {
free_list[len] = PyTuple_GET_ITEM (self, 0);
numfree[len]--;
for (i=0; i < len; i++) {
PyTuple_SET_ITEM (self, i, NULL);
}
Py_TYPE (self) = subclass;
Py_INCREF (subclass);
_Py_NewReference (self);
PyObject_GC_Track (self);
return self;
}
}
/* For zero length tuples and in case the free list is empty, alloc
* as usual.
*/
return subclass->tp_alloc (subclass, len);
}
开发者ID:Distrotech,项目名称:pygobject,代码行数:39,代码来源:pygi-resulttuple.c
示例15: PyModule_New
PyObject *
PyModule_New(char *name)
{
PyModuleObject *m;
PyObject *nameobj;
m = PyObject_GC_New(PyModuleObject, &PyModule_Type);
if (m == NULL)
return NULL;
nameobj = PyString_FromString(name);
m->md_dict = PyDict_New();
if (m->md_dict == NULL || nameobj == NULL)
goto fail;
if (PyDict_SetItemString(m->md_dict, "__name__", nameobj) != 0)
goto fail;
if (PyDict_SetItemString(m->md_dict, "__doc__", Py_None) != 0)
goto fail;
Py_DECREF(nameobj);
PyObject_GC_Track(m);
return (PyObject *)m;
fail:
Py_XDECREF(nameobj);
Py_DECREF(m);
return NULL;
}
开发者ID:MatiasNAmendola,项目名称:cleese,代码行数:25,代码来源:moduleobject.c
示例16: PyMemorySimpleView_FromObject
/*
* Factory
*/
static PyObject *
PyMemorySimpleView_FromObject(PyObject *base)
{
PyMemorySimpleViewObject *mview = NULL;
Py_buffer view;
if (Py_TYPE(base)->tp_as_buffer == NULL ||
Py_TYPE(base)->tp_as_buffer->bf_getbuffer == NULL) {
PyErr_SetString(PyExc_TypeError,
"cannot make memory view because object does "
"not have the buffer interface");
return NULL;
}
memset(&view, 0, sizeof(Py_buffer));
if (PyObject_GetBuffer(base, &view, PyBUF_FULL_RO) < 0)
return NULL;
mview = (PyMemorySimpleViewObject *)
PyObject_GC_New(PyMemorySimpleViewObject, &PyMemorySimpleView_Type);
if (mview == NULL) {
PyBuffer_Release(&view);
return NULL;
}
memcpy(&mview->view, &view, sizeof(Py_buffer));
mview->base = base;
Py_INCREF(base);
PyObject_GC_Track(mview);
return (PyObject *)mview;
}
开发者ID:Eothred,项目名称:jpype,代码行数:35,代码来源:jpype_memory_view.c
示例17: PyObject_GC_Track
PyObject *Example_FromExample(PyTypeObject *type, PExample example, POrange lock)
{ TPyExample *self=PyObject_GC_New(TPyExample, type);
self->example.init();
self->lock.init();
self->example = example;
self->lock = lock;
PyObject_GC_Track(self);
return (PyObject *)self;
}
开发者ID:pauloortins,项目名称:Computer-Vision-Classes---UFBA,代码行数:9,代码来源:cls_example.cpp
示例18: Py_INCREF
/** Create a new parameter collection object. */
ParamsObject *Params_New(LPXObject *py_lp) {
ParamsObject *p = (ParamsObject*)PyObject_GC_New(ParamsObject, &ParamsType);
if (p==NULL) return p;
Py_INCREF(py_lp);
p->py_lp = py_lp;
p->weakreflist = NULL;
PyObject_GC_Track(p);
return p;
}
开发者ID:aa755,项目名称:scene_labelling,代码行数:12,代码来源:params.c
示例19: new_weakref
static PyWeakReference *
new_weakref(PyObject *ob, PyObject *callback)
{
PyWeakReference *result;
result = PyObject_GC_New(PyWeakReference, &_PyWeakref_RefType);
if (result) {
init_weakref(result, ob, callback);
PyObject_GC_Track(result);
}
return result;
}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:12,代码来源:weakrefobject.c
示例20: Node_NewContainer
PyDocumentFragmentObject *DocumentFragment_New(PyDocumentObject *ownerDocument)
{
PyDocumentFragmentObject *self;
self = Node_NewContainer(PyDocumentFragmentObject,
&DomletteDocumentFragment_Type,
ownerDocument);
PyObject_GC_Track(self);
return self;
}
开发者ID:H1d3r,项目名称:binary_blobs,代码行数:12,代码来源:documentfragment.c
注:本文中的PyObject_GC_Track函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论