Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
Run on Windows on Python 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ddfisher committed Jan 5, 2017
1 parent 93d4e80 commit a3f63eb
Show file tree
Hide file tree
Showing 22 changed files with 193 additions and 63 deletions.
4 changes: 2 additions & 2 deletions ast27/Include/asdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ typedef struct {
#define _Py_asdl_seq_new asdl_seq_new
#define _Py_asdl_int_seq_new asdl_int_seq_new
#endif
asdl_seq *asdl_seq_new(int size, PyArena *arena);
asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena);
asdl_seq *asdl_seq_new(Py_ssize_t size, PyArena *arena);
asdl_int_seq *asdl_int_seq_new(Py_ssize_t size, PyArena *arena);

#define asdl_seq_GET(S, I) (S)->elements[(I)]
#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
Expand Down
2 changes: 1 addition & 1 deletion ast27/Include/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
extern "C" {
#endif

PyAPI_FUNC(mod_ty) Ta27AST_FromNode(const node *, PyCompilerFlags *flags,
mod_ty Ta27AST_FromNode(const node *, PyCompilerFlags *flags,
const char *, PyArena *);

#ifdef __cplusplus
Expand Down
10 changes: 5 additions & 5 deletions ast27/Include/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ typedef struct _node {
struct _node *n_child;
} node;

PyAPI_FUNC(node *) Ta27Node_New(int type);
PyAPI_FUNC(int) Ta27Node_AddChild(node *n, int type,
char *str, int lineno, int col_offset);
PyAPI_FUNC(void) Ta27Node_Free(node *n);
PyAPI_FUNC(Py_ssize_t) _Ta27Node_SizeOf(node *n);
node *Ta27Node_New(int type);
int Ta27Node_AddChild(node *n, int type,
char *str, int lineno, int col_offset);
void Ta27Node_Free(node *n);
Py_ssize_t _Ta27Node_SizeOf(node *n);

/* Node access functions */
#define NCH(n) ((n)->n_nchildren)
Expand Down
36 changes: 18 additions & 18 deletions ast27/Include/parsetok.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,30 @@ typedef struct {
#define PyPARSE_IGNORE_COOKIE 0x0010


PyAPI_FUNC(node *) Ta27Parser_ParseString(const char *, grammar *, int,
perrdetail *);
PyAPI_FUNC(node *) Ta27Parser_ParseFile (FILE *, const char *, grammar *, int,
char *, char *, perrdetail *);
node *Ta27Parser_ParseString(const char *, grammar *, int,
perrdetail *);
node *Ta27Parser_ParseFile (FILE *, const char *, grammar *, int,
char *, char *, perrdetail *);

PyAPI_FUNC(node *) Ta27Parser_ParseStringFlags(const char *, grammar *, int,
perrdetail *, int);
PyAPI_FUNC(node *) Ta27Parser_ParseFileFlags(FILE *, const char *, grammar *,
int, char *, char *,
perrdetail *, int);
PyAPI_FUNC(node *) Ta27Parser_ParseFileFlagsEx(FILE *, const char *, grammar *,
int, char *, char *,
perrdetail *, int *);
node *Ta27Parser_ParseStringFlags(const char *, grammar *, int,
perrdetail *, int);
node *Ta27Parser_ParseFileFlags(FILE *, const char *, grammar *,
int, char *, char *,
perrdetail *, int);
node *Ta27Parser_ParseFileFlagsEx(FILE *, const char *, grammar *,
int, char *, char *,
perrdetail *, int *);

PyAPI_FUNC(node *) Ta27Parser_ParseStringFlagsFilename(const char *,
const char *,
grammar *, int,
perrdetail *, int);
PyAPI_FUNC(node *) Ta27Parser_ParseStringFlagsFilenameEx(const char *,
node *Ta27Parser_ParseStringFlagsFilename(const char *,
const char *,
grammar *, int,
perrdetail *, int);
node *Ta27Parser_ParseStringFlagsFilenameEx(const char *,
const char *,
grammar *, int,
perrdetail *, int *);

PyAPI_FUNC(node *) Ta27Parser_ParseStringObject(
node *Ta27Parser_ParseStringObject(
const char *s,
PyObject *filename,
grammar *g,
Expand Down
8 changes: 4 additions & 4 deletions ast27/Include/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ extern "C" {
#define ISEOF(x) ((x) == ENDMARKER)


PyAPI_DATA(char *) _Ta27Parser_TokenNames[]; /* Token names */
PyAPI_FUNC(int) Ta27Token_OneChar(int);
PyAPI_FUNC(int) Ta27Token_TwoChars(int, int);
PyAPI_FUNC(int) Ta27Token_ThreeChars(int, int, int);
extern char *_Ta27Parser_TokenNames[]; /* Token names */
int Ta27Token_OneChar(int);
int Ta27Token_TwoChars(int, int);
int Ta27Token_ThreeChars(int, int, int);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion ast27/Parser/asdl_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def visitModule(self, mod):
};
static PyTypeObject AST_type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
PyVarObject_HEAD_INIT(NULL, 0)
"_ast27.AST",
sizeof(PyObject),
0,
Expand Down
2 changes: 1 addition & 1 deletion ast27/Parser/grammar.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include <unixlib.h>
#endif

extern int Py_DebugFlag;
PyAPI_DATA(int) Py_DebugFlag;

grammar *
newgrammar(int start)
Expand Down
4 changes: 2 additions & 2 deletions ast27/Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#endif /* PGEN */

#if PY_MINOR_VERSION >= 4
extern char *PyOS_Readline(FILE *, FILE *, const char *);
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
#else
extern char *PyOS_Readline(FILE *, FILE *, char *);
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
#endif
/* Return malloc'ed string including trailing \n;
empty malloc'ed string for EOF;
Expand Down
2 changes: 1 addition & 1 deletion ast27/Python/Python-ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ static PyMethodDef ast_type_methods[] = {
};

static PyTypeObject AST_type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
PyVarObject_HEAD_INIT(NULL, 0)
"_ast27.AST",
sizeof(PyObject),
0,
Expand Down
64 changes: 64 additions & 0 deletions ast27/Python/asdl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "Python.h"
#include "asdl.h"

asdl_seq *
_Py_asdl_seq_new(Py_ssize_t size, PyArena *arena)
{
asdl_seq *seq = NULL;
size_t n;

/* check size is sane */
if (size < 0 ||
(size && (((size_t)size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
PyErr_NoMemory();
return NULL;
}
n = (size ? (sizeof(void *) * (size - 1)) : 0);

/* check if size can be added safely */
if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
PyErr_NoMemory();
return NULL;
}
n += sizeof(asdl_seq);

seq = (asdl_seq *)PyArena_Malloc(arena, n);
if (!seq) {
PyErr_NoMemory();
return NULL;
}
memset(seq, 0, n);
seq->size = size;
return seq;
}

asdl_int_seq *
_Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena)
{
asdl_int_seq *seq = NULL;
size_t n;

/* check size is sane */
if (size < 0 ||
(size && (((size_t)size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
PyErr_NoMemory();
return NULL;
}
n = (size ? (sizeof(void *) * (size - 1)) : 0);

/* check if size can be added safely */
if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
PyErr_NoMemory();
return NULL;
}
n += sizeof(asdl_seq);

seq = (asdl_int_seq *)PyArena_Malloc(arena, n);
if (!seq) {
PyErr_NoMemory();
return NULL;
}
memset(seq, 0, n);
seq->size = size;
return seq;
}
2 changes: 1 addition & 1 deletion ast27/Python/graminit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "pgenheaders.h"
#include "grammar.h"
PyAPI_DATA(grammar) _Ta27Parser_Grammar;
grammar _Ta27Parser_Grammar;
static arc arcs_0_0[3] = {
{2, 1},
{3, 1},
Expand Down
6 changes: 3 additions & 3 deletions ast35/Include/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
extern "C" {
#endif

PyAPI_FUNC(int) Ta35AST_Validate(mod_ty);
PyAPI_FUNC(mod_ty) Ta35AST_FromNode(
int Ta35AST_Validate(mod_ty);
mod_ty Ta35AST_FromNode(
const node *n,
PyCompilerFlags *flags,
const char *filename, /* decoded from the filesystem encoding */
PyArena *arena);
PyAPI_FUNC(mod_ty) Ta35AST_FromNodeObject(
mod_ty Ta35AST_FromNodeObject(
const node *n,
PyCompilerFlags *flags,
PyObject *filename,
Expand Down
10 changes: 5 additions & 5 deletions ast35/Include/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ typedef struct _node {
struct _node *n_child;
} node;

PyAPI_FUNC(node *) Ta35Node_New(int type);
PyAPI_FUNC(int) Ta35Node_AddChild(node *n, int type,
node *Ta35Node_New(int type);
int Ta35Node_AddChild(node *n, int type,
char *str, int lineno, int col_offset);
PyAPI_FUNC(void) Ta35Node_Free(node *n);
void Ta35Node_Free(node *n);
#ifndef Py_LIMITED_API
PyAPI_FUNC(Py_ssize_t) _Ta35Node_SizeOf(node *n);
Py_ssize_t _Ta35Node_SizeOf(node *n);
#endif

/* Node access functions */
Expand All @@ -36,7 +36,7 @@ PyAPI_FUNC(Py_ssize_t) _Ta35Node_SizeOf(node *n);
/* Assert that the type of a node is what we expect */
#define REQ(n, type) assert(TYPE(n) == (type))

PyAPI_FUNC(void) Ta35Node_ListTree(node *);
void Ta35Node_ListTree(node *);

#ifdef __cplusplus
}
Expand Down
18 changes: 9 additions & 9 deletions ast35/Include/parsetok.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ typedef struct {
#define PyPARSE_IGNORE_COOKIE 0x0010
#define PyPARSE_BARRY_AS_BDFL 0x0020

PyAPI_FUNC(node *) Ta35Parser_ParseString(const char *, grammar *, int,
node *Ta35Parser_ParseString(const char *, grammar *, int,
perrdetail *);
PyAPI_FUNC(node *) Ta35Parser_ParseFile (FILE *, const char *, grammar *, int,
node *Ta35Parser_ParseFile (FILE *, const char *, grammar *, int,
const char *, const char *,
perrdetail *);

PyAPI_FUNC(node *) Ta35Parser_ParseStringFlags(const char *, grammar *, int,
node *Ta35Parser_ParseStringFlags(const char *, grammar *, int,
perrdetail *, int);
PyAPI_FUNC(node *) Ta35Parser_ParseFileFlags(
node *Ta35Parser_ParseFileFlags(
FILE *fp,
const char *filename, /* decoded from the filesystem encoding */
const char *enc,
Expand All @@ -53,7 +53,7 @@ PyAPI_FUNC(node *) Ta35Parser_ParseFileFlags(
const char *ps2,
perrdetail *err_ret,
int flags);
PyAPI_FUNC(node *) Ta35Parser_ParseFileFlagsEx(
node *Ta35Parser_ParseFileFlagsEx(
FILE *fp,
const char *filename, /* decoded from the filesystem encoding */
const char *enc,
Expand All @@ -63,7 +63,7 @@ PyAPI_FUNC(node *) Ta35Parser_ParseFileFlagsEx(
const char *ps2,
perrdetail *err_ret,
int *flags);
PyAPI_FUNC(node *) Ta35Parser_ParseFileObject(
node *Ta35Parser_ParseFileObject(
FILE *fp,
PyObject *filename,
const char *enc,
Expand All @@ -74,21 +74,21 @@ PyAPI_FUNC(node *) Ta35Parser_ParseFileObject(
perrdetail *err_ret,
int *flags);

PyAPI_FUNC(node *) Ta35Parser_ParseStringFlagsFilename(
node *Ta35Parser_ParseStringFlagsFilename(
const char *s,
const char *filename, /* decoded from the filesystem encoding */
grammar *g,
int start,
perrdetail *err_ret,
int flags);
PyAPI_FUNC(node *) Ta35Parser_ParseStringFlagsFilenameEx(
node *Ta35Parser_ParseStringFlagsFilenameEx(
const char *s,
const char *filename, /* decoded from the filesystem encoding */
grammar *g,
int start,
perrdetail *err_ret,
int *flags);
PyAPI_FUNC(node *) Ta35Parser_ParseStringObject(
node *Ta35Parser_ParseStringObject(
const char *s,
PyObject *filename,
grammar *g,
Expand Down
8 changes: 4 additions & 4 deletions ast35/Include/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ extern "C" {
#define ISEOF(x) ((x) == ENDMARKER)


PyAPI_DATA(const char *) _Ta35Parser_TokenNames[]; /* Token names */
PyAPI_FUNC(int) Ta35Token_OneChar(int);
PyAPI_FUNC(int) Ta35Token_TwoChars(int, int);
PyAPI_FUNC(int) Ta35Token_ThreeChars(int, int, int);
extern const char *_Ta35Parser_TokenNames[]; /* Token names */
int Ta35Token_OneChar(int);
int Ta35Token_TwoChars(int, int);
int Ta35Token_ThreeChars(int, int, int);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion ast35/Parser/asdl_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def visitModule(self, mod):
};
static PyTypeObject AST_type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
PyVarObject_HEAD_INIT(NULL, 0)
"_ast35.AST",
sizeof(AST_object),
0,
Expand Down
2 changes: 1 addition & 1 deletion ast35/Parser/grammar.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "token.h"
#include "grammar.h"

extern int Py_DebugFlag;
PyAPI_DATA(int) Py_DebugFlag;

grammar *
newgrammar(int start)
Expand Down
4 changes: 2 additions & 2 deletions ast35/Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
|| (c >= 128))

#if PY_MINOR_VERSION >= 4
extern char *PyOS_Readline(FILE *, FILE *, const char *);
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
#else
extern char *PyOS_Readline(FILE *, FILE *, char *);
PyAPY_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
#endif
/* Return malloc'ed string including trailing \n;
empty malloc'ed string for EOF;
Expand Down
2 changes: 1 addition & 1 deletion ast35/Python/Python-ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ static PyGetSetDef ast_type_getsets[] = {
};

static PyTypeObject AST_type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
PyVarObject_HEAD_INIT(NULL, 0)
"_ast35.AST",
sizeof(AST_object),
0,
Expand Down
Loading

0 comments on commit a3f63eb

Please sign in to comment.