cpython/Mac/Modules/ibcarbon/IBCarbonsupport.py
Jack Jansen 96cebde909 Added PEP253 support to most Carbon modules. This isn't complete yet:
some of the more compilcated cases (CF, Res) haven't been done yet. Also,
various types should inherit from each other (anything with an as_Resource
method should be a Resource subtype, the CF types should become one family).
2002-12-03 23:40:22 +00:00

58 lines
1.4 KiB
Python

# IBCarbonsupport.py
from macsupport import *
IBNibRef = OpaqueByValueType('IBNibRef', 'IBNibRefObj')
#CFBundleRef = OpaqueByValueType('CFBundleRef')
IBCarbonFunction = OSErrFunctionGenerator
IBCarbonMethod = OSErrMethodGenerator
includestuff = """
#ifdef WITHOUT_FRAMEWORKS
#include <IBCarbonRuntime.h>
#else
#include <Carbon/Carbon.h>
#endif /* WITHOUT_FRAMEWORKS */
#include "macglue.h"
#ifdef USE_TOOLBOX_OBJECT_GLUE
extern int _CFStringRefObj_Convert(PyObject *, CFStringRef *);
//#define CFStringRefObj_Convert _CFStringRefObj_Convert
#endif
//extern int CFBundleRefObj_Convert(PyObject *, CFBundleRef *); // need to wrap CFBundle
"""
initstuff = """
"""
module = MacModule('_IBCarbon', 'IBCarbon', includestuff, finalstuff, initstuff)
class CFReleaserObject(PEP253Mixin, GlobalObjectDefinition):
def outputFreeIt(self, name):
Output("CFRelease(%s);" % name)
class CFNibDesc(PEP253Mixin, GlobalObjectDefinition):
def outputFreeIt(self, name):
Output("DisposeNibReference(%s);" % name)
#cfstringobject = CFReleaserObject("CFStringRef")
#module.addobject(cfstringobject)
#cfbundleobject = CFReleaserObject("CFBundleRef")
#module.addobject(cfbundleobject)
ibnibobject = CFNibDesc("IBNibRef", "IBNibRefObj")
module.addobject(ibnibobject)
functions = []
methods = []
execfile('IBCarbongen.py')
for f in functions: module.add(f)
for m in methods: ibnibobject.add(m)
SetOutputFileName('_IBCarbon.c')
module.generate()