Compile extensions in test_peg_generator with C99 (GH-19668)
This commit is contained in:
parent
1def7754b7
commit
0b7829e089
@ -275,8 +275,7 @@ static inline void shift_arg(expr_ty parent, arg_ty n, int line, int col) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void fstring_shift_seq_locations(expr_ty parent, asdl_seq *seq, int lineno, int col_offset) {
|
static void fstring_shift_seq_locations(expr_ty parent, asdl_seq *seq, int lineno, int col_offset) {
|
||||||
Py_ssize_t i;
|
for (Py_ssize_t i = 0, l = asdl_seq_LEN(seq); i < l; i++) {
|
||||||
for (i = 0; i < asdl_seq_LEN(seq); i++) {
|
|
||||||
expr_ty expr = asdl_seq_GET(seq, i);
|
expr_ty expr = asdl_seq_GET(seq, i);
|
||||||
if (expr == NULL){
|
if (expr == NULL){
|
||||||
continue;
|
continue;
|
||||||
@ -323,13 +322,12 @@ static void fstring_shift_argument(expr_ty parent, arg_ty arg, int lineno, int c
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void fstring_shift_arguments(expr_ty parent, arguments_ty args, int lineno, int col_offset) {
|
static void fstring_shift_arguments(expr_ty parent, arguments_ty args, int lineno, int col_offset) {
|
||||||
Py_ssize_t i;
|
for (Py_ssize_t i = 0, l = asdl_seq_LEN(args->posonlyargs); i < l; i++) {
|
||||||
for (i = 0; i < asdl_seq_LEN(args->posonlyargs); i++) {
|
|
||||||
arg_ty arg = asdl_seq_GET(args->posonlyargs, i);
|
arg_ty arg = asdl_seq_GET(args->posonlyargs, i);
|
||||||
shift_arg(parent, arg, lineno, col_offset);
|
shift_arg(parent, arg, lineno, col_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < asdl_seq_LEN(args->args); i++) {
|
for (Py_ssize_t i = 0, l = asdl_seq_LEN(args->args); i < l; i++) {
|
||||||
arg_ty arg = asdl_seq_GET(args->args, i);
|
arg_ty arg = asdl_seq_GET(args->args, i);
|
||||||
shift_arg(parent, arg, lineno, col_offset);
|
shift_arg(parent, arg, lineno, col_offset);
|
||||||
}
|
}
|
||||||
@ -338,7 +336,7 @@ static void fstring_shift_arguments(expr_ty parent, arguments_ty args, int linen
|
|||||||
shift_arg(parent, args->vararg, lineno, col_offset);
|
shift_arg(parent, args->vararg, lineno, col_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < asdl_seq_LEN(args->kwonlyargs); i++) {
|
for (Py_ssize_t i = 0, l = asdl_seq_LEN(args->kwonlyargs); i < l; i++) {
|
||||||
arg_ty arg = asdl_seq_GET(args->kwonlyargs, i);
|
arg_ty arg = asdl_seq_GET(args->kwonlyargs, i);
|
||||||
shift_arg(parent, arg, lineno, col_offset);
|
shift_arg(parent, arg, lineno, col_offset);
|
||||||
}
|
}
|
||||||
@ -353,7 +351,6 @@ static void fstring_shift_arguments(expr_ty parent, arguments_ty args, int linen
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void fstring_shift_children_locations(expr_ty n, int lineno, int col_offset) {
|
static void fstring_shift_children_locations(expr_ty n, int lineno, int col_offset) {
|
||||||
Py_ssize_t i;
|
|
||||||
switch (n->kind) {
|
switch (n->kind) {
|
||||||
case BoolOp_kind:
|
case BoolOp_kind:
|
||||||
fstring_shift_seq_locations(n, n->v.BoolOp.values, lineno, col_offset);
|
fstring_shift_seq_locations(n, n->v.BoolOp.values, lineno, col_offset);
|
||||||
@ -387,14 +384,14 @@ static void fstring_shift_children_locations(expr_ty n, int lineno, int col_offs
|
|||||||
break;
|
break;
|
||||||
case ListComp_kind:
|
case ListComp_kind:
|
||||||
shift_expr(n, n->v.ListComp.elt, lineno, col_offset);
|
shift_expr(n, n->v.ListComp.elt, lineno, col_offset);
|
||||||
for (i = 0; i < asdl_seq_LEN(n->v.ListComp.generators); i++) {
|
for (Py_ssize_t i = 0, l = asdl_seq_LEN(n->v.ListComp.generators); i < l; i++) {
|
||||||
comprehension_ty comp = asdl_seq_GET(n->v.ListComp.generators, i);
|
comprehension_ty comp = asdl_seq_GET(n->v.ListComp.generators, i);
|
||||||
fstring_shift_comprehension(n, comp, lineno, col_offset);
|
fstring_shift_comprehension(n, comp, lineno, col_offset);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SetComp_kind:
|
case SetComp_kind:
|
||||||
shift_expr(n, n->v.SetComp.elt, lineno, col_offset);
|
shift_expr(n, n->v.SetComp.elt, lineno, col_offset);
|
||||||
for (i = 0; i < asdl_seq_LEN(n->v.SetComp.generators); i++) {
|
for (Py_ssize_t i = 0, l = asdl_seq_LEN(n->v.SetComp.generators); i < l; i++) {
|
||||||
comprehension_ty comp = asdl_seq_GET(n->v.SetComp.generators, i);
|
comprehension_ty comp = asdl_seq_GET(n->v.SetComp.generators, i);
|
||||||
fstring_shift_comprehension(n, comp, lineno, col_offset);
|
fstring_shift_comprehension(n, comp, lineno, col_offset);
|
||||||
}
|
}
|
||||||
@ -402,14 +399,14 @@ static void fstring_shift_children_locations(expr_ty n, int lineno, int col_offs
|
|||||||
case DictComp_kind:
|
case DictComp_kind:
|
||||||
shift_expr(n, n->v.DictComp.key, lineno, col_offset);
|
shift_expr(n, n->v.DictComp.key, lineno, col_offset);
|
||||||
shift_expr(n, n->v.DictComp.value, lineno, col_offset);
|
shift_expr(n, n->v.DictComp.value, lineno, col_offset);
|
||||||
for (i = 0; i < asdl_seq_LEN(n->v.DictComp.generators); i++) {
|
for (Py_ssize_t i = 0, l = asdl_seq_LEN(n->v.DictComp.generators); i < l; i++) {
|
||||||
comprehension_ty comp = asdl_seq_GET(n->v.DictComp.generators, i);
|
comprehension_ty comp = asdl_seq_GET(n->v.DictComp.generators, i);
|
||||||
fstring_shift_comprehension(n, comp, lineno, col_offset);
|
fstring_shift_comprehension(n, comp, lineno, col_offset);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GeneratorExp_kind:
|
case GeneratorExp_kind:
|
||||||
shift_expr(n, n->v.GeneratorExp.elt, lineno, col_offset);
|
shift_expr(n, n->v.GeneratorExp.elt, lineno, col_offset);
|
||||||
for (i = 0; i < asdl_seq_LEN(n->v.GeneratorExp.generators); i++) {
|
for (Py_ssize_t i = 0, l = asdl_seq_LEN(n->v.GeneratorExp.generators); i < l; i++) {
|
||||||
comprehension_ty comp = asdl_seq_GET(n->v.GeneratorExp.generators, i);
|
comprehension_ty comp = asdl_seq_GET(n->v.GeneratorExp.generators, i);
|
||||||
fstring_shift_comprehension(n, comp, lineno, col_offset);
|
fstring_shift_comprehension(n, comp, lineno, col_offset);
|
||||||
}
|
}
|
||||||
@ -430,7 +427,7 @@ static void fstring_shift_children_locations(expr_ty n, int lineno, int col_offs
|
|||||||
case Call_kind:
|
case Call_kind:
|
||||||
shift_expr(n, n->v.Call.func, lineno, col_offset);
|
shift_expr(n, n->v.Call.func, lineno, col_offset);
|
||||||
fstring_shift_seq_locations(n, n->v.Call.args, lineno, col_offset);
|
fstring_shift_seq_locations(n, n->v.Call.args, lineno, col_offset);
|
||||||
for (i = 0; i < asdl_seq_LEN(n->v.Call.keywords); i++) {
|
for (Py_ssize_t i = 0, l = asdl_seq_LEN(n->v.Call.keywords); i < l; i++) {
|
||||||
keyword_ty keyword = asdl_seq_GET(n->v.Call.keywords, i);
|
keyword_ty keyword = asdl_seq_GET(n->v.Call.keywords, i);
|
||||||
shift_expr(n, keyword->value, lineno, col_offset);
|
shift_expr(n, keyword->value, lineno, col_offset);
|
||||||
}
|
}
|
||||||
@ -521,8 +518,7 @@ fstring_fix_expr_location(Token *parent, expr_ty n, char *expr_str)
|
|||||||
}
|
}
|
||||||
/* adjust the start based on the number of newlines encountered
|
/* adjust the start based on the number of newlines encountered
|
||||||
before the f-string expression */
|
before the f-string expression */
|
||||||
char *p;
|
for (char* p = parent_str; p < substr; p++) {
|
||||||
for (p = parent_str; p < substr; p++) {
|
|
||||||
if (*p == '\n') {
|
if (*p == '\n') {
|
||||||
lines++;
|
lines++;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import pathlib
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
import tokenize
|
import tokenize
|
||||||
|
import sys
|
||||||
|
|
||||||
from typing import Optional, Tuple
|
from typing import Optional, Tuple
|
||||||
|
|
||||||
@ -42,6 +43,8 @@ def compile_c_extension(
|
|||||||
source_file_path = pathlib.Path(generated_source_path)
|
source_file_path = pathlib.Path(generated_source_path)
|
||||||
extension_name = source_file_path.stem
|
extension_name = source_file_path.stem
|
||||||
extra_compile_args = []
|
extra_compile_args = []
|
||||||
|
if not sys.platform.startswith('win'):
|
||||||
|
extra_compile_args.append("-std=c99")
|
||||||
if keep_asserts:
|
if keep_asserts:
|
||||||
extra_compile_args.append("-UNDEBUG")
|
extra_compile_args.append("-UNDEBUG")
|
||||||
extension = [
|
extension = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user