Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6576bd8

Browse files
committed
Prevent name pollution by making lots of internal functions static.
1 parent f6a9044 commit 6576bd8

5 files changed

Lines changed: 35 additions & 35 deletions

File tree

Include/Python-ast.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* File automatically generated by ../Parser/asdl_c.py */
1+
/* File automatically generated by ./Parser/asdl_c.py */
22

33
#include "asdl.h"
44

@@ -402,17 +402,3 @@ void free_excepthandler(excepthandler_ty);
402402
void free_arguments(arguments_ty);
403403
void free_keyword(keyword_ty);
404404
void free_alias(alias_ty);
405-
int marshal_write_mod(PyObject **, int *, mod_ty);
406-
int marshal_write_stmt(PyObject **, int *, stmt_ty);
407-
int marshal_write_expr(PyObject **, int *, expr_ty);
408-
int marshal_write_expr_context(PyObject **, int *, expr_context_ty);
409-
int marshal_write_slice(PyObject **, int *, slice_ty);
410-
int marshal_write_boolop(PyObject **, int *, boolop_ty);
411-
int marshal_write_operator(PyObject **, int *, operator_ty);
412-
int marshal_write_unaryop(PyObject **, int *, unaryop_ty);
413-
int marshal_write_cmpop(PyObject **, int *, cmpop_ty);
414-
int marshal_write_comprehension(PyObject **, int *, comprehension_ty);
415-
int marshal_write_excepthandler(PyObject **, int *, excepthandler_ty);
416-
int marshal_write_arguments(PyObject **, int *, arguments_ty);
417-
int marshal_write_keyword(PyObject **, int *, keyword_ty);
418-
int marshal_write_alias(PyObject **, int *, alias_ty);

Objects/setobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,7 @@ set_iand(PySetObject *so, PyObject *other)
12141214
return (PyObject *)so;
12151215
}
12161216

1217-
int
1217+
static int
12181218
set_difference_update_internal(PySetObject *so, PyObject *other)
12191219
{
12201220
if ((PyObject *)so == other)

Parser/asdl_c.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class MarshalPrototypeVisitor(PickleVisitor):
334334

335335
def prototype(self, sum, name):
336336
ctype = get_c_type(name)
337-
self.emit("int marshal_write_%s(PyObject **, int *, %s);"
337+
self.emit("static int marshal_write_%s(PyObject **, int *, %s);"
338338
% (name, ctype), 0)
339339

340340
visitProduct = visitSum = prototype
@@ -487,7 +487,7 @@ class MarshalFunctionVisitor(PickleVisitor):
487487

488488
def func_begin(self, name, has_seq):
489489
ctype = get_c_type(name)
490-
self.emit("int", 0)
490+
self.emit("static int", 0)
491491
self.emit("marshal_write_%s(PyObject **buf, int *off, %s o)" %
492492
(name, ctype), 0)
493493
self.emit("{", 0)
@@ -580,7 +580,6 @@ def main(srcfile):
580580
StructVisitor(f),
581581
PrototypeVisitor(f),
582582
FreePrototypeVisitor(f),
583-
MarshalPrototypeVisitor(f),
584583
)
585584
c.visit(mod)
586585
f.close()
@@ -594,7 +593,8 @@ def main(srcfile):
594593
print >> f, '#include "Python.h"'
595594
print >> f, '#include "%s-ast.h"' % mod.name
596595
print >> f
597-
v = ChainOfVisitors(FunctionVisitor(f),
596+
v = ChainOfVisitors(MarshalPrototypeVisitor(f),
597+
FunctionVisitor(f),
598598
StaticVisitor(f),
599599
FreeVisitor(f),
600600
MarshalFunctionVisitor(f),

Python/Python-ast.c

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
#include "Python.h"
44
#include "Python-ast.h"
55

6+
static int marshal_write_mod(PyObject **, int *, mod_ty);
7+
static int marshal_write_stmt(PyObject **, int *, stmt_ty);
8+
static int marshal_write_expr(PyObject **, int *, expr_ty);
9+
static int marshal_write_expr_context(PyObject **, int *, expr_context_ty);
10+
static int marshal_write_slice(PyObject **, int *, slice_ty);
11+
static int marshal_write_boolop(PyObject **, int *, boolop_ty);
12+
static int marshal_write_operator(PyObject **, int *, operator_ty);
13+
static int marshal_write_unaryop(PyObject **, int *, unaryop_ty);
14+
static int marshal_write_cmpop(PyObject **, int *, cmpop_ty);
15+
static int marshal_write_comprehension(PyObject **, int *, comprehension_ty);
16+
static int marshal_write_excepthandler(PyObject **, int *, excepthandler_ty);
17+
static int marshal_write_arguments(PyObject **, int *, arguments_ty);
18+
static int marshal_write_keyword(PyObject **, int *, keyword_ty);
19+
static int marshal_write_alias(PyObject **, int *, alias_ty);
620
mod_ty
721
Module(asdl_seq * body)
822
{
@@ -1519,7 +1533,7 @@ free_alias(alias_ty o)
15191533
free(o);
15201534
}
15211535

1522-
int
1536+
static int
15231537
marshal_write_mod(PyObject **buf, int *off, mod_ty o)
15241538
{
15251539
int i;
@@ -1557,7 +1571,7 @@ marshal_write_mod(PyObject **buf, int *off, mod_ty o)
15571571
return 1;
15581572
}
15591573

1560-
int
1574+
static int
15611575
marshal_write_stmt(PyObject **buf, int *off, stmt_ty o)
15621576
{
15631577
int i;
@@ -1818,7 +1832,7 @@ marshal_write_stmt(PyObject **buf, int *off, stmt_ty o)
18181832
return 1;
18191833
}
18201834

1821-
int
1835+
static int
18221836
marshal_write_expr(PyObject **buf, int *off, expr_ty o)
18231837
{
18241838
int i;
@@ -1989,7 +2003,7 @@ marshal_write_expr(PyObject **buf, int *off, expr_ty o)
19892003
return 1;
19902004
}
19912005

1992-
int
2006+
static int
19932007
marshal_write_expr_context(PyObject **buf, int *off, expr_context_ty o)
19942008
{
19952009
switch (o) {
@@ -2015,7 +2029,7 @@ marshal_write_expr_context(PyObject **buf, int *off, expr_context_ty o)
20152029
return 1;
20162030
}
20172031

2018-
int
2032+
static int
20192033
marshal_write_slice(PyObject **buf, int *off, slice_ty o)
20202034
{
20212035
int i;
@@ -2063,7 +2077,7 @@ marshal_write_slice(PyObject **buf, int *off, slice_ty o)
20632077
return 1;
20642078
}
20652079

2066-
int
2080+
static int
20672081
marshal_write_boolop(PyObject **buf, int *off, boolop_ty o)
20682082
{
20692083
switch (o) {
@@ -2077,7 +2091,7 @@ marshal_write_boolop(PyObject **buf, int *off, boolop_ty o)
20772091
return 1;
20782092
}
20792093

2080-
int
2094+
static int
20812095
marshal_write_operator(PyObject **buf, int *off, operator_ty o)
20822096
{
20832097
switch (o) {
@@ -2121,7 +2135,7 @@ marshal_write_operator(PyObject **buf, int *off, operator_ty o)
21212135
return 1;
21222136
}
21232137

2124-
int
2138+
static int
21252139
marshal_write_unaryop(PyObject **buf, int *off, unaryop_ty o)
21262140
{
21272141
switch (o) {
@@ -2141,7 +2155,7 @@ marshal_write_unaryop(PyObject **buf, int *off, unaryop_ty o)
21412155
return 1;
21422156
}
21432157

2144-
int
2158+
static int
21452159
marshal_write_cmpop(PyObject **buf, int *off, cmpop_ty o)
21462160
{
21472161
switch (o) {
@@ -2179,7 +2193,7 @@ marshal_write_cmpop(PyObject **buf, int *off, cmpop_ty o)
21792193
return 1;
21802194
}
21812195

2182-
int
2196+
static int
21832197
marshal_write_comprehension(PyObject **buf, int *off, comprehension_ty o)
21842198
{
21852199
int i;
@@ -2193,7 +2207,7 @@ marshal_write_comprehension(PyObject **buf, int *off, comprehension_ty o)
21932207
return 1;
21942208
}
21952209

2196-
int
2210+
static int
21972211
marshal_write_excepthandler(PyObject **buf, int *off, excepthandler_ty o)
21982212
{
21992213
int i;
@@ -2219,7 +2233,7 @@ marshal_write_excepthandler(PyObject **buf, int *off, excepthandler_ty o)
22192233
return 1;
22202234
}
22212235

2222-
int
2236+
static int
22232237
marshal_write_arguments(PyObject **buf, int *off, arguments_ty o)
22242238
{
22252239
int i;
@@ -2250,15 +2264,15 @@ marshal_write_arguments(PyObject **buf, int *off, arguments_ty o)
22502264
return 1;
22512265
}
22522266

2253-
int
2267+
static int
22542268
marshal_write_keyword(PyObject **buf, int *off, keyword_ty o)
22552269
{
22562270
marshal_write_identifier(buf, off, o->arg);
22572271
marshal_write_expr(buf, off, o->value);
22582272
return 1;
22592273
}
22602274

2261-
int
2275+
static int
22622276
marshal_write_alias(PyObject **buf, int *off, alias_ty o)
22632277
{
22642278
marshal_write_identifier(buf, off, o->name);

Python/future.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename)
4646
return 1;
4747
}
4848

49-
int
49+
static int
5050
future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename)
5151
{
5252
int i, found_docstring = 0, done = 0, prev_line = 0;

0 commit comments

Comments
 (0)