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

Commit a3f63eb

Browse files
committed
Run on Windows on Python 3.5
1 parent 93d4e80 commit a3f63eb

22 files changed

+193
-63
lines changed

ast27/Include/asdl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ typedef struct {
3434
#define _Py_asdl_seq_new asdl_seq_new
3535
#define _Py_asdl_int_seq_new asdl_int_seq_new
3636
#endif
37-
asdl_seq *asdl_seq_new(int size, PyArena *arena);
38-
asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena);
37+
asdl_seq *asdl_seq_new(Py_ssize_t size, PyArena *arena);
38+
asdl_int_seq *asdl_int_seq_new(Py_ssize_t size, PyArena *arena);
3939

4040
#define asdl_seq_GET(S, I) (S)->elements[(I)]
4141
#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)

ast27/Include/ast.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
extern "C" {
55
#endif
66

7-
PyAPI_FUNC(mod_ty) Ta27AST_FromNode(const node *, PyCompilerFlags *flags,
7+
mod_ty Ta27AST_FromNode(const node *, PyCompilerFlags *flags,
88
const char *, PyArena *);
99

1010
#ifdef __cplusplus

ast27/Include/node.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ typedef struct _node {
1616
struct _node *n_child;
1717
} node;
1818

19-
PyAPI_FUNC(node *) Ta27Node_New(int type);
20-
PyAPI_FUNC(int) Ta27Node_AddChild(node *n, int type,
21-
char *str, int lineno, int col_offset);
22-
PyAPI_FUNC(void) Ta27Node_Free(node *n);
23-
PyAPI_FUNC(Py_ssize_t) _Ta27Node_SizeOf(node *n);
19+
node *Ta27Node_New(int type);
20+
int Ta27Node_AddChild(node *n, int type,
21+
char *str, int lineno, int col_offset);
22+
void Ta27Node_Free(node *n);
23+
Py_ssize_t _Ta27Node_SizeOf(node *n);
2424

2525
/* Node access functions */
2626
#define NCH(n) ((n)->n_nchildren)

ast27/Include/parsetok.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,30 +33,30 @@ typedef struct {
3333
#define PyPARSE_IGNORE_COOKIE 0x0010
3434

3535

36-
PyAPI_FUNC(node *) Ta27Parser_ParseString(const char *, grammar *, int,
37-
perrdetail *);
38-
PyAPI_FUNC(node *) Ta27Parser_ParseFile (FILE *, const char *, grammar *, int,
39-
char *, char *, perrdetail *);
36+
node *Ta27Parser_ParseString(const char *, grammar *, int,
37+
perrdetail *);
38+
node *Ta27Parser_ParseFile (FILE *, const char *, grammar *, int,
39+
char *, char *, perrdetail *);
4040

41-
PyAPI_FUNC(node *) Ta27Parser_ParseStringFlags(const char *, grammar *, int,
42-
perrdetail *, int);
43-
PyAPI_FUNC(node *) Ta27Parser_ParseFileFlags(FILE *, const char *, grammar *,
44-
int, char *, char *,
45-
perrdetail *, int);
46-
PyAPI_FUNC(node *) Ta27Parser_ParseFileFlagsEx(FILE *, const char *, grammar *,
47-
int, char *, char *,
48-
perrdetail *, int *);
41+
node *Ta27Parser_ParseStringFlags(const char *, grammar *, int,
42+
perrdetail *, int);
43+
node *Ta27Parser_ParseFileFlags(FILE *, const char *, grammar *,
44+
int, char *, char *,
45+
perrdetail *, int);
46+
node *Ta27Parser_ParseFileFlagsEx(FILE *, const char *, grammar *,
47+
int, char *, char *,
48+
perrdetail *, int *);
4949

50-
PyAPI_FUNC(node *) Ta27Parser_ParseStringFlagsFilename(const char *,
51-
const char *,
52-
grammar *, int,
53-
perrdetail *, int);
54-
PyAPI_FUNC(node *) Ta27Parser_ParseStringFlagsFilenameEx(const char *,
50+
node *Ta27Parser_ParseStringFlagsFilename(const char *,
51+
const char *,
52+
grammar *, int,
53+
perrdetail *, int);
54+
node *Ta27Parser_ParseStringFlagsFilenameEx(const char *,
5555
const char *,
5656
grammar *, int,
5757
perrdetail *, int *);
5858

59-
PyAPI_FUNC(node *) Ta27Parser_ParseStringObject(
59+
node *Ta27Parser_ParseStringObject(
6060
const char *s,
6161
PyObject *filename,
6262
grammar *g,

ast27/Include/token.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ extern "C" {
7777
#define ISEOF(x) ((x) == ENDMARKER)
7878

7979

80-
PyAPI_DATA(char *) _Ta27Parser_TokenNames[]; /* Token names */
81-
PyAPI_FUNC(int) Ta27Token_OneChar(int);
82-
PyAPI_FUNC(int) Ta27Token_TwoChars(int, int);
83-
PyAPI_FUNC(int) Ta27Token_ThreeChars(int, int, int);
80+
extern char *_Ta27Parser_TokenNames[]; /* Token names */
81+
int Ta27Token_OneChar(int);
82+
int Ta27Token_TwoChars(int, int);
83+
int Ta27Token_ThreeChars(int, int, int);
8484

8585
#ifdef __cplusplus
8686
}

ast27/Parser/asdl_c.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ def visitModule(self, mod):
667667
};
668668
669669
static PyTypeObject AST_type = {
670-
PyVarObject_HEAD_INIT(&PyType_Type, 0)
670+
PyVarObject_HEAD_INIT(NULL, 0)
671671
"_ast27.AST",
672672
sizeof(PyObject),
673673
0,

ast27/Parser/grammar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <unixlib.h>
1414
#endif
1515

16-
extern int Py_DebugFlag;
16+
PyAPI_DATA(int) Py_DebugFlag;
1717

1818
grammar *
1919
newgrammar(int start)

ast27/Parser/tokenizer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#endif /* PGEN */
2121

2222
#if PY_MINOR_VERSION >= 4
23-
extern char *PyOS_Readline(FILE *, FILE *, const char *);
23+
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
2424
#else
25-
extern char *PyOS_Readline(FILE *, FILE *, char *);
25+
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
2626
#endif
2727
/* Return malloc'ed string including trailing \n;
2828
empty malloc'ed string for EOF;

ast27/Python/Python-ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ static PyMethodDef ast_type_methods[] = {
476476
};
477477

478478
static PyTypeObject AST_type = {
479-
PyVarObject_HEAD_INIT(&PyType_Type, 0)
479+
PyVarObject_HEAD_INIT(NULL, 0)
480480
"_ast27.AST",
481481
sizeof(PyObject),
482482
0,

ast27/Python/asdl.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#include "Python.h"
2+
#include "asdl.h"
3+
4+
asdl_seq *
5+
_Py_asdl_seq_new(Py_ssize_t size, PyArena *arena)
6+
{
7+
asdl_seq *seq = NULL;
8+
size_t n;
9+
10+
/* check size is sane */
11+
if (size < 0 ||
12+
(size && (((size_t)size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
13+
PyErr_NoMemory();
14+
return NULL;
15+
}
16+
n = (size ? (sizeof(void *) * (size - 1)) : 0);
17+
18+
/* check if size can be added safely */
19+
if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
20+
PyErr_NoMemory();
21+
return NULL;
22+
}
23+
n += sizeof(asdl_seq);
24+
25+
seq = (asdl_seq *)PyArena_Malloc(arena, n);
26+
if (!seq) {
27+
PyErr_NoMemory();
28+
return NULL;
29+
}
30+
memset(seq, 0, n);
31+
seq->size = size;
32+
return seq;
33+
}
34+
35+
asdl_int_seq *
36+
_Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena)
37+
{
38+
asdl_int_seq *seq = NULL;
39+
size_t n;
40+
41+
/* check size is sane */
42+
if (size < 0 ||
43+
(size && (((size_t)size - 1) > (PY_SIZE_MAX / sizeof(void *))))) {
44+
PyErr_NoMemory();
45+
return NULL;
46+
}
47+
n = (size ? (sizeof(void *) * (size - 1)) : 0);
48+
49+
/* check if size can be added safely */
50+
if (n > PY_SIZE_MAX - sizeof(asdl_seq)) {
51+
PyErr_NoMemory();
52+
return NULL;
53+
}
54+
n += sizeof(asdl_seq);
55+
56+
seq = (asdl_int_seq *)PyArena_Malloc(arena, n);
57+
if (!seq) {
58+
PyErr_NoMemory();
59+
return NULL;
60+
}
61+
memset(seq, 0, n);
62+
seq->size = size;
63+
return seq;
64+
}

ast27/Python/graminit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "pgenheaders.h"
44
#include "grammar.h"
5-
PyAPI_DATA(grammar) _Ta27Parser_Grammar;
5+
grammar _Ta27Parser_Grammar;
66
static arc arcs_0_0[3] = {
77
{2, 1},
88
{3, 1},

ast35/Include/ast.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
extern "C" {
55
#endif
66

7-
PyAPI_FUNC(int) Ta35AST_Validate(mod_ty);
8-
PyAPI_FUNC(mod_ty) Ta35AST_FromNode(
7+
int Ta35AST_Validate(mod_ty);
8+
mod_ty Ta35AST_FromNode(
99
const node *n,
1010
PyCompilerFlags *flags,
1111
const char *filename, /* decoded from the filesystem encoding */
1212
PyArena *arena);
13-
PyAPI_FUNC(mod_ty) Ta35AST_FromNodeObject(
13+
mod_ty Ta35AST_FromNodeObject(
1414
const node *n,
1515
PyCompilerFlags *flags,
1616
PyObject *filename,

ast35/Include/node.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ typedef struct _node {
1616
struct _node *n_child;
1717
} node;
1818

19-
PyAPI_FUNC(node *) Ta35Node_New(int type);
20-
PyAPI_FUNC(int) Ta35Node_AddChild(node *n, int type,
19+
node *Ta35Node_New(int type);
20+
int Ta35Node_AddChild(node *n, int type,
2121
char *str, int lineno, int col_offset);
22-
PyAPI_FUNC(void) Ta35Node_Free(node *n);
22+
void Ta35Node_Free(node *n);
2323
#ifndef Py_LIMITED_API
24-
PyAPI_FUNC(Py_ssize_t) _Ta35Node_SizeOf(node *n);
24+
Py_ssize_t _Ta35Node_SizeOf(node *n);
2525
#endif
2626

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

39-
PyAPI_FUNC(void) Ta35Node_ListTree(node *);
39+
void Ta35Node_ListTree(node *);
4040

4141
#ifdef __cplusplus
4242
}

ast35/Include/parsetok.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ typedef struct {
3535
#define PyPARSE_IGNORE_COOKIE 0x0010
3636
#define PyPARSE_BARRY_AS_BDFL 0x0020
3737

38-
PyAPI_FUNC(node *) Ta35Parser_ParseString(const char *, grammar *, int,
38+
node *Ta35Parser_ParseString(const char *, grammar *, int,
3939
perrdetail *);
40-
PyAPI_FUNC(node *) Ta35Parser_ParseFile (FILE *, const char *, grammar *, int,
40+
node *Ta35Parser_ParseFile (FILE *, const char *, grammar *, int,
4141
const char *, const char *,
4242
perrdetail *);
4343

44-
PyAPI_FUNC(node *) Ta35Parser_ParseStringFlags(const char *, grammar *, int,
44+
node *Ta35Parser_ParseStringFlags(const char *, grammar *, int,
4545
perrdetail *, int);
46-
PyAPI_FUNC(node *) Ta35Parser_ParseFileFlags(
46+
node *Ta35Parser_ParseFileFlags(
4747
FILE *fp,
4848
const char *filename, /* decoded from the filesystem encoding */
4949
const char *enc,
@@ -53,7 +53,7 @@ PyAPI_FUNC(node *) Ta35Parser_ParseFileFlags(
5353
const char *ps2,
5454
perrdetail *err_ret,
5555
int flags);
56-
PyAPI_FUNC(node *) Ta35Parser_ParseFileFlagsEx(
56+
node *Ta35Parser_ParseFileFlagsEx(
5757
FILE *fp,
5858
const char *filename, /* decoded from the filesystem encoding */
5959
const char *enc,
@@ -63,7 +63,7 @@ PyAPI_FUNC(node *) Ta35Parser_ParseFileFlagsEx(
6363
const char *ps2,
6464
perrdetail *err_ret,
6565
int *flags);
66-
PyAPI_FUNC(node *) Ta35Parser_ParseFileObject(
66+
node *Ta35Parser_ParseFileObject(
6767
FILE *fp,
6868
PyObject *filename,
6969
const char *enc,
@@ -74,21 +74,21 @@ PyAPI_FUNC(node *) Ta35Parser_ParseFileObject(
7474
perrdetail *err_ret,
7575
int *flags);
7676

77-
PyAPI_FUNC(node *) Ta35Parser_ParseStringFlagsFilename(
77+
node *Ta35Parser_ParseStringFlagsFilename(
7878
const char *s,
7979
const char *filename, /* decoded from the filesystem encoding */
8080
grammar *g,
8181
int start,
8282
perrdetail *err_ret,
8383
int flags);
84-
PyAPI_FUNC(node *) Ta35Parser_ParseStringFlagsFilenameEx(
84+
node *Ta35Parser_ParseStringFlagsFilenameEx(
8585
const char *s,
8686
const char *filename, /* decoded from the filesystem encoding */
8787
grammar *g,
8888
int start,
8989
perrdetail *err_ret,
9090
int *flags);
91-
PyAPI_FUNC(node *) Ta35Parser_ParseStringObject(
91+
node *Ta35Parser_ParseStringObject(
9292
const char *s,
9393
PyObject *filename,
9494
grammar *g,

ast35/Include/token.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ extern "C" {
8080
#define ISEOF(x) ((x) == ENDMARKER)
8181

8282

83-
PyAPI_DATA(const char *) _Ta35Parser_TokenNames[]; /* Token names */
84-
PyAPI_FUNC(int) Ta35Token_OneChar(int);
85-
PyAPI_FUNC(int) Ta35Token_TwoChars(int, int);
86-
PyAPI_FUNC(int) Ta35Token_ThreeChars(int, int, int);
83+
extern const char *_Ta35Parser_TokenNames[]; /* Token names */
84+
int Ta35Token_OneChar(int);
85+
int Ta35Token_TwoChars(int, int);
86+
int Ta35Token_ThreeChars(int, int, int);
8787

8888
#ifdef __cplusplus
8989
}

ast35/Parser/asdl_c.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ def visitModule(self, mod):
724724
};
725725
726726
static PyTypeObject AST_type = {
727-
PyVarObject_HEAD_INIT(&PyType_Type, 0)
727+
PyVarObject_HEAD_INIT(NULL, 0)
728728
"_ast35.AST",
729729
sizeof(AST_object),
730730
0,

ast35/Parser/grammar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "token.h"
1010
#include "grammar.h"
1111

12-
extern int Py_DebugFlag;
12+
PyAPI_DATA(int) Py_DebugFlag;
1313

1414
grammar *
1515
newgrammar(int start)

ast35/Parser/tokenizer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
|| (c >= 128))
3333

3434
#if PY_MINOR_VERSION >= 4
35-
extern char *PyOS_Readline(FILE *, FILE *, const char *);
35+
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
3636
#else
37-
extern char *PyOS_Readline(FILE *, FILE *, char *);
37+
PyAPY_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
3838
#endif
3939
/* Return malloc'ed string including trailing \n;
4040
empty malloc'ed string for EOF;

ast35/Python/Python-ast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ static PyGetSetDef ast_type_getsets[] = {
610610
};
611611

612612
static PyTypeObject AST_type = {
613-
PyVarObject_HEAD_INIT(&PyType_Type, 0)
613+
PyVarObject_HEAD_INIT(NULL, 0)
614614
"_ast35.AST",
615615
sizeof(AST_object),
616616
0,

0 commit comments

Comments
 (0)