Author: Ronan Lamy <ronan.l...@gmail.com>
Branch: rffi-parser-2
Changeset: r89552:7d32ade95762
Date: 2017-01-13 18:12 +0000
http://bitbucket.org/pypy/pypy/changeset/7d32ade95762/

Log:    Remove duplication between cpyext_object.h and the regular headers

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -51,6 +51,7 @@
 translator_c_dir = py.path.local(cdir)
 include_dirs = [
     include_dir,
+    parse_dir,
     translator_c_dir,
     udir,
     ]
diff --git a/pypy/module/cpyext/include/descrobject.h 
b/pypy/module/cpyext/include/descrobject.h
--- a/pypy/module/cpyext/include/descrobject.h
+++ b/pypy/module/cpyext/include/descrobject.h
@@ -1,16 +1,5 @@
 #ifndef Py_DESCROBJECT_H
 #define Py_DESCROBJECT_H
-typedef PyObject *(*getter)(PyObject *, void *);
-typedef int (*setter)(PyObject *, PyObject *, void *);
-
-typedef struct PyGetSetDef {
-       char *name;
-       getter get;
-       setter set;
-       char *doc;
-       void *closure;
-} PyGetSetDef;
-
 
 #define PyDescr_COMMON \
     PyObject_HEAD \
diff --git a/pypy/module/cpyext/include/methodobject.h 
b/pypy/module/cpyext/include/methodobject.h
--- a/pypy/module/cpyext/include/methodobject.h
+++ b/pypy/module/cpyext/include/methodobject.h
@@ -7,20 +7,6 @@
 extern "C" {
 #endif
 
-typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
-typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
-                                             PyObject *);
-typedef PyObject *(*PyNoArgsFunction)(PyObject *);
-
-struct PyMethodDef {
-    const char  *ml_name;   /* The name of the built-in function/method */
-    PyCFunction  ml_meth;   /* The C function that implements it */
-    int          ml_flags;  /* Combination of METH_xxx flags, which mostly
-                               describe the args expected by the C func */
-    const char  *ml_doc;    /* The __doc__ attribute, or NULL */
-};
-typedef struct PyMethodDef PyMethodDef;
-
 typedef struct
 {
     PyObject_HEAD
diff --git a/pypy/module/cpyext/include/object.h 
b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -7,6 +7,9 @@
 extern "C" {
 #endif
 
+
+#include <cpyext_object.h>
+
 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
 
 
@@ -16,29 +19,12 @@
 */
 #define staticforward static
 
-#define PyObject_HEAD  \
-    Py_ssize_t ob_refcnt;        \
-    Py_ssize_t ob_pypy_link;     \
-    struct _typeobject *ob_type;
-
-#define PyObject_VAR_HEAD              \
-       PyObject_HEAD                   \
-       Py_ssize_t ob_size; /* Number of items in variable part */
-
 #define PyObject_HEAD_INIT(type)       \
        1, 0, type,
 
 #define PyVarObject_HEAD_INIT(type, size)      \
        PyObject_HEAD_INIT(type) size,
 
-typedef struct _object {
-    PyObject_HEAD
-} PyObject;
-
-typedef struct {
-       PyObject_VAR_HEAD
-} PyVarObject;
-
 #ifdef PYPY_DEBUG_REFCOUNT
 /* Slow version, but useful for debugging */
 #define Py_INCREF(ob)   (Py_IncRef((PyObject *)(ob)))
@@ -94,84 +80,7 @@
 #define Py_GT 4
 #define Py_GE 5
 
-struct _typeobject;
-typedef void (*freefunc)(void *);
-typedef void (*destructor)(PyObject *);
-typedef int (*printfunc)(PyObject *, FILE *, int);
-typedef PyObject *(*getattrfunc)(PyObject *, char *);
-typedef PyObject *(*getattrofunc)(PyObject *, PyObject *);
-typedef int (*setattrfunc)(PyObject *, char *, PyObject *);
-typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *);
-typedef int (*cmpfunc)(PyObject *, PyObject *);
-typedef PyObject *(*reprfunc)(PyObject *);
-typedef long (*hashfunc)(PyObject *);
-typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int);
-typedef PyObject *(*getiterfunc) (PyObject *);
-typedef PyObject *(*iternextfunc) (PyObject *);
-typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *);
-typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *);
-typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
-typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
-typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t);
-
-typedef PyObject * (*unaryfunc)(PyObject *);
-typedef PyObject * (*binaryfunc)(PyObject *, PyObject *);
-typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *);
-typedef int (*inquiry)(PyObject *);
-typedef Py_ssize_t (*lenfunc)(PyObject *);
-typedef int (*coercion)(PyObject **, PyObject **);
-typedef PyObject *(*intargfunc)(PyObject *, int) Py_DEPRECATED(2.5);
-typedef PyObject *(*intintargfunc)(PyObject *, int, int) Py_DEPRECATED(2.5);
-typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t);
-typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t);
-typedef int(*intobjargproc)(PyObject *, int, PyObject *);
-typedef int(*intintobjargproc)(PyObject *, int, int, PyObject *);
-typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *);
-typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, 
PyObject *);
-typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *);
-
-
-/* int-based buffer interface */
-typedef int (*getreadbufferproc)(PyObject *, int, void **);
-typedef int (*getwritebufferproc)(PyObject *, int, void **);
-typedef int (*getsegcountproc)(PyObject *, int *);
-typedef int (*getcharbufferproc)(PyObject *, int, char **);
-/* ssize_t-based buffer interface */
-typedef Py_ssize_t (*readbufferproc)(PyObject *, Py_ssize_t, void **);
-typedef Py_ssize_t (*writebufferproc)(PyObject *, Py_ssize_t, void **);
-typedef Py_ssize_t (*segcountproc)(PyObject *, Py_ssize_t *);
-typedef Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, char **);
-
 /* Py3k buffer interface, adapted for PyPy */
