Kaydet (Commit) 2cf08ab4 authored tarafından Jack Jansen's avatar Jack Jansen

Sigh, due to sloppiness on my part bgen has become pretty mixed up wrt. tabs

and spaces. Detabbed the lot.
üst 28256f27
This diff is collapsed.
......@@ -2,39 +2,39 @@ from bgenOutput import *
class GeneratorGroup:
def __init__(self, prefix):
self.prefix = prefix
self.generators = []
def __init__(self, prefix):
self.prefix = prefix
self.generators = []
def add(self, g, dupcheck=0):
if dupcheck:
if g in self.generators:
print 'DUP', g.name
return
g.setprefix(self.prefix)
self.generators.append(g)
def add(self, g, dupcheck=0):
if dupcheck:
if g in self.generators:
print 'DUP', g.name
return
g.setprefix(self.prefix)
self.generators.append(g)
def generate(self):
for g in self.generators:
g.generate()
Output()
Output("static PyMethodDef %s_methods[] = {", self.prefix)
IndentLevel()
for g in self.generators:
g.reference()
Output("{NULL, NULL, 0}")
DedentLevel()
Output("};")
def generate(self):
for g in self.generators:
g.generate()
Output()
Output("static PyMethodDef %s_methods[] = {", self.prefix)
IndentLevel()
for g in self.generators:
g.reference()
Output("{NULL, NULL, 0}")
DedentLevel()
Output("};")
def _test():
void = None
from bgenGenerator import FunctionGenerator
group = GeneratorGroup("spam")
eggs = FunctionGenerator(void, "eggs")
group.add(eggs)
print "/* START */"
group.generate()
void = None
from bgenGenerator import FunctionGenerator
group = GeneratorGroup("spam")
eggs = FunctionGenerator(void, "eggs")
group.add(eggs)
print "/* START */"
group.generate()
if __name__ == "__main__":
_test()
_test()
......@@ -7,105 +7,105 @@ from bgenBuffer import FixedInputOutputBufferType
class HeapInputOutputBufferType(FixedInputOutputBufferType):
"""Input-output buffer allocated on the heap -- passed as (inbuffer, outbuffer, size).
"""Input-output buffer allocated on the heap -- passed as (inbuffer, outbuffer, size).
Instantiate without parameters.
Call from Python with input buffer.
"""
Instantiate without parameters.
Call from Python with input buffer.
"""
def __init__(self, datatype = 'char', sizetype = 'int', sizeformat = None):
FixedInputOutputBufferType.__init__(self, "0", datatype, sizetype, sizeformat)
def __init__(self, datatype = 'char', sizetype = 'int', sizeformat = None):
FixedInputOutputBufferType.__init__(self, "0", datatype, sizetype, sizeformat)
def declareOutputBuffer(self, name):
Output("%s *%s__out__;", self.datatype, name)
def declareOutputBuffer(self, name):
Output("%s *%s__out__;", self.datatype, name)
def getargsCheck(self, name):
Output("if ((%s__out__ = malloc(%s__in_len__)) == NULL)", name, name)
OutLbrace()
Output('PyErr_NoMemory();')
Output("goto %s__error__;", name)
self.label_needed = 1
OutRbrace()
Output("%s__len__ = %s__in_len__;", name, name)
def getargsCheck(self, name):
Output("if ((%s__out__ = malloc(%s__in_len__)) == NULL)", name, name)
OutLbrace()
Output('PyErr_NoMemory();')
Output("goto %s__error__;", name)
self.label_needed = 1
OutRbrace()
Output("%s__len__ = %s__in_len__;", name, name)
def passOutput(self, name):
return "%s__in__, %s__out__, (%s)%s__len__" % \
(name, name, self.sizetype, name)
def passOutput(self, name):
return "%s__in__, %s__out__, (%s)%s__len__" % \
(name, name, self.sizetype, name)
def mkvalueArgs(self, name):
return "%s__out__, (int)%s__len__" % (name, name)
def mkvalueArgs(self, name):
return "%s__out__, (int)%s__len__" % (name, name)
def cleanup(self, name):
Output("free(%s__out__);", name)
FixedInputOutputBufferType.cleanup(self, name)
def cleanup(self, name):
Output("free(%s__out__);", name)
FixedInputOutputBufferType.cleanup(self, name)
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)
"""same as base class, but passed as (inbuffer, outbuffer, &size)"""
def passOutput(self, name):
return "%s__in__, %s__out__, &%s__len__" % (name, name, name)
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)
"""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)
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)
"""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)
class HeapOutputBufferType(OutputOnlyMixIn, HeapInputOutputBufferType):
"""Output buffer allocated on the heap -- passed as (buffer, size).
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)
"""Output buffer allocated on the heap -- passed as (buffer, size).
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)
class VarHeapOutputBufferType(HeapOutputBufferType):
"""Output buffer allocated on the heap -- passed as (buffer, &size).
"""Output buffer allocated on the heap -- passed as (buffer, &size).
Instantiate without parameters.
Call from Python with buffer size.
"""
Instantiate without parameters.
Call from Python with buffer size.
"""
def passOutput(self, name):
return "%s__out__, &%s__len__" % (name, name)
def passOutput(self, name):
return "%s__out__, &%s__len__" % (name, name)
class VarVarHeapOutputBufferType(VarHeapOutputBufferType):
"""Output buffer allocated on the heap -- passed as (buffer, size, &size).
"""Output buffer allocated on the heap -- passed as (buffer, size, &size).
Instantiate without parameters.
Call from Python with buffer size.
"""
Instantiate without parameters.
Call from Python with buffer size.
"""
def passOutput(self, name):
return "%s__out__, %s__len__, &%s__len__" % (name, name, name)
def passOutput(self, name):
return "%s__out__, %s__len__, &%s__len__" % (name, name, name)
......@@ -3,92 +3,92 @@ from bgenGeneratorGroup import GeneratorGroup
class Module(GeneratorGroup):
def __init__(self, name, prefix = None,
includestuff = None,
finalstuff = None,
initstuff = None,
variablestuff = None,
longname = None):
GeneratorGroup.__init__(self, prefix or name)
self.name = name
if longname:
self.longname = longname
else:
self.longname = name
self.includestuff = includestuff
self.initstuff = initstuff
self.finalstuff = finalstuff
self.variablestuff = variablestuff
self.typeobjects = []
def addobject(self, od):
self.generators.append(od)
self.typeobjects.append(od)
od.setmodulename(self.longname)
def generate(self):
OutHeader1("Module " + self.name)
Output("#include \"Python.h\"")
Output()
if self.includestuff:
Output()
Output("%s", self.includestuff)
self.declareModuleVariables()
GeneratorGroup.generate(self)
if self.finalstuff:
Output()
Output("%s", self.finalstuff)
Output()
Output("void init%s(void)", self.name)
OutLbrace()
Output("PyObject *m;")
Output("PyObject *d;")
Output()
if self.initstuff:
Output("%s", self.initstuff)
Output()
Output("m = Py_InitModule(\"%s\", %s_methods);",
self.name, self.prefix)
Output("d = PyModule_GetDict(m);")
self.createModuleVariables()
OutRbrace()
OutHeader1("End module " + self.name)
def declareModuleVariables(self):
self.errorname = self.prefix + "_Error"
Output("static PyObject *%s;", self.errorname)
def createModuleVariables(self):
Output("""%s = %s;""", self.errorname, self.exceptionInitializer())
Output("""if (%s == NULL ||""", self.errorname)
Output(""" PyDict_SetItemString(d, "Error", %s) != 0)""",
self.errorname)
IndentLevel()
Output("""return;""")
DedentLevel()
for tp in self.typeobjects:
tp.outputTypeObjectInitializer()
if self.variablestuff:
Output("%s", self.variablestuff)
Output()
def exceptionInitializer(self):
return """PyErr_NewException("%s.Error", NULL, NULL)""" % self.name
def __init__(self, name, prefix = None,
includestuff = None,
finalstuff = None,
initstuff = None,
variablestuff = None,
longname = None):
GeneratorGroup.__init__(self, prefix or name)
self.name = name
if longname:
self.longname = longname
else:
self.longname = name
self.includestuff = includestuff
self.initstuff = initstuff
self.finalstuff = finalstuff
self.variablestuff = variablestuff
self.typeobjects = []
def addobject(self, od):
self.generators.append(od)
self.typeobjects.append(od)
od.setmodulename(self.longname)
def generate(self):
OutHeader1("Module " + self.name)
Output("#include \"Python.h\"")
Output()
if self.includestuff:
Output()
Output("%s", self.includestuff)
self.declareModuleVariables()
GeneratorGroup.generate(self)
if self.finalstuff:
Output()
Output("%s", self.finalstuff)
Output()
Output("void init%s(void)", self.name)
OutLbrace()
Output("PyObject *m;")
Output("PyObject *d;")
Output()
if self.initstuff:
Output("%s", self.initstuff)
Output()
Output("m = Py_InitModule(\"%s\", %s_methods);",
self.name, self.prefix)
Output("d = PyModule_GetDict(m);")
self.createModuleVariables()
OutRbrace()
OutHeader1("End module " + self.name)
def declareModuleVariables(self):
self.errorname = self.prefix + "_Error"
Output("static PyObject *%s;", self.errorname)
def createModuleVariables(self):
Output("""%s = %s;""", self.errorname, self.exceptionInitializer())
Output("""if (%s == NULL ||""", self.errorname)
Output(""" PyDict_SetItemString(d, "Error", %s) != 0)""",
self.errorname)
IndentLevel()
Output("""return;""")
DedentLevel()
for tp in self.typeobjects:
tp.outputTypeObjectInitializer()
if self.variablestuff:
Output("%s", self.variablestuff)
Output()
def exceptionInitializer(self):
return """PyErr_NewException("%s.Error", NULL, NULL)""" % self.name
def _test():
from bgenGenerator import FunctionGenerator
m = Module("spam", "", "#include <stdio.h>")
g = FunctionGenerator(None, "bacon")
m.add(g)
m.generate()
from bgenGenerator import FunctionGenerator
m = Module("spam", "", "#include <stdio.h>")
g = FunctionGenerator(None, "bacon")
m.add(g)
m.generate()
if __name__ == "__main__":
_test()
_test()
This diff is collapsed.
......@@ -6,54 +6,54 @@ from bgenBuffer import FixedInputBufferType, FixedOutputBufferType
class StackOutputBufferType(FixedOutputBufferType):
"""Fixed output buffer allocated on the stack -- passed as (buffer, size).
"""Fixed output buffer allocated on the stack -- passed as (buffer, size).
Instantiate with the buffer size as parameter.
"""
Instantiate with the buffer size as parameter.
"""
def passOutput(self, name):
return "%s__out__, %s" % (name, self.size)
def passOutput(self, name):
return "%s__out__, %s" % (name, self.size)
class VarStackOutputBufferType(StackOutputBufferType):
"""Output buffer allocated on the stack -- passed as (buffer, &size).
"""Output buffer allocated on the stack -- passed as (buffer, &size).
Instantiate with the buffer size as parameter.
"""
Instantiate with the buffer size as parameter.
"""
def declareSize(self, name):
Output("int %s__len__ = %s;", name, self.size)
def declareSize(self, name):
Output("int %s__len__ = %s;", name, self.size)
def passOutput(self, name):
return "%s__out__, &%s__len__" % (name, name)
def passOutput(self, name):
return "%s__out__, &%s__len__" % (name, name)
def mkvalueArgs(self, name):
return "%s__out__, (int)%s__len__" % (name, name)
def mkvalueArgs(self, name):
return "%s__out__, (int)%s__len__" % (name, name)
class VarVarStackOutputBufferType(VarStackOutputBufferType):
"""Output buffer allocated on the stack -- passed as (buffer, size, &size).
"""Output buffer allocated on the stack -- passed as (buffer, size, &size).
Instantiate with the buffer size as parameter.
"""
Instantiate with the buffer size as parameter.
"""
def passOutput(self, name):
return "%s__out__, %s__len__, &%s__len__" % (name, name, name)
def passOutput(self, name):
return "%s__out__, %s__len__, &%s__len__" % (name, name, name)
class ReturnVarStackOutputBufferType(VarStackOutputBufferType):
"""Output buffer allocated on the stack -- passed as (buffer, size) -> size.
"""Output buffer allocated on the stack -- passed as (buffer, size) -> size.
Instantiate with the buffer size as parameter.
The function's return value is the size.
(XXX Should have a way to suppress returning it separately, too.)
"""
Instantiate with the buffer size as parameter.
The function's return value is the size.
(XXX Should have a way to suppress returning it separately, too.)
"""
def passOutput(self, name):
return "%s__out__, %s__len__" % (name, name)
def passOutput(self, name):
return "%s__out__, %s__len__" % (name, name)
def mkvalueArgs(self, name):
return "%s__out__, (int)_rv" % name
def mkvalueArgs(self, name):
return "%s__out__, (int)_rv" % name
......@@ -8,57 +8,57 @@ from bgenHeapBuffer import HeapOutputBufferType
class StringBufferMixIn:
"""Mix-in class to create various string buffer types.
Strings are character arrays terminated by a null byte.
(For input, this is also covered by stringptr.)
For output, there are again three variants:
- Fixed: size is a constant given in the documentation; or
- Stack: size is passed to the C function but we decide on a size at
code generation time so we can still allocate on the heap); or
- Heap: size is passed to the C function and we let the Python caller
pass a size.
(Note that this doesn't cover output parameters in which a string
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
def mkvalueFormat(self):
return "s"
def mkvalueArgs(self, name):
return "%s__out__" % name
"""Mix-in class to create various string buffer types.
Strings are character arrays terminated by a null byte.
(For input, this is also covered by stringptr.)
For output, there are again three variants:
- Fixed: size is a constant given in the documentation; or
- Stack: size is passed to the C function but we decide on a size at
code generation time so we can still allocate on the heap); or
- Heap: size is passed to the C function and we let the Python caller
pass a size.
(Note that this doesn't cover output parameters in which a string
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
def mkvalueFormat(self):
return "s"
def mkvalueArgs(self, name):
return "%s__out__" % name
class FixedOutputStringType(StringBufferMixIn, FixedOutputBufferType):
"""Null-terminated output string -- passed without size.
"""Null-terminated output string -- passed without size.
Instantiate with buffer size as parameter.
"""
Instantiate with buffer size as parameter.
"""
class StackOutputStringType(StringBufferMixIn, StackOutputBufferType):
"""Null-terminated output string -- passed as (buffer, size).
"""Null-terminated output string -- passed as (buffer, size).
Instantiate with buffer size as parameter.
"""
Instantiate with buffer size as parameter.
"""
class HeapOutputStringType(StringBufferMixIn, HeapOutputBufferType):
"""Null-terminated output string -- passed as (buffer, size).
"""Null-terminated output string -- passed as (buffer, size).
Instantiate without parameters.
Call from Python with buffer size.
"""
Instantiate without parameters.
Call from Python with buffer size.
"""
This diff is collapsed.
......@@ -17,72 +17,72 @@ ErrorMode = 16+OutMode # this is an error status -- turn it into an exception
class Variable:
"""A Variable holds a type, a name, a transfer mode and flags.
Most of its methods call the correponding type method with the
variable name.
"""
def __init__(self, type, name = None, flags = InMode):
"""Call with a type, a name and flags.
If name is None, it muse be set later.
flags defaults to InMode.
"""
self.type = type
self.name = name
self.flags = flags
self.mode = flags & ModeMask
def declare(self):
"""Declare the variable if necessary.
If it is "self", it is not declared.
"""
if self.flags != SelfMode:
self.type.declare(self.name)
def getargsFormat(self):
"""Call the type's getargsFormatmethod."""
return self.type.getargsFormat()
def getargsArgs(self):
"""Call the type's getargsArgsmethod."""
return self.type.getargsArgs(self.name)
def getargsCheck(self):
return self.type.getargsCheck(self.name)
def passArgument(self):
"""Return the string required to pass the variable as argument.
For "in" arguments, return the variable name.
For "out" and "in out" arguments,
return its name prefixed with "&".
"""
if self.mode == InMode:
return self.type.passInput(self.name)
if self.mode in (OutMode, InOutMode):
return self.type.passOutput(self.name)
# XXX Shouldn't get here
return "/*mode?*/" + self.type.passInput(self.name)
def errorCheck(self):
"""Check for an error if necessary.
This only generates code if the variable's mode is ErrorMode.
"""
if self.flags == ErrorMode:
self.type.errorCheck(self.name)
def mkvalueFormat (self):
"""Call the type's mkvalueFormat method."""
return self.type.mkvalueFormat()
def mkvalueArgs(self):
"""Call the type's mkvalueArgs method."""
return self.type.mkvalueArgs(self.name)
def cleanup(self):
"""Call the type's cleanup method."""
return self.type.cleanup(self.name)
"""A Variable holds a type, a name, a transfer mode and flags.
Most of its methods call the correponding type method with the
variable name.
"""
def __init__(self, type, name = None, flags = InMode):
"""Call with a type, a name and flags.
If name is None, it muse be set later.
flags defaults to InMode.
"""
self.type = type
self.name = name
self.flags = flags
self.mode = flags & ModeMask
def declare(self):
"""Declare the variable if necessary.
If it is "self", it is not declared.
"""
if self.flags != SelfMode:
self.type.declare(self.name)
def getargsFormat(self):
"""Call the type's getargsFormatmethod."""
return self.type.getargsFormat()
def getargsArgs(self):
"""Call the type's getargsArgsmethod."""
return self.type.getargsArgs(self.name)
def getargsCheck(self):
return self.type.getargsCheck(self.name)
def passArgument(self):
"""Return the string required to pass the variable as argument.
For "in" arguments, return the variable name.
For "out" and "in out" arguments,
return its name prefixed with "&".
"""
if self.mode == InMode:
return self.type.passInput(self.name)
if self.mode in (OutMode, InOutMode):
return self.type.passOutput(self.name)
# XXX Shouldn't get here
return "/*mode?*/" + self.type.passInput(self.name)
def errorCheck(self):
"""Check for an error if necessary.
This only generates code if the variable's mode is ErrorMode.
"""
if self.flags == ErrorMode:
self.type.errorCheck(self.name)
def mkvalueFormat (self):
"""Call the type's mkvalueFormat method."""
return self.type.mkvalueFormat()
def mkvalueArgs(self):
"""Call the type's mkvalueArgs method."""
return self.type.mkvalueArgs(self.name)
def cleanup(self):
"""Call the type's cleanup method."""
return self.type.cleanup(self.name)
......@@ -52,7 +52,7 @@ FSRef = OpaqueByValueStructType("FSRef", "PyMac_BuildFSRef", "PyMac_GetFSRef")
# OSType and ResType: 4-byte character strings
def OSTypeType(typename):
return OpaqueByValueType(typename, "PyMac_BuildOSType", "PyMac_GetOSType")
return OpaqueByValueType(typename, "PyMac_BuildOSType", "PyMac_GetOSType")
OSType = OSTypeType("OSType")
ResType = OSTypeType("ResType")
FourCharCode = OSTypeType("FourCharCode")
......@@ -104,35 +104,35 @@ OptionalCFURLRef = OpaqueByValueType("CFURLRef", "OptionalCFURLRefObj")
# OSErr is special because it is turned into an exception
# (Could do this with less code using a variant of mkvalue("O&")?)
class OSErrType(Type):
def errorCheck(self, name):
Output("if (%s != noErr) return PyMac_Error(%s);", name, name)
self.used = 1
def errorCheck(self, name):
Output("if (%s != noErr) return PyMac_Error(%s);", name, name)
self.used = 1
OSErr = OSErrType("OSErr", 'h')
OSStatus = OSErrType("OSStatus", 'l')
# Various buffer types
InBuffer = VarInputBufferType('char', 'long', 'l') # (buf, len)
UcharInBuffer = VarInputBufferType('unsigned char', 'long', 'l') # (buf, len)
OptionalInBuffer = OptionalVarInputBufferType('char', 'long', 'l') # (buf, len)
InBuffer = VarInputBufferType('char', 'long', 'l') # (buf, len)
UcharInBuffer = VarInputBufferType('unsigned char', 'long', 'l') # (buf, len)
OptionalInBuffer = OptionalVarInputBufferType('char', 'long', 'l') # (buf, len)
InOutBuffer = HeapInputOutputBufferType('char', 'long', 'l') # (inbuf, outbuf, len)
InOutBuffer = HeapInputOutputBufferType('char', 'long', 'l') # (inbuf, outbuf, len)
VarInOutBuffer = VarHeapInputOutputBufferType('char', 'long', 'l') # (inbuf, outbuf, &len)
OutBuffer = HeapOutputBufferType('char', 'long', 'l') # (buf, len)
VarOutBuffer = VarHeapOutputBufferType('char', 'long', 'l') # (buf, &len)
OutBuffer = HeapOutputBufferType('char', 'long', 'l') # (buf, len)
VarOutBuffer = VarHeapOutputBufferType('char', 'long', 'l') # (buf, &len)
VarVarOutBuffer = VarVarHeapOutputBufferType('char', 'long', 'l') # (buf, len, &len)
# Unicode arguments sometimes have reversed len, buffer (don't understand why Apple did this...)
class VarUnicodeInputBufferType(VarInputBufferType):
def getargsFormat(self):
return "u#"
def getargsFormat(self):
return "u#"
class VarUnicodeReverseInputBufferType(ReverseInputBufferMixin, VarUnicodeInputBufferType):
pass
pass
UnicodeInBuffer = VarUnicodeInputBufferType('UniChar', 'UniCharCount', 'l')
UnicodeReverseInBuffer = VarUnicodeReverseInputBufferType('UniChar', 'UniCharCount', 'l')
UniChar_ptr = InputOnlyType("UniCharPtr", "u")
......@@ -151,9 +151,9 @@ includestuff = """
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\\
PyErr_SetString(PyExc_NotImplementedError, \\
"Not available in this shared library/OS version"); \\
return NULL; \\
PyErr_SetString(PyExc_NotImplementedError, \\
"Not available in this shared library/OS version"); \\
return NULL; \\
}} while(0)
"""
......@@ -173,23 +173,23 @@ initstuff = """
# This requires that the OSErr type (defined above) has a non-trivial
# errorCheck method.
class OSErrMixIn:
"Mix-in class to treat OSErr/OSStatus return values special"
def makereturnvar(self):
if self.returntype.__class__ == OSErrType:
return Variable(self.returntype, "_err", ErrorMode)
else:
return Variable(self.returntype, "_rv", OutMode)
"Mix-in class to treat OSErr/OSStatus return values special"
def makereturnvar(self):
if self.returntype.__class__ == OSErrType:
return Variable(self.returntype, "_err", ErrorMode)
else:
return Variable(self.returntype, "_rv", OutMode)
class OSErrFunctionGenerator(OSErrMixIn, FunctionGenerator): pass
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)
Output('#endif')
"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)
Output('#endif')
class WeakLinkFunctionGenerator(WeakLinkMixIn, FunctionGenerator): pass
class WeakLinkMethodGenerator(WeakLinkMixIn, MethodGenerator): pass
......@@ -197,14 +197,14 @@ class OSErrWeakLinkFunctionGenerator(OSErrMixIn, WeakLinkMixIn, FunctionGenerato
class OSErrWeakLinkMethodGenerator(OSErrMixIn, WeakLinkMixIn, MethodGenerator): pass
class MacModule(Module):
"Subclass which gets the exception initializer from macglue.c"
def exceptionInitializer(self):
return "PyMac_GetOSErrException()"
"Subclass which gets the exception initializer from macglue.c"
def exceptionInitializer(self):
return "PyMac_GetOSErrException()"
_SetOutputFileName = SetOutputFileName # Save original
def SetOutputFileName(file = None):
"Set the output file name and set its creator&type to CWIE&TEXT"
_SetOutputFileName(file)
if file:
import MacOS
MacOS.SetCreatorAndType(file, 'CWIE', 'TEXT')
"Set the output file name and set its creator&type to CWIE&TEXT"
_SetOutputFileName(file)
if file:
import MacOS
MacOS.SetCreatorAndType(file, 'CWIE', 'TEXT')
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment