Commit 3bd1c068 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Import gcmodule.c and genobject.h

parent b528ca09
......@@ -377,4 +377,4 @@ install(FILES test/lib/virtualenv/virtualenv_support/setuptools-12.0.5-py2.py3-n
include(CPack)
# last file added (need to change this if we add a file that is added via a glob):
# from_cpython/Lib/test/test_zipimport.py
# from_cpython/Include/genobject.h
......@@ -44,6 +44,7 @@ file(GLOB_RECURSE STDMODULE_SRCS Modules
fcntlmodule.c
fileio.c
future_builtins.c
gcmodule.c
getpath.c
iobase.c
itertoolsmodule.c
......
......@@ -82,6 +82,7 @@
#include "traceback.h"
#include "sliceobject.h"
#include "iterobject.h"
#include "genobject.h"
#include "descrobject.h"
#include "warnings.h"
#include "weakrefobject.h"
......
// This file is originally from CPython 2.7, with modifications for Pyston
/* Generator object interface */
#ifndef Py_GENOBJECT_H
#define Py_GENOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
struct _frame; /* Avoid including frameobject.h */
// Pyston change: this is not our object format
#if 0
typedef struct {
PyObject_HEAD
/* The gi_ prefix is intended to remind of generator-iterator. */
/* Note: gi_frame can be NULL if the generator is "finished" */
struct _frame *gi_frame;
/* True if generator is being executed. */
int gi_running;
/* The code object backing the generator */
PyObject *gi_code;
/* List of weak reference. */
PyObject *gi_weakreflist;
} PyGenObject;
#endif
typedef struct _PyGenObject PyGenObject;
// Pyston change: not a static object
//PyAPI_DATA(PyTypeObject) PyGen_Type;
PyAPI_DATA(PyTypeObject*) generator_cls;
#define PyGen_Type (*generator_cls)
#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type)
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
#ifdef __cplusplus
}
#endif
#endif /* !Py_GENOBJECT_H */
......@@ -241,9 +241,6 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t) PYSTON_NO
/* C equivalent of gc.collect(). */
PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void) PYSTON_NOEXCEPT;
// Pyston changes: everything is GC tracked now
#if 0
/* Test if a type has a GC head */
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
......@@ -311,10 +308,7 @@ extern PyGC_Head *_PyGC_generation0;
#define _PyObject_GC_MAY_BE_TRACKED(obj) \
(PyObject_IS_GC(obj) && \
(!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj)))
#else
/* for source compatibility with 2.2 */
#define _PyObject_GC_Del PyObject_GC_Del
#endif
PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t) PYSTON_NOEXCEPT;
PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *) PYSTON_NOEXCEPT;
......@@ -322,15 +316,6 @@ PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t) PYSTON
PyAPI_FUNC(void) PyObject_GC_Track(void *) PYSTON_NOEXCEPT;
PyAPI_FUNC(void) PyObject_GC_UnTrack(void *) PYSTON_NOEXCEPT;
PyAPI_FUNC(void) PyObject_GC_Del(void *) PYSTON_NOEXCEPT;
#define PyType_IS_GC(t) ((t),1)
#define _PyObject_GC_TRACK(o) ((void)(o))
#define _PyObject_GC_UNTRACK(o) ((void)(o))
#define _PyObject_GC_Malloc(size) ((PyObject*)PyObject_MALLOC(size))
#define _PyObject_GC_New _PyObject_New
#define PyObject_GC_Track(o) ((void)(o))
#define PyObject_GC_UnTrack(o) ((void)(o))
#define PyObject_GC_Del PyObject_Del
#define PyObject_GC_New(type, typeobj) \
( (type *) _PyObject_GC_New(typeobj) )
......
......@@ -19,7 +19,7 @@
*/
#include "Python.h"
#include "frameobject.h" /* for PyFrame_ClearFreeList */
//#include "frameobject.h" /* for PyFrame_ClearFreeList */
/* Get an object's GC head */
#define AS_GC(o) ((PyGC_Head *)(o)-1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment