summaryrefslogtreecommitdiff
path: root/Mac/Modules/cg
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 +0000
committerTim Peters <tim.peters@gmail.com>2004-07-18 06:16:08 +0000
commitc71fe97a2c07d09144fd634f442a8ad29c84e0c0 (patch)
treea3058fb9abd3146b5bafd435e449cce2df397876 /Mac/Modules/cg
parentacbad78022027cf7d94c4b9d60b1a1f44441ad93 (diff)
downloadcpython-c71fe97a2c07d09144fd634f442a8ad29c84e0c0.tar.gz
Whitespace normalization, via reindent.py.
Diffstat (limited to 'Mac/Modules/cg')
-rwxr-xr-xMac/Modules/cg/cgscan.py124
-rwxr-xr-xMac/Modules/cg/cgsupport.py99
2 files changed, 111 insertions, 112 deletions
diff --git a/Mac/Modules/cg/cgscan.py b/Mac/Modules/cg/cgscan.py
index 5d84500d6e..b2e7946195 100755
--- a/Mac/Modules/cg/cgscan.py
+++ b/Mac/Modules/cg/cgscan.py
@@ -8,77 +8,77 @@ from scantools import Scanner_OSX
LONG = "CoreGraphics"
SHORT = "cg"
-OBJECTS = ("CGContextRef",
- )
+OBJECTS = ("CGContextRef",
+ )
# ADD object typenames here
def main():
- input = [
- "CGContext.h",
- ]
- output = SHORT + "gen.py"
- defsoutput = TOOLBOXDIR + LONG + ".py"
- scanner = MyScanner(input, output, defsoutput)
- scanner.scan()
- scanner.gentypetest(SHORT+"typetest.py")
- scanner.close()
- print "=== Testing definitions output code ==="
- execfile(defsoutput, {}, {})
- print "=== Done scanning and generating, now importing the generated code... ==="
- exec "import " + SHORT + "support"
- print "=== Done. It's up to you to compile it now! ==="
+ input = [
+ "CGContext.h",
+ ]
+ output = SHORT + "gen.py"
+ defsoutput = TOOLBOXDIR + LONG + ".py"
+ scanner = MyScanner(input, output, defsoutput)
+ scanner.scan()
+ scanner.gentypetest(SHORT+"typetest.py")
+ scanner.close()
+ print "=== Testing definitions output code ==="
+ execfile(defsoutput, {}, {})
+ print "=== Done scanning and generating, now importing the generated code... ==="
+ exec "import " + SHORT + "support"
+ print "=== Done. It's up to you to compile it now! ==="
class MyScanner(Scanner_OSX):
- def destination(self, type, name, arglist):
- classname = "Function"
- listname = "functions"
- if arglist:
- t, n, m = arglist[0]
- if t in OBJECTS and m == "InMode":
- classname = "Method"
- listname = t + "_methods"
- # Special case for the silly first AllocatorRef argument
- if t == 'CFAllocatorRef' and m == 'InMode' and len(arglist) > 1:
- t, n, m = arglist[1]
- if t in OBJECTS and m == "InMode":
- classname = "MethodSkipArg1"
- listname = t + "_methods"
- return classname, listname
+ def destination(self, type, name, arglist):
+ classname = "Function"
+ listname = "functions"
+ if arglist:
+ t, n, m = arglist[0]
+ if t in OBJECTS and m == "InMode":
+ classname = "Method"
+ listname = t + "_methods"
+ # Special case for the silly first AllocatorRef argument
+ if t == 'CFAllocatorRef' and m == 'InMode' and len(arglist) > 1:
+ t, n, m = arglist[1]
+ if t in OBJECTS and m == "InMode":
+ classname = "MethodSkipArg1"
+ listname = t + "_methods"
+ return classname, listname
- def writeinitialdefs(self):
- self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
+ def writeinitialdefs(self):
+ self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
- def makeblacklistnames(self):
- return [
- "CGContextRetain",
- "CGContextRelease",
- ]
+ def makeblacklistnames(self):
+ return [
+ "CGContextRetain",
+ "CGContextRelease",
+ ]
- def makegreylist(self):
- return []
+ def makegreylist(self):
+ return []
- def makeblacklisttypes(self):
- return [
- "float_ptr",
- "CGRect_ptr",
- "CGPoint_ptr",
- "CGColorSpaceRef",
- "CGColorRenderingIntent",
- "CGFontRef",
-# "char_ptr",
- "CGGlyph_ptr",
- "CGImageRef",
- "CGPDFDocumentRef",
- ]
+ def makeblacklisttypes(self):
+ return [
+ "float_ptr",
+ "CGRect_ptr",
+ "CGPoint_ptr",
+ "CGColorSpaceRef",
+ "CGColorRenderingIntent",
+ "CGFontRef",
+# "char_ptr",
+ "CGGlyph_ptr",
+ "CGImageRef",
+ "CGPDFDocumentRef",
+ ]
+
+ def makerepairinstructions(self):
+ return [
+ ([("char_ptr", "cstring", "InMode"), ("size_t", "length", "InMode")],
+ [("InBuffer", "*", "*")]),
+# ([("char_ptr", "name", "InMode"),],
+# [("CCCCC", "*", "*")]),
+ ]
- def makerepairinstructions(self):
- return [
- ([("char_ptr", "cstring", "InMode"), ("size_t", "length", "InMode")],
- [("InBuffer", "*", "*")]),
-# ([("char_ptr", "name", "InMode"),],
-# [("CCCCC", "*", "*")]),
- ]
-
if __name__ == "__main__":
- main()
+ main()
diff --git a/Mac/Modules/cg/cgsupport.py b/Mac/Modules/cg/cgsupport.py
index 7dc2d54cdf..6eedfbef3f 100755
--- a/Mac/Modules/cg/cgsupport.py
+++ b/Mac/Modules/cg/cgsupport.py
@@ -8,12 +8,12 @@
import string
# Declarations that change for each manager
-MODNAME = '_CG' # The name of the module
+MODNAME = '_CG' # The name of the module
# The following is *usually* unchanged but may still require tuning
-MODPREFIX = 'CG' # The prefix for module-wide routines
+MODPREFIX = 'CG' # The prefix for module-wide routines
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
-OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
+OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import *
@@ -34,74 +34,74 @@ extern int GrafObj_Convert(PyObject *, GrafPtr *);
PyObject *CGPoint_New(CGPoint *itself)
{
- return Py_BuildValue("(ff)",
- itself->x,
- itself->y);
+ return Py_BuildValue("(ff)",
+ itself->x,
+ itself->y);
}
int
CGPoint_Convert(PyObject *v, CGPoint *p_itself)
{
- if( !PyArg_Parse(v, "(ff)",
- &p_itself->x,
- &p_itself->y) )
- return 0;
- return 1;
+ if( !PyArg_Parse(v, "(ff)",
+ &p_itself->x,
+ &p_itself->y) )
+ return 0;
+ return 1;
}
PyObject *CGRect_New(CGRect *itself)
{
- return Py_BuildValue("(ffff)",
- itself->origin.x,
- itself->origin.y,
- itself->size.width,
- itself->size.height);
+ return Py_BuildValue("(ffff)",
+ itself->origin.x,
+ itself->origin.y,
+ itself->size.width,
+ itself->size.height);
}
int
CGRect_Convert(PyObject *v, CGRect *p_itself)
{
- if( !PyArg_Parse(v, "(ffff)",
- &p_itself->origin.x,
- &p_itself->origin.y,
- &p_itself->size.width,
- &p_itself->size.height) )
- return 0;
- return 1;
+ if( !PyArg_Parse(v, "(ffff)",
+ &p_itself->origin.x,
+ &p_itself->origin.y,
+ &p_itself->size.width,
+ &p_itself->size.height) )
+ return 0;
+ return 1;
}
PyObject *CGAffineTransform_New(CGAffineTransform *itself)
{
- return Py_BuildValue("(ffffff)",
- itself->a,
- itself->b,
- itself->c,
- itself->d,
- itself->tx,
- itself->ty);
+ return Py_BuildValue("(ffffff)",
+ itself->a,
+ itself->b,
+ itself->c,
+ itself->d,
+ itself->tx,
+ itself->ty);
}
int
CGAffineTransform_Convert(PyObject *v, CGAffineTransform *p_itself)
{
- if( !PyArg_Parse(v, "(ffffff)",
- &p_itself->a,
- &p_itself->b,
- &p_itself->c,
- &p_itself->d,
- &p_itself->tx,
- &p_itself->ty) )
- return 0;
- return 1;
+ if( !PyArg_Parse(v, "(ffffff)",
+ &p_itself->a,
+ &p_itself->b,
+ &p_itself->c,
+ &p_itself->d,
+ &p_itself->tx,
+ &p_itself->ty) )
+ return 0;
+ return 1;
}
"""
class MyOpaqueByValueType(OpaqueByValueType):
- """Sort of a mix between OpaqueByValueType and OpaqueType."""
- def mkvalueArgs(self, name):
- return "%s, &%s" % (self.new, name)
+ """Sort of a mix between OpaqueByValueType and OpaqueType."""
+ def mkvalueArgs(self, name):
+ return "%s, &%s" % (self.new, name)
CGPoint = MyOpaqueByValueType('CGPoint', 'CGPoint')
CGRect = MyOpaqueByValueType('CGRect', 'CGRect')
@@ -121,10 +121,10 @@ CGContextRef = OpaqueByValueType("CGContextRef", "CGContextRefObj")
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
- def outputStructMembers(self):
- ObjectDefinition.outputStructMembers(self)
- def outputCleanupStructMembers(self):
- Output("CGContextRelease(self->ob_itself);")
+ def outputStructMembers(self):
+ ObjectDefinition.outputStructMembers(self)
+ def outputCleanupStructMembers(self):
+ Output("CGContextRelease(self->ob_itself);")
# Create the generator groups and link them
@@ -169,11 +169,11 @@ CGContextRef ctx;
OSStatus _err;
if (!PyArg_ParseTuple(_args, "O&", GrafObj_Convert, &port))
- return NULL;
+ return NULL;
_err = CreateCGContextForPort(port, &ctx);
if (_err != noErr)
- if (_err != noErr) return PyMac_Error(_err);
+ if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&", CGContextRefObj_New, ctx);
return _res;
"""
@@ -185,9 +185,8 @@ module.add(f)
# ADD add forloop here
for f in CGContextRef_methods:
- CGContextRef_object.add(f)
+ CGContextRef_object.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName(OUTPUTFILE)
module.generate()
-