mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
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).
This commit is contained in:
parent
3d3a91c188
commit
6f70d62855
3 changed files with 300 additions and 326 deletions
|
@ -17,11 +17,38 @@ OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
|
|||
|
||||
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
|
||||
|
||||
includestuff = includestuff + """
|
||||
#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
|
||||
#include <CoreFoundation.h>
|
||||
#endif
|
||||
|
@ -31,6 +58,8 @@ staticforward PyObject *CFTypeRefObj_New(CFTypeRef);
|
|||
staticforward int CFTypeRefObj_Convert(PyObject *, CFTypeRef *);
|
||||
staticforward PyObject *CFStringRefObj_New(CFStringRef);
|
||||
staticforward int CFStringRefObj_Convert(PyObject *, CFStringRef *);
|
||||
staticforward PyObject *CFURLRefObj_New(CFURLRef);
|
||||
staticforward int CFURLRefObj_Convert(PyObject *, CFURLRef *);
|
||||
|
||||
staticforward int CFURLRefObj_Convert(PyObject *, CFURLRef *);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue