[Python-checkins] CVS: python/dist/src/Tools/bgen/bgen bgenGenerator.py,1.6,1.7 bgenlocations.py,1.3,1.4 scantools.py,1.16,1.17

Guido van Rossum python-dev@python.org
Wed, 28 Jun 2000 13:53:36 -0700


Update of /cvsroot/python/python/dist/src/Tools/bgen/bgen
In directory slayer.i.sourceforge.net:/tmp/cvs-serv28490

Modified Files:
	bgenGenerator.py bgenlocations.py scantools.py 
Log Message:
Jack Jansen: Support for conditional inclusion of methods and functions


Index: bgenGenerator.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenGenerator.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** bgenGenerator.py	1995/06/18 20:08:28	1.6
--- bgenGenerator.py	2000/06/28 20:53:33	1.7
***************
*** 15,23 ****
  class BaseFunctionGenerator:
  
! 	def __init__(self, name):
  		print "<--", name
  		self.name = name
  		self.prefix = name
  		self.objecttype = "PyObject" # Type of _self argument to function
  
  	def setprefix(self, prefix):
--- 15,24 ----
  class BaseFunctionGenerator:
  
! 	def __init__(self, name, condition=None):
  		print "<--", name
  		self.name = name
  		self.prefix = name
  		self.objecttype = "PyObject" # Type of _self argument to function
+ 		self.condition = condition
  
  	def setprefix(self, prefix):
***************
*** 26,32 ****
--- 27,38 ----
  	def generate(self):
  		print "-->", self.name
+ 		if self.condition:
+ 			Output()
+ 			Output(self.condition)
  		self.functionheader()
  		self.functionbody()
  		self.functiontrailer()
+ 		if self.condition:
+ 			Output("#endif")
  
  	def functionheader(self):
***************
*** 51,56 ****
--- 57,67 ----
  			name = self.name
  		docstring = self.docstring()
+ 		if self.condition:
+ 			Output()
+ 			Output(self.condition)		
  		Output("{\"%s\", (PyCFunction)%s_%s, 1,", name, self.prefix, self.name)
  		Output(" %s},", stringify(docstring))
+ 		if self.condition:
+ 			Output("#endif")
  
  	def docstring(self):
***************
*** 74,79 ****
  class ManualGenerator(BaseFunctionGenerator):
  
! 	def __init__(self, name, body):
! 		BaseFunctionGenerator.__init__(self, name)
  		self.body = body
  
--- 85,90 ----
  class ManualGenerator(BaseFunctionGenerator):
  
! 	def __init__(self, name, body, condition=None):
! 		BaseFunctionGenerator.__init__(self, name, condition=condition)
  		self.body = body
  
***************
*** 88,93 ****
  class FunctionGenerator(BaseFunctionGenerator):
  
! 	def __init__(self, returntype, name, *argumentList):
! 		BaseFunctionGenerator.__init__(self, name)
  		self.returntype = returntype
  		self.argumentList = []
--- 99,104 ----
  class FunctionGenerator(BaseFunctionGenerator):
  
! 	def __init__(self, returntype, name, *argumentList, **conditionlist):
! 		BaseFunctionGenerator.__init__(self, name, **conditionlist)
  		self.returntype = returntype
  		self.argumentList = []

Index: bgenlocations.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/bgenlocations.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** bgenlocations.py	1998/02/23 15:30:40	1.3
--- bgenlocations.py	2000/06/28 20:53:33	1.4
***************
*** 4,12 ****
  
  # Where to find the Universal Header include files:
! MWERKSDIR="flap:Metrowerks:Metrowerks CodeWarrior:"
! INCLUDEDIR=MWERKSDIR + "MacOS Support:Headers:Universal Headers:"
  
  # Where to put the python definitions file:
! TOOLBOXDIR="flap:Jack:Python:Mac:Lib:lib-toolbox:"
  
  # Creator for C files:
--- 4,12 ----
  
  # Where to find the Universal Header include files:
! MWERKSDIR="Macintosh HD:SWDev:Codewarrior Pro 5:Metrowerks CodeWarrior:"
! INCLUDEDIR=MWERKSDIR + "MacOS Support:Universal:Interfaces:CIncludes:"
  
  # Where to put the python definitions file:
! TOOLBOXDIR="Macintosh HD:SWDev:Jack:Python:Mac:Lib:lib-toolbox:"
  
  # Creator for C files:

Index: scantools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/bgen/bgen/scantools.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** scantools.py	2000/01/20 20:49:28	1.16
--- scantools.py	2000/06/28 20:53:33	1.17
***************
*** 100,103 ****
--- 100,111 ----
  		self.blacklistnames = self.makeblacklistnames()
  		self.blacklisttypes = ["unknown", "-"] + self.makeblacklisttypes()
+ 		self.greydictnames = self.greylist2dict(self.makegreylist())
+ 		
+ 	def greylist2dict(self, list):
+ 		rv = {}
+ 		for define, namelist in list:
+ 			for name in namelist:
+ 				rv[name] = define
+ 		return rv
  
  	def makeblacklistnames(self):
***************
*** 106,109 ****
--- 114,120 ----
  	def makeblacklisttypes(self):
  		return []
+ 		
+ 	def makegreylist(self):
+ 		return []
  
  	def initrepairinstructions(self):
***************
*** 396,399 ****
--- 407,411 ----
  		else:
  			self.defsfile.write("# %s = %s\n" % (name, defn))
+ 		# XXXX No way to handle greylisted names
  
  	def dofuncspec(self):
***************
*** 520,523 ****
--- 532,537 ----
  			self.specfile.write("    (%s, %s, %s),\n" %
  			                    (atype, `aname`, amode))
+ 		if self.greydictnames.has_key(name):
+ 			self.specfile.write("    condition=%s,\n"%`self.greydictnames[name]`)
  		self.specfile.write(")\n")
  		self.specfile.write("%s.append(f)\n\n" % listname)