summaryrefslogtreecommitdiffstats
path: root/Tools/bgen
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 (GMT)
commit182b5aca27d376b08a2904bed42b751496f932f3 (patch)
treedf13115820dbc879c0fe2eae488c9f8c0215a7da /Tools/bgen
parente6ddc8b20b493fef2e7cffb2e1351fe1d238857e (diff)
downloadcpython-182b5aca27d376b08a2904bed42b751496f932f3.zip
cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.gz
cpython-182b5aca27d376b08a2904bed42b751496f932f3.tar.bz2
Whitespace normalization, via reindent.py.
Diffstat (limited to 'Tools/bgen')
-rw-r--r--Tools/bgen/bgen/bgenBuffer.py66
-rw-r--r--Tools/bgen/bgen/bgenGenerator.py14
-rw-r--r--Tools/bgen/bgen/bgenHeapBuffer.py14
-rw-r--r--Tools/bgen/bgen/bgenModule.py2
-rw-r--r--Tools/bgen/bgen/bgenObjectDefinition.py98
-rw-r--r--Tools/bgen/bgen/bgenOutput.py18
-rw-r--r--Tools/bgen/bgen/bgenStringBuffer.py6
-rw-r--r--Tools/bgen/bgen/bgenType.py6
-rw-r--r--Tools/bgen/bgen/macsupport.py6
-rw-r--r--Tools/bgen/bgen/scantools.py25
10 files changed, 126 insertions, 129 deletions
diff --git a/Tools/bgen/bgen/bgenBuffer.py b/Tools/bgen/bgen/bgenBuffer.py
index 4b888d7..ca7e026 100644
--- a/Tools/bgen/bgen/bgenBuffer.py
+++ b/Tools/bgen/bgen/bgenBuffer.py
@@ -27,7 +27,7 @@ type2format = {
class FixedInputOutputBufferType(InputOnlyType):
-
+
"""Fixed buffer -- passed as (inbuffer, outbuffer)."""
def __init__(self, size, datatype = 'char', sizetype = 'int', sizeformat = None):
@@ -41,14 +41,14 @@ class FixedInputOutputBufferType(InputOnlyType):
def declare(self, name):
self.declareBuffer(name)
self.declareSize(name)
-
+
def declareBuffer(self, name):
self.declareInputBuffer(name)
self.declareOutputBuffer(name)
-
+
def declareInputBuffer(self, name):
Output("%s *%s__in__;", self.datatype, name)
-
+
def declareOutputBuffer(self, name):
Output("%s %s__out__[%s];", self.datatype, name, self.size)
@@ -61,7 +61,7 @@ class FixedInputOutputBufferType(InputOnlyType):
def getargsArgs(self, name):
return "&%s__in__, &%s__in_len__" % (name, name)
-
+
def getargsCheck(self, name):
Output("if (%s__in_len__ != %s)", name, self.size)
OutLbrace()
@@ -71,19 +71,19 @@ class FixedInputOutputBufferType(InputOnlyType):
self.label_needed = 1
OutRbrace()
self.transferSize(name)
-
+
def transferSize(self, name):
Output("%s__len__ = %s__in_len__;", name, name)
def passOutput(self, name):
return "%s__in__, %s__out__" % (name, name)
-
+
def mkvalueFormat(self):
return "s#"
def mkvalueArgs(self, name):
return "%s__out__, (int)%s" % (name, self.size)
-
+
def cleanup(self, name):
if self.label_needed:
DedentLevel()
@@ -92,9 +92,9 @@ class FixedInputOutputBufferType(InputOnlyType):
class FixedCombinedInputOutputBufferType(FixedInputOutputBufferType):
-
+
"""Like fixed buffer -- but same parameter is input and output."""
-
+
def passOutput(self, name):
return "(%s *)memcpy(%s__out__, %s__in__, %s)" % \
(self.datatype, name, name, self.size)
@@ -112,10 +112,10 @@ class OutputOnlyBufferMixIn(OutputOnlyMixIn):
pass
class OptionalInputBufferMixIn:
-
+
"""Add to input buffers if the buffer may be omitted: pass None in Python
and the C code will get a NULL pointer and zero size"""
-
+
def getargsFormat(self):
return "z#"
@@ -147,63 +147,63 @@ class FixedOutputBufferType(OutputOnlyBufferMixIn, FixedInputOutputBufferType):
class VarInputBufferType(FixedInputBufferType):
"""Variable size input buffer -- passed as (buffer, size).
-
+
Instantiate without size parameter.
"""
-
+
def __init__(self, datatype = 'char', sizetype = 'int', sizeformat = None):
FixedInputBufferType.__init__(self, "0", datatype, sizetype, sizeformat)
-
+
def getargsCheck(self, name):
Output("%s__len__ = %s__in_len__;", name, name)
-
+
def passInput(self, name):
return "%s__in__, %s__len__" % (name, name)
-
+
class ReverseInputBufferMixin:
""" Mixin for input buffers that are passed as (size, buffer) """
-
+
def passInput(self, name):
return "%s__len__, %s__in__" % (name, name)
-
+
class OptionalVarInputBufferType(OptionalInputBufferMixIn, VarInputBufferType):
pass
-
+
# ----- PART 2: Structure buffers -----
class StructInputOutputBufferType(FixedInputOutputBufferType):
-
+
"""Structure buffer -- passed as a structure pointer.
Instantiate with the struct type as parameter.
"""
-
+
def __init__(self, type):
FixedInputOutputBufferType.__init__(self, "sizeof(%s)" % type)
self.typeName = self.type = type
-
+
def declareInputBuffer(self, name):
Output("%s *%s__in__;", self.type, name)
-
+
def declareSize(self, name):
Output("int %s__in_len__;", name)
-
+
def declareOutputBuffer(self, name):
Output("%s %s__out__;", self.type, name)
-
+
def getargsArgs(self, name):
return "(char **)&%s__in__, &%s__in_len__" % (name, name)
-
+
def transferSize(self, name):
pass
-
+
def passInput(self, name):
return "%s__in__" % name
-
+
def passOutput(self, name):
return "%s__in__, &%s__out__" % (name, name)
-
+
def mkvalueArgs(self, name):
return "(char *)&%s__out__, (int)%s" % (name, self.size)
@@ -211,7 +211,7 @@ class StructInputOutputBufferType(FixedInputOutputBufferType):
class StructCombinedInputOutputBufferType(StructInputOutputBufferType):
"""Like structure buffer -- but same parameter is input and output."""
-
+
def passOutput(self, name):
return "(%s *)memcpy((char *)%s__out__, (char *)%s__in__, %s)" % \
(self.type, name, name, self.size)
@@ -242,7 +242,7 @@ class StructOutputBufferType(OutputOnlyBufferMixIn, StructInputOutputBufferType)
Instantiate with the struct type as parameter.
"""
-
+
def declareSize(self, name):
pass
@@ -256,7 +256,7 @@ class ArrayOutputBufferType(OutputOnlyBufferMixIn, StructInputOutputBufferType):
Instantiate with the struct type as parameter.
"""
-
+
def declareSize(self, name):
pass
diff --git a/Tools/bgen/bgen/bgenGenerator.py b/Tools/bgen/bgen/bgenGenerator.py
index f3cdfce..e1f240c 100644
--- a/Tools/bgen/bgen/bgenGenerator.py
+++ b/Tools/bgen/bgen/bgenGenerator.py
@@ -55,7 +55,7 @@ class BaseFunctionGenerator:
docstring = self.docstring()
if self.condition:
Output()
- Output(self.condition)
+ Output(self.condition)
Output("{\"%s\", (PyCFunction)%s_%s, 1,", name, self.prefix, self.name)
Output(" PyDoc_STR(%s)},", stringify(docstring))
if self.condition:
@@ -91,7 +91,7 @@ class ManualGenerator(BaseFunctionGenerator):
def functionbody(self):
Output("%s", self.body)
-
+
def setselftype(self, selftype, itselftype):
self.objecttype = selftype
self.itselftype = itselftype
@@ -114,7 +114,7 @@ class FunctionGenerator(BaseFunctionGenerator):
self.argumentList.append(self.rv)
else:
self.rv = None
-
+
def makereturnvar(self):
return Variable(self.returntype, "_rv", OutMode)
@@ -129,7 +129,7 @@ class FunctionGenerator(BaseFunctionGenerator):
if name is None: name = "_arg%d" % iarg
arg = Variable(type, name, mode)
self.argumentList.append(arg)
-
+
def docstring(self):
input = []
output = []
@@ -146,7 +146,7 @@ class FunctionGenerator(BaseFunctionGenerator):
else:
typeName = "?"
print "Nameless type", arg.type
-
+
str = typeName + ' ' + arg.name
if arg.mode in (InMode, InOutMode):
input.append(str)
@@ -161,7 +161,7 @@ class FunctionGenerator(BaseFunctionGenerator):
else:
outstr = "(%s)" % ", ".join(output)
return instr + " -> " + outstr
-
+
def functionbody(self):
self.declarations()
self.precheck()
@@ -195,7 +195,7 @@ class FunctionGenerator(BaseFunctionGenerator):
continue
if arg.mode in (InMode, InOutMode):
arg.getargsCheck()
-
+
def precheck(self):
pass
diff --git a/Tools/bgen/bgen/bgenHeapBuffer.py b/Tools/bgen/bgen/bgenHeapBuffer.py
index 9bfc5a1..64cf2a4 100644
--- a/Tools/bgen/bgen/bgenHeapBuffer.py
+++ b/Tools/bgen/bgen/bgenHeapBuffer.py
@@ -43,7 +43,7 @@ class HeapInputOutputBufferType(FixedInputOutputBufferType):
class VarHeapInputOutputBufferType(HeapInputOutputBufferType):
"""same as base class, but passed as (inbuffer, outbuffer, &size)"""
-
+
def passOutput(self, name):
return "%s__in__, %s__out__, &%s__len__" % (name, name, name)
@@ -51,7 +51,7 @@ class VarHeapInputOutputBufferType(HeapInputOutputBufferType):
class HeapCombinedInputOutputBufferType(HeapInputOutputBufferType):
"""same as base class, but passed as (inoutbuffer, size)"""
-
+
def passOutput(self, name):
return "(%s *)memcpy(%s__out__, %s__in__, %s__len__)" % \
(self.datatype, name, name, name)
@@ -60,7 +60,7 @@ class HeapCombinedInputOutputBufferType(HeapInputOutputBufferType):
class VarHeapCombinedInputOutputBufferType(HeapInputOutputBufferType):
"""same as base class, but passed as (inoutbuffer, &size)"""
-
+
def passOutput(self, name):
return "(%s *)memcpy(%s__out__, %s__in__, &%s__len__)" % \
(self.datatype, name, name, name)
@@ -73,16 +73,16 @@ class HeapOutputBufferType(OutputOnlyMixIn, HeapInputOutputBufferType):
Instantiate without parameters.
Call from Python with buffer size.
"""
-
+
def declareInputBuffer(self, name):
pass
-
+
def getargsFormat(self):
return "i"
-
+
def getargsArgs(self, name):
return "&%s__in_len__" % name
-
+
def passOutput(self, name):
return "%s__out__, %s__len__" % (name, name)
diff --git a/Tools/bgen/bgen/bgenModule.py b/Tools/bgen/bgen/bgenModule.py
index 3e26b16..d41aa05 100644
--- a/Tools/bgen/bgen/bgenModule.py
+++ b/Tools/bgen/bgen/bgenModule.py
@@ -38,7 +38,7 @@ class Module(GeneratorGroup):
self.declareModuleVariables()
GeneratorGroup.generate(self)
-
+
if self.finalstuff:
Output()
Output("%s", self.finalstuff)
diff --git a/Tools/bgen/bgen/bgenObjectDefinition.py b/Tools/bgen/bgen/bgenObjectDefinition.py
index 9c205e3..72e2678 100644
--- a/Tools/bgen/bgen/bgenObjectDefinition.py
+++ b/Tools/bgen/bgen/bgenObjectDefinition.py
@@ -9,14 +9,14 @@ class ObjectDefinition(GeneratorGroup):
def __init__(self, name, prefix, itselftype):
"""ObjectDefinition constructor. May be extended, but do not override.
-
+
- name: the object's official name, e.g. 'SndChannel'.
- prefix: the prefix used for the object's functions and data, e.g. 'SndCh'.
- itselftype: the C type actually contained in the object, e.g. 'SndChannelPtr'.
-
+
XXX For official Python data types, rules for the 'Py' prefix are a problem.
"""
-
+
GeneratorGroup.__init__(self, prefix or name)
self.name = name
self.itselftype = itselftype
@@ -35,7 +35,7 @@ class ObjectDefinition(GeneratorGroup):
def reference(self):
# In case we are referenced from a module
pass
-
+
def setmodulename(self, name):
self.modulename = name
@@ -58,7 +58,7 @@ class ObjectDefinition(GeneratorGroup):
Output("} %s;", self.objecttype)
self.outputNew()
-
+
self.outputConvert()
self.outputDealloc()
@@ -71,19 +71,19 @@ class ObjectDefinition(GeneratorGroup):
self.outputGetattr()
self.outputSetattr()
-
+
self.outputCompare()
-
+
self.outputRepr()
-
+
self.outputHash()
-
+
self.outputPEP253Hooks()
-
+
self.outputTypeObject()
OutHeader2("End object type " + self.name)
-
+
def outputMethodChain(self):
Output("%sPyMethodChain %s_chain = { %s_methods, %s };",
self.static, self.prefix, self.prefix, self.basechain)
@@ -108,10 +108,10 @@ class ObjectDefinition(GeneratorGroup):
def outputInitStructMembers(self):
Output("it->ob_itself = %sitself;", self.argref)
-
+
def outputCheckNewArg(self):
- "Override this method to apply additional checks/conversions"
-
+ "Override this method to apply additional checks/conversions"
+
def outputConvert(self):
Output("%sint %s_Convert(PyObject *v, %s *p_itself)", self.static, self.prefix,
self.itselftype)
@@ -206,7 +206,7 @@ class ObjectDefinition(GeneratorGroup):
Output("(hashfunc) %s_hash, /*tp_hash*/", self.prefix)
DedentLevel()
Output("};")
-
+
def outputTypeObjectInitializer(self):
Output("""%s.ob_type = &PyType_Type;""", self.typename)
if self.basetype:
@@ -220,10 +220,10 @@ class ObjectDefinition(GeneratorGroup):
def outputPEP253Hooks(self):
pass
-
+
class PEP252Mixin:
getsetlist = []
-
+
def assertions(self):
# Check that various things aren't overridden. If they are it could
# signify a bgen-client that has been partially converted to PEP252.
@@ -232,21 +232,21 @@ class PEP252Mixin:
assert self.outputGetattrBody == None
assert self.outputGetattrHook == None
assert self.basechain == "NULL"
-
+
def outputGetattr(self):
pass
-
+
outputGetattrBody = None
outputGetattrHook = None
def outputSetattr(self):
pass
-
+
def outputMethodChain(self):
# This is a good place to output the getters and setters
self.outputGetSetList()
-
+
def outputHook(self, name):
methodname = "outputHook_" + name
if hasattr(self, methodname):
@@ -254,7 +254,7 @@ class PEP252Mixin:
func()
else:
Output("0, /*%s*/", name)
-
+
def outputTypeObject(self):
sf = self.static and "static "
Output()
@@ -268,7 +268,7 @@ class PEP252Mixin:
Output("\"%s\", /*tp_name*/", self.name)
Output("sizeof(%s), /*tp_basicsize*/", self.objecttype)
Output("0, /*tp_itemsize*/")
-
+
Output("/* methods */")
Output("(destructor) %s_dealloc, /*tp_dealloc*/", self.prefix)
Output("0, /*tp_print*/")
@@ -276,17 +276,17 @@ class PEP252Mixin:
Output("(setattrfunc)0, /*tp_setattr*/")
Output("(cmpfunc) %s_compare, /*tp_compare*/", self.prefix)
Output("(reprfunc) %s_repr, /*tp_repr*/", self.prefix)
-
+
Output("(PyNumberMethods *)0, /* tp_as_number */")
Output("(PySequenceMethods *)0, /* tp_as_sequence */")
Output("(PyMappingMethods *)0, /* tp_as_mapping */")
-
+
Output("(hashfunc) %s_hash, /*tp_hash*/", self.prefix)
self.outputHook("tp_call")
Output("0, /*tp_str*/")
Output("PyObject_GenericGetAttr, /*tp_getattro*/")
Output("PyObject_GenericSetAttr, /*tp_setattro */")
-
+
self.outputHook("tp_as_buffer")
Output("%s, /* tp_flags */", self.tp_flags)
self.outputHook("tp_doc")
@@ -310,7 +310,7 @@ class PEP252Mixin:
self.outputHook("tp_free")
DedentLevel()
Output("};")
-
+
def outputGetSetList(self):
if self.getsetlist:
for name, get, set, doc in self.getsetlist:
@@ -324,7 +324,7 @@ class PEP252Mixin:
else:
Output("#define %s_set_%s NULL", self.prefix, name)
Output()
-
+
Output("static PyGetSetDef %s_getsetlist[] = {", self.prefix)
IndentLevel()
for name, get, set, doc in self.getsetlist:
@@ -332,7 +332,7 @@ class PEP252Mixin:
doc = '"' + doc + '"'
else:
doc = "NULL"
- Output("{\"%s\", (getter)%s_get_%s, (setter)%s_set_%s, %s},",
+ Output("{\"%s\", (getter)%s_get_%s, (setter)%s_set_%s, %s},",
name, self.prefix, name, self.prefix, name, doc)
Output("{NULL, NULL, NULL, NULL},")
DedentLevel()
@@ -340,7 +340,7 @@ class PEP252Mixin:
else:
Output("#define %s_getsetlist NULL", self.prefix)
Output()
-
+
def outputGetter(self, name, code):
Output("static PyObject *%s_get_%s(%s *self, void *closure)",
self.prefix, name, self.objecttype)
@@ -348,7 +348,7 @@ class PEP252Mixin:
Output(code)
OutRbrace()
Output()
-
+
def outputSetter(self, name, code):
Output("static int %s_set_%s(%s *self, PyObject *v, void *closure)",
self.prefix, name, self.objecttype)
@@ -357,24 +357,24 @@ class PEP252Mixin:
Output("return 0;")
OutRbrace()
Output()
-
+
class PEP253Mixin(PEP252Mixin):
tp_flags = "Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE"
-
+
def outputHook_tp_init(self):
Output("%s_tp_init, /* tp_init */", self.prefix)
-
+
def outputHook_tp_alloc(self):
Output("%s_tp_alloc, /* tp_alloc */", self.prefix)
-
+
def outputHook_tp_new(self):
Output("%s_tp_new, /* tp_new */", self.prefix)
-
+
def outputHook_tp_free(self):
Output("%s_tp_free, /* tp_free */", self.prefix)
-
+
output_tp_initBody = None
-
+
def output_tp_init(self):
if self.output_tp_initBody:
Output("static int %s_tp_init(PyObject *self, PyObject *args, PyObject *kwds)", self.prefix)
@@ -384,9 +384,9 @@ class PEP253Mixin(PEP252Mixin):
else:
Output("#define %s_tp_init 0", self.prefix)
Output()
-
+
output_tp_allocBody = None
-
+
def output_tp_alloc(self):
if self.output_tp_allocBody:
Output("static PyObject *%s_tp_alloc(PyTypeObject *type, int nitems)",
@@ -397,7 +397,7 @@ class PEP253Mixin(PEP252Mixin):
else:
Output("#define %s_tp_alloc PyType_GenericAlloc", self.prefix)
Output()
-
+
def output_tp_newBody(self):
Output("PyObject *self;");
Output("%s itself;", self.itselftype);
@@ -408,7 +408,7 @@ class PEP253Mixin(PEP252Mixin):
Output("if ((self = type->tp_alloc(type, 0)) == NULL) return NULL;")
Output("((%s *)self)->ob_itself = itself;", self.objecttype)
Output("return self;")
-
+
def output_tp_new(self):
if self.output_tp_newBody:
Output("static PyObject *%s_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)", self.prefix)
@@ -418,9 +418,9 @@ class PEP253Mixin(PEP252Mixin):
else:
Output("#define %s_tp_new PyType_GenericNew", self.prefix)
Output()
-
+
output_tp_freeBody = None
-
+
def output_tp_free(self):
if self.output_tp_freeBody:
Output("static void %s_tp_free(PyObject *self)", self.prefix)
@@ -430,7 +430,7 @@ class PEP253Mixin(PEP252Mixin):
else:
Output("#define %s_tp_free PyObject_Del", self.prefix)
Output()
-
+
def outputPEP253Hooks(self):
self.output_tp_init()
self.output_tp_alloc()
@@ -439,7 +439,7 @@ class PEP253Mixin(PEP252Mixin):
class GlobalObjectDefinition(ObjectDefinition):
"""Like ObjectDefinition but exports some parts.
-
+
XXX Should also somehow generate a .h file for them.
"""
@@ -453,7 +453,7 @@ class ObjectIdentityMixin:
be returned by library calls and it is difficult (or impossible) to find
the corresponding Python objects. With this you can create Python object
wrappers on the fly"""
-
+
def outputCompare(self):
Output()
Output("static int %s_compare(%s *self, %s *other)", self.prefix, self.objecttype,
@@ -475,12 +475,10 @@ class ObjectIdentityMixin:
Output("if( v > w ) return 1;")
Output("return 0;")
OutRbrace()
-
+
def outputHash(self):
Output()
Output("static long %s_hash(%s *self)", self.prefix, self.objecttype)
OutLbrace()
Output("return (long)self->ob_itself;")
OutRbrace()
-
-
diff --git a/Tools/bgen/bgen/bgenOutput.py b/Tools/bgen/bgen/bgenOutput.py
index 304a52d..53d4f55 100644
--- a/Tools/bgen/bgen/bgenOutput.py
+++ b/Tools/bgen/bgen/bgenOutput.py
@@ -30,7 +30,7 @@ def SetOutputFile(file = None, needclose = 0):
def SetOutputFileName(filename = None):
"""Call this with a filename to make it the output file.
-
+
Call it without arguments to close the current file (if necessary)
and reset it to sys.stdout.
"""
@@ -95,7 +95,7 @@ def DedentLevel(by = 1):
def OutIndent(format = "", *args):
"""Combine Output() followed by IndentLevel().
-
+
If no text is given, acts like lone IndentLevel().
"""
if format: VaOutput(format, args)
@@ -103,7 +103,7 @@ def OutIndent(format = "", *args):
def OutDedent(format = "", *args):
"""Combine Output() followed by DedentLevel().
-
+
If no text is given, acts like loneDedentLevel().
"""
if format: VaOutput(format, args)
@@ -111,7 +111,7 @@ def OutDedent(format = "", *args):
def OutLbrace(format = "", *args):
"""Like Output, but add a '{' and increase the indentation level.
-
+
If no text is given a lone '{' is output.
"""
if format:
@@ -143,13 +143,13 @@ def OutHeader2(text):
def Out(text):
"""Output multiline text that's internally indented.
-
+
Pass this a multiline character string. The whitespace before the
first nonblank line of the string will be subtracted from all lines.
The lines are then output using Output(), but without interpretation
of formatting (if you need formatting you can do it before the call).
Recommended use:
-
+
Out('''
int main(argc, argv)
int argc;
@@ -159,14 +159,14 @@ def Out(text):
exit(0);
}
''')
-
+
Caveat: the indentation must be consistent -- if you use three tabs
in the first line, (up to) three tabs are removed from following lines,
but a line beginning with 24 spaces is not trimmed at all. Don't use
this as a feature.
"""
# (Don't you love using triple quotes *inside* triple quotes? :-)
-
+
lines = text.split('\n')
indent = ""
for line in lines:
@@ -193,7 +193,7 @@ def _test():
Out("""
#include <Python.h>
#include <stdio.h>
-
+
main(argc, argv)
int argc;
char **argv;
diff --git a/Tools/bgen/bgen/bgenStringBuffer.py b/Tools/bgen/bgen/bgenStringBuffer.py
index 39c8cf9..683bc0f 100644
--- a/Tools/bgen/bgen/bgenStringBuffer.py
+++ b/Tools/bgen/bgen/bgenStringBuffer.py
@@ -22,13 +22,13 @@ class StringBufferMixIn:
pointer is returned. These are actually easier (no allocation) but far
less common. I'll write the classes when there is demand.)
"""
-
+
def declareSize(self, name):
pass
-
+
def getargsFormat(self):
return "s"
-
+
def getargsArgs(self, name):
return "&%s__in__" % name
diff --git a/Tools/bgen/bgen/bgenType.py b/Tools/bgen/bgen/bgenType.py
index aa87aee..4f3026a 100644
--- a/Tools/bgen/bgen/bgenType.py
+++ b/Tools/bgen/bgen/bgenType.py
@@ -204,8 +204,8 @@ class OpaqueType(Type):
self.convert = arg + '_Convert'
else:
# Three arguments (name, new, convert)
- self.new = arg
- self.convert = extra
+ self.new = arg
+ self.convert = extra
def getargsFormat(self):
return "O&"
@@ -236,7 +236,7 @@ class OpaqueByValueType(OpaqueType):
def mkvalueArgs(self, name):
return "%s, %s" % (self.new, name)
-
+
class OpaqueByValueStructType(OpaqueByValueType):
"""Similar to OpaqueByValueType, but we also pass this to mkvalue by
address, in stead of by value.
diff --git a/Tools/bgen/bgen/macsupport.py b/Tools/bgen/bgen/macsupport.py
index eef6db8..7cd2b81 100644
--- a/Tools/bgen/bgen/macsupport.py
+++ b/Tools/bgen/bgen/macsupport.py
@@ -129,10 +129,10 @@ class VarUnicodeInputBufferType(VarInputBufferType):
def getargsFormat(self):
return "u#"
-
+
class VarUnicodeReverseInputBufferType(ReverseInputBufferMixin, VarUnicodeInputBufferType):
pass
-
+
UnicodeInBuffer = VarUnicodeInputBufferType('UniChar', 'UniCharCount', 'l')
UnicodeReverseInBuffer = VarUnicodeReverseInputBufferType('UniChar', 'UniCharCount', 'l')
UniChar_ptr = InputOnlyType("UniCharPtr", "u")
@@ -180,7 +180,7 @@ class OSErrMethodGenerator(OSErrMixIn, MethodGenerator): pass
class WeakLinkMixIn:
"Mix-in to test the function actually exists (!= NULL) before calling"
-
+
def precheck(self):
Output('#ifndef %s', self.name)
Output('PyMac_PRECHECK(%s);', self.name)
diff --git a/Tools/bgen/bgen/scantools.py b/Tools/bgen/bgen/scantools.py
index 4afd7c8..df7ddfb 100644
--- a/Tools/bgen/bgen/scantools.py
+++ b/Tools/bgen/bgen/scantools.py
@@ -51,15 +51,15 @@ class Scanner:
self.setoutput(output, defsoutput)
if input:
self.setinput(input)
-
+
def initusedtypes(self):
self.usedtypes = {}
-
+
def typeused(self, type, mode):
if not self.usedtypes.has_key(type):
self.usedtypes[type] = {}
self.usedtypes[type][mode] = None
-
+
def reportusedtypes(self):
types = self.usedtypes.keys()
types.sort()
@@ -100,12 +100,12 @@ if missing: raise "Missing Types"
def writeinitialdefs(self):
pass
-
+
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:
@@ -118,7 +118,7 @@ if missing: raise "Missing Types"
def makeblacklisttypes(self):
return []
-
+
def makegreylist(self):
return []
@@ -128,7 +128,7 @@ if missing: raise "Missing Types"
def makerepairinstructions(self):
"""Parse the repair file into repair instructions.
-
+
The file format is simple:
1) use \ to split a long logical line in multiple physical lines
2) everything after the first # on a line is ignored (as comment)
@@ -216,10 +216,10 @@ if missing: raise "Missing Types"
replacements.append(replacement)
list.append((fpat, patterns, replacements))
return list
-
+
def makeinherentpointertypes(self):
return []
-
+
def openrepairfile(self, filename = "REPAIR"):
try:
return open(filename, "rU")
@@ -337,7 +337,7 @@ if missing: raise "Missing Types"
scan = [scan]
self.allscaninputs = scan
self._nextinput()
-
+
def _nextinput(self):
if not self.allscaninputs:
return 0
@@ -526,7 +526,7 @@ if missing: raise "Missing Types"
type = type.strip()
type = re.sub("[ \t]+", "_", type)
return self.modifyarg(type, name, mode)
-
+
def modifyarg(self, type, name, mode):
if type[:6] == "const_":
type = type[6:]
@@ -567,7 +567,7 @@ if missing: raise "Missing Types"
else: # No patterns match
i = i+1
return arglist
-
+
def matcharg(self, patarg, arg):
return len(filter(None, map(fnmatch.fnmatchcase, arg, patarg))) == 3
@@ -666,4 +666,3 @@ def test():
if __name__ == '__main__':
test()
-