[PyObjC-svn] r2398 - in trunk/pyobjc/pyobjc-framework-Cocoa: . Lib/AppKit Lib/CoreFoundation Lib/Foundation Modules PyObjCTest

[email protected] Tue, 02 Feb 2010 10:58:46 -0600
Newsgroups gmane.comp.python.pyobjc.cvs
Message-ID <[email protected]>
Author: ronaldoussoren
Date: Tue Feb  2 10:58:46 2010
New Revision: 2398

Log:
Reduce the number of extensions modules. Every framework now
contains two extensions: one with the table of inline functions
and one with all manual wrappers.

This removes a lot of boilerplate code and should slightly improve
speed of initialization.


Added:
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation.m
Modified:
   trunk/pyobjc/pyobjc-framework-Cocoa/Lib/AppKit/__init__.py
   trunk/pyobjc/pyobjc-framework-Cocoa/Lib/CoreFoundation/__init__.py
   trunk/pyobjc/pyobjc-framework-Cocoa/Lib/Foundation/__init__.py
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_appmain.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_carbon.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsbezierpath.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsbitmap.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsfont.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsquickdrawview.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsview.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nswindow.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFBag.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFBinaryHeap.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFBitVector.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFCalendar.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFDictionary.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFFileDescriptor.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFMachPort.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFMessagePort.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFNumber.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFReadStream.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFRunLoopObserver.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFRunLoopSource.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFRunLoopTimer.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFSet.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFSocket.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFTree.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFWriteStream.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_NSDecimal.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_NSInvocation.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_data.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_netservice.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_nscoder.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_string.m
   trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_typecode.m
   trunk/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nsgraphicscontext.py
   trunk/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nspointerfunctions.py
   trunk/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nswindow.py
   trunk/pyobjc/pyobjc-framework-Cocoa/setup.py

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Lib/AppKit/__init__.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Lib/AppKit/__init__.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Lib/AppKit/__init__.py	Tue Feb  2 10:58:46 2010
@@ -21,16 +21,8 @@
 # NSApp in Python)
 from AppKit._nsapp import NSApp
 
-# Import some manually maintained helper code:
-from AppKit._appmain import *
-from AppKit._nsbezierpath import *
-from AppKit._nsfont import *
-from AppKit._nsquickdrawview import *
-from AppKit._nsbezierpath import *
-from AppKit._nsview import *
-from AppKit._nsbitmap import *
-from AppKit._nswindow import *
-
+# Manually written wrappers:
+from AppKit._AppKit import *
 
 # Fix types for a number of character constants
 NSEnterCharacter = unichr(NSEnterCharacter)

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Lib/CoreFoundation/__init__.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Lib/CoreFoundation/__init__.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Lib/CoreFoundation/__init__.py	Tue Feb  2 10:58:46 2010
@@ -18,27 +18,7 @@
     scan_classes=False,
     inlineTab=_inline_list_)
 
-#from CoreFoundation._CFArray import *
-from CoreFoundation._CFBag import *
-from CoreFoundation._CFBinaryHeap import *
-from CoreFoundation._CFBitVector import *
-
-from CoreFoundation._CFCalendar import *
-from CoreFoundation._CFDictionary import *
-from CoreFoundation._CFTree import *
-from CoreFoundation._CFFileDescriptor import *
-from CoreFoundation._CFMachPort import *
-from CoreFoundation._CFMessagePort import *
-from CoreFoundation._CFNumber import *
-from CoreFoundation._CFReadStream import *
-from CoreFoundation._CFRunLoopObserver import *
-from CoreFoundation._CFRunLoopTimer import *
-from CoreFoundation._CFWriteStream import *
-from CoreFoundation._CFRunLoopObserver import *
-from CoreFoundation._CFRunLoopSource import *
-from CoreFoundation._CFRunLoopTimer import *
-from CoreFoundation._CFSet import *
-from CoreFoundation._CFSocket import *
+from CoreFoundation._CoreFoundation import *
 
 #
 # 'Emulation' for CFArray contructors

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Lib/Foundation/__init__.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Lib/Foundation/__init__.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Lib/Foundation/__init__.py	Tue Feb  2 10:58:46 2010
@@ -20,13 +20,7 @@
 
 # Import the various manually maintained bits:
 from Foundation._functiondefines import *
-from Foundation._NSDecimal import *
-from Foundation._nsinvocation import *
-from Foundation._typecode import *
-from Foundation._nscoder import *
-from Foundation._data import *
-from Foundation._netservice import *
-from Foundation._string import *
+from Foundation._Foundation import *
 
 import Foundation._nsobject
 import Foundation._nsindexset

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_appmain.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_appmain.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_appmain.m	Tue Feb  2 10:58:46 2010
@@ -129,63 +129,10 @@
 }
 
 
-static PyMethodDef mod_methods[] = {
-	{ 
-		"NSApplicationMain", 
-		(PyCFunction)objc_NSApplicationMain, 
-		METH_VARARGS|METH_KEYWORDS, 
-		"int NSApplicationMain(int argc, const char *argv[]);"
+#define APPKIT_APPMAIN_METHODS \
+	{  							\
+		"NSApplicationMain", 				\
+		(PyCFunction)objc_NSApplicationMain, 		\
+		METH_VARARGS|METH_KEYWORDS, 			\
+		"int NSApplicationMain(int argc, const char *argv[]);" \
 	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_appmain",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__appmain(void);
-
-PyObject*
-PyInit__appmain(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_appmain(void);
-
-void
-init_appmain(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_appmain", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_carbon.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_carbon.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_carbon.m	Tue Feb  2 10:58:46 2010
@@ -2,11 +2,6 @@
  * Support code for dealing with Carbon types (at least those
  * used in AppKit and wrapped in the python core).
  */
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <AppKit/AppKit.h>
-#import <Carbon/Carbon.h>
 
 #ifndef __LP64__
 
@@ -20,7 +15,6 @@
 extern int WinObj_Convert(PyObject *, WindowPtr *);
 extern PyObject *WinObj_WhichWindow(WindowPtr);
 
-
 #endif
 
 static int
@@ -35,62 +29,11 @@
 	return WinObj_New((WindowPtr)value);
 }
 
-
-static PyMethodDef mod_methods[] = {
-        { 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_carbon",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__carbon(void);
-
-PyObject*
-PyInit__carbon(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_carbon(void);
-
-void
-init_carbon(void)
-#endif
+static int setup_carbon(PyObject* m __attribute__((__unused__)))
 {
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_carbon", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
 	if (PyObjCPointerWrapper_Register(@encode(WindowRef),
 	                &window2py, &py2window) < 0)
-		INITERROR();
+		return -1;
 
-	INITDONE();
+	return 0;
 }

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsbezierpath.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsbezierpath.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsbezierpath.m	Tue Feb  2 10:58:46 2010
@@ -2,10 +2,6 @@
  * Several methods of NSBezierPath cannot be handled automaticly because the 
  * size of a C-style array depends on the value of another argument.
  */
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <AppKit/AppKit.h>
 
 static PyObject* 
 call_NSBezierPath_elementAtIndex_associatedPoints_(
@@ -260,67 +256,19 @@
 }
 
 
-static PyMethodDef mod_methods[] = {
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_nsbezierpath",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__nsbezierpath(void);
-
-PyObject*
-PyInit__nsbezierpath(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_nsbezierpath(void);
-
-void
-init_nsbezierpath(void)
-#endif
+static int setup_nsbezierpath(PyObject* m __attribute__((__unused__)))
 {
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_nsbezierpath", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
 	Class cls = objc_lookUpClass("NSBezierPath");
-	if (!cls) INITDONE();
+	if (!cls) {
+		return 0;
+	}
 
 	if (PyObjC_RegisterMethodMapping(cls,
 		@selector(elementAtIndex:associatedPoints:),
 		call_NSBezierPath_elementAtIndex_associatedPoints_,
 		imp_NSBezierPath_elementAtIndex_associatedPoints_) < 0 ) {
 
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(cls,
@@ -328,8 +276,7 @@
 		call_NSBezierPath_setAssociatedPoints_atIndex_,
 		PyObjCUnsupportedMethod_IMP) < 0 ) {
 
-		INITERROR();
+		return -1;
 	}
-
-	INITDONE();
+	return 0;
 }

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsbitmap.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsbitmap.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsbitmap.m	Tue Feb  2 10:58:46 2010
@@ -1,7 +1,3 @@
-#include <Python.h>
-#include <AppKit/AppKit.h>
-#include "pyobjc-api.h"
-
 static PyObject* 
 call_NSBitmapImageRep_getTIFFCompressionTypes_count_(
 	PyObject* method, PyObject* self, PyObject* arguments)
@@ -349,60 +345,11 @@
 
 
 
-static PyMethodDef mod_methods[] = {
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_nsbitmap",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__nsbitmap(void);
-
-PyObject*
-PyInit__nsbitmap(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_nsbitmap(void);
-
-void
-init_nsbitmap(void)
-#endif
+static int setup_nsbitmap(PyObject* m __attribute__((__unused__)))
 {
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_nsbitmap", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
 	Class class_NSBitmapImageRep = objc_lookUpClass("NSBitmapImageRep");
 	if (class_NSBitmapImageRep == NULL) {
-		INITDONE();
+		return 0;
 	}
 
 	if (PyObjC_RegisterMethodMapping(class_NSBitmapImageRep, 
@@ -410,7 +357,7 @@
 		call_NSBitmapImageRep_getTIFFCompressionTypes_count_,
 		PyObjCUnsupportedMethod_IMP) < 0 ) {
 
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -419,7 +366,7 @@
 			call_NSBitmapImageRep_initWithBitmap,
 			PyObjCUnsupportedMethod_IMP) < 0) {
 
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -428,7 +375,7 @@
 			call_NSBitmapImageRep_getBitmapDataPlanes_,
 			PyObjCUnsupportedMethod_IMP) < 0) {
 
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -437,8 +384,8 @@
 			call_NSBitmapImageRep_bitmapData,
 			PyObjCUnsupportedMethod_IMP) < 0) {
 
-		INITERROR();
+		return -1;
 	}
 
-	INITDONE();
+	return -1;
 }

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsfont.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsfont.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsfont.m	Tue Feb  2 10:58:46 2010
@@ -1,8 +1,3 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <AppKit/AppKit.h>
-
 static PyObject* 
 m_NSConvertGlyphsToPackedGlyphs(
 	PyObject* self __attribute__((__unused__)), PyObject* arguments)
@@ -90,64 +85,10 @@
 
 
 
-static PyMethodDef mod_methods[] = {
-	{
-	   "NSConvertGlyphsToPackedGlyphs",
-	   (PyCFunction)m_NSConvertGlyphsToPackedGlyphs,
-	   METH_VARARGS,
-	   0
+#define APPKIT_NSFONT_METHODS \
+	{							\
+	   "NSConvertGlyphsToPackedGlyphs",			\
+	   (PyCFunction)m_NSConvertGlyphsToPackedGlyphs,	\
+	   METH_VARARGS,					\
+	   0							\
 	},
-
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_nsfont",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__nsfont(void);
-
-PyObject*
-PyInit__nsfont(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_nsfont(void);
-
-void
-init_nsfont(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_nsfont", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsquickdrawview.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsquickdrawview.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsquickdrawview.m	Tue Feb  2 10:58:46 2010
@@ -1,13 +1,9 @@
-#include <Python.h>
-#include <AppKit/AppKit.h>
 
 #ifndef __LP64__
-	/* Quickdraw only exists in 32-bit mode. We do define a dummy init function to avoid
-	 * breaking the Python module.
+	/* Quickdraw only exists in 32-bit mode. We do define a dummy 
+	 * init function to avoid breaking the Python module.
 	 */
 
-#include "pyobjc-api.h"
-
 #include "pymactoolbox.h"
 
 static PyObject* 
@@ -101,62 +97,12 @@
 #endif
 
 
-static PyMethodDef mod_methods[] = {
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_nsquickdrawview",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__nsquickdrawview(void);
-
-PyObject*
-PyInit__nsquickdrawview(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_nsquickdrawview(void);
-
-void
-init_nsquickdrawview(void)
-#endif
+static int setup_nsquickdrawview(PyObject* m __attribute__((__unused__)))
 {
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_nsquickdrawview", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-
 #ifndef __LP64__
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
 	Class classNSQuickDrawView = objc_lookUpClass("NSQuickDrawView");
 	if (classNSQuickDrawView == NULL) {
-		INITDONE();
+		return 0;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -165,9 +111,9 @@
 		call_NSQuickDrawView_qdport,
 		imp_NSQuickDrawView_qdport) < 0) {
 
-		INITERROR();
+		return -1;
 	}
 #endif
 
-	INITDONE();
+	return 0;
 }

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsview.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsview.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nsview.m	Tue Feb  2 10:58:46 2010
@@ -1,8 +1,3 @@
-#include <Python.h>
-#include <AppKit/AppKit.h>
-#include "pyobjc-api.h"
-
-
 static PyObject* 
 call_NSView_getRectsBeingDrawn_count_(
 	PyObject* method, PyObject* self, PyObject* arguments)
@@ -54,61 +49,11 @@
 
 
 
-static PyMethodDef mod_methods[] = {
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_nsview",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__nsview(void);
-
-PyObject*
-PyInit__nsview(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_nsview(void);
-
-void
-init_nsview(void)
-#endif
+static int setup_nsview(PyObject* m __attribute__((__unused__)))
 {
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_nsview", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
 	Class classNSView = objc_lookUpClass("NSView");
 	if (classNSView == NULL) {
-		INITDONE();
+		return 0;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -117,8 +62,8 @@
 		call_NSView_getRectsBeingDrawn_count_,
 		PyObjCUnsupportedMethod_IMP) < 0) {
 
-		INITERROR();
+		return -1;
 	}
 
-	INITDONE();
+	return 0;
 }

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nswindow.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nswindow.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_AppKit_nswindow.m	Tue Feb  2 10:58:46 2010
@@ -1,7 +1,3 @@
-#include <Python.h>
-#include <AppKit/AppKit.h>
-#include "pyobjc-api.h"
-
 #ifndef __LP64__
 
 #include "pymactoolbox.h"
@@ -11,7 +7,7 @@
 	 * of pymactoolbox.h that we need because that header
 	 * doesn't work in 64-bit mode.
 	 */
-#	include <Carbon/Carbon.h>
+#	import <Carbon/Carbon.h>
 extern PyObject *WinObj_New(WindowPtr);
 extern int WinObj_Convert(PyObject *, WindowPtr *);
 extern PyObject *WinObj_WhichWindow(WindowPtr);
@@ -193,60 +189,11 @@
 
 
 
-static PyMethodDef mod_methods[] = {
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_nswindow",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__nswindow(void);
-
-PyObject*
-PyInit__nswindow(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_nswindow(void);
-
-void
-init_nswindow(void)
-#endif
+static int setup_nswindows(PyObject* m __attribute__((__unused__)))
 {
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_nswindow", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
 	Class classNSWindow = objc_lookUpClass("NSWindow");
 	if (classNSWindow == NULL) {
-		INITDONE();
+		return 0;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -255,7 +202,7 @@
 		call_NSWindow_initWithWindowRef_,
 		imp_NSWindow_initWithWindowRef_) < 0) {
 
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -264,8 +211,8 @@
 		call_NSWindow_windowRef,
 		imp_NSWindow_windowRef) < 0) {
 
-		INITERROR();
+		return -1;
 	}
 
-	INITDONE();
+	return 0;
 }

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFBag.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFBag.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFBag.m	Tue Feb  2 10:58:46 2010
@@ -1,11 +1,6 @@
 /*
  * Manual wrappers for CFBag
  */
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
-
 static PyObject*
 mod_CFBagGetValues(
 	PyObject* self __attribute__((__unused__)), 
@@ -104,76 +99,22 @@
 	return result;
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFBagCreate",
-		(PyCFunction)mod_CFBagCreate,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFBagCreateMutable",
-		(PyCFunction)mod_CFBagCreateMutable,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_CFBAG_METHODS \
+        {						\
+		"CFBagCreate",				\
+		(PyCFunction)mod_CFBagCreate,		\
+		METH_VARARGS,				\
+		NULL					\
+	},						\
+        {						\
+		"CFBagCreateMutable",			\
+		(PyCFunction)mod_CFBagCreateMutable,	\
+		METH_VARARGS,				\
+		NULL					\
+	},						\
+        {						\
+		"CFBagGetValues",			\
+		(PyCFunction)mod_CFBagGetValues,	\
+		METH_VARARGS,				\
+		NULL					\
 	},
-        {
-		"CFBagGetValues",
-		(PyCFunction)mod_CFBagGetValues,
-		METH_VARARGS,
-		NULL
-	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFBag",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFBag(void);
-
-PyObject*
-PyInit__CFBag(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFBag(void);
-
-void
-init_CFBag(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFBag", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}
-

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFBinaryHeap.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFBinaryHeap.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFBinaryHeap.m	Tue Feb  2 10:58:46 2010
@@ -1,18 +1,13 @@
 /*
  * Manual wrappers for CFBinaryHeap
  */
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
-#import <Foundation/Foundation.h>
 
 @interface NSObject (OC_Comparison)
 -(NSComparisonResult)compare:(NSObject*)other;
 @end
 
 
-static const void *mod_retain (CFAllocatorRef allocator __attribute__((__unused__)), const void *ptr)
+static const void *mod_binheap_retain (CFAllocatorRef allocator __attribute__((__unused__)), const void *ptr)
 {
 	if (ptr) {
 		CFRetain(ptr);
@@ -20,20 +15,20 @@
 	return ptr;
 }
 
-static void mod_release (CFAllocatorRef allocator __attribute__((__unused__)), const void *ptr)
+static void mod_binheap_release (CFAllocatorRef allocator __attribute__((__unused__)), const void *ptr)
 {
 	if (ptr) {
 		CFRelease(ptr);
 	}
 }
 
-static CFStringRef mod_copydescription(const void* ptr)
+static CFStringRef mod_binheap_copydescription(const void* ptr)
 {
 	CFStringRef r =  CFCopyDescription(ptr);	
 	return r;
 }
 
-CFComparisonResult mod_compare(const void *ptr1, const void *ptr2, void *info __attribute__((__unused__)))
+CFComparisonResult mod_binheap_compare(const void *ptr1, const void *ptr2, void *info __attribute__((__unused__)))
 {
 	NSObject* o1 = (NSObject*)ptr1;
 	NSObject* o2 = (NSObject*)ptr2;
@@ -46,10 +41,10 @@
 
 static CFBinaryHeapCallBacks mod_NSObjectBinaryHeapCallbacks = {
 	0, 
-	mod_retain,
-	mod_release,
-	mod_copydescription,
-	mod_compare
+	mod_binheap_retain,
+	mod_binheap_release,
+	mod_binheap_copydescription,
+	mod_binheap_compare
 };
 
 
@@ -112,68 +107,16 @@
 	return result;
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFBinaryHeapCreate",
-		(PyCFunction)mod_CFBinaryHeapCreate,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFBinaryHeapGetValues",
-		(PyCFunction)mod_CFBinaryHeapGetValues,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_CFBINARYHEAP_METHODS \
+        { \
+		"CFBinaryHeapCreate", \
+		(PyCFunction)mod_CFBinaryHeapCreate, \
+		METH_VARARGS, \
+		NULL \
+	}, \
+        { \
+		"CFBinaryHeapGetValues", \
+		(PyCFunction)mod_CFBinaryHeapGetValues, \
+		METH_VARARGS, \
+		NULL \
 	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFBinaryHeap",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFBinaryHeap(void);
-
-PyObject*
-PyInit__CFBinaryHeap(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFBinaryHeap(void);
-
-void
-init_CFBinaryHeap(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFBinaryHeap", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFBitVector.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFBitVector.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFBitVector.m	Tue Feb  2 10:58:46 2010
@@ -1,12 +1,6 @@
 /*
  * Manual wrappers for CFBitVector
  */
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
-
-
 static PyObject* 
 mod_CFBitVectorCreate(PyObject* self __attribute__((__unused__)),
 	PyObject* args)
@@ -99,69 +93,16 @@
 
 
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFBitVectorCreate",
-		(PyCFunction)mod_CFBitVectorCreate,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_BITVECTOR_METHODS \
+        {	\
+		"CFBitVectorCreate",	\
+		(PyCFunction)mod_CFBitVectorCreate,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFBitVectorGetBits",	\
+		(PyCFunction)mod_CFBitVectorGetBits,	\
+		METH_VARARGS,	\
+		NULL	\
 	},
-        {
-		"CFBitVectorGetBits",
-		(PyCFunction)mod_CFBitVectorGetBits,
-		METH_VARARGS,
-		NULL
-	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFBitVector",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFBitVector(void);
-
-PyObject*
-PyInit__CFBitVector(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFBitVector(void);
-
-void
-init_CFBitVector(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFBitVector", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFCalendar.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFCalendar.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFCalendar.m	Tue Feb  2 10:58:46 2010
@@ -5,10 +5,6 @@
  * arguments are integers and the number of arguments is trivially derived
  * from the format string these implementations are fairly trivial.
  */
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
 
 static PyObject*
 mod_CFCalendarAddComponents(
@@ -425,82 +421,28 @@
 	return rv;
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFCalendarAddComponents",
-		(PyCFunction)mod_CFCalendarAddComponents,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFCalendarComposeAbsoluteTime",
-		(PyCFunction)mod_CFCalendarComposeAbsoluteTime,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFCalendarDecomposeAbsoluteTime",
-		(PyCFunction)mod_CFCalendarDecomposeAbsoluteTime,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_CALENDAR_METHODS \
+        {	\
+		"CFCalendarAddComponents",	\
+		(PyCFunction)mod_CFCalendarAddComponents,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFCalendarComposeAbsoluteTime",	\
+		(PyCFunction)mod_CFCalendarComposeAbsoluteTime,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFCalendarDecomposeAbsoluteTime",	\
+		(PyCFunction)mod_CFCalendarDecomposeAbsoluteTime,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFCalendarGetComponentDifference",	\
+		(PyCFunction)mod_CFCalendarGetComponentDifference,	\
+		METH_VARARGS,	\
+		NULL	\
 	},
-        {
-		"CFCalendarGetComponentDifference",
-		(PyCFunction)mod_CFCalendarGetComponentDifference,
-		METH_VARARGS,
-		NULL
-	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFCalendar",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFCalendar(void);
-
-PyObject*
-PyInit__CFCalendar(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFCalendar(void);
-
-void
-init_CFCalendar(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFCalendar", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFDictionary.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFDictionary.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFDictionary.m	Tue Feb  2 10:58:46 2010
@@ -1,8 +1,3 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
-
 static PyObject*
 mod_CFDictionaryGetKeysAndValues(
 	PyObject* self __attribute__((__unused__)),
@@ -100,63 +95,10 @@
 	return result;
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFDictionaryGetKeysAndValues",
-		(PyCFunction)mod_CFDictionaryGetKeysAndValues,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_DICTIONARY_METHODS \
+        {	\
+		"CFDictionaryGetKeysAndValues",	\
+		(PyCFunction)mod_CFDictionaryGetKeysAndValues,	\
+		METH_VARARGS,	\
+		NULL	\
 	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFDictionary",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFDictionary(void);
-
-PyObject*
-PyInit__CFDictionary(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFDictionary(void);
-
-void
-init_CFDictionary(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFDictionary", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFFileDescriptor.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFFileDescriptor.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFFileDescriptor.m	Tue Feb  2 10:58:46 2010
@@ -1,12 +1,7 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
-
 #if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED
 
 static void* 
-mod_retain(void* info) 
+mod_filedescr_retain(void* info) 
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_INCREF((PyObject*)info);
@@ -15,7 +10,7 @@
 }
 
 static void
-mod_release(void* info)
+mod_filedescr_release(void* info)
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_DECREF((PyObject*)info);
@@ -26,8 +21,8 @@
 static CFFileDescriptorContext mod_CFFileDescriptorContext = {
 	0,		
 	NULL,
-	mod_retain,
-	mod_release,
+	mod_filedescr_retain,
+	mod_filedescr_release,
 	NULL
 };
 
@@ -156,7 +151,7 @@
 		return NULL;
 	}
 
-	if (context.retain != mod_retain) {
+	if (context.retain != mod_filedescr_retain) {
 		PyErr_SetString(PyExc_ValueError, 
 			"retrieved context is not supported");
 		return NULL;
@@ -167,71 +162,16 @@
 }
 #endif
 
-static PyMethodDef mod_methods[] = {
-#if MAC_OS_X_VERSION_10_5 <= MAC_OS_X_VERSION_MAX_ALLOWED
-        {
-		"CFFileDescriptorCreate",
-		(PyCFunction)mod_CFFileDescriptorCreate,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFFileDescriptorGetContext",
-		(PyCFunction)mod_CFFileDescriptorGetContext,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_FILEDESCRIPTOR_METHODS		\
+        {		\
+		"CFFileDescriptorCreate",		\
+		(PyCFunction)mod_CFFileDescriptorCreate,		\
+		METH_VARARGS,		\
+		NULL		\
+	},		\
+        {		\
+		"CFFileDescriptorGetContext",		\
+		(PyCFunction)mod_CFFileDescriptorGetContext,		\
+		METH_VARARGS,		\
+		NULL		\
 	},
-#endif
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFFileDescriptor",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFFileDescriptor(void);
-
-PyObject*
-PyInit__CFFileDescriptor(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFFileDescriptor(void);
-
-void
-init_CFFileDescriptor(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFFileDescriptor", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFMachPort.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFMachPort.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFMachPort.m	Tue Feb  2 10:58:46 2010
@@ -1,10 +1,5 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
-
 static const void* 
-mod_retain(const void* info) 
+mod_machport_retain(const void* info) 
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_INCREF((PyObject*)info);
@@ -13,7 +8,7 @@
 }
 
 static void
-mod_release(const void* info)
+mod_machport_release(const void* info)
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_DECREF((PyObject*)info);
@@ -24,8 +19,8 @@
 static CFMachPortContext mod_CFMachPortContext = {
 	0,		
 	NULL,
-	mod_retain,
-	mod_release,
+	mod_machport_retain,
+	mod_machport_release,
 	NULL
 };
 
@@ -244,7 +239,7 @@
 		return NULL;
 	}
 
-	if (context.retain != mod_retain) {
+	if (context.retain != mod_machport_retain) {
 		PyErr_SetString(PyExc_ValueError, 
 			"retrieved context is not supported");
 		return NULL;
@@ -289,7 +284,7 @@
 		return NULL;
 	}
 
-	if (context.version != 0 || context.retain != mod_retain) {
+	if (context.version != 0 || context.retain != mod_machport_retain) {
 		PyErr_SetString(PyExc_ValueError, "invalid context");
 		return NULL;
 	}
@@ -346,7 +341,7 @@
 		return NULL;
 	}
 
-	if (context.version != 0 || context.retain != mod_retain) {
+	if (context.version != 0 || context.retain != mod_machport_retain) {
 		PyErr_SetString(PyExc_ValueError, "invalid context");
 		return NULL;
 	}
@@ -382,87 +377,34 @@
 	return NULL;
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFMachPortCreate",
-		(PyCFunction)mod_CFMachPortCreate,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFMachPortCreateWithPort",
-		(PyCFunction)mod_CFMachPortCreateWithPort,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFMachPortGetContext",
-		(PyCFunction)mod_CFMachPortGetContext,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_MACHPORT_METHODS \
+        {	\
+		"CFMachPortCreate",	\
+		(PyCFunction)mod_CFMachPortCreate,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFMachPortCreateWithPort",	\
+		(PyCFunction)mod_CFMachPortCreateWithPort,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFMachPortGetContext",	\
+		(PyCFunction)mod_CFMachPortGetContext,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFMachPortSetInvalidationCallBack",	\
+		(PyCFunction)mod_CFMachPortSetInvalidationCallBack,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFMachPortGetInvalidationCallBack",	\
+		(PyCFunction)mod_CFMachPortGetInvalidationCallBack,	\
+		METH_VARARGS,	\
+		NULL	\
 	},
-        {
-		"CFMachPortSetInvalidationCallBack",
-		(PyCFunction)mod_CFMachPortSetInvalidationCallBack,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFMachPortGetInvalidationCallBack",
-		(PyCFunction)mod_CFMachPortGetInvalidationCallBack,
-		METH_VARARGS,
-		NULL
-	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFMachPort",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFMachPort(void);
-
-PyObject*
-PyInit__CFMachPort(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFMachPort(void);
-
-void
-init_CFMachPort(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFMachPort", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFMessagePort.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFMessagePort.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFMessagePort.m	Tue Feb  2 10:58:46 2010
@@ -1,10 +1,5 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
-
 static const void* 
-mod_retain(const void* info) 
+mod_messageport_retain(const void* info) 
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_INCREF((PyObject*)info);
@@ -13,7 +8,7 @@
 }
 
 static void
-mod_release(const void* info)
+mod_messageport_release(const void* info)
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_DECREF((PyObject*)info);
@@ -24,8 +19,8 @@
 static CFMessagePortContext mod_CFMessagePortContext = {
 	0,		
 	NULL,
-	mod_retain,
-	mod_release,
+	mod_messageport_retain,
+	mod_messageport_release,
 	NULL
 };
 
@@ -173,7 +168,7 @@
 		return NULL;
 	}
 
-	if (context.retain != mod_retain) {
+	if (context.retain != mod_messageport_retain) {
 		PyErr_SetString(PyExc_ValueError, 
 			"retrieved context is not supported");
 		return NULL;
@@ -183,69 +178,16 @@
 	return PyTuple_GET_ITEM((PyObject*)context.info, 1);
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFMessagePortCreateLocal",
-		(PyCFunction)mod_CFMessagePortCreateLocal,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_MESSAGEPORT_METHODS \
+        {	\
+		"CFMessagePortCreateLocal",	\
+		(PyCFunction)mod_CFMessagePortCreateLocal,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFMessagePortGetContext",	\
+		(PyCFunction)mod_CFMessagePortGetContext,	\
+		METH_VARARGS,	\
+		NULL	\
 	},
-        {
-		"CFMessagePortGetContext",
-		(PyCFunction)mod_CFMessagePortGetContext,
-		METH_VARARGS,
-		NULL
-	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFMessagePort",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFMessagePort(void);
-
-PyObject*
-PyInit__CFMessagePort(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFMessagePort(void);
-
-void
-init_CFMessagePort(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFMessagePort", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) { 
-		INITERROR();
-	}
-
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFNumber.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFNumber.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFNumber.m	Tue Feb  2 10:58:46 2010
@@ -1,8 +1,3 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
-
 static PyObject*
 mod_CFNumberGetValue(
 	PyObject* self __attribute__((__unused__)),
@@ -246,69 +241,16 @@
 
 
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFNumberGetValue",
-		(PyCFunction)mod_CFNumberGetValue,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFNumberCreate",
-		(PyCFunction)mod_CFNumberCreate,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_NUMBER_METHODS \
+        {	\
+		"CFNumberGetValue",	\
+		(PyCFunction)mod_CFNumberGetValue,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFNumberCreate",	\
+		(PyCFunction)mod_CFNumberCreate,	\
+		METH_VARARGS,	\
+		NULL	\
 	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFNumber",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFNumber(void);
-
-PyObject*
-PyInit__CFNumber(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFNumber(void);
-
-void
-init_CFNumber(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFNumber", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFReadStream.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFReadStream.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFReadStream.m	Tue Feb  2 10:58:46 2010
@@ -1,10 +1,5 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
-
 static void* 
-mod_retain(void* info) 
+mod_readstream_retain(void* info) 
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_INCREF((PyObject*)info);
@@ -13,7 +8,7 @@
 }
 
 static void
-mod_release(void* info)
+mod_readstream_release(void* info)
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_DECREF((PyObject*)info);
@@ -21,11 +16,11 @@
 }
 
 
-static CFStreamClientContext mod_CFStreamClientContext = {
+static CFStreamClientContext mod_CFStreamClientContext_Read = {
 	0,		
 	NULL,
-	mod_retain,
-	mod_release,
+	mod_readstream_retain,
+	mod_readstream_release,
 	NULL
 };
 
@@ -77,7 +72,7 @@
 	}
 
 	if (info != PyObjC_NULL) {
-		context = mod_CFStreamClientContext;
+		context = mod_CFStreamClientContext_Read;
 		context.info = Py_BuildValue("OO", callout, info);
 		if (context.info == NULL) {
 			return NULL;
@@ -114,62 +109,10 @@
 	return PyBool_FromLong(rv);
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFReadStreamSetClient",
-		(PyCFunction)mod_CFReadStreamSetClient,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_READSTREAM_METHODS \
+        {	\
+		"CFReadStreamSetClient",	\
+		(PyCFunction)mod_CFReadStreamSetClient,	\
+		METH_VARARGS,	\
+		NULL	\
 	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFReadStream",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFReadStream(void);
-
-PyObject*
-PyInit__CFReadStream(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFReadStream(void);
-
-void
-init_CFReadStream(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFReadStream", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFRunLoopObserver.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFRunLoopObserver.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFRunLoopObserver.m	Tue Feb  2 10:58:46 2010
@@ -1,10 +1,6 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
 
 static const void* 
-mod_retain(const void* info) 
+mod_observer_retain(const void* info) 
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_INCREF((PyObject*)info);
@@ -13,7 +9,7 @@
 }
 
 static void
-mod_release(const void* info)
+mod_observer_release(const void* info)
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_DECREF((PyObject*)info);
@@ -24,8 +20,8 @@
 static CFRunLoopObserverContext mod_CFRunLoopObserverContext = {
 	0,		
 	NULL,
-	mod_retain,
-	mod_release,
+	mod_observer_retain,
+	mod_observer_release,
 	NULL
 };
 
@@ -159,7 +155,7 @@
 		return NULL;
 	}
 
-	if (context.retain != mod_retain) {
+	if (context.retain != mod_observer_retain) {
 		PyErr_SetString(PyExc_ValueError, 
 			"retrieved context is not supported");
 		return NULL;
@@ -175,68 +171,16 @@
 	return PyTuple_GET_ITEM((PyObject*)context.info, 1);
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFRunLoopObserverCreate",
-		(PyCFunction)mod_CFRunLoopObserverCreate,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFRunLoopObserverGetContext",
-		(PyCFunction)mod_CFRunLoopObserverGetContext,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_RUNLOOP_METHODS \
+        {	\
+		"CFRunLoopObserverCreate",	\
+		(PyCFunction)mod_CFRunLoopObserverCreate,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFRunLoopObserverGetContext",	\
+		(PyCFunction)mod_CFRunLoopObserverGetContext,	\
+		METH_VARARGS,	\
+		NULL	\
 	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFRunLoopObserver",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFRunLoopObserver(void);
-
-PyObject*
-PyInit__CFRunLoopObserver(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFRunLoopObserver(void);
-
-void
-init_CFRunLoopObserver(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFRunLoopObserver", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFRunLoopSource.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFRunLoopSource.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFRunLoopSource.m	Tue Feb  2 10:58:46 2010
@@ -1,10 +1,6 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
 
 static const void* 
-mod_retain(const void* info) 
+mod_source_retain(const void* info) 
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_INCREF((PyObject*)info);
@@ -13,7 +9,7 @@
 }
 
 static void
-mod_release(const void* info)
+mod_source_release(const void* info)
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_DECREF((PyObject*)info);
@@ -99,8 +95,8 @@
 static CFRunLoopSourceContext mod_CFRunLoopSourceContext = {
 	0,		
 	NULL,
-	mod_retain,
-	mod_release,
+	mod_source_retain,
+	mod_source_release,
 	NULL,
 	NULL,
 	NULL,
@@ -214,7 +210,7 @@
 		return NULL;
 	}
 
-	if (context.retain != mod_retain) {
+	if (context.retain != mod_source_retain) {
 		PyErr_SetString(PyExc_ValueError, 
 			"retrieved context is not supported");
 		return NULL;
@@ -229,67 +225,16 @@
 	return (PyObject*)(context.info);
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFRunLoopSourceCreate",
-		(PyCFunction)mod_CFRunLoopSourceCreate,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFRunLoopSourceGetContext",
-		(PyCFunction)mod_CFRunLoopSourceGetContext,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_RUNLOOPSOURCE_METHODS \
+        {	\
+		"CFRunLoopSourceCreate",	\
+		(PyCFunction)mod_CFRunLoopSourceCreate,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFRunLoopSourceGetContext",	\
+		(PyCFunction)mod_CFRunLoopSourceGetContext,	\
+		METH_VARARGS,	\
+		NULL	\
 	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFRunLoopSource",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFRunLoopSource(void);
-
-PyObject*
-PyInit__CFRunLoopSource(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFRunLoopSource(void);
-
-void
-init_CFRunLoopSource(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFRunLoopSource", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFRunLoopTimer.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFRunLoopTimer.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFRunLoopTimer.m	Tue Feb  2 10:58:46 2010
@@ -1,10 +1,5 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
-
 static const void* 
-mod_retain(const void* info) 
+mod_timer_retain(const void* info) 
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_INCREF((PyObject*)info);
@@ -13,7 +8,7 @@
 }
 
 static void
-mod_release(const void* info)
+mod_timer_release(const void* info)
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_DECREF((PyObject*)info);
@@ -24,8 +19,8 @@
 static CFRunLoopTimerContext mod_CFRunLoopTimerContext = {
 	0,		
 	NULL,
-	mod_retain,
-	mod_release,
+	mod_timer_retain,
+	mod_timer_release,
 	NULL
 };
 
@@ -161,7 +156,7 @@
 		return NULL;
 	}
 
-	if (context.retain != mod_retain) {
+	if (context.retain != mod_timer_retain) {
 		PyErr_SetString(PyExc_ValueError, 
 			"retrieved context is not supported");
 		return NULL;
@@ -176,69 +171,16 @@
 	return PyTuple_GET_ITEM((PyObject*)context.info, 1);
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFRunLoopTimerCreate",
-		(PyCFunction)mod_CFRunLoopTimerCreate,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_RUNLOOPTIMER_METHODS \
+        {	\
+		"CFRunLoopTimerCreate",	\
+		(PyCFunction)mod_CFRunLoopTimerCreate, \
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFRunLoopTimerGetContext",	\
+		(PyCFunction)mod_CFRunLoopTimerGetContext,	\
+		METH_VARARGS,	\
+		NULL	\
 	},
-        {
-		"CFRunLoopTimerGetContext",
-		(PyCFunction)mod_CFRunLoopTimerGetContext,
-		METH_VARARGS,
-		NULL
-	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFRunLoopTimer",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFRunLoopTimer(void);
-
-PyObject*
-PyInit__CFRunLoopTimer(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFRunLoopTimer(void);
-
-void
-init_CFRunLoopTimer(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFRunLoopTimer", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFSet.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFSet.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFSet.m	Tue Feb  2 10:58:46 2010
@@ -1,8 +1,3 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
-
 static PyObject*
 mod_CFSetGetValues(
 	PyObject* self __attribute__((__unused__)),
@@ -65,61 +60,10 @@
 	return pyValues;
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFSetGetValues",
-		(PyCFunction)mod_CFSetGetValues,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_SET_METHODS \
+        { 	\
+		"CFSetGetValues", 	\
+		(PyCFunction)mod_CFSetGetValues, 	\
+		METH_VARARGS, 	\
+		NULL 	\
 	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFSet",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFSet(void);
-
-PyObject*
-PyInit__CFSet(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFSet(void);
-
-void
-init_CFSet(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFSet", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFSocket.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFSocket.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFSocket.m	Tue Feb  2 10:58:46 2010
@@ -1,10 +1,6 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
 
 static const void* 
-mod_retain(const void* info) 
+mod_socket_retain(const void* info) 
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_INCREF((PyObject*)info);
@@ -13,7 +9,7 @@
 }
 
 static void
-mod_release(const void* info)
+mod_socket_release(const void* info)
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_DECREF((PyObject*)info);
@@ -24,8 +20,8 @@
 static CFSocketContext mod_CFSocketContext = {
 	0,		
 	NULL,
-	mod_retain,
-	mod_release,
+	mod_socket_retain,
+	mod_socket_release,
 	NULL
 };
 
@@ -362,7 +358,7 @@
 
 	PyObjC_ENDHANDLER
 
-        if (context.retain != mod_retain) {
+        if (context.retain != mod_socket_retain) {
 		PyErr_SetString(PyExc_ValueError,
 			"retrieved context is not supported");
 		return NULL;
@@ -378,87 +374,34 @@
 	return PyTuple_GetItem(context.info, 1);
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFSocketCreate",
-		(PyCFunction)mod_CFSocketCreate,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFSocketCreateWithNative",
-		(PyCFunction)mod_CFSocketCreateWithNative,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFSocketCreateWithSocketSignature",
-		(PyCFunction)mod_CFSocketCreateWithSocketSignature,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFSocketCreateConnectedToSocketSignature",
-		(PyCFunction)mod_CFSocketCreateConnectedToSocketSignature,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_SOCKET_METHODS \
+        {	\
+		"CFSocketCreate",	\
+		(PyCFunction)mod_CFSocketCreate,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFSocketCreateWithNative",	\
+		(PyCFunction)mod_CFSocketCreateWithNative,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFSocketCreateWithSocketSignature",	\
+		(PyCFunction)mod_CFSocketCreateWithSocketSignature,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFSocketCreateConnectedToSocketSignature",	\
+		(PyCFunction)mod_CFSocketCreateConnectedToSocketSignature,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFSocketGetContext",	\
+		(PyCFunction)mod_CFSocketGetContext,	\
+		METH_VARARGS,	\
+		NULL	\
 	},
-        {
-		"CFSocketGetContext",
-		(PyCFunction)mod_CFSocketGetContext,
-		METH_VARARGS,
-		NULL
-	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFSocket",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFSocket(void);
-
-PyObject*
-PyInit__CFSocket(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFSocket(void);
-
-void
-init_CFSocket(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFSocket", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFTree.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFTree.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFTree.m	Tue Feb  2 10:58:46 2010
@@ -1,7 +1,3 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
 
 static const void* 
 mod_CFTreeRetainCallback(const void* info) 
@@ -234,81 +230,28 @@
 }
 
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFTreeCreate",
-		(PyCFunction)mod_CFTreeCreate,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFTreeGetContext",
-		(PyCFunction)mod_CFTreeGetContext,
-		METH_VARARGS,
-		NULL
-	},
-        {
-		"CFTreeSetContext",
-		(PyCFunction)mod_CFTreeSetContext,
-		METH_VARARGS,
-		NULL
-	},
-	{
-		"CFTreeGetChildren",
-		(PyCFunction)mod_CFTreeGetChildren,
-		METH_VARARGS,
-		NULL,
-	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFTree",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFTree(void);
-
-PyObject*
-PyInit__CFTree(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFTree(void);
-
-void
-init_CFTree(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFTree", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}
+#define COREFOUNDATION_TREE_METHODS \
+        {	\
+		"CFTreeCreate",	\
+		(PyCFunction)mod_CFTreeCreate,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFTreeGetContext",	\
+		(PyCFunction)mod_CFTreeGetContext,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+        {	\
+		"CFTreeSetContext",	\
+		(PyCFunction)mod_CFTreeSetContext,	\
+		METH_VARARGS,	\
+		NULL	\
+	},	\
+	{	\
+		"CFTreeGetChildren",	\
+		(PyCFunction)mod_CFTreeGetChildren,	\
+		METH_VARARGS,	\
+		NULL,	\
+	},	

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFWriteStream.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFWriteStream.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_CoreFoundation_CFWriteStream.m	Tue Feb  2 10:58:46 2010
@@ -1,10 +1,6 @@
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#import <CoreFoundation/CoreFoundation.h>
 
 static void* 
-mod_retain(void* info) 
+mod_writestream_retain(void* info) 
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_INCREF((PyObject*)info);
@@ -13,7 +9,7 @@
 }
 
 static void
-mod_release(void* info)
+mod_writestream_release(void* info)
 {
 	PyGILState_STATE state = PyGILState_Ensure();
 	Py_DECREF((PyObject*)info);
@@ -21,11 +17,11 @@
 }
 
 
-static CFStreamClientContext mod_CFStreamClientContext = {
+static CFStreamClientContext mod_CFStreamClientContext_Write = {
 	0,		
 	NULL,
-	mod_retain,
-	mod_release,
+	mod_writestream_retain,
+	mod_writestream_release,
 	NULL
 };
 
@@ -75,7 +71,7 @@
 		return NULL;
 	}
 
-	CFStreamClientContext context = mod_CFStreamClientContext;
+	CFStreamClientContext context = mod_CFStreamClientContext_Write;
 	context.info = Py_BuildValue("OO", callout, info);
 	if (context.info == NULL) {
 		return NULL;
@@ -108,63 +104,10 @@
 	return PyBool_FromLong(rv);
 }
 
-static PyMethodDef mod_methods[] = {
-        {
-		"CFWriteStreamSetClient",
-		(PyCFunction)mod_CFWriteStreamSetClient,
-		METH_VARARGS,
-		NULL
+#define COREFOUNDATION_WRITESTREAM_METHODS \
+        {	\
+		"CFWriteStreamSetClient",	\
+		(PyCFunction)mod_CFWriteStreamSetClient,	\
+		METH_VARARGS,	\
+		NULL	\
 	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_CFWriteStream",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__CFWriteStream(void);
-
-PyObject*
-PyInit__CFWriteStream(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_CFWriteStream(void);
-
-void
-init_CFWriteStream(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_CFWriteStream", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_NSDecimal.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_NSDecimal.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_NSDecimal.m	Tue Feb  2 10:58:46 2010
@@ -9,15 +9,10 @@
  *   correspond with NSDecimal* functions with the NSRoundPlain argument.
  *   They also support unary -, unary + and abs, with the obvious semantics.
  */
-#include "Python.h"
-#include "pyobjc-api.h"
-
 #ifndef  _C_CONST
 #define _C_CONST    'r'
 #endif
 
-#import <Foundation/Foundation.h>
-
 typedef struct {
 	PyObject_HEAD
 	NSDecimal value;
@@ -1069,76 +1064,25 @@
 }
 
 
-PyDoc_STRVAR(mod_doc, "_NSDecimal provides a wrapper for NSDecimal");
-
-static PyMethodDef mod_methods[] = {
-	{
-		NULL,
-		NULL,
-		0,
-		NULL
-	}
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_NSDecimal",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__NSDecimal(void);
-
-PyObject*
-PyInit__NSDecimal(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_NSDecimal(void);
-
-void
-init_NSDecimal(void)
-#endif
+static int setup_nsdecimal(PyObject* m)
 {
-	PyObject* m;
 	PyType_Ready(&Decimal_Type);
 
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_NSDecimal", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
+	if (PyModule_AddObject(m, "NSDecimal", (PyObject*)&Decimal_Type) == -1) {
+		return -1;
 	}
 
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	PyModule_AddObject(m, "NSDecimal", (PyObject*)&Decimal_Type);
-
-	PyObjCPointerWrapper_Register(@encode(NSDecimal*),
+	if (PyObjCPointerWrapper_Register(@encode(NSDecimal*),
 			pythonify_nsdecimal,
-			depythonify_nsdecimal);
+			depythonify_nsdecimal) < 0) {
+		return -1;
+	}
 
-	PyObjCPointerWrapper_Register(@encode(const NSDecimal*),
+	if (PyObjCPointerWrapper_Register(@encode(const NSDecimal*),
 			pythonify_nsdecimal,
-			depythonify_nsdecimal);
+			depythonify_nsdecimal) < 0) {
+		return -1;
+	}
 
 	/* Also register some variations of the encoded name because NSDecimal
          * doesn't have a struct tag and the metadata generators make up one
@@ -1156,13 +1100,17 @@
 				sizeof(buffer)-2-sizeof("_NSDecimal"),
 				@encode(NSDecimal) + 2);
 
-		PyObjCPointerWrapper_Register(buffer+1,
+		if (PyObjCPointerWrapper_Register(buffer+1,
 				pythonify_nsdecimal,
-				depythonify_nsdecimal);
+				depythonify_nsdecimal) < 0) {
+			return -1;
+		}
 
-		PyObjCPointerWrapper_Register(buffer,
+		if (PyObjCPointerWrapper_Register(buffer,
 				pythonify_nsdecimal,
-				depythonify_nsdecimal);
+				depythonify_nsdecimal) < 0) {
+			return -1;
+		}
        	} 
 
 
@@ -1174,7 +1122,7 @@
 			@selector(initWithDecimal:),
 			call_NSDecimalNumber_initWithDecimal_,
 			imp_NSDecimalNumber_initWithDecimal_) < 0) {
-		INITERROR();
+		return -1;
 	}
 
 	Class classNSDecimalNumberPlaceholder = objc_lookUpClass("NSDecimalNumberPlaceholder");
@@ -1185,7 +1133,7 @@
 			call_NSDecimalNumber_initWithDecimal_,
 			imp_NSDecimalNumber_initWithDecimal_) < 0) {
 
-			INITERROR();
+			return -1;
 		}
 	}
 
@@ -1194,7 +1142,7 @@
 			@selector(decimalNumberWithDecimal:),
 			call_NSDecimalNumber_decimalWithDecimal_,
 			imp_NSDecimalNumber_initWithDecimal_) < 0) {
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -1202,8 +1150,8 @@
 			@selector(decimalValue),
 			call_NSDecimalNumber_decimalValue,
 			imp_NSDecimalNumber_decimalValue) < 0) {
-		INITERROR();
+		return -1;
 	}
 
-	INITDONE();
+	return 0;
 }

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_NSInvocation.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_NSInvocation.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_NSInvocation.m	Tue Feb  2 10:58:46 2010
@@ -1,8 +1,3 @@
-#include "Python.h"
-#include "pyobjc-api.h"
-
-#include <Foundation/Foundation.h>
-
 static PyObject* 
 call_NSInvocation_setArgument_atIndex_(
 	PyObject* method, PyObject* self, PyObject* arguments)
@@ -328,60 +323,8 @@
 }
 
 
-PyDoc_STRVAR(mod_doc, "");
-
-static PyMethodDef mod_methods[] = {
-	        { 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_nsinvocation",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__nsinvocation(void);
-
-PyObject*
-PyInit__nsinvocation(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_nsinvocation(void);
-
-void
-init_nsinvocation(void)
-#endif
+static int setup_nsinvocation(PyObject* m __attribute__((__unused__)))
 {
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_nsinvocation", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
 	Class classNSInvocation = objc_lookUpClass("NSInvocation");
   
 	if (PyObjC_RegisterMethodMapping(
@@ -389,7 +332,7 @@
 			@selector(setArgument:atIndex:),
 			call_NSInvocation_setArgument_atIndex_,
 			PyObjCUnsupportedMethod_IMP) < 0) {
-		return;
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -397,7 +340,7 @@
 			@selector(setReturnValue:),
 			call_NSInvocation_setReturnValue_,
 			PyObjCUnsupportedMethod_IMP) < 0) {
-		return;
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -405,7 +348,7 @@
 			@selector(getArgument:atIndex:),
 			call_NSInvocation_getArgument_atIndex_,
 			PyObjCUnsupportedMethod_IMP) < 0) {
-		return;
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -413,8 +356,8 @@
 			@selector(getReturnValue:),
 			call_NSInvocation_getReturnValue_,
 			PyObjCUnsupportedMethod_IMP) < 0) {
-		return;
+		return -1;
 	}
 
-	INITDONE();
+	return 0;
 }

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_data.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_data.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_data.m	Tue Feb  2 10:58:46 2010
@@ -1,14 +1,3 @@
-/*
- * These NSData methods don't "fit" the metadata model.
- * -bytes
- * -mutableBytes
- */
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#include <Foundation/Foundation.h>
-
-
 static PyObject* call_NSData_bytes(
 	PyObject* method, PyObject* self, PyObject* arguments)
 {
@@ -220,57 +209,8 @@
 	PyObjCErr_ToObjCWithGILState(&state);
 }
 
-static PyMethodDef mod_methods[] = {
-	        { 0, 0, 0, 0 } /* sentinel */
-};
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_data",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__data(void);
-
-PyObject*
-PyInit__data(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_data(void);
-
-void
-init_data(void)
-#endif
+static int setup_nsdata(PyObject* m __attribute__((__unused__)))
 {
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_data", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
 	Class classNSData = objc_lookUpClass("NSData");
 	Class classNSMutableData = objc_lookUpClass("NSMutableData");
 
@@ -280,7 +220,7 @@
 				 @selector(bytes),
 				 call_NSData_bytes,
 				 imp_NSData_bytes) < 0 ) {
-			INITERROR();
+			return -1;
 		}
 
 	}
@@ -291,10 +231,9 @@
 				@selector(mutableBytes),
 				call_NSMutableData_mutableBytes,
 				imp_NSMutableData_mutableBytes) < 0 ) {
-			INITERROR();
+			return -1;
 		}
 	}
-
   
-	INITDONE();
+	return 0;
 }

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_netservice.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_netservice.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_netservice.m	Tue Feb  2 10:58:46 2010
@@ -3,15 +3,11 @@
  *
  * -addresses				[call]
  */
-#include <Python.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <sys/un.h>
 #include <netdb.h>
 
-#include <Foundation/Foundation.h>
-#include "pyobjc-api.h"
-
 
 static PyObject *
 makeipaddr(struct sockaddr *addr, int addrlen)
@@ -149,61 +145,11 @@
 }
 
 
-static PyMethodDef mod_methods[] = {
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_netservice",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__netservice(void);
-
-PyObject*
-PyInit__netservice(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_netservice(void);
-
-void
-init_netservice(void)
-#endif
+static int setup_nsnetservice(PyObject* m __attribute__((__unused__)))
 {
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_netservice", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-
 	Class classNSNetService = objc_lookUpClass("NSNetService");
 	if (classNSNetService == NULL) {
-		INITDONE();
+		return 0;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -212,8 +158,8 @@
 		call_NSNetService_addresses,
 		PyObjCUnsupportedMethod_IMP) < 0) {
 
-		INITERROR();
+		return -1;
 	}
 
-	INITDONE();
+	return 0;
 }

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_nscoder.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_nscoder.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_nscoder.m	Tue Feb  2 10:58:46 2010
@@ -1,8 +1,3 @@
-#include "Python.h"
-#include "pyobjc-api.h"
-
-#include <Foundation/Foundation.h>
-
 static PyObject* 
 call_NSCoder_encodeValueOfObjCType_at_(
 	PyObject* method, PyObject* self, PyObject* arguments)
@@ -1093,60 +1088,8 @@
 	PyObjCErr_ToObjCWithGILState(&state);
 }
 
-PyDoc_STRVAR(mod_doc, "");
-
-static PyMethodDef mod_methods[] = {
-	        { 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_nscoder",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__nscoder(void);
-
-PyObject*
-PyInit__nscoder(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_nscoder(void);
-
-void
-init_nscoder(void)
-#endif
+static int setup_nscoder(PyObject* m __attribute__((__unused__)))
 {
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_nscoder", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
 	Class classNSCoder = objc_lookUpClass("NSCoder");
   
 	if (PyObjC_RegisterMethodMapping(
@@ -1154,7 +1097,7 @@
 			@selector(encodeArrayOfObjCType:count:at:),
 			call_NSCoder_encodeArrayOfObjCType_count_at_,
 			imp_NSCoder_encodeArrayOfObjCType_count_at_) < 0) {
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -1162,7 +1105,7 @@
 			@selector(encodeValueOfObjCType:at:),
 			call_NSCoder_encodeValueOfObjCType_at_,
 			imp_NSCoder_encodeValueOfObjCType_at_) < 0) {
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -1170,7 +1113,7 @@
 			@selector(decodeArrayOfObjCType:count:at:),
 			call_NSCoder_decodeArrayOfObjCType_count_at_,
 			imp_NSCoder_decodeArrayOfObjCType_count_at_) < 0) {
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -1178,7 +1121,7 @@
 			@selector(decodeValueOfObjCType:at:),
 			call_NSCoder_decodeValueOfObjCType_at_,
 			imp_NSCoder_decodeValueOfObjCType_at_) < 0) {
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -1186,7 +1129,7 @@
 			@selector(encodeBytes:length:),
 			call_NSCoder_encodeBytes_length_,
 			imp_NSCoder_encodeBytes_length_) < 0) {
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -1194,7 +1137,7 @@
 			@selector(encodeBytes:length:forKey:),
 			call_NSCoder_encodeBytes_length_forKey_,
 			imp_NSCoder_encodeBytes_length_forKey_) < 0) {
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -1202,7 +1145,7 @@
 			@selector(decodeBytesWithReturnedLength:),
 			call_NSCoder_decodeBytesWithReturnedLength_,
 			imp_NSCoder_decodeBytesWithReturnedLength_) < 0) {
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -1210,7 +1153,7 @@
 			@selector(decodeBytesForKey:returnedLength::),
 			call_NSCoder_decodeBytesForKey_returnedLength_,
 			imp_NSCoder_decodeBytesForKey_returnedLength_) < 0) {
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -1218,7 +1161,7 @@
 			@selector(decodeBytesWithoutReturnedLength),
 			PyObjCUnsupportedMethod_Caller,
 			PyObjCUnsupportedMethod_IMP) < 0) {
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -1226,7 +1169,7 @@
 			@selector(encodeValuesOfObjCTypes:),
 			PyObjCUnsupportedMethod_Caller,
 			PyObjCUnsupportedMethod_IMP) < 0) {
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -1234,8 +1177,8 @@
 			@selector(decodeValuesOfObjCTypes:),
 			PyObjCUnsupportedMethod_Caller,
 			PyObjCUnsupportedMethod_IMP) < 0) {
-		INITERROR();
+		return -1;
 	}
 
-	INITDONE();
+	return 0;
 }

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_string.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_string.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_string.m	Tue Feb  2 10:58:46 2010
@@ -5,11 +5,6 @@
  * -getCString:maxLength:			[call]
  *
  */
-#include <Python.h>
-#include "pyobjc-api.h"
-
-#include <Foundation/Foundation.h>
-
 
 static PyObject*
 call_NSString_getCString_maxLength_range_remainingRange_(
@@ -123,59 +118,12 @@
 	return res;
 }
 
-static PyMethodDef mod_methods[] = {
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_string",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__string(void);
-
-PyObject*
-PyInit__string(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_string(void);
-
-void
-init_string(void)
-#endif
+static int setup_nssstring(PyObject* m __attribute__((__unused__)))
 {
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_string", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-
 	Class classNSString = objc_lookUpClass("NSString");
-	if (classNSString == NULL) INITDONE();
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
+	if (classNSString == NULL) {
+		return 0;
+	}
 
 	if (PyObjC_RegisterMethodMapping(
 		classNSString,
@@ -183,7 +131,7 @@
 		call_NSString_getCString_maxLength_range_remainingRange_,
 		PyObjCUnsupportedMethod_IMP) < 0) {
 
-		INITERROR();
+		return -1;
 	}
 
 	if (PyObjC_RegisterMethodMapping(
@@ -192,8 +140,8 @@
 		call_NSString_getCString_maxLength_,
 		PyObjCUnsupportedMethod_IMP) < 0) {
 
-		INITERROR();
+		return -1;
 	}
 
-	INITDONE();
+	return 0;
 }

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_typecode.m
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_typecode.m	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/Modules/_Foundation_typecode.m	Tue Feb  2 10:58:46 2010
@@ -3,14 +3,6 @@
  *
  * Needed for backward compatiblity with earlier versions of PyObjC.
  */
-#include "Python.h"
-
-
-
-#include "pyobjc-api.h"
-
-#include <Foundation/Foundation.h>
-
 /* inline definition of PyMac_GetOSType pymactoolbox.h doesn't work in 64-bit mode */
 extern int PyMac_GetOSType(PyObject *v, OSType *pr);
 extern PyObject * PyMac_BuildOSType(OSType t);
@@ -87,69 +79,16 @@
 
 PyDoc_STRVAR(mod_doc, "");
 
-static PyMethodDef mod_methods[] = {
-	{ 
-		"NSFileTypeForHFSTypeCode", 
-		(PyCFunction)objc_NSFileTypeForHFSTypeCode, 
-		METH_VARARGS|METH_KEYWORDS, 
-		objc_NSFileTypeForHFSTypeCode_doc
-	},
-	{ 
-		"NSHFSFTypeCodeFromFileType", 
-		(PyCFunction)objc_NSHFSTypeCodeFromFileType, 
-		METH_VARARGS|METH_KEYWORDS, 
-		objc_NSHFSTypeCodeFromFileType_doc 
+#define FOUNDATION_TYPECODE_METHODS				\
+	{ 							\
+		"NSFileTypeForHFSTypeCode", 			\
+		(PyCFunction)objc_NSFileTypeForHFSTypeCode, 	\
+		METH_VARARGS|METH_KEYWORDS, 			\
+		objc_NSFileTypeForHFSTypeCode_doc		\
+	},							\
+	{ 							\
+		"NSHFSFTypeCodeFromFileType",			\
+		(PyCFunction)objc_NSHFSTypeCodeFromFileType, 	\
+		METH_VARARGS|METH_KEYWORDS, 			\
+		objc_NSHFSTypeCodeFromFileType_doc 		\
 	},
-	{ 0, 0, 0, 0 } /* sentinel */
-};
-
-
-/* Python glue */
-#if PY_VERSION_HEX >= 0x03000000
-
-static struct PyModuleDef mod_module = {
-        PyModuleDef_HEAD_INIT,
-	"_typecode",
-	NULL,
-	0,
-	mod_methods,
-	NULL,
-	NULL,
-	NULL,
-	NULL
-};
-
-#define INITERROR() return NULL
-#define INITDONE() return m
-
-PyObject* PyInit__typecode(void);
-
-PyObject*
-PyInit__typecode(void)
-
-#else
-
-#define INITERROR() return
-#define INITDONE() return
-
-void init_typecode(void);
-
-void
-init_typecode(void)
-#endif
-{
-	PyObject* m;
-#if PY_VERSION_HEX >= 0x03000000
-	m = PyModule_Create(&mod_module);
-#else
-	m = Py_InitModule4("_typecode", mod_methods,
-		NULL, NULL, PYTHON_API_VERSION);
-#endif
-	if (!m) {
-		INITERROR();
-	}
-
-	if (PyObjC_ImportAPI(m) == -1) INITERROR();
-
-	INITDONE();
-}

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nsgraphicscontext.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nsgraphicscontext.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nsgraphicscontext.py	Tue Feb  2 10:58:46 2010
@@ -1,7 +1,12 @@
 
 from PyObjCTools.TestSupport import *
 from AppKit import *
-import Quartz.CoreGraphics
+
+try:
+    import Quartz
+except ImportError:
+    Quartz = None
+
 
 class TestNSGraphicsContext (TestCase):
     def testConstants(self):
@@ -35,7 +40,8 @@
         context = NSGraphicsContext.graphicsContextWithBitmapImageRep_(img)
         self.assertIsInstance(context, NSGraphicsContext)
         port = context.graphicsPort()
-        self.assertIsInstance(port, Quartz.CoreGraphics.CGContextRef)
+        if Quartz is not None:
+            self.assertIsInstance(port, Quartz.CGContextRef)
 
         self.assertArgHasType(NSGraphicsContext.graphicsContextWithGraphicsPort_flipped_, 0, '^{CGContext=}')
         self.assertResultHasType(NSGraphicsContext.graphicsPort, '^{CGContext=}')

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nspointerfunctions.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nspointerfunctions.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nspointerfunctions.py	Tue Feb  2 10:58:46 2010
@@ -26,7 +26,7 @@
         v = o.usesStrongWriteBarrier()
         self.assertTrue((v is True) or (v is False) )
         v = o.usesWeakReadAndWriteBarriers()
-        self.assertIsTrue((v is True) or (v is False) )
+        self.assertTrue((v is True) or (v is False) )
 
 if __name__ == "__main__":
     main()

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nswindow.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nswindow.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/PyObjCTest/test_nswindow.py	Tue Feb  2 10:58:46 2010
@@ -1,6 +1,11 @@
 from PyObjCTools.TestSupport import *
 from AppKit import *
-from Quartz.CoreGraphics import *
+
+try:
+    from Quartz.CoreGraphics import *
+    have_Quartz = 1
+except ImportError:
+    have_Quartz = 0
 
 class TestNSWindowHelper (NSObject):
     def windowShouldClose_(self, w): return 1
@@ -85,6 +90,7 @@
         self.assertIsInstance(NSWindowWillStartLiveResizeNotification, unicode)
         self.assertIsInstance(NSWindowDidEndLiveResizeNotification, unicode)
 
+    @onlyIf(have_Quartz)
     def testMagicConstants(self):
         self.assertEqual(NSNormalWindowLevel, kCGNormalWindowLevel)
         self.assertEqual(NSFloatingWindowLevel, kCGFloatingWindowLevel)

Modified: trunk/pyobjc/pyobjc-framework-Cocoa/setup.py
==============================================================================
--- trunk/pyobjc/pyobjc-framework-Cocoa/setup.py	(original)
+++ trunk/pyobjc/pyobjc-framework-Cocoa/setup.py	Tue Feb  2 10:58:46 2010
@@ -8,6 +8,7 @@
 and (Objective-)C frameworks
 '''
 from pyobjc_setup import setup, Extension
+import os
 
 setup(
     name='pyobjc-framework-Cocoa',
@@ -23,112 +24,37 @@
         Extension('CoreFoundation._inlines', 
                 [ 'Modules/_CoreFoundation_inlines.m' ],
                 extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFCalendar', 
-                [ 'Modules/_CoreFoundation_CFCalendar.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFTree', 
-                [ 'Modules/_CoreFoundation_CFTree.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFBag', 
-                [ 'Modules/_CoreFoundation_CFBag.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFBinaryHeap', 
-                [ 'Modules/_CoreFoundation_CFBinaryHeap.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFBitVector', 
-                [ 'Modules/_CoreFoundation_CFBitVector.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFDictionary', 
-                [ 'Modules/_CoreFoundation_CFDictionary.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFFileDescriptor', 
-                [ 'Modules/_CoreFoundation_CFFileDescriptor.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFMachPort', 
-                [ 'Modules/_CoreFoundation_CFMachPort.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFMessagePort', 
-                [ 'Modules/_CoreFoundation_CFMessagePort.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFNumber', 
-                [ 'Modules/_CoreFoundation_CFNumber.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFReadStream', 
-                [ 'Modules/_CoreFoundation_CFReadStream.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFSet', 
-                [ 'Modules/_CoreFoundation_CFSet.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFSocket', 
-                [ 'Modules/_CoreFoundation_CFSocket.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFWriteStream', 
-                [ 'Modules/_CoreFoundation_CFWriteStream.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFRunLoopObserver', 
-                [ 'Modules/_CoreFoundation_CFRunLoopObserver.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFRunLoopSource', 
-                [ 'Modules/_CoreFoundation_CFRunLoopSource.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
-        Extension('CoreFoundation._CFRunLoopTimer', 
-                [ 'Modules/_CoreFoundation_CFRunLoopTimer.m' ],
-                extra_link_args=['-framework', 'CoreFoundation']),
+        Extension('CoreFoundation._CoreFoundation', 
+            [ 'Modules/_CoreFoundation.m' ],
+            extra_link_args=['-framework', 'CoreFoundation'],
+            depends=[
+                os.path.join('Modules', fn) 
+                for fn in os.listdir('Modules')
+                if fn.startswith('_CoreFoundation') ]),
 
         # Foundation
-        Extension('Foundation._nsinvocation', 
-                [ 'Modules/_Foundation_NSInvocation.m' ],
-                extra_link_args=['-framework', 'Foundation']),
-        Extension('Foundation._NSDecimal', 
-                [ 'Modules/_Foundation_NSDecimal.m' ],
-                extra_link_args=['-framework', 'Foundation']),
-        Extension('Foundation._nscoder', 
-                [ 'Modules/_Foundation_nscoder.m' ],
-                extra_link_args=['-framework', 'Foundation']),
-        Extension('Foundation._typecode', 
-                [ 'Modules/_Foundation_typecode.m' ],
-                extra_link_args=['-framework', 'Foundation']),
         Extension('Foundation._inlines', 
                 [ 'Modules/_Foundation_inlines.m' ],
                 extra_link_args=['-framework', 'Foundation']),
-        Extension('Foundation._data', 
-                [ 'Modules/_Foundation_data.m' ],
-                extra_link_args=['-framework', 'Foundation']),
-        Extension('Foundation._netservice', 
-                [ 'Modules/_Foundation_netservice.m' ],
-                extra_link_args=['-framework', 'Foundation']),
-        Extension('Foundation._string', 
-                [ 'Modules/_Foundation_string.m' ],
-                extra_link_args=['-framework', 'Foundation']),
+        Extension('Foundation._Foundation', 
+            [ 'Modules/_Foundation.m' ],
+            extra_link_args=['-framework', 'Foundation'],
+            depends=[
+                os.path.join('Modules', fn) 
+                for fn in os.listdir('Modules')
+                if fn.startswith('_Foundation') ]),
 
         # AppKit
         Extension("AppKit._inlines",
             [ "Modules/_AppKit_inlines.m" ],
             extra_link_args=["-framework", "AppKit"]),
-        Extension("AppKit._appmain",
-            [ "Modules/_AppKit_appmain.m" ],
-            extra_link_args=["-framework", "AppKit"]),
-        Extension("AppKit._nsfont",
-            [ "Modules/_AppKit_nsfont.m"],
-            extra_link_args=["-framework", "AppKit"]),
-        Extension("AppKit._nsquickdrawview",
-            [ "Modules/_AppKit_nsquickdrawview.m"],
-            extra_link_args=["-framework", "AppKit"]),
-        Extension("AppKit._nsbezierpath",
-            [ "Modules/_AppKit_nsbezierpath.m"],
-            extra_link_args=["-framework", "AppKit"]),
-        Extension("AppKit._nsview",
-            [ "Modules/_AppKit_nsview.m"],
-            extra_link_args=["-framework", "AppKit"]),
-        Extension("AppKit._nsbitmap",
-            [ "Modules/_AppKit_nsbitmap.m"],
-            extra_link_args=["-framework", "AppKit"]),
-        Extension("AppKit._nswindow",
-            [ "Modules/_AppKit_nswindow.m"],
-            extra_link_args=["-framework", "AppKit"]),
-        Extension("AppKit._carbon",
-            [ "Modules/_AppKit_carbon.m"],
-            extra_link_args=["-framework", "AppKit"]),
+        Extension("AppKit._AppKit",
+            [ "Modules/_AppKit.m" ],
+            extra_link_args=["-framework", "AppKit"],
+            depends=[
+                os.path.join('Modules', fn) 
+                for fn in os.listdir('Modules')
+                if fn.startswith('_AppKit') ]),
 
 
         #

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com