-#define Py_MAX_NDIMS 32
-#define Py_MAX_FMT 128
-typedef struct bufferinfo {
-    void *buf;
-    PyObject *obj;        /* owned reference */
-    Py_ssize_t len;
-
-    /* This is Py_ssize_t so it can be
-       pointed to by strides in simple case.*/
-    Py_ssize_t itemsize;
-    int readonly;
-    int ndim;
-    char *format;
-    Py_ssize_t *shape;
-    Py_ssize_t *strides;
-    Py_ssize_t *suboffsets; /* alway NULL for app-level objects*/
-    unsigned char _format[Py_MAX_FMT];
-    Py_ssize_t _strides[Py_MAX_NDIMS];
-    Py_ssize_t _shape[Py_MAX_NDIMS];
-    /* static store for shape and strides of
-       mono-dimensional buffers. */
-    /* Py_ssize_t smalltable[2]; */
-    void *internal; /* always NULL for app-level objects */
-} Py_buffer;
-
-
-typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
-typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
-
     /* Flags for getting buffers */
 #define PyBUF_SIMPLE 0
 #define PyBUF_WRITABLE 0x0001
@@ -203,178 +112,6 @@
 #define PyBUF_SHADOW 0x400
 /* end Py3k buffer interface */
 
-typedef int (*objobjproc)(PyObject *, PyObject *);
-typedef int (*visitproc)(PyObject *, void *);
-typedef int (*traverseproc)(PyObject *, visitproc, void *);
-
-typedef struct {
-       /* For numbers without flag bit Py_TPFLAGS_CHECKTYPES set, all
-          arguments are guaranteed to be of the object's type (modulo
-          coercion hacks -- i.e. if the type's coercion function
-          returns other types, then these are allowed as well).  Numbers that
-          have the Py_TPFLAGS_CHECKTYPES flag bit set should check *both*
-          arguments for proper type and implement the necessary conversions
-          in the slot functions themselves. */
-
-       binaryfunc nb_add;
-       binaryfunc nb_subtract;
-       binaryfunc nb_multiply;
-       binaryfunc nb_divide;
-       binaryfunc nb_remainder;
-       binaryfunc nb_divmod;
-       ternaryfunc nb_power;
-       unaryfunc nb_negative;
-       unaryfunc nb_positive;
-       unaryfunc nb_absolute;
-       inquiry nb_nonzero;
-       unaryfunc nb_invert;
-       binaryfunc nb_lshift;
-       binaryfunc nb_rshift;
-       binaryfunc nb_and;
-       binaryfunc nb_xor;
-       binaryfunc nb_or;
-       coercion nb_coerce;
-       unaryfunc nb_int;
-       unaryfunc nb_long;
-       unaryfunc nb_float;
-       unaryfunc nb_oct;
-       unaryfunc nb_hex;
-       /* Added in release 2.0 */
-       binaryfunc nb_inplace_add;
-       binaryfunc nb_inplace_subtract;
-       binaryfunc nb_inplace_multiply;
-       binaryfunc nb_inplace_divide;
-       binaryfunc nb_inplace_remainder;
-       ternaryfunc nb_inplace_power;
-       binaryfunc nb_inplace_lshift;
-       binaryfunc nb_inplace_rshift;
-       binaryfunc nb_inplace_and;
-       binaryfunc nb_inplace_xor;
-       binaryfunc nb_inplace_or;
-
-       /* Added in release 2.2 */
-       /* The following require the Py_TPFLAGS_HAVE_CLASS flag */
-       binaryfunc nb_floor_divide;
-       binaryfunc nb_true_divide;
-       binaryfunc nb_inplace_floor_divide;
-       binaryfunc nb_inplace_true_divide;
-
-       /* Added in release 2.5 */
-       unaryfunc nb_index;
-} PyNumberMethods;
-
-typedef struct {
-       lenfunc sq_length;
-       binaryfunc sq_concat;
-       ssizeargfunc sq_repeat;
-       ssizeargfunc sq_item;
-       ssizessizeargfunc sq_slice;
-       ssizeobjargproc sq_ass_item;
-       ssizessizeobjargproc sq_ass_slice;
-       objobjproc sq_contains;
-       /* Added in release 2.0 */
-       binaryfunc sq_inplace_concat;
-       ssizeargfunc sq_inplace_repeat;
-} PySequenceMethods;
-
-typedef struct {
-       lenfunc mp_length;
-       binaryfunc mp_subscript;
-       objobjargproc mp_ass_subscript;
-} PyMappingMethods;
-
-typedef struct {
-       readbufferproc bf_getreadbuffer;
-       writebufferproc bf_getwritebuffer;
-       segcountproc bf_getsegcount;
-       charbufferproc bf_getcharbuffer;
-       getbufferproc bf_getbuffer;
-       releasebufferproc bf_releasebuffer;
-} PyBufferProcs;
-
-
-
-typedef struct _typeobject {
-       PyObject_VAR_HEAD
-       const char *tp_name; /* For printing, in format "<module>.<name>" */
-       Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
-
-       /* Methods to implement standard operations */
-
-       destructor tp_dealloc;
-       printfunc tp_print;
-       getattrfunc tp_getattr;
-       setattrfunc tp_setattr;
-       cmpfunc tp_compare;
-       reprfunc tp_repr;
-
-       /* Method suites for standard classes */
-
-       PyNumberMethods *tp_as_number;
-       PySequenceMethods *tp_as_sequence;
-       PyMappingMethods *tp_as_mapping;
-
-       /* More standard operations (here for binary compatibility) */
-
-       hashfunc tp_hash;
-       ternaryfunc tp_call;
-       reprfunc tp_str;
-       getattrofunc tp_getattro;
-       setattrofunc tp_setattro;
-
-       /* Functions to access object as input/output buffer */
-       PyBufferProcs *tp_as_buffer;
-
-       /* Flags to define presence of optional/expanded features */
-       long tp_flags;
-
-       const char *tp_doc; /* Documentation string */
-
-       /* Assigned meaning in release 2.0 */
-       /* call function for all accessible objects */
-       traverseproc tp_traverse;
-
-       /* delete references to contained objects */
-       inquiry tp_clear;
-
-       /* Assigned meaning in release 2.1 */
-       /* rich comparisons */
-       richcmpfunc tp_richcompare;
-
-       /* weak reference enabler */
-       Py_ssize_t tp_weaklistoffset;
-
-       /* Added in release 2.2 */
-       /* Iterators */
-       getiterfunc tp_iter;
-       iternextfunc tp_iternext;
-
-       /* Attribute descriptor and subclassing stuff */
-       struct PyMethodDef *tp_methods;
-       struct PyMemberDef *tp_members;
-       struct PyGetSetDef *tp_getset;
-       struct _typeobject *tp_base;
-       PyObject *tp_dict;
-       descrgetfunc tp_descr_get;
-       descrsetfunc tp_descr_set;
-       Py_ssize_t tp_dictoffset;
-       initproc tp_init;
-       allocfunc tp_alloc;
-       newfunc tp_new;
-       freefunc tp_free; /* Low-level free-memory routine */
-       inquiry tp_is_gc; /* For PyObject_IS_GC */
-       PyObject *tp_bases;
-       PyObject *tp_mro; /* method resolution order */
-       PyObject *tp_cache;
-       PyObject *tp_subclasses;
-       PyObject *tp_weaklist;
-       destructor tp_del;
-
-       /* Type attribute cache version tag. Added in version 2.6 */
-       unsigned int tp_version_tag;
-
-} PyTypeObject;
-
 typedef struct {
     PyTypeObject ht_type;
     PyNumberMethods as_number;
diff --git a/pypy/module/cpyext/include/structmember.h 
b/pypy/module/cpyext/include/structmember.h
--- a/pypy/module/cpyext/include/structmember.h
+++ b/pypy/module/cpyext/include/structmember.h
@@ -19,22 +19,6 @@
 #define offsetof(type, member) ( (int) & ((type*)0) -> member )
 #endif
 
-/* An array of memberlist structures defines the name, type and offset
-   of selected members of a C structure.  These can be read by
-   PyMember_Get() and set by PyMember_Set() (except if their READONLY flag
-   is set).  The array must be terminated with an entry whose name
-   pointer is NULL. */
-
-
-
-typedef struct PyMemberDef {
-    /* Current version, use this */
-    char *name;
-    int type;
-    Py_ssize_t offset;
-    int flags;
-    char *doc;
-} PyMemberDef;
 
 /* Types */
 #define T_SHORT         0
diff --git a/pypy/module/cpyext/parse/cpyext_object.h 
b/pypy/module/cpyext/parse/cpyext_object.h
--- a/pypy/module/cpyext/parse/cpyext_object.h
+++ b/pypy/module/cpyext/parse/cpyext_object.h
@@ -19,7 +19,6 @@
 } PyVarObject;
 
 struct _typeobject;
-
 typedef void (*freefunc)(void *);
 typedef void (*destructor)(PyObject *);
 typedef int (*printfunc)(PyObject *, FILE *, int);
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to