Kaydet (Commit) ea9cb5ae authored tarafından Fred Drake's avatar Fred Drake

ANSI-fication and Py_PROTO extermination.

üst 5eb6d4e3
This diff is collapsed.
#ifndef Py_BUFFEROBJECT_H
#define Py_BUFFEROBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
......@@ -18,6 +12,12 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
/* Note: the object's structure is private */
#ifndef Py_BUFFEROBJECT_H
#define Py_BUFFEROBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
extern DL_IMPORT(PyTypeObject) PyBuffer_Type;
......@@ -25,16 +25,18 @@ extern DL_IMPORT(PyTypeObject) PyBuffer_Type;
#define Py_END_OF_BUFFER (-1)
extern DL_IMPORT(PyObject *) PyBuffer_FromObject Py_PROTO((PyObject *base, int offset, int size));
extern DL_IMPORT(PyObject *) PyBuffer_FromReadWriteObject Py_PROTO((PyObject *base, int offset, int size));
extern DL_IMPORT(PyObject *) PyBuffer_FromObject(PyObject *base,
int offset, int size);
extern DL_IMPORT(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base,
int offset,
int size);
extern DL_IMPORT(PyObject *) PyBuffer_FromMemory Py_PROTO((void *ptr, int size));
extern DL_IMPORT(PyObject *) PyBuffer_FromReadWriteMemory Py_PROTO((void *ptr, int size));
extern DL_IMPORT(PyObject *) PyBuffer_FromMemory(void *ptr, int size);
extern DL_IMPORT(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, int size);
extern DL_IMPORT(PyObject *) PyBuffer_New Py_PROTO((int size));
extern DL_IMPORT(PyObject *) PyBuffer_New(int size);
#ifdef __cplusplus
}
#endif
#endif /* !Py_BUFFEROBJECT_H */
#ifndef Py_CLASSOBJECT_H
#define Py_CLASSOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
......@@ -18,28 +12,34 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
/* Revealing some structures (not for general use) */
#ifndef Py_CLASSOBJECT_H
#define Py_CLASSOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_HEAD
PyObject *cl_bases; /* A tuple of class objects */
PyObject *cl_dict; /* A dictionary */
PyObject *cl_name; /* A string */
/* The following three are functions or NULL */
PyObject *cl_getattr;
PyObject *cl_setattr;
PyObject *cl_delattr;
PyObject_HEAD
PyObject *cl_bases; /* A tuple of class objects */
PyObject *cl_dict; /* A dictionary */
PyObject *cl_name; /* A string */
/* The following three are functions or NULL */
PyObject *cl_getattr;
PyObject *cl_setattr;
PyObject *cl_delattr;
} PyClassObject;
typedef struct {
PyObject_HEAD
PyClassObject *in_class; /* The class object */
PyObject *in_dict; /* A dictionary */
PyObject_HEAD
PyClassObject *in_class; /* The class object */
PyObject *in_dict; /* A dictionary */
} PyInstanceObject;
typedef struct {
PyObject_HEAD
PyObject *im_func; /* The callable object implementing the method */
PyObject *im_self; /* The instance it is bound to, or NULL */
PyObject *im_class; /* The class that defined the method */
PyObject_HEAD
PyObject *im_func; /* The callable object implementing the method */
PyObject *im_self; /* The instance it is bound to, or NULL */
PyObject *im_class; /* The class that defined the method */
} PyMethodObject;
extern DL_IMPORT(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type;
......@@ -48,13 +48,14 @@ extern DL_IMPORT(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type;
#define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type)
#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
extern DL_IMPORT(PyObject *) PyClass_New Py_PROTO((PyObject *, PyObject *, PyObject *));
extern DL_IMPORT(PyObject *) PyInstance_New Py_PROTO((PyObject *, PyObject *, PyObject *));
extern DL_IMPORT(PyObject *) PyMethod_New Py_PROTO((PyObject *, PyObject *, PyObject *));
extern DL_IMPORT(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *);
extern DL_IMPORT(PyObject *) PyInstance_New(PyObject *, PyObject *,
PyObject *);
extern DL_IMPORT(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *);
extern DL_IMPORT(PyObject *) PyMethod_Function Py_PROTO((PyObject *));
extern DL_IMPORT(PyObject *) PyMethod_Self Py_PROTO((PyObject *));
extern DL_IMPORT(PyObject *) PyMethod_Class Py_PROTO((PyObject *));
extern DL_IMPORT(PyObject *) PyMethod_Function(PyObject *);
extern DL_IMPORT(PyObject *) PyMethod_Self(PyObject *);
extern DL_IMPORT(PyObject *) PyMethod_Class(PyObject *);
/* Macros for direct access to these values. Type checks are *not*
done, so use with care. */
......@@ -65,12 +66,12 @@ extern DL_IMPORT(PyObject *) PyMethod_Class Py_PROTO((PyObject *));
#define PyMethod_GET_CLASS(meth) \
(((PyMethodObject *)meth) -> im_class)
extern DL_IMPORT(int) PyClass_IsSubclass Py_PROTO((PyObject *, PyObject *));
extern DL_IMPORT(int) PyClass_IsSubclass(PyObject *, PyObject *);
extern DL_IMPORT(PyObject *) PyInstance_DoBinOp
Py_PROTO((PyObject *, PyObject *,
char *, char *,
PyObject * (*) Py_PROTO((PyObject *, PyObject *)) ));
extern DL_IMPORT(PyObject *) PyInstance_DoBinOp(PyObject *, PyObject *,
char *, char *,
PyObject * (*)(PyObject *,
PyObject *));
#ifdef __cplusplus
}
......
#ifndef Py_COBJECT_H
#define Py_COBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
......@@ -23,6 +17,12 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef Py_COBJECT_H
#define Py_COBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
extern DL_IMPORT(PyTypeObject) PyCObject_Type;
#define PyCObject_Check(op) ((op)->ob_type == &PyCObject_Type)
......@@ -34,7 +34,7 @@ extern DL_IMPORT(PyTypeObject) PyCObject_Type;
*/
extern DL_IMPORT(PyObject *)
PyCObject_FromVoidPtr Py_PROTO((void *cobj, void (*destruct)(void*)));
PyCObject_FromVoidPtr(void *cobj, void (*destruct)(void*));
/* Create a PyCObject from a pointer to a C object, a description object,
......@@ -43,20 +43,20 @@ PyCObject_FromVoidPtr Py_PROTO((void *cobj, void (*destruct)(void*)));
the PyCObject is destroyed.
*/
extern DL_IMPORT(PyObject *)
PyCObject_FromVoidPtrAndDesc Py_PROTO((void *cobj, void *desc,
void (*destruct)(void*,void*)));
PyCObject_FromVoidPtrAndDesc(void *cobj, void *desc,
void (*destruct)(void*,void*));
/* Retrieve a pointer to a C object from a PyCObject. */
extern DL_IMPORT(void *)
PyCObject_AsVoidPtr Py_PROTO((PyObject *));
PyCObject_AsVoidPtr(PyObject *);
/* Retrieve a pointer to a description object from a PyCObject. */
extern DL_IMPORT(void *)
PyCObject_GetDesc Py_PROTO((PyObject *));
PyCObject_GetDesc(PyObject *);
/* Import a pointer to a C object from a module using a PyCObject. */
extern DL_IMPORT(void *)
PyCObject_Import Py_PROTO((char *module_name, char *cobject_name));
PyCObject_Import(char *module_name, char *cobject_name);
#ifdef __cplusplus
}
......
#ifndef Py_COMPILE_H
#define Py_COMPILE_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
......@@ -16,22 +10,28 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
/* Definitions for bytecode */
#ifndef Py_COMPILE_H
#define Py_COMPILE_H
#ifdef __cplusplus
extern "C" {
#endif
/* Bytecode object */
typedef struct {
PyObject_HEAD
int co_argcount; /* #arguments, except *args */
int co_nlocals; /* #local variables */
int co_stacksize; /* #entries needed for evaluation stack */
int co_flags; /* CO_..., see below */
PyObject *co_code; /* instruction opcodes */
PyObject *co_consts; /* list (constants used) */
PyObject *co_names; /* list of strings (names used) */
PyObject *co_varnames; /* tuple of strings (local variable names) */
/* The rest doesn't count for hash/cmp */
PyObject *co_filename; /* string (where it was loaded from) */
PyObject *co_name; /* string (name, for reference) */
int co_firstlineno; /* first source line number */
PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) */
PyObject_HEAD
int co_argcount; /* #arguments, except *args */
int co_nlocals; /* #local variables */
int co_stacksize; /* #entries needed for evaluation stack */
int co_flags; /* CO_..., see below */
PyObject *co_code; /* instruction opcodes */
PyObject *co_consts; /* list (constants used) */
PyObject *co_names; /* list of strings (names used) */
PyObject *co_varnames; /* tuple of strings (local variable names) */
/* The rest doesn't count for hash/cmp */
PyObject *co_filename; /* string (where it was loaded from) */
PyObject *co_name; /* string (name, for reference) */
int co_firstlineno; /* first source line number */
PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) */
} PyCodeObject;
/* Masks for co_flags above */
......@@ -48,11 +48,11 @@ extern DL_IMPORT(PyTypeObject) PyCode_Type;
/* Public interface */
struct _node; /* Declare the existence of this type */
DL_IMPORT(PyCodeObject *) PyNode_Compile Py_PROTO((struct _node *, char *));
DL_IMPORT(PyCodeObject *) PyCode_New Py_PROTO((
DL_IMPORT(PyCodeObject *) PyNode_Compile(struct _node *, char *);
DL_IMPORT(PyCodeObject *) PyCode_New(
int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *,
PyObject *, PyObject *, int, PyObject *)); /* same as struct above */
DL_IMPORT(int) PyCode_Addr2Line Py_PROTO((PyCodeObject *, int));
PyObject *, PyObject *, int, PyObject *); /* same as struct above */
DL_IMPORT(int) PyCode_Addr2Line(PyCodeObject *, int);
/* for internal use only */
#define _PyCode_GETCODEPTR(co, pp) \
......
/* Complex number structure */
#ifndef COMPLEXOBJECT_H
#define COMPLEXOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Complex number structure */
typedef struct {
double real;
double imag;
double real;
double imag;
} Py_complex;
/* Operations on complex numbers from complexmodule.c */
......@@ -20,12 +20,12 @@ typedef struct {
#define c_quot _Py_c_quot
#define c_pow _Py_c_pow
extern DL_IMPORT(Py_complex) c_sum Py_PROTO((Py_complex, Py_complex));
extern DL_IMPORT(Py_complex) c_diff Py_PROTO((Py_complex, Py_complex));
extern DL_IMPORT(Py_complex) c_neg Py_PROTO((Py_complex));
extern DL_IMPORT(Py_complex) c_prod Py_PROTO((Py_complex, Py_complex));
extern DL_IMPORT(Py_complex) c_quot Py_PROTO((Py_complex, Py_complex));
extern DL_IMPORT(Py_complex) c_pow Py_PROTO((Py_complex, Py_complex));
extern DL_IMPORT(Py_complex) c_sum(Py_complex, Py_complex);
extern DL_IMPORT(Py_complex) c_diff(Py_complex, Py_complex);
extern DL_IMPORT(Py_complex) c_neg(Py_complex);
extern DL_IMPORT(Py_complex) c_prod(Py_complex, Py_complex);
extern DL_IMPORT(Py_complex) c_quot(Py_complex, Py_complex);
extern DL_IMPORT(Py_complex) c_pow(Py_complex, Py_complex);
/* Complex object interface */
......@@ -36,20 +36,20 @@ real and imaginary parts.
*/
typedef struct {
PyObject_HEAD
Py_complex cval;
PyObject_HEAD
Py_complex cval;
} PyComplexObject;
extern DL_IMPORT(PyTypeObject) PyComplex_Type;
#define PyComplex_Check(op) ((op)->ob_type == &PyComplex_Type)
extern DL_IMPORT(PyObject *) PyComplex_FromCComplex Py_PROTO((Py_complex));
extern DL_IMPORT(PyObject *) PyComplex_FromDoubles Py_PROTO((double real, double imag));
extern DL_IMPORT(PyObject *) PyComplex_FromCComplex(Py_complex);
extern DL_IMPORT(PyObject *) PyComplex_FromDoubles(double real, double imag);
extern DL_IMPORT(double) PyComplex_RealAsDouble Py_PROTO((PyObject *op));
extern DL_IMPORT(double) PyComplex_ImagAsDouble Py_PROTO((PyObject *op));
extern DL_IMPORT(Py_complex) PyComplex_AsCComplex Py_PROTO((PyObject *op));
extern DL_IMPORT(double) PyComplex_RealAsDouble(PyObject *op);
extern DL_IMPORT(double) PyComplex_ImagAsDouble(PyObject *op);
extern DL_IMPORT(Py_complex) PyComplex_AsCComplex(PyObject *op);
#ifdef __cplusplus
}
......
#ifndef Py_FILEOBJECT_H
#define Py_FILEOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
......@@ -16,20 +10,26 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
/* File object interface */
#ifndef Py_FILEOBJECT_H
#define Py_FILEOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
extern DL_IMPORT(PyTypeObject) PyFile_Type;
#define PyFile_Check(op) ((op)->ob_type == &PyFile_Type)
extern DL_IMPORT(PyObject *) PyFile_FromString Py_PROTO((char *, char *));
extern DL_IMPORT(void) PyFile_SetBufSize Py_PROTO((PyObject *, int));
extern DL_IMPORT(PyObject *) PyFile_FromFile
Py_PROTO((FILE *, char *, char *, int (*)Py_FPROTO((FILE *))));
extern DL_IMPORT(FILE *) PyFile_AsFile Py_PROTO((PyObject *));
extern DL_IMPORT(PyObject *) PyFile_Name Py_PROTO((PyObject *));
extern DL_IMPORT(PyObject *) PyFile_GetLine Py_PROTO((PyObject *, int));
extern DL_IMPORT(int) PyFile_WriteObject Py_PROTO((PyObject *, PyObject *, int));
extern DL_IMPORT(int) PyFile_SoftSpace Py_PROTO((PyObject *, int));
extern DL_IMPORT(int) PyFile_WriteString Py_PROTO((char *, PyObject *));
extern DL_IMPORT(PyObject *) PyFile_FromString(char *, char *);
extern DL_IMPORT(void) PyFile_SetBufSize(PyObject *, int);
extern DL_IMPORT(PyObject *) PyFile_FromFile(FILE *, char *, char *,
int (*)(FILE *));
extern DL_IMPORT(FILE *) PyFile_AsFile(PyObject *);
extern DL_IMPORT(PyObject *) PyFile_Name(PyObject *);
extern DL_IMPORT(PyObject *) PyFile_GetLine(PyObject *, int);
extern DL_IMPORT(int) PyFile_WriteObject(PyObject *, PyObject *, int);
extern DL_IMPORT(int) PyFile_SoftSpace(PyObject *, int);
extern DL_IMPORT(int) PyFile_WriteString(char *, PyObject *);
#ifdef __cplusplus
}
......
#ifndef Py_FLOATOBJECT_H
#define Py_FLOATOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
......@@ -20,18 +14,24 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
PyFloatObject represents a (double precision) floating point number.
*/
#ifndef Py_FLOATOBJECT_H
#define Py_FLOATOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_HEAD
double ob_fval;
PyObject_HEAD
double ob_fval;
} PyFloatObject;
extern DL_IMPORT(PyTypeObject) PyFloat_Type;
#define PyFloat_Check(op) ((op)->ob_type == &PyFloat_Type)
extern DL_IMPORT(PyObject *) PyFloat_FromString Py_PROTO((PyObject*, char**));
extern DL_IMPORT(PyObject *) PyFloat_FromDouble Py_PROTO((double));
extern DL_IMPORT(double) PyFloat_AsDouble Py_PROTO((PyObject *));
extern DL_IMPORT(PyObject *) PyFloat_FromString(PyObject*, char**);
extern DL_IMPORT(PyObject *) PyFloat_FromDouble(double);
extern DL_IMPORT(double) PyFloat_AsDouble(PyObject *);
/* Macro, trading safety for speed */
#define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval)
......
#ifndef Py_FRAMEOBJECT_H
#define Py_FRAMEOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
......@@ -16,32 +10,38 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
/* Frame object interface */
#ifndef Py_FRAMEOBJECT_H
#define Py_FRAMEOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
int b_type; /* what kind of block this is */
int b_handler; /* where to jump to find handler */
int b_level; /* value stack level to pop to */
int b_type; /* what kind of block this is */
int b_handler; /* where to jump to find handler */
int b_level; /* value stack level to pop to */
} PyTryBlock;
typedef struct _frame {
PyObject_HEAD
struct _frame *f_back; /* previous frame, or NULL */
PyCodeObject *f_code; /* code segment */
PyObject *f_builtins; /* builtin symbol table (PyDictObject) */
PyObject *f_globals; /* global symbol table (PyDictObject) */
PyObject *f_locals; /* local symbol table (PyDictObject) */
PyObject **f_valuestack; /* points after the last local */
PyObject *f_trace; /* Trace function */
PyObject *f_exc_type, *f_exc_value, *f_exc_traceback;
PyThreadState *f_tstate;
int f_lasti; /* Last instruction if called */
int f_lineno; /* Current line number */
int f_restricted; /* Flag set if restricted operations
PyObject_HEAD
struct _frame *f_back; /* previous frame, or NULL */
PyCodeObject *f_code; /* code segment */
PyObject *f_builtins; /* builtin symbol table (PyDictObject) */
PyObject *f_globals; /* global symbol table (PyDictObject) */
PyObject *f_locals; /* local symbol table (PyDictObject) */
PyObject **f_valuestack; /* points after the last local */
PyObject *f_trace; /* Trace function */
PyObject *f_exc_type, *f_exc_value, *f_exc_traceback;
PyThreadState *f_tstate;
int f_lasti; /* Last instruction if called */
int f_lineno; /* Current line number */
int f_restricted; /* Flag set if restricted operations
in this scope */
int f_iblock; /* index in f_blockstack */
PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */
int f_nlocals; /* number of locals */
int f_stacksize; /* size of value stack */
PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */
int f_iblock; /* index in f_blockstack */
PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */
int f_nlocals; /* number of locals */
int f_stacksize; /* size of value stack */
PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */
} PyFrameObject;
......@@ -51,9 +51,8 @@ extern DL_IMPORT(PyTypeObject) PyFrame_Type;
#define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type)
DL_IMPORT(PyFrameObject *) PyFrame_New
Py_PROTO((PyThreadState *, PyCodeObject *,
PyObject *, PyObject *));
DL_IMPORT(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
PyObject *, PyObject *);
/* The rest of the interface is specific for frame objects */
......@@ -80,17 +79,17 @@ DL_IMPORT(PyFrameObject *) PyFrame_New
/* Block management functions */
DL_IMPORT(void) PyFrame_BlockSetup Py_PROTO((PyFrameObject *, int, int, int));
DL_IMPORT(PyTryBlock *) PyFrame_BlockPop Py_PROTO((PyFrameObject *));
DL_IMPORT(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int);
DL_IMPORT(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *);
/* Extend the value stack */
DL_IMPORT(PyObject **) PyFrame_ExtendStack Py_PROTO((PyFrameObject *, int, int));
DL_IMPORT(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int);
/* Conversions between "fast locals" and locals in dictionary */
DL_IMPORT(void) PyFrame_LocalsToFast Py_PROTO((PyFrameObject *, int));
DL_IMPORT(void) PyFrame_FastToLocals Py_PROTO((PyFrameObject *));
DL_IMPORT(void) PyFrame_LocalsToFast(PyFrameObject *, int);
DL_IMPORT(void) PyFrame_FastToLocals(PyFrameObject *);
#ifdef __cplusplus
}
......
#ifndef Py_FUNCOBJECT_H
#define Py_FUNCOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
......@@ -16,24 +10,30 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
/* Function object interface */
#ifndef Py_FUNCOBJECT_H
#define Py_FUNCOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_HEAD
PyObject *func_code;
PyObject *func_globals;
PyObject *func_defaults;
PyObject *func_doc;
PyObject *func_name;
PyObject_HEAD
PyObject *func_code;
PyObject *func_globals;
PyObject *func_defaults;
PyObject *func_doc;
PyObject *func_name;
} PyFunctionObject;
extern DL_IMPORT(PyTypeObject) PyFunction_Type;
#define PyFunction_Check(op) ((op)->ob_type == &PyFunction_Type)
extern DL_IMPORT(PyObject *) PyFunction_New Py_PROTO((PyObject *, PyObject *));
extern DL_IMPORT(PyObject *) PyFunction_GetCode Py_PROTO((PyObject *));
extern DL_IMPORT(PyObject *) PyFunction_GetGlobals Py_PROTO((PyObject *));
extern DL_IMPORT(PyObject *) PyFunction_GetDefaults Py_PROTO((PyObject *));
extern DL_IMPORT(int) PyFunction_SetDefaults Py_PROTO((PyObject *, PyObject *));
extern DL_IMPORT(PyObject *) PyFunction_New(PyObject *, PyObject *);
extern DL_IMPORT(PyObject *) PyFunction_GetCode(PyObject *);
extern DL_IMPORT(PyObject *) PyFunction_GetGlobals(PyObject *);
extern DL_IMPORT(PyObject *) PyFunction_GetDefaults(PyObject *);
extern DL_IMPORT(int) PyFunction_SetDefaults(PyObject *, PyObject *);
/* Macros for direct access to these values. Type checks are *not*
done, so use with care. */
......
#ifndef Py_GRAMMAR_H
#define Py_GRAMMAR_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
......@@ -16,13 +10,19 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
/* Grammar interface */
#ifndef Py_GRAMMAR_H
#define Py_GRAMMAR_H
#ifdef __cplusplus
extern "C" {
#endif
#include "bitset.h" /* Sigh... */
/* A label of an arc */
typedef struct {
int lb_type;
char *lb_str;
int lb_type;
char *lb_str;
} label;
#define EMPTY 0 /* Label number 0 is by definition the empty label */
......@@ -30,72 +30,72 @@ typedef struct {
/* A list of labels */
typedef struct {
int ll_nlabels;
label *ll_label;
int ll_nlabels;
label *ll_label;
} labellist;
/* An arc from one state to another */
typedef struct {
short a_lbl; /* Label of this arc */
short a_arrow; /* State where this arc goes to */
short a_lbl; /* Label of this arc */
short a_arrow; /* State where this arc goes to */
} arc;
/* A state in a DFA */
typedef struct {
int s_narcs;
arc *s_arc; /* Array of arcs */
int s_narcs;
arc *s_arc; /* Array of arcs */
/* Optional accelerators */
int s_lower; /* Lowest label index */
int s_upper; /* Highest label index */
int *s_accel; /* Accelerator */
int s_accept; /* Nonzero for accepting state */
/* Optional accelerators */
int s_lower; /* Lowest label index */
int s_upper; /* Highest label index */
int *s_accel; /* Accelerator */
int s_accept; /* Nonzero for accepting state */
} state;
/* A DFA */
typedef struct {
int d_type; /* Non-terminal this represents */
char *d_name; /* For printing */
int d_initial; /* Initial state */
int d_nstates;
state *d_state; /* Array of states */
bitset d_first;
int d_type; /* Non-terminal this represents */
char *d_name; /* For printing */
int d_initial; /* Initial state */
int d_nstates;
state *d_state; /* Array of states */
bitset d_first;
} dfa;
/* A grammar */
typedef struct {
int g_ndfas;
dfa *g_dfa; /* Array of DFAs */
labellist g_ll;
int g_start; /* Start symbol of the grammar */
int g_accel; /* Set if accelerators present */
int g_ndfas;
dfa *g_dfa; /* Array of DFAs */
labellist g_ll;
int g_start; /* Start symbol of the grammar */
int g_accel; /* Set if accelerators present */
} grammar;
/* FUNCTIONS */
grammar *newgrammar Py_PROTO((int start));
dfa *adddfa Py_PROTO((grammar *g, int type, char *name));
int addstate Py_PROTO((dfa *d));
void addarc Py_PROTO((dfa *d, int from, int to, int lbl));
dfa *PyGrammar_FindDFA Py_PROTO((grammar *g, int type));
char *typename Py_PROTO((grammar *g, int lbl));
grammar *newgrammar(int start);
dfa *adddfa(grammar *g, int type, char *name);
int addstate(dfa *d);
void addarc(dfa *d, int from, int to, int lbl);
dfa *PyGrammar_FindDFA(grammar *g, int type);
char *typename(grammar *g, int lbl);
int addlabel Py_PROTO((labellist *ll, int type, char *str));
int findlabel Py_PROTO((labellist *ll, int type, char *str));
char *PyGrammar_LabelRepr Py_PROTO((label *lb));
void translatelabels Py_PROTO((grammar *g));
int addlabel(labellist *ll, int type, char *str);
int findlabel(labellist *ll, int type, char *str);
char *PyGrammar_LabelRepr(label *lb);
void translatelabels(grammar *g);
void addfirstsets Py_PROTO((grammar *g));
void addfirstsets(grammar *g);
void PyGrammar_AddAccelerators Py_PROTO((grammar *g));
void PyGrammar_RemoveAccelerators Py_PROTO((grammar *));
void PyGrammar_AddAccelerators(grammar *g);
void PyGrammar_RemoveAccelerators(grammar *);
void printgrammar Py_PROTO((grammar *g, FILE *fp));
void printnonterminals Py_PROTO((grammar *g, FILE *fp));
void printgrammar(grammar *g, FILE *fp);
void printnonterminals(grammar *g, FILE *fp);
#ifdef __cplusplus
}
......
#ifndef Py_INTOBJECT_H
#define Py_INTOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
......@@ -29,20 +23,26 @@ The type PyIntObject is (unfortunately) exposed here so we can declare
_Py_TrueStruct and _Py_ZeroStruct below; don't use this.
*/
#ifndef Py_INTOBJECT_H
#define Py_INTOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_HEAD
long ob_ival;
PyObject_HEAD
long ob_ival;
} PyIntObject;
extern DL_IMPORT(PyTypeObject) PyInt_Type;
#define PyInt_Check(op) ((op)->ob_type == &PyInt_Type)
extern DL_IMPORT(PyObject *) PyInt_FromString Py_PROTO((char*, char**, int));
extern DL_IMPORT(PyObject *) PyInt_FromUnicode Py_PROTO((Py_UNICODE*, int, int));
extern DL_IMPORT(PyObject *) PyInt_FromLong Py_PROTO((long));
extern DL_IMPORT(long) PyInt_AsLong Py_PROTO((PyObject *));
extern DL_IMPORT(long) PyInt_GetMax Py_PROTO((void));
extern DL_IMPORT(PyObject *) PyInt_FromString(char*, char**, int);
extern DL_IMPORT(PyObject *) PyInt_FromUnicode(Py_UNICODE*, int, int);
extern DL_IMPORT(PyObject *) PyInt_FromLong(long);
extern DL_IMPORT(long) PyInt_AsLong(PyObject *);
extern DL_IMPORT(long) PyInt_GetMax(void);
/*
......@@ -68,8 +68,8 @@ extern DL_IMPORT(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct; /* Don't use these
* into the main Python shared library/DLL. Guido thinks I'm weird for
* building it this way. :-) [cjh]
*/
extern DL_IMPORT(unsigned long) PyOS_strtoul Py_PROTO((char *, char **, int));
extern DL_IMPORT(long) PyOS_strtol Py_PROTO((char *, char **, int));
extern DL_IMPORT(unsigned long) PyOS_strtoul(char *, char **, int);
extern DL_IMPORT(long) PyOS_strtol(char *, char **, int);
#ifdef __cplusplus
}
......
#ifndef Py_LISTOBJECT_H
#define Py_LISTOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
......@@ -28,26 +22,32 @@ inserted in the list. Similarly, PyList_GetItem does not increment the
returned item's reference count.
*/
#ifndef Py_LISTOBJECT_H
#define Py_LISTOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PyObject_VAR_HEAD
PyObject **ob_item;
PyObject_VAR_HEAD
PyObject **ob_item;
} PyListObject;
extern DL_IMPORT(PyTypeObject) PyList_Type;
#define PyList_Check(op) ((op)->ob_type == &PyList_Type)
extern DL_IMPORT(PyObject *) PyList_New Py_PROTO((int size));
extern DL_IMPORT(int) PyList_Size Py_PROTO((PyObject *));
extern DL_IMPORT(PyObject *) PyList_GetItem Py_PROTO((PyObject *, int));
extern DL_IMPORT(int) PyList_SetItem Py_PROTO((PyObject *, int, PyObject *));
extern DL_IMPORT(int) PyList_Insert Py_PROTO((PyObject *, int, PyObject *));
extern DL_IMPORT(int) PyList_Append Py_PROTO((PyObject *, PyObject *));
extern DL_IMPORT(PyObject *) PyList_GetSlice Py_PROTO((PyObject *, int, int));
extern DL_IMPORT(int) PyList_SetSlice Py_PROTO((PyObject *, int, int, PyObject *));
extern DL_IMPORT(int) PyList_Sort Py_PROTO((PyObject *));
extern DL_IMPORT(int) PyList_Reverse Py_PROTO((PyObject *));
extern DL_IMPORT(PyObject *) PyList_AsTuple Py_PROTO((PyObject *));
extern DL_IMPORT(PyObject *) PyList_New(int size);
extern DL_IMPORT(int) PyList_Size(PyObject *);
extern DL_IMPORT(PyObject *) PyList_GetItem(PyObject *, int);
extern DL_IMPORT(int) PyList_SetItem(PyObject *, int, PyObject *);
extern DL_IMPORT(int) PyList_Insert(PyObject *, int, PyObject *);
extern DL_IMPORT(int) PyList_Append(PyObject *, PyObject *);
extern DL_IMPORT(PyObject *) PyList_GetSlice(PyObject *, int, int);
extern DL_IMPORT(int) PyList_SetSlice(PyObject *, int, int, PyObject *);
extern DL_IMPORT(int) PyList_Sort(PyObject *);
extern DL_IMPORT(int) PyList_Reverse(PyObject *);
extern DL_IMPORT(PyObject *) PyList_AsTuple(PyObject *);
/* Macro, trading safety for speed */
#define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
......
#ifndef Py_METHODOBJECT_H
#define Py_METHODOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
......@@ -16,6 +10,12 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
/* Method object interface */
#ifndef Py_METHODOBJECT_H
#define Py_METHODOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
extern DL_IMPORT(PyTypeObject) PyCFunction_Type;
#define PyCFunction_Check(op) ((op)->ob_type == &PyCFunction_Type)
......@@ -24,9 +24,9 @@ typedef PyObject *(*PyCFunction) Py_FPROTO((PyObject *, PyObject *));
typedef PyObject *(*PyCFunctionWithKeywords)
Py_FPROTO((PyObject *, PyObject *, PyObject *));
extern DL_IMPORT(PyCFunction) PyCFunction_GetFunction Py_PROTO((PyObject *));
extern DL_IMPORT(PyObject *) PyCFunction_GetSelf Py_PROTO((PyObject *));
extern DL_IMPORT(int) PyCFunction_GetFlags Py_PROTO((PyObject *));
extern DL_IMPORT(PyCFunction) PyCFunction_GetFunction(PyObject *);
extern DL_IMPORT(PyObject *) PyCFunction_GetSelf(PyObject *);
extern DL_IMPORT(int) PyCFunction_GetFlags(PyObject *);
/* Macros for direct access to these values. Type checks are *not*
done, so use with care. */
......@@ -38,35 +38,33 @@ extern DL_IMPORT(int) PyCFunction_GetFlags Py_PROTO((PyObject *));
(((PyCFunctionObject *)func) -> m_ml -> ml_flags)
struct PyMethodDef {
char *ml_name;
PyCFunction ml_meth;
int ml_flags;
char *ml_doc;
char *ml_name;
PyCFunction ml_meth;
int ml_flags;
char *ml_doc;
};
typedef struct PyMethodDef PyMethodDef;
extern DL_IMPORT(PyObject *) Py_FindMethod
Py_PROTO((PyMethodDef[], PyObject *, char *));
extern DL_IMPORT(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, char *);
extern DL_IMPORT(PyObject *) PyCFunction_New
Py_PROTO((PyMethodDef *, PyObject *));
extern DL_IMPORT(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *);
/* Flag passed to newmethodobject */
#define METH_VARARGS 0x0001
#define METH_KEYWORDS 0x0002
typedef struct PyMethodChain {
PyMethodDef *methods; /* Methods of this type */
struct PyMethodChain *link; /* NULL or base type */
PyMethodDef *methods; /* Methods of this type */
struct PyMethodChain *link; /* NULL or base type */
} PyMethodChain;
extern DL_IMPORT(PyObject *) Py_FindMethodInChain
Py_PROTO((PyMethodChain *, PyObject *, char *));
extern DL_IMPORT(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *,
char *);
typedef struct {
PyObject_HEAD
PyMethodDef *m_ml;
PyObject *m_self;
PyObject_HEAD
PyMethodDef *m_ml;
PyObject *m_self;
} PyCFunctionObject;
#ifdef __cplusplus
......
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