Commit 146b292e authored by Jack Jansen's avatar Jack Jansen

Used an adapted MethodGenerator to generate methods too for functions that...

Used an adapted MethodGenerator to generate methods too for functions that have the object as the second arg after a first CFAllocatorRef arg (which we pass as NULL always anyway).
parent 582cbe83
This diff is collapsed.
...@@ -58,6 +58,12 @@ class MyScanner(Scanner_OSX): ...@@ -58,6 +58,12 @@ class MyScanner(Scanner_OSX):
if t in OBJECTS and m == "InMode": if t in OBJECTS and m == "InMode":
classname = "Method" classname = "Method"
listname = t + "_methods" 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 return classname, listname
def writeinitialdefs(self): def writeinitialdefs(self):
...@@ -85,9 +91,7 @@ class MyScanner(Scanner_OSX): ...@@ -85,9 +91,7 @@ class MyScanner(Scanner_OSX):
"CFStringGetCharactersPtr", "CFStringGetCharactersPtr",
"CFStringGetCString", "CFStringGetCString",
"CFStringGetCharacters", "CFStringGetCharacters",
# OSX only, to be done "CFURLCreateStringWithFileSystemPath", # Gone in later releases
## "CFURLCreateWithFileSystemPath",
## "CFURLCreateStringWithFileSystemPath",
] ]
def makegreylist(self): def makegreylist(self):
......
...@@ -17,11 +17,38 @@ OUTPUTFILE = MODNAME + "module.c" # The file generated by this program ...@@ -17,11 +17,38 @@ OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
from macsupport import * from macsupport import *
# Special case generator for the functions that have an AllocatorRef first argument,
# which we skip anyway, and the object as the second arg.
class MethodSkipArg1(MethodGenerator):
"""Similar to MethodGenerator, but has self as last argument"""
def parseArgumentList(self, args):
if len(args) < 2:
raise ValueError, "MethodSkipArg1 expects at least 2 args"
a0, a1, args = args[0], args[1], args[2:]
t0, n0, m0 = a0
if t0 != "CFAllocatorRef" and m0 != InMode:
raise ValueError, "MethodSkipArg1 should have dummy AllocatorRef first arg"
t1, n1, m1 = a1
if m1 != InMode:
raise ValueError, "method's 'self' must be 'InMode'"
dummy = Variable(t0, n0, m0)
self.argumentList.append(dummy)
self.itself = Variable(t1, "_self->ob_itself", SelfMode)
self.argumentList.append(self.itself)
FunctionGenerator.parseArgumentList(self, args)
# Create the type objects # Create the type objects
includestuff = includestuff + """ includestuff = includestuff + """
#ifdef WITHOUT_FRAMEWORKS #ifdef WITHOUT_FRAMEWORKS
#include <CoreFoundation.h> #include <CFBase.h>
#include <CFArray.h>
#include <CFData.h>
#include <CFDictionary.h>
#include <CFString.h>
#include <CFURL.h>
#else #else
#include <CoreFoundation.h> #include <CoreFoundation.h>
#endif #endif
...@@ -31,6 +58,8 @@ staticforward PyObject *CFTypeRefObj_New(CFTypeRef); ...@@ -31,6 +58,8 @@ staticforward PyObject *CFTypeRefObj_New(CFTypeRef);
staticforward int CFTypeRefObj_Convert(PyObject *, CFTypeRef *); staticforward int CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
staticforward PyObject *CFStringRefObj_New(CFStringRef); staticforward PyObject *CFStringRefObj_New(CFStringRef);
staticforward int CFStringRefObj_Convert(PyObject *, CFStringRef *); staticforward int CFStringRefObj_Convert(PyObject *, CFStringRef *);
staticforward PyObject *CFURLRefObj_New(CFURLRef);
staticforward int CFURLRefObj_Convert(PyObject *, CFURLRef *);
staticforward int CFURLRefObj_Convert(PyObject *, CFURLRef *); staticforward int CFURLRefObj_Convert(PyObject *, CFURLRef *);
......
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