[Patches] Patches to Tools/bgen/bgen
Jack Jansen
Jack.Jansen@oratrix.com
Fri, 02 Jun 2000 23:07:01 +0200
This is a multi-part message in MIME format.
--------------E35E8D3A3B57D281C34DA3E2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
These patches contain a new feature, greylists, to allow conditional
compilation of certain methods. Greylist items are a string like "#ifdef FOO"
plus a list of function names whose wrappers will be generated within such an #if/#ifdef.
----
I confirm that, to the
best of my knowledge and belief, this
contribution is free of
any claims of third parties under
copyright, patent or
other rights or interests ("claims"). To
the extent that I have
any such claims, I hereby grant to CNRI a
nonexclusive,
irrevocable, royalty-free, worldwide license to
reproduce, distribute,
perform and/or display publicly, prepare
derivative versions, and
otherwise use this contribution as part
of the Python software
and its related documentation, or any
derivative versions
thereof, at no cost to CNRI or its licensed
users, and to authorize
others to do so.
I acknowledge that CNRI
may, at its sole discretion, decide
whether or not to
incorporate this contribution in the Python
software and its related
documentation. I further grant CNRI
permission to use my
name and other identifying information
provided to CNRI by me
for use in connection with the Python
software and its related documentation.
--------------E35E8D3A3B57D281C34DA3E2
Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="522A6368";
name="bgen.diffs"
Content-Transfer-Encoding: 7bit
Content-Description: Unknown Document
Content-Disposition: inline;
filename="bgen.diffs"
cvs server: Diffing .
cvs server: Diffing bgen
Index: bgen/bgenGenerator.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Tools/bgen/bgen/bgenGenerator.py,v
retrieving revision 1.6
diff -c -r1.6 bgenGenerator.py
*** bgenGenerator.py 1995/06/18 20:08:28 1.6
--- bgenGenerator.py 2000/06/02 13:31:49
***************
*** 14,33 ****
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):
self.prefix = prefix
def generate(self):
print "-->", self.name
self.functionheader()
self.functionbody()
self.functiontrailer()
def functionheader(self):
Output()
--- 14,39 ----
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):
self.prefix = prefix
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):
Output()
***************
*** 50,57 ****
--- 56,68 ----
if name is None:
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):
return None
***************
*** 73,80 ****
class ManualGenerator(BaseFunctionGenerator):
! def __init__(self, name, body):
! BaseFunctionGenerator.__init__(self, name)
self.body = body
def functionbody(self):
--- 84,91 ----
class ManualGenerator(BaseFunctionGenerator):
! def __init__(self, name, body, condition=None):
! BaseFunctionGenerator.__init__(self, name, condition=condition)
self.body = body
def functionbody(self):
***************
*** 87,94 ****
class FunctionGenerator(BaseFunctionGenerator):
! def __init__(self, returntype, name, *argumentList):
! BaseFunctionGenerator.__init__(self, name)
self.returntype = returntype
self.argumentList = []
self.setreturnvar()
--- 98,105 ----
class FunctionGenerator(BaseFunctionGenerator):
! def __init__(self, returntype, name, *argumentList, **conditionlist):
! BaseFunctionGenerator.__init__(self, name, **conditionlist)
self.returntype = returntype
self.argumentList = []
self.setreturnvar()
Index: bgen/bgenlocations.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Tools/bgen/bgen/bgenlocations.py,v
retrieving revision 1.3
diff -c -r1.3 bgenlocations.py
*** bgenlocations.py 1998/02/23 15:30:40 1.3
--- bgenlocations.py 2000/06/02 13:31:49
***************
*** 3,13 ****
#
# 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:
CREATOR="CWIE"
--- 3,13 ----
#
# 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:
CREATOR="CWIE"
Index: bgen/scantools.py
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Tools/bgen/bgen/scantools.py,v
retrieving revision 1.16
diff -c -r1.16 scantools.py
*** scantools.py 2000/01/20 20:49:28 1.16
--- scantools.py 2000/06/02 13:31:49
***************
*** 99,110 ****
--- 99,121 ----
def initblacklists(self):
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):
return []
def makeblacklisttypes(self):
return []
+
+ def makegreylist(self):
+ return []
def initrepairinstructions(self):
self.repairinstructions = self.makerepairinstructions()
***************
*** 395,400 ****
--- 406,412 ----
self.defsfile.write("%s = %s\n" % (name, defn))
else:
self.defsfile.write("# %s = %s\n" % (name, defn))
+ # XXXX No way to handle greylisted names
def dofuncspec(self):
raw = self.line
***************
*** 519,524 ****
--- 531,538 ----
self.typeused(atype, amode)
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)
--------------E35E8D3A3B57D281C34DA3E2--