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

Skip to content

Commit 53d960c

Browse files
committed
Don't pollute namespace as bad as before. All the types are static now.
1 parent 8ae1295 commit 53d960c

2 files changed

Lines changed: 159 additions & 159 deletions

File tree

Parser/asdl_c.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,18 +347,18 @@ def prototype(self, sum, name):
347347
class PyTypesDeclareVisitor(PickleVisitor):
348348

349349
def visitProduct(self, prod, name):
350-
self.emit("PyTypeObject *%s_type;" % name, 0)
350+
self.emit("static PyTypeObject *%s_type;" % name, 0)
351351
self.emit("static PyObject* ast2obj_%s(void*);" % name, 0)
352352
if prod.fields:
353-
self.emit("char *%s_fields[]={" % name,0)
353+
self.emit("static char *%s_fields[]={" % name,0)
354354
for f in prod.fields:
355355
self.emit('"%s",' % f.name, 1)
356356
self.emit("};", 0)
357357

358358
def visitSum(self, sum, name):
359-
self.emit("PyTypeObject *%s_type;" % name, 0)
359+
self.emit("static PyTypeObject *%s_type;" % name, 0)
360360
if sum.attributes:
361-
self.emit("char *%s_attributes[] = {" % name, 0)
361+
self.emit("static char *%s_attributes[] = {" % name, 0)
362362
for a in sum.attributes:
363363
self.emit('"%s",' % a.name, 1)
364364
self.emit("};", 0)
@@ -375,9 +375,9 @@ def visitSum(self, sum, name):
375375
self.visitConstructor(t, name)
376376

377377
def visitConstructor(self, cons, name):
378-
self.emit("PyTypeObject *%s_type;" % cons.name, 0)
378+
self.emit("static PyTypeObject *%s_type;" % cons.name, 0)
379379
if cons.fields:
380-
self.emit("char *%s_fields[]={" % cons.name, 0)
380+
self.emit("static char *%s_fields[]={" % cons.name, 0)
381381
for t in cons.fields:
382382
self.emit('"%s",' % t.name, 1)
383383
self.emit("};",0)
@@ -736,7 +736,7 @@ def main(srcfile):
736736
print >> f, '#include "Python.h"'
737737
print >> f, '#include "%s-ast.h"' % mod.name
738738
print >> f
739-
print >>f, "PyTypeObject* AST_type;"
739+
print >>f, "static PyTypeObject* AST_type;"
740740
v = ChainOfVisitors(
741741
PyTypesDeclareVisitor(f),
742742
PyTypesVisitor(f),

0 commit comments

Comments
 (0)