diff options
author | Benjamin Peterson <benjamin@python.org> | 2010-03-21 22:36:19 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2010-03-21 22:36:19 (GMT) |
commit | 2614cda20910e1b2529d5af4a95327f8cdfcc35a (patch) | |
tree | 4a2d95569150aa2b6f81eb8ea921eac67afa2bf8 /Tools/modulator/genmodule.py | |
parent | b5023a1433c4afbf2460a6433593769d1d99bee5 (diff) | |
download | cpython-2614cda20910e1b2529d5af4a95327f8cdfcc35a.zip cpython-2614cda20910e1b2529d5af4a95327f8cdfcc35a.tar.gz cpython-2614cda20910e1b2529d5af4a95327f8cdfcc35a.tar.bz2 |
Merged revisions 78338,78345-78346,78561-78562,78566,78574,78581,78634,78660,78675 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78338 | andrew.kuchling | 2010-02-22 15:04:02 -0600 (Mon, 22 Feb 2010) | 4 lines
Remove Tools/modulator, a reference to it in the docs, and a screenshot of it.
(I asked the BDFL first, and he approved removing it. The last actual bugfix
to Tools/modulator was in 2001; since then all changes have been search-and-replace:
string methods, whitespace fixes, etc.)
........
r78345 | andrew.kuchling | 2010-02-22 17:10:52 -0600 (Mon, 22 Feb 2010) | 1 line
#7706: DONT_HAVE_ERRNO_H is no longer defined by configure (after rev.46819).
........
r78346 | andrew.kuchling | 2010-02-22 17:12:00 -0600 (Mon, 22 Feb 2010) | 1 line
#7706: add include guards where they're missing; required for Windows CE
........
r78561 | andrew.kuchling | 2010-03-01 13:51:43 -0600 (Mon, 01 Mar 2010) | 1 line
#7191: describe more details of wbits parameter
........
r78562 | andrew.kuchling | 2010-03-01 14:11:57 -0600 (Mon, 01 Mar 2010) | 1 line
#7637: avoid repeated-concatenation antipattern in example
........
r78566 | barry.warsaw | 2010-03-01 15:46:51 -0600 (Mon, 01 Mar 2010) | 4 lines
Manually copy patch for bug 7250 from the release26-maint branch. I suck
because I did this in the wrong order and couldn't smack svnmerge into
submission.
........
r78574 | benjamin.peterson | 2010-03-01 17:25:13 -0600 (Mon, 01 Mar 2010) | 1 line
remove CVS id
........
r78581 | michael.foord | 2010-03-02 08:22:15 -0600 (Tue, 02 Mar 2010) | 1 line
Link correction in documentation.
........
r78634 | benjamin.peterson | 2010-03-03 15:28:25 -0600 (Wed, 03 Mar 2010) | 1 line
rephrase
........
r78660 | dirkjan.ochtman | 2010-03-04 13:21:53 -0600 (Thu, 04 Mar 2010) | 4 lines
Try to fix buildbot breakage from r78384.
Thanks bitdancer and briancurtin for the help.
........
r78675 | florent.xicluna | 2010-03-04 19:12:14 -0600 (Thu, 04 Mar 2010) | 2 lines
These line should not be there.
........
Diffstat (limited to 'Tools/modulator/genmodule.py')
-rwxr-xr-x | Tools/modulator/genmodule.py | 160 |
1 files changed, 0 insertions, 160 deletions
diff --git a/Tools/modulator/genmodule.py b/Tools/modulator/genmodule.py deleted file mode 100755 index f8703ef..0000000 --- a/Tools/modulator/genmodule.py +++ /dev/null @@ -1,160 +0,0 @@ -# -# Genmodule - A python program to help you build (template) modules. -# -# Usage: -# -# o = genmodule.object() -# o.name = 'dwarve object' -# o.abbrev = 'dw' -# o.funclist = ['new', 'dealloc', 'getattr', 'setattr'] -# o.methodlist = ['dig'] -# -# m = genmodule.module() -# m.name = 'beings' -# m.abbrev = 'be' -# m.methodlist = ['newdwarve'] -# m.objects = [o] -# -# genmodule.write(sys.stdout, m) -# -import sys -import os -import varsubst - -error = 'genmodule.error' - -# -# Names of functions in the object-description struct. -# -FUNCLIST = ['new', 'tp_dealloc', 'tp_print', 'tp_getattr', 'tp_setattr', - 'tp_compare', 'tp_repr', 'tp_hash', 'tp_call', 'tp_str'] -TYPELIST = ['tp_as_number', 'tp_as_sequence', 'tp_as_mapping', 'structure'] - -# -# writer is a base class for the object and module classes -# it contains code common to both. -# -class writer: - def __init__(self): - self._subst = None - - def makesubst(self): - if not self._subst: - if 'abbrev' not in self.__dict__: - self.abbrev = self.name - self.Abbrev = self.abbrev[0].upper()+self.abbrev[1:] - subst = varsubst.Varsubst(self.__dict__) - subst.useindent(1) - self._subst = subst.subst - - def addcode(self, name, fp): - ifp = self.opentemplate(name) - self.makesubst() - d = ifp.read() - d = self._subst(d) - fp.write(d) - - def opentemplate(self, name): - for p in sys.path: - fn = os.path.join(p, name) - if os.path.exists(fn): - return open(fn, 'r') - fn = os.path.join(p, 'Templates') - fn = os.path.join(fn, name) - if os.path.exists(fn): - return open(fn, 'r') - raise error('Template '+name+' not found for '+self._type+' '+ \ - self.name) - -class module(writer): - _type = 'module' - - def writecode(self, fp): - self.addcode('copyright', fp) - self.addcode('module_head', fp) - for o in self.objects: - o.writehead(fp) - for o in self.objects: - o.writebody(fp) - new_ml = '' - for fn in self.methodlist: - self.method = fn - self.addcode('module_method', fp) - new_ml = new_ml + ( - '{"%s",\t(PyCFunction)%s_%s,\tMETH_VARARGS,\t%s_%s__doc__},\n' - %(fn, self.abbrev, fn, self.abbrev, fn)) - self.methodlist = new_ml - self.addcode('module_tail', fp) - -class object(writer): - _type = 'object' - def __init__(self): - self.typelist = [] - self.methodlist = [] - self.funclist = ['new'] - writer.__init__(self) - - def writecode(self, fp): - self.addcode('copyright', fp) - self.writehead(fp) - self.writebody(fp) - - def writehead(self, fp): - self.addcode('object_head', fp) - - def writebody(self, fp): - new_ml = '' - for fn in self.methodlist: - self.method = fn - self.addcode('object_method', fp) - new_ml = new_ml + ( - '{"%s",\t(PyCFunction)%s_%s,\tMETH_VARARGS,\t%s_%s__doc__},\n' - %(fn, self.abbrev, fn, self.abbrev, fn)) - self.methodlist = new_ml - self.addcode('object_mlist', fp) - - # Add getattr if we have methods - if self.methodlist and not 'tp_getattr' in self.funclist: - self.funclist.insert(0, 'tp_getattr') - - for fn in FUNCLIST: - setattr(self, fn, '0') - - # - # Special case for structure-access objects: put getattr in the - # list of functions but don't generate code for it directly, - # the code is obtained from the object_structure template. - # The same goes for setattr. - # - if 'structure' in self.typelist: - if 'tp_getattr' in self.funclist: - self.funclist.remove('tp_getattr') - if 'tp_setattr' in self.funclist: - self.funclist.remove('tp_setattr') - self.tp_getattr = self.abbrev + '_getattr' - self.tp_setattr = self.abbrev + '_setattr' - for fn in self.funclist: - self.addcode('object_'+fn, fp) - setattr(self, fn, '%s_%s'%(self.abbrev, fn[3:])) - for tn in TYPELIST: - setattr(self, tn, '0') - for tn in self.typelist: - self.addcode('object_'+tn, fp) - setattr(self, tn, '&%s_%s'%(self.abbrev, tn[3:])) - self.addcode('object_tail', fp) - -def write(fp, obj): - obj.writecode(fp) - -if __name__ == '__main__': - o = object() - o.name = 'dwarve object' - o.abbrev = 'dw' - o.funclist = ['new', 'tp_dealloc'] - o.methodlist = ['dig'] - m = module() - m.name = 'beings' - m.abbrev = 'be' - m.methodlist = ['newdwarve'] - m.objects = [o] - write(sys.stdout, m) |