Ronald Oussoren avatar Ronald Oussoren committed 1f23dbf

- Add wrappers for ScreenSaver, PreferencePanes and InterfaceBuilder
frameworks (not very usefull without the plugin-hack I posted on the list,
but that will eventually be added too)
- Add some more extensive testing of the core bridge, including a test-specific
Objective-C class/module.

Comments (0)

Files changed (23)

Lib/AddressBook/__init__.py

 """
 
 # Load the AddressBook bundle, and gather all classes defined there
-import Foundation
+import objc
 
-Foundation._objc.loadBundle("AddressBook", globals(), bundle_path="/System/Library/Frameworks/AddressBook.framework")
-Foundation._objc.recycle_autorelease_pool()
+objc.loadBundle("AddressBook", globals(), bundle_path="/System/Library/Frameworks/AddressBook.framework")
 
-del Foundation
+from _AddressBook import *
+del _AddressBook, objc
 
 # Define usefull utility methods here

Lib/Foundation/test/test_nsnumber.py

 
 from Foundation import *
 
-class TestNSNumber( unittest.TestCase ):
-    def testNSNumber( self ):
-        x = NSMutableArray.arrayWithArray_( range(1, 10) )
-        y = range( 1, 10 )
+if 0:
+    # NSNumber is proxied into python
 
-        self.assert_( isinstance( x[4], NSNumber ) )
-        self.assertEquals( x[3], y[3] )
-        self.assertEquals( x[3] + x[5], y[3] + y[5] )
-        self.assertEquals( x[2] + y[3], y[2] + x[3] )
-        self.assertEquals( x[8] * x[7], y[7] * y[8] )
-        self.assertEquals( y[8] * x[7], x[7] * y[8] )
+    class TestNSNumber( unittest.TestCase ):
+        def testNSNumber( self ):
+            x = NSMutableArray.arrayWithArray_( range(1, 10) )
+            y = range( 1, 10 )
 
-    def testAsBool(self):
-        trues = (
-            NSNumber.numberWithFloat_(1.0),
-            NSNumber.numberWithInt_(1),
-            NSNumber.numberWithFloat_(-0.01),
-            NSNumber.numberWithInt_(-4),
-        )
-        falses = (
-            NSNumber.numberWithFloat_(0.0),
-            NSNumber.numberWithInt_(0),
-        )
+            self.assert_( isinstance( x[4], NSNumber ) )
+            self.assertEquals( x[3], y[3] )
+            self.assertEquals( x[3] + x[5], y[3] + y[5] )
+            self.assertEquals( x[2] + y[3], y[2] + x[3] )
+            self.assertEquals( x[8] * x[7], y[7] * y[8] )
+            self.assertEquals( y[8] * x[7], x[7] * y[8] )
 
-        for a in trues:
-            if a:
-                pass
-            else:
-                raise AssertionError, "%s is not true"%(a.description())
+        def testAsBool(self):
+            trues = (
+                NSNumber.numberWithFloat_(1.0),
+                NSNumber.numberWithInt_(1),
+                NSNumber.numberWithFloat_(-0.01),
+                NSNumber.numberWithInt_(-4),
+            )
+            falses = (
+                NSNumber.numberWithFloat_(0.0),
+                NSNumber.numberWithInt_(0),
+            )
 
-        for a in falses:
-            if a:
-                raise AssertionError, "%s is true"%(a.description())
+            for a in trues:
+                if a:
+                    pass
+                else:
+                    raise AssertionError, "%s is not true"%(a.description())
 
-    def testStr(self):
-        x = NSNumber.numberWithInt_(4)
-        self.assertEquals(4, int(str(x)))
+            for a in falses:
+                if a:
+                    raise AssertionError, "%s is true"%(a.description())
+
+        def testStr(self):
+            x = NSNumber.numberWithInt_(4)
+            self.assertEquals(4, int(str(x)))
+
+else:
+    # NSNumber instances are converted to Python numbers
+
+    class TestNSNumber( unittest.TestCase ):
+        def testNSNumber( self ):
+                self.assertEquals(NSNumber.numberWithFloat_(1.0), 1,0)
+                self.assertEquals(NSNumber.numberWithInt_(1), 1)
+                self.assertEquals(NSNumber.numberWithFloat_(-0.5), -0.5)
+                self.assertEquals(NSNumber.numberWithInt_(-4), -4)
+                self.assertEquals(NSNumber.numberWithInt_(0), 0)
+                self.assertEquals(NSNumber.numberWithFloat_(0.0), 0,0)
+            
 
 def suite():
     suite = unittest.TestSuite()

Lib/Foundation/test/test_nsstring.py

     def testTypesAndClasses(self):
         self.assert_(isinstance(self.py7String, "".__class__))
         self.assert_(isinstance(self.pyUniString, u"".__class__))
-        self.assert_(isinstance(self.ns7String, NSString))
-        self.assert_(isinstance(self.pyUniString, NSString))
+        self.assert_(isinstance(self.ns7String, unicode))
+        self.assert_(isinstance(self.pyUniString, unicode))
         
 def suite():
     suite = unittest.TestSuite()

Lib/InterfaceBuilder/__init__.py

+"""
+Python mapping for the InterfaceBuilder framework
+
+This module does not contain docstrings for the wrapped code, check Apple's
+documentation for details on how to use these functions and classes.
+"""
+
+# Load the AddressBook bundle, and gather all classes defined there
+import objc 
+
+objc.loadBundle("InterfaceBuilder", globals(), bundle_path="/System/Library/Frameworks/InterfaceBuilder.framework")
+
+del objc
+from _InterfaceBuilder import *
+del _InterfaceBuilder
+
+# Define usefull utility methods here

Lib/PreferencePanes/__init__.py

+"""
+Python mapping for the PreferencePanes framework on MacOS X >= 10.1
+
+This module does not contain docstrings for the wrapped code, check Apple's
+documentation for details on how to use these functions and classes.
+"""
+
+# Load the AddressBook bundle, and gather all classes defined there
+import objc 
+
+objc.loadBundle("PreferencePanes", globals(), bundle_path="/System/Library/Frameworks/PreferencePanes.framework")
+
+del objc
+from _PreferencePanes import *
+del _PreferencePanes
+
+# Define usefull utility methods here

Lib/ScreenSaver.py

+"""
+Python mapping for the ScreenSaver framework on MacOS X
+
+This module does not contain docstrings for the wrapped code, check Apple's
+documentation for details on how to use these functions and classes.
+"""
+
+
+# Load the ScreenSaver framework, and gather all classes defined there
+import objc
+
+objc.loadBundle("ScreenSaver", globals(), bundle_path="/System/Library/Frameworks/ScreenSaver.framework")
+
+del objc
+# NOTE: One MacOSX 10.2.4 the framework doesn't define constants,
+# therefore there is no _ScreenSaver module.
+
+# Define usefull utility methods here

Lib/objc/test/test_methods.py

+"""
+Test lowlevel message passing details (Python -> ObjC)
+
+Note: See also testbndl.m, the implementation there must be synchronized with
+this file.
+
+Done:
+- Return simple values
+
+Todo:
+- Return structs
+- Pass in basic types
+- Pass in struct types
+- Pass by reference of basic types (in, out, inout)
+- Pass by reference of struct types (in, out, inout)
+- 0, 1, 4 arguments
+
+Also Todo: Passing from Objective-C to python
+- Using NSInvocation '[obj forwardInvocation:inv]'
+- Using normal calls
+"""
+import unittest
+import objc
+
+# This should be an extension module (basicly an empty module that happens
+# to define objective-C classes), that should allow for using distutils to
+# build the extension module and removes the need for an absolute path.
+from objc.test.testbndl import *
+
+print OC_TestClass1.new().dummyFunc()
+
+class TestSimpleReturns(unittest.TestCase):
+    #
+    # Test returns of basic types from instance and classs methods
+    #
+    def testClsLongLong(self):
+        OC_TestClass1.clsReset()
+        self.assertEquals(OC_TestClass1.longlongClsFunc(), -(1L << 60))
+        self.assertEquals(OC_TestClass1.longlongClsFunc(), -42)
+        self.assertEquals(OC_TestClass1.longlongClsFunc(), 0)
+        self.assertEquals(OC_TestClass1.longlongClsFunc(), 42)
+        self.assertEquals(OC_TestClass1.longlongClsFunc(), (1L << 60))
+
+    def testClsULongLong(self):
+        OC_TestClass1.clsReset()
+        self.assertEquals(OC_TestClass1.ulonglongClsFunc(), 0)
+        self.assertEquals(OC_TestClass1.ulonglongClsFunc(), 42)
+        self.assertEquals(OC_TestClass1.ulonglongClsFunc(), (1L << 63))
+
+    def testClsLong(self):
+        OC_TestClass1.clsReset()
+        self.assertEquals(OC_TestClass1.longClsFunc(), -(1 << 30))
+        self.assertEquals(OC_TestClass1.longClsFunc(), -42)
+        self.assertEquals(OC_TestClass1.longClsFunc(), 0)
+        self.assertEquals(OC_TestClass1.longClsFunc(), 42)
+        self.assertEquals(OC_TestClass1.longClsFunc(), (1 << 30))
+
+    def testClsULong(self):
+        OC_TestClass1.clsReset()
+        self.assertEquals(OC_TestClass1.ulongClsFunc(), 0)
+        self.assertEquals(OC_TestClass1.ulongClsFunc(), 42)
+        self.assertEquals(OC_TestClass1.ulongClsFunc(), (1 << 30))
+
+    def testClsInt(self):
+        OC_TestClass1.clsReset()
+        self.assertEquals(OC_TestClass1.intClsFunc(), -(1 << 30))
+        self.assertEquals(OC_TestClass1.intClsFunc(), -42)
+        self.assertEquals(OC_TestClass1.intClsFunc(), 0)
+        self.assertEquals(OC_TestClass1.intClsFunc(), 42)
+        self.assertEquals(OC_TestClass1.intClsFunc(), (1 << 30))
+
+    def testClsUInt(self):
+        OC_TestClass1.clsReset()
+        self.assertEquals(OC_TestClass1.uintClsFunc(), 0)
+        self.assertEquals(OC_TestClass1.uintClsFunc(), 42)
+        self.assertEquals(OC_TestClass1.uintClsFunc(), (1 << 30))
+
+    def testClsShort(self):
+        OC_TestClass1.clsReset()
+        self.assertEquals(OC_TestClass1.shortClsFunc(), -(1 << 14))
+        self.assertEquals(OC_TestClass1.shortClsFunc(), -42)
+        self.assertEquals(OC_TestClass1.shortClsFunc(), 0)
+        self.assertEquals(OC_TestClass1.shortClsFunc(), 42)
+        self.assertEquals(OC_TestClass1.shortClsFunc(), (1 << 14))
+
+    def testClsUShort(self):
+        OC_TestClass1.clsReset()
+        self.assertEquals(OC_TestClass1.ushortClsFunc(), 0)
+        self.assertEquals(OC_TestClass1.ushortClsFunc(), 42)
+        self.assertEquals(OC_TestClass1.ushortClsFunc(), (1 << 14))
+
+    def testClsChar(self):
+        # Fails with libffi due to the way we treat 'char' at the moment
+        OC_TestClass1.clsReset()
+        self.assertEquals(OC_TestClass1.charClsFunc(), '\x10')
+        self.assertEquals(OC_TestClass1.charClsFunc(), '\x00')
+        self.assertEquals(OC_TestClass1.charClsFunc(), '\xef')
+
+    def testClsUChar(self):
+        OC_TestClass1.clsReset()
+        self.assertEquals(OC_TestClass1.ucharClsFunc(), 0)
+        self.assertEquals(OC_TestClass1.ucharClsFunc(), 128)
+        self.assertEquals(OC_TestClass1.ucharClsFunc(), 255)
+
+    def testClsFloat(self):
+        # Fails, possibly rounding error
+        OC_TestClass1.clsReset()
+        self.assertEquals(OC_TestClass1.floatClsFunc(), 0.128)
+        self.assertEquals(OC_TestClass1.floatClsFunc(), 1.0)
+        self.assertEquals(OC_TestClass1.floatClsFunc(), 42.0)
+        self.assertEquals(OC_TestClass1.floatClsFunc(), 1e10)
+
+    def testClsDouble(self):
+        OC_TestClass1.clsReset()
+        self.assertEquals(OC_TestClass1.doubleClsFunc(), 0.128)
+        self.assertEquals(OC_TestClass1.doubleClsFunc(), 1.0)
+        self.assertEquals(OC_TestClass1.doubleClsFunc(), 42.0)
+        self.assertEquals(OC_TestClass1.doubleClsFunc(), 1e10)
+
+    def testLongLong(self):
+        obj = OC_TestClass1.new()
+        obj.reset()
+        self.assertEquals(obj.longlongFunc(), -(1L << 60))
+        self.assertEquals(obj.longlongFunc(), -42)
+        self.assertEquals(obj.longlongFunc(), 0)
+        self.assertEquals(obj.longlongFunc(), 42)
+        self.assertEquals(obj.longlongFunc(), (1L << 60))
+
+    def testULongLong(self):
+        obj = OC_TestClass1.new()
+        obj.reset()
+        self.assertEquals(obj.ulonglongFunc(), 0)
+        self.assertEquals(obj.ulonglongFunc(), 42)
+        self.assertEquals(obj.ulonglongFunc(), (1L << 63))
+
+    def testLong(self):
+        obj = OC_TestClass1.new()
+        obj.reset()
+        self.assertEquals(obj.longFunc(), -(1 << 30))
+        self.assertEquals(obj.longFunc(), -42)
+        self.assertEquals(obj.longFunc(), 0)
+        self.assertEquals(obj.longFunc(), 42)
+        self.assertEquals(obj.longFunc(), (1 << 30))
+
+    def testULong(self):
+        obj = OC_TestClass1.new()
+        obj.reset()
+        self.assertEquals(obj.ulongFunc(), 0)
+        self.assertEquals(obj.ulongFunc(), 42)
+        self.assertEquals(obj.ulongFunc(), (1 << 30))
+
+    def testInt(self):
+        obj = OC_TestClass1.new()
+        obj.reset()
+        self.assertEquals(obj.intFunc(), -(1 << 30))
+        self.assertEquals(obj.intFunc(), -42)
+        self.assertEquals(obj.intFunc(), 0)
+        self.assertEquals(obj.intFunc(), 42)
+        self.assertEquals(obj.intFunc(), (1 << 30))
+
+    def testUInt(self):
+        obj = OC_TestClass1.new()
+        obj.reset()
+        self.assertEquals(obj.uintFunc(), 0)
+        self.assertEquals(obj.uintFunc(), 42)
+        self.assertEquals(obj.uintFunc(), (1 << 30))
+
+    def testShort(self):
+        obj = OC_TestClass1.new()
+        obj.reset()
+        self.assertEquals(obj.shortFunc(), -(1 << 14))
+        self.assertEquals(obj.shortFunc(), -42)
+        self.assertEquals(obj.shortFunc(), 0)
+        self.assertEquals(obj.shortFunc(), 42)
+        self.assertEquals(obj.shortFunc(), (1 << 14))
+
+    def testUShort(self):
+        obj = OC_TestClass1.new()
+        obj.reset()
+        self.assertEquals(obj.ushortFunc(), 0)
+        self.assertEquals(obj.ushortFunc(), 42)
+        self.assertEquals(obj.ushortFunc(), (1 << 14))
+
+    def testChar(self):
+        obj = OC_TestClass1.new()
+        # Fails with libffi due to the way we treat 'char' at the moment
+        obj.reset()
+        self.assertEquals(obj.charFunc(), '\x10')
+        self.assertEquals(obj.charFunc(), '\x00')
+        self.assertEquals(obj.charFunc(), '\xef')
+
+    def testUChar(self):
+        obj = OC_TestClass1.new()
+        obj.reset()
+        self.assertEquals(obj.ucharFunc(), 0)
+        self.assertEquals(obj.ucharFunc(), 128)
+        self.assertEquals(obj.ucharFunc(), 255)
+
+    def testFloat(self):
+        # Fails, possibly rounding error
+        obj = OC_TestClass1.new()
+        obj.clsReset()
+        self.assertEquals(obj.floatFunc(), 0.128)
+        self.assertEquals(obj.floatFunc(), 1.0)
+        self.assertEquals(obj.floatFunc(), 42.0)
+        self.assertEquals(obj.floatFunc(), 1e10)
+
+    def testDouble(self):
+        obj = OC_TestClass1.new()
+        obj.clsReset()
+        self.assertEquals(obj.doubleFunc(), 0.128)
+        self.assertEquals(obj.doubleFunc(), 1.0)
+        self.assertEquals(obj.doubleFunc(), 42.0)
+        self.assertEquals(obj.doubleFunc(), 1e10)
+
+    def testStruct1(self):
+        obj = OC_TestClass1.new()
+
+        self.assertEquals(obj.dummyFunc(), (-1, 1))
+
+    def testStruct2(self):
+        obj = OC_TestClass1.new()
+
+        self.assertEquals(obj.dummy2Func(), ((1,2,3,4)))
+
+def suite():
+    suite = unittest.TestSuite()
+    suite.addTest(unittest.makeSuite(TestSimpleCalls))
+    return suite
+
+if __name__ == '__main__':
+    unittest.main()

Lib/objc/test/testbndl.m

+/*
+ * This file implements a (number of) class(es) that are used to test
+ * method calling with PyObjC (both python -> ObjC and back)
+ */
+#import <Foundation/Foundation.h>
+
+#include <Python.h>
+#include <pyobjc-api.h>
+
+struct dummy
+{
+	int f1;
+	int f2;
+};
+
+struct dummy2
+{
+	int array[100];
+};
+
+
+
+@interface OC_TestClass1 : NSObject
+{
+}
+
+/* Reset the test counter */
++ (void)clsReset;
+- (void)reset;
+
+
+/* Test return values, return various values */
++ (long long)longlongClsFunc;
++ (unsigned long long)ulonglongClsFunc;
++ (long)longClsFunc;
++ (unsigned long)ulongClsFunc;
++ (int)intClsFunc;
++ (unsigned int)uintClsFunc;
++ (short)shortClsFunc;
++ (unsigned short)ushortClsFunc;
++ (char)charClsFunc;
++ (unsigned char)ucharClsFunc;
++ (float)floatClsFunc;
++ (double)doubleClsFunc;
+
+- (long long)longlongFunc;
+- (unsigned long long)ulonglongFunc;
+- (long)longFunc;
+- (unsigned long)ulongFunc;
+- (int)intFunc;
+- (unsigned int)uintFunc;
+- (short)shortFunc;
+- (unsigned short)ushortFunc;
+- (char)charFunc;
+- (unsigned char)ucharFunc;
+- (float)floatFunc;
+- (double)doubleFunc;
+
+/* returns of complex values */
+- (struct dummy)dummyFunc;
+- (struct dummy2)dummy2Func;
+
+@end
+
+@implementation OC_TestClass1
+
+#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
+static int g_idx = 0;
+static unsigned long long g_ulonglongs[] = {
+	0, 42, (1LL << 63)
+};
+static unsigned long g_ulongs[] = {
+	0, 42, (1 << 30)
+};
+static long long g_longlongs[] = {
+	-(1LL << 60), -42, 0, 42, (1LL << 60)
+};
+static long g_longs[] = {
+	-(1 << 30), -42, 0, 42, (1 << 30)
+};
+static int g_ints[] = {
+	-(1 << 30), -42, 0, 42, (1 << 30)
+};
+static unsigned int g_uints[] = {
+	0, 42, 1 << 30
+};
+static short g_shorts[] = {
+	-(1 << 14), -42, 0, 42, (1 << 14)
+};
+static unsigned short g_ushorts[] = {
+	0, 42, 1 << 14
+};
+static char g_chars[] = {
+	-128, 0, 127
+};
+static unsigned char g_uchars[] = {
+	0, 128, 255
+};
+static float g_floats[] = {
+	0.128, 1.0, 42.0, 1e10
+};
+static double g_doubles[] = {
+	0.128, 1.0, 42.0, 1e10
+};
+
++ (void)clsReset
+{
+	g_idx = 0;
+}
+
++ (long long)longlongClsFunc;
+{
+	if (g_idx > ARRAYSIZE(g_longlongs)) g_idx = 0;
+	return g_longlongs[g_idx++];
+}
+
++ (unsigned long long)ulonglongClsFunc
+{
+	if (g_idx > ARRAYSIZE(g_ulonglongs)) g_idx = 0;
+	return g_ulonglongs[g_idx++];
+}
+
++ (long)longClsFunc;
+{
+	if (g_idx > ARRAYSIZE(g_longs)) g_idx = 0;
+	return g_longs[g_idx++];
+}
+
++ (unsigned long)ulongClsFunc
+{
+	if (g_idx > ARRAYSIZE(g_ulongs)) g_idx = 0;
+	return g_ulongs[g_idx++];
+}
+
++ (int)intClsFunc;
+{
+	if (g_idx > ARRAYSIZE(g_ints)) g_idx = 0;
+	return g_ints[g_idx++];
+}
+
++ (unsigned int)uintClsFunc
+{
+	if (g_idx > ARRAYSIZE(g_uints)) g_idx = 0;
+	return g_uints[g_idx++];
+}
+
++ (short)shortClsFunc
+{
+	if (g_idx > ARRAYSIZE(g_shorts)) g_idx = 0;
+	return g_shorts[g_idx++];
+}
+
++ (unsigned short)ushortClsFunc
+{
+	if (g_idx > ARRAYSIZE(g_ushorts)) g_idx = 0;
+	return g_ushorts[g_idx++];
+}
+
++ (char)charClsFunc;
+{
+	if (g_idx > ARRAYSIZE(g_chars)) g_idx = 0;
+	return g_chars[g_idx++];
+}
+
++ (unsigned char)ucharClsFunc;
+{
+	if (g_idx > ARRAYSIZE(g_uchars)) g_idx = 0;
+	return g_uchars[g_idx++];
+}
+
++ (float)floatClsFunc;
+{
+	if (g_idx > ARRAYSIZE(g_floats)) g_idx = 0;
+	return g_floats[g_idx++];
+}
+
++ (double)doubleClsFunc;
+{
+	if (g_idx > ARRAYSIZE(g_doubles)) g_idx = 0;
+	return g_doubles[g_idx++];
+}
+
+- (void)reset
+{
+	g_idx = 0;
+}
+
+- (long long)longlongFunc;
+{
+	if (g_idx > ARRAYSIZE(g_longlongs)) g_idx = 0;
+	return g_longlongs[g_idx++];
+}
+
+- (unsigned long long)ulonglongFunc
+{
+	if (g_idx > ARRAYSIZE(g_ulonglongs)) g_idx = 0;
+	return g_ulonglongs[g_idx++];
+}
+
+- (long)longFunc;
+{
+	if (g_idx > ARRAYSIZE(g_longs)) g_idx = 0;
+	return g_longs[g_idx++];
+}
+
+- (unsigned long)ulongFunc
+{
+	if (g_idx > ARRAYSIZE(g_ulongs)) g_idx = 0;
+	return g_ulongs[g_idx++];
+}
+
+- (int)intFunc;
+{
+	if (g_idx > ARRAYSIZE(g_ints)) g_idx = 0;
+	return g_ints[g_idx++];
+}
+
+- (unsigned int)uintFunc
+{
+	if (g_idx > ARRAYSIZE(g_uints)) g_idx = 0;
+	return g_uints[g_idx++];
+}
+
+- (short)shortFunc
+{
+	if (g_idx > ARRAYSIZE(g_shorts)) g_idx = 0;
+	return g_shorts[g_idx++];
+}
+
+- (unsigned short)ushortFunc
+{
+	if (g_idx > ARRAYSIZE(g_ushorts)) g_idx = 0;
+	return g_ushorts[g_idx++];
+}
+
+- (char)charFunc;
+{
+	if (g_idx > ARRAYSIZE(g_chars)) g_idx = 0;
+	return g_chars[g_idx++];
+}
+
+- (unsigned char)ucharFunc;
+{
+	if (g_idx > ARRAYSIZE(g_uchars)) g_idx = 0;
+	return g_uchars[g_idx++];
+}
+
+- (float)floatFunc;
+{
+	if (g_idx > ARRAYSIZE(g_floats)) g_idx = 0;
+	return g_floats[g_idx++];
+}
+
+- (double)doubleFunc;
+{
+	if (g_idx > ARRAYSIZE(g_doubles)) g_idx = 0;
+	return g_doubles[g_idx++];
+}
+
+- (struct dummy)dummyFunc
+{
+	struct dummy res;
+
+	res.f1 = -1;
+	res.f2 = +1;
+
+	return res;
+}
+
+- (struct dummy2)dummy2Func
+{
+	struct dummy2 res;
+
+	res.array[0]  = 1;
+	res.array[1]  = 2;
+	res.array[2]  = 3;
+	res.array[3]  = 4;
+
+	return res;
+}
+
+@end
+
+
+
+static PyMethodDef no_methods[] = {
+	{ 0, 0, 0, 0 }
+};
+
+
+/* Python glue */
+void inittestbndl(void)
+{
+	PyObject* m;
+
+	m = Py_InitModule4("testbndl", no_methods, 
+		NULL, NULL, PYTHON_API_VERSION);
+	if (!m) return;
+
+	if (ObjC_ImportModule(m) < 0) return;
+
+	PyModule_AddObject(m, "OC_TestClass1", 
+		ObjCClass_New([OC_TestClass1 class]));
+}

Modules/Cocoa/AppKit.prototypes

 # From: NSAppleScriptExtensions.h
 
 # From: NSApplication.h
-int NSApplicationMain(int argc, const char *argv[]);
 BOOL NSApplicationLoad(void);
 BOOL NSShowsServicesMenuItem(NSString * itemName);
 int NSSetShowsServicesMenuItem(NSString * itemName, BOOL enabled);
 void NSCopyBits(int srcGState, NSRect srcRect, NSPoint destPoint);
 void NSHighlightRect(NSRect aRect);
 void NSBeep(void);
-void NSCountWindows(int *count);
 void NSWindowList(int size, int list[]);
-void NSCountWindowsForContext(int context, int *count);
 void NSWindowListForContext(int context, int size, int list[]);
 int NSGetWindowServerMemory(int context, int *virtualMemory, int *windowBackingMemory, NSString **windowDumpString);
 NSRect NSDrawColorTiledRects(NSRect boundsRect, NSRect clipRect, const NSRectEdge *sides, NSColor **colors, int count);

Modules/Cocoa/Foundation.prototypes

 # From: NSEnumerator.h
 
 # From: NSException.h
-void _NSAddHandler2(NSHandler2 *handler);
-void _NSRemoveHandler2(NSHandler2 *handler);
-NSException *_NSExceptionObjectFromHandler2(NSHandler2 *handler);
 NSUncaughtExceptionHandler *NSGetUncaughtExceptionHandler(void);
 void NSSetUncaughtExceptionHandler(NSUncaughtExceptionHandler *);
 

Modules/Cocoa/_AppKit.m

 	return NULL;
 }
 
+
 static PyObject*
 objc_NSApp(PyObject* self, PyObject* args, PyObject* kwds)
 {
 }
 
 static PyObject*
+objc_NSAvailableWindowDepths(PyObject* self, PyObject* args, PyObject* kwds)
+{
+static  char* keywords[] = { NULL };
+	int       count;
+	const NSWindowDepth*	  depths;
+	PyObject *result, *tmp;
+
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, ":NSAvailableWindowDepts", keywords)) {
+		return NULL;
+	}
+
+	NS_DURING
+		depths = NSAvailableWindowDepths();
+	NS_HANDLER
+		ObjCErr_FromObjC(localException);
+	NS_ENDHANDLER
+	if (PyErr_Occurred()) return NULL;
+
+	result = PyList_New(0);
+	if (result == NULL) return NULL;
+
+	while (*depths != 0) {
+		PyObject* v = PyInt_FromLong(*depths);
+		if (v == NULL) {
+			Py_DECREF(result);
+			return NULL;
+		}
+
+		if (PyList_Append(result, v) == -1) {
+			Py_DECREF(result);
+			return NULL;
+		}
+
+		depths++;
+	}
+
+	tmp = PyList_AsTuple(result);
+	Py_XDECREF(result);
+	return tmp;
+}
+
+
+static PyObject*
 objc_NSRectFillList(PyObject* self, PyObject* args, PyObject* kwds)
 {
   unsigned char *rectBytes;
 		METH_VARARGS,
 		NULL
 	},
+	{
+	        "NSAvailableWindowDepths",
+		(PyCFunction)objc_NSAvailableWindowDepths,
+		METH_VARARGS,
+		NULL
+	},
 
 	METHOD_TABLE_ENTRIES
 

Modules/Cocoa/_App_Functions.inc

 static inline int convert_NSAffineTransformStruct(PyObject* object, void* pvar)
 {
-	const char* errstr;
+	int err;
 
-	errstr = ObjC_PythonToObjC(@encode(NSAffineTransformStruct), object, pvar);
-	if (errstr) {
-		PyErr_SetString(PyExc_TypeError, errstr);
+	err = ObjC_PythonToObjC(@encode(NSAffineTransformStruct), object, pvar);
+	if (err == -1) {
 		return 0;
 	}
 	return 1;
 }
 static inline int convert_NSRect(PyObject* object, void* pvar)
 {
-	const char* errstr;
+	int err;
 
-	errstr = ObjC_PythonToObjC(@encode(NSRect), object, pvar);
-	if (errstr) {
-		PyErr_SetString(PyExc_TypeError, errstr);
+	err = ObjC_PythonToObjC(@encode(NSRect), object, pvar);
+	if (err == -1) {
 		return 0;
 	}
 	return 1;
 }
 static inline int convert_NSPoint(PyObject* object, void* pvar)
 {
-	const char* errstr;
+	int err;
 
-	errstr = ObjC_PythonToObjC(@encode(NSPoint), object, pvar);
-	if (errstr) {
-		PyErr_SetString(PyExc_TypeError, errstr);
+	err = ObjC_PythonToObjC(@encode(NSPoint), object, pvar);
+	if (err == -1) {
 		return 0;
 	}
 	return 1;

Modules/Cocoa/_Fnd_Functions.inc

 static inline int convert_NSPoint(PyObject* object, void* pvar)
 {
-	const char* errstr;
+	int err;
 
-	errstr = ObjC_PythonToObjC(@encode(NSPoint), object, pvar);
-	if (errstr) {
-		PyErr_SetString(PyExc_TypeError, errstr);
+	err = ObjC_PythonToObjC(@encode(NSPoint), object, pvar);
+	if (err == -1) {
 		return 0;
 	}
 	return 1;
 }
 static inline int convert_NSSize(PyObject* object, void* pvar)
 {
-	const char* errstr;
+	int err;
 
-	errstr = ObjC_PythonToObjC(@encode(NSSize), object, pvar);
-	if (errstr) {
-		PyErr_SetString(PyExc_TypeError, errstr);
+	err = ObjC_PythonToObjC(@encode(NSSize), object, pvar);
+	if (err == -1) {
 		return 0;
 	}
 	return 1;
 }
 static inline int convert_NSRect(PyObject* object, void* pvar)
 {
-	const char* errstr;
+	int err;
 
-	errstr = ObjC_PythonToObjC(@encode(NSRect), object, pvar);
-	if (errstr) {
-		PyErr_SetString(PyExc_TypeError, errstr);
+	err = ObjC_PythonToObjC(@encode(NSRect), object, pvar);
+	if (err == -1) {
 		return 0;
 	}
 	return 1;
 }
 static inline int convert_NSRange(PyObject* object, void* pvar)
 {
-	const char* errstr;
+	int err;
 
-	errstr = ObjC_PythonToObjC(@encode(NSRange), object, pvar);
-	if (errstr) {
-		PyErr_SetString(PyExc_TypeError, errstr);
+	err = ObjC_PythonToObjC(@encode(NSRange), object, pvar);
+	if (err == -1) {
 		return 0;
 	}
 	return 1;

Modules/Cocoa/_FoundationMapping_NSCoder.m

 	PyObject* result;
 	void*     buf;
 	size_t    size;
-	const char* errstr;
+	int err;
 
 	if  (PyArg_ParseTuple(arguments, "sO", &signature, &value) < 0) {
 		return NULL;
 		return NULL;
 	}
 
-	errstr = ObjC_PythonToObjC(signature, value, buf);
-	if (errstr) {
-		printf("Cannot encode %s of %s into %p: %p '%s', %s\n",
-				PyString_AS_STRING(PyObject_Repr(value)),
-				signature, buf, errstr, errstr, ((PyObject*)errstr)->ob_type->tp_name);
-		PyErr_SetString(PyExc_ValueError, errstr);
+	err = ObjC_PythonToObjC(signature, value, buf);
+	if (err == -1) {
 		return NULL;
 	}
 
 	PyObject* result;
 	void*     buf;
 	size_t    size;
-	const char* errstr;
+	int err;
 	struct objc_super super;
 
 	if  (PyArg_ParseTuple(arguments, "sO", &signature, &value) < 0) {
 		return NULL;
 	}
 
-	errstr = ObjC_PythonToObjC(signature, value, buf);
-	if (errstr) {
-		PyErr_SetString(PyExc_ValueError, errstr);
+	err = ObjC_PythonToObjC(signature, value, buf);
+	if (err == -1) {
 		return NULL;
 	}
 
 	PyObject* result;
 	void*     buf;
 	size_t    size;
-	const char* errstr;
+	int err;
 
 	if  (PyArg_ParseTuple(arguments, "siO", &signature, &count, &value) < 0) {
 		return NULL;
 	}
 
 	for (i = 0; i < count; i++) {
-		errstr = ObjC_PythonToObjC(signature, 
+		err = ObjC_PythonToObjC(signature, 
 				PySequence_GetItem(value, i), 
 				((char*)buf) + (size * i));
-		if (errstr) {
-			PyErr_SetString(PyExc_ValueError, errstr);
+		if (err == -1) {
 			return NULL;
 		}
 	}
 	PyObject* result;
 	void*     buf;
 	size_t    size;
-	const char* errstr;
+	int err;
 	struct objc_super super;
 
 	if  (PyArg_ParseTuple(arguments, "siO", &signature, &count, &value) < 0) {
 	}
 
 	for (i = 0; i < count; i++) {
-		errstr = ObjC_PythonToObjC(signature, 
+		err = ObjC_PythonToObjC(signature, 
 				PySequence_GetItem(value, i), 
 				((char*)buf) + (size * i));
-		if (errstr) {
-			PyErr_SetString(PyExc_ValueError, errstr);
+		if (err == -1) {
 			return NULL;
 		}
 	}

Modules/Cocoa/_InterfaceBuilder.m

+/*
+ * Mapping of static items in the InterfaceBuilder framework
+ * 
+ * - constants 
+ * - enumerations
+ */
+#include <Python.h>
+
+#import <InterfaceBuilder/InterfaceBuilder.h>
+
+#include "pyobjc-api.h"
+#include "objc_support.h"
+#include "OC_PythonObject.h"
+#include "const-table.h"
+
+static PyMethodDef ib_methods[] = {
+	{ 0, 0, 0, 0 }
+};
+
+
+PyDoc_STRVAR(ib_doc,
+"Cocoa._AddressBook defines constants, types and global functions used by "
+"Cocoa.AddressBook."
+);
+
+
+#include "_InterfaceBuilder_Enum.inc"
+#include "_InterfaceBuilder_Str.inc"
+
+void init_InterfaceBuilder(void)
+{
+	PyObject *m, *d;
+
+	m = Py_InitModule4("_InterfaceBuilder", ib_methods, 
+		ib_doc, NULL, PYTHON_API_VERSION);
+	if (!m) return;
+
+	d = PyModule_GetDict(m);
+	if (!d) return;
+
+	if (ObjC_ImportModule(m) < 0) {
+		return;
+	}
+
+	if (register_ints(d, enum_table) < 0) return;
+	if (register_strings(d, string_table) < 0) return;
+}

Modules/Cocoa/_InterfaceBuilder_Enum.inc

+/*
+ * Enumeration constants. This file is generated from files in
+ * /System/Library/Frameworks/InterfaceBuilder.framework/Headers
+ */
+static struct inttable enum_table[] = {
+
+	/* From: IBApplicationAdditions.h */
+
+	/* From: IBCellAdditions.h */
+
+	/* From: IBCellProtocol.h */
+
+	/* From: IBConnectors.h */
+
+	/* From: IBDefines.h */
+	 { "IBNoKnobPosition", IBNoKnobPosition },
+	 { "IBBottomLeftKnobPosition", IBBottomLeftKnobPosition },
+	 { "IBMiddleLeftKnobPosition", IBMiddleLeftKnobPosition },
+	 { "IBTopLeftKnobPosition", IBTopLeftKnobPosition },
+	 { "IBTopMiddleKnobPosition", IBTopMiddleKnobPosition },
+	 { "IBTopRightKnobPosition", IBTopRightKnobPosition },
+	 { "IBMiddleRightKnobPosition", IBMiddleRightKnobPosition },
+	 { "IBBottomRightKnobPosition", IBBottomRightKnobPosition },
+	 { "IBBottomMiddleKnobPosition", IBBottomMiddleKnobPosition },
+
+	/* From: IBDocuments.h */
+
+	/* From: IBEditors.h */
+
+	/* From: IBInspector.h */
+
+	/* From: IBInspectorManager.h */
+
+	/* From: IBObjectAdditions.h */
+
+	/* From: IBObjectProtocol.h */
+
+	/* From: IBPalette.h */
+
+	/* From: IBProjectFiles.h */
+
+	/* From: IBProjects.h */
+
+	/* From: IBResourceManager.h */
+	 { "kNibResource", kNibResource },
+	 { "kProjectResource", kProjectResource },
+	 { "kPaletteResource", kPaletteResource },
+	 { "kSystemResource", kSystemResource },
+	 { "kUnknownResource", kUnknownResource },
+
+	/* From: IBSystem.h */
+
+	/* From: IBViewAdditions.h */
+
+	/* From: IBViewProtocol.h */
+
+	/* From: IBViewResourceDragging.h */
+
+	/* From: InterfaceBuilder.h */
+	{0, 0} /* Sentinel */
+};

Modules/Cocoa/_InterfaceBuilder_Str.inc

+/*
+ * String constants. This file is generated from files in
+ * /System/Library/Frameworks/InterfaceBuilder.framework/Headers
+ */
+static struct stringtable string_table[] = {
+
+	/* From: IBApplicationAdditions.h */
+	 { "IBWillBeginTestingInterfaceNotification", &IBWillBeginTestingInterfaceNotification },
+	 { "IBDidBeginTestingInterfaceNotification", &IBDidBeginTestingInterfaceNotification },
+	 { "IBWillEndTestingInterfaceNotification", &IBWillEndTestingInterfaceNotification },
+	 { "IBDidEndTestingInterfaceNotification", &IBDidEndTestingInterfaceNotification },
+
+	/* From: IBCellAdditions.h */
+
+	/* From: IBCellProtocol.h */
+
+	/* From: IBConnectors.h */
+	 { "IBWillAddConnectorNotification", &IBWillAddConnectorNotification },
+	 { "IBDidAddConnectorNotification", &IBDidAddConnectorNotification },
+	 { "IBWillRemoveConnectorNotification", &IBWillRemoveConnectorNotification },
+	 { "IBDidRemoveConnectorNotification", &IBDidRemoveConnectorNotification },
+
+	/* From: IBDefines.h */
+
+	/* From: IBDocuments.h */
+	 { "IBDidOpenDocumentNotification", &IBDidOpenDocumentNotification },
+	 { "IBWillSaveDocumentNotification", &IBWillSaveDocumentNotification },
+	 { "IBDidSaveDocumentNotification", &IBDidSaveDocumentNotification },
+	 { "IBWillCloseDocumentNotification", &IBWillCloseDocumentNotification },
+
+	/* From: IBEditors.h */
+	 { "IBSelectionChangedNotification", &IBSelectionChangedNotification },
+	 { "IBAttributesChangedNotification", &IBAttributesChangedNotification },
+
+	/* From: IBInspector.h */
+
+	/* From: IBInspectorManager.h */
+	 { "IBWillInspectWithModeNotification", &IBWillInspectWithModeNotification },
+	 { "IBWillInspectObjectNotification", &IBWillInspectObjectNotification },
+	 { "IBInspectAttributesMode", &IBInspectAttributesMode },
+	 { "IBInspectConnectionsMode", &IBInspectConnectionsMode },
+
+	/* From: IBObjectAdditions.h */
+
+	/* From: IBObjectProtocol.h */
+
+	/* From: IBPalette.h */
+	 { "IBCellPboardType", &IBCellPboardType },
+	 { "IBFormatterPboardType", &IBFormatterPboardType },
+	 { "IBMenuItemPboardType", &IBMenuItemPboardType },
+	 { "IBMenuPboardType", &IBMenuPboardType },
+	 { "IBObjectPboardType", &IBObjectPboardType },
+	 { "IBTableColumnPboardType", &IBTableColumnPboardType },
+	 { "IBTabViewItemPboardType", &IBTabViewItemPboardType },
+	 { "IBViewPboardType", &IBViewPboardType },
+	 { "IBWindowPboardType", &IBWindowPboardType },
+	 { "IBScriptControllerPboardType", &IBScriptControllerPboardType },
+
+	/* From: IBProjectFiles.h */
+
+	/* From: IBProjects.h */
+	 { "IBProjectSourcesFileType", &IBProjectSourcesFileType },
+	 { "IBProjectHeadersFileType", &IBProjectHeadersFileType },
+	 { "IBProjectInterfacesFileType", &IBProjectInterfacesFileType },
+	 { "IBProjectResourcesFileType", &IBProjectResourcesFileType },
+	 { "IBProjectSubprojectsFileType", &IBProjectSubprojectsFileType },
+	 { "IBProjectContextHelpFilesFileType", &IBProjectContextHelpFilesFileType },
+	 { "IBProjectDocumentationFilesFileType", &IBProjectDocumentationFilesFileType },
+	 { "IBProjectLibrariesFileType", &IBProjectLibrariesFileType },
+	 { "IBProjectFrameworksFileType", &IBProjectFrameworksFileType },
+	 { "IBProjectSupportingFilesFileType", &IBProjectSupportingFilesFileType },
+	 { "IBProjectZombieProjectReanimated", &IBProjectZombieProjectReanimated },
+	 { "IBProjectLiveProjectMadeZombie", &IBProjectLiveProjectMadeZombie },
+
+	/* From: IBResourceManager.h */
+	 { "IBResourceManagerRegistryDidChangeNotification", &IBResourceManagerRegistryDidChangeNotification },
+
+	/* From: IBSystem.h */
+
+	/* From: IBViewAdditions.h */
+
+	/* From: IBViewProtocol.h */
+
+	/* From: IBViewResourceDragging.h */
+	 { "IBViewResourceDraggingDelegatesRegistryDidChangeNotification", &IBViewResourceDraggingDelegatesRegistryDidChangeNotification },
+
+	/* From: InterfaceBuilder.h */
+	{0, 0} /* Sentinel */
+};

Modules/Cocoa/_PrefPanes.m

+/*
+ * Mapping of static items in the PreferencePanes framework
+ * 
+ * - constants 
+ * - enumerations
+ */
+#include <Python.h>
+
+#import <PreferencePanes/PreferencePanes.h>
+
+#include "pyobjc-api.h"
+#include "objc_support.h"
+#include "OC_PythonObject.h"
+#include "const-table.h"
+
+static PyMethodDef prefpanes_methods[] = {
+	{ 0, 0, 0, 0 }
+};
+
+
+PyDoc_STRVAR(prefpanes_doc,
+"Cocoa._AddressBook defines constants, types and global functions used by "
+"Cocoa.AddressBook."
+);
+
+
+#include "_PrefPanes_Enum.inc"
+#include "_PrefPanes_Str.inc"
+
+void init_PreferencePanes(void)
+{
+	PyObject *m, *d;
+
+	m = Py_InitModule4("_PreferencePanes", prefpanes_methods, 
+		prefpanes_doc, NULL, PYTHON_API_VERSION);
+	if (!m) return;
+
+	d = PyModule_GetDict(m);
+	if (!d) return;
+
+	if (ObjC_ImportModule(m) < 0) {
+		return;
+	}
+
+	if (register_ints(d, enum_table) < 0) return;
+	if (register_strings(d, string_table) < 0) return;
+}

Modules/Cocoa/_PrefPanes_Enum.inc

+/*
+ * Enumeration constants. This file is generated from files in
+ * /System/Library/Frameworks/PreferencePanes.framework/Headers
+ */
+static struct inttable enum_table[] = {
+
+	/* From: NSPreferencePane.h */
+	 { "NSUnselectCancel", NSUnselectCancel },
+	 { "NSUnselectNow", NSUnselectNow },
+	 { "NSUnselectLater", NSUnselectLater },
+
+	/* From: PreferencePanes.h */
+	{0, 0} /* Sentinel */
+};

Modules/Cocoa/_PrefPanes_Str.inc

+/*
+ * String constants. This file is generated from files in
+ * /System/Library/Frameworks/PreferencePanes.framework/Headers
+ */
+static struct stringtable string_table[] = {
+
+	/* From: NSPreferencePane.h */
+	 { "NSPreferencePaneDoUnselectNotification", &NSPreferencePaneDoUnselectNotification },
+	 { "NSPreferencePaneCancelUnselectNotification", &NSPreferencePaneCancelUnselectNotification },
+
+	/* From: PreferencePanes.h */
+	{0, 0} /* Sentinel */
+};

Modules/Cocoa/scripts/cocoa_generator.py

 FOUNDATION=os.path.join(FRAMEWORKS, "Foundation.framework")
 APPKIT=os.path.join(FRAMEWORKS, "AppKit.framework")
 ADDRESSBOOK=os.path.join(FRAMEWORKS, "AddressBook.framework")
+PREFPANES=os.path.join(FRAMEWORKS, "PreferencePanes.framework")
+IB=os.path.join(FRAMEWORKS, "InterfaceBuilder.framework")
 FOUNDATION_HDRS=os.path.join(FOUNDATION, 'Headers')
 APPKIT_HDRS=os.path.join(APPKIT, 'Headers')
 ADDRESSBOOK_HDRS=os.path.join(ADDRESSBOOK, 'Headers')
+PREFPANES_HDRS=os.path.join(PREFPANES, 'Headers')
+IB_HDRS=os.path.join(IB, 'Headers')
 
 enum_generator.generate(FOUNDATION_HDRS, '_Fnd_Enum.inc')
 enum_generator.generate(APPKIT_HDRS, '_App_Enum.inc')
 enum_generator.generate(ADDRESSBOOK_HDRS, '_Addr_Enum.inc')
+enum_generator.generate(PREFPANES_HDRS, '_PrefPanes_Enum.inc')
+enum_generator.generate(IB_HDRS, '_InterfaceBuilder_Enum.inc')
 
 strconst_generator.generate(FOUNDATION_HDRS, '_Fnd_Str.inc')
 strconst_generator.generate(APPKIT_HDRS, '_App_Str.inc')
 strconst_generator.generate(ADDRESSBOOK_HDRS, '_Addr_Str.inc')
+strconst_generator.generate(PREFPANES_HDRS, '_PrefPanes_Str.inc')
+strconst_generator.generate(IB_HDRS, '_InterfaceBuilder_Str.inc')
 
 FOUNDATION_PREFIX="FOUNDATION_EXPORT"
 FOUNDATION_IGNORE_LIST=(
 	'_NSRemoveHandler2',
 	'_NSExceptionObjectFromHandler2'
 
+        # List of functions that are not usefull from Python:
+
         # List of manually wrapped functions:
 )
 APPKIT_IGNORE_LIST=(
 
         # List of manually wrapped functions:
-        'NSApplicationMain',
+        'NSApplicationMain(',
+        'NSCountWindows(',
+        'NSCountWindowsForContext(',
+        'NSAvailableWindowDepths(',
+        'NSRectFillList(',
 )
 func_collector.generate(FOUNDATION_HDRS, 'Foundation.prototypes', 
 	FOUNDATION_PREFIX, FOUNDATION_IGNORE_LIST)
 	fd.write('''\
 static inline int convert_%(type)s(PyObject* object, void* pvar)
 {
-	const char* errstr;
+	int err;
 
-	errstr = ObjC_PythonToObjC(@encode(%(type)s), object, pvar);
-	if (errstr) {
-		PyErr_SetString(PyExc_TypeError, errstr);
+	err = ObjC_PythonToObjC(@encode(%(type)s), object, pvar);
+	if (err == -1) {
 		return 0;
 	}
 	return 1;
 	fd.write('''\
 static inline int convert_%(type)s(PyObject* object, void* pvar)
 {
-	const char* errstr;
+	int err;
 
-	errstr = ObjC_PythonToObjC(@encode(%(type)s), object, pvar);
-	if (errstr) {
-		PyErr_SetString(PyExc_TypeError, errstr);
+	err = ObjC_PythonToObjC(@encode(%(type)s), object, pvar);
+	if (err == -1) {
 		return 0;
 	}
 	return 1;

Modules/Cocoa/scripts/func_collector.py

 		m = MATCH_RE.match(ln)
 		if not m: continue
 
-		outfp.write('%s\n'%m.group(1).strip())
+                prototype=m.group(1).strip()
+
+                ign = 0
+                for i in ignore_list:
+                    if i in prototype:
+                        ign=1
+                        break
+
+                if not ign:
+                    outfp.write('%s\n'%prototype)
 
 def generate(dirname, fn = None, match_prefix='', ignore_list=()):
 	if fn:
 #!/usr/bin/env python
 
+# If true we use libffi instead of register.m
 USE_FFI = 1
 
+# It true we use libffi for normal invocations, instead of NSInvocation
 USE_FFI_SHORTCUTS = 1
+
+# If true we adjust the reference count for copy/alloc, otherwise users
+# have to do that manually. (Experimental)
+USE_ADJUST_REFCOUNTS = 1
+
 import sys
+import os
 
-if sys.platform == 'darwin':
+if sys.platform == 'darwin': 
     # Apple has used build options that don't work with a 'normal' system.
     # Remove '-arch i386' from the LDFLAGS.
     import distutils.sysconfig
         "Modules/objc/selector.m",
         "Modules/objc/method-accessor.m",
         "Modules/objc/instance-var.m",
-        "Modules/objc/OC_PythonInt.m",
         "Modules/objc/OC_PythonObject.m",
-        "Modules/objc/OC_PythonString.m",
         "Modules/objc/OC_PythonArray.m",
         "Modules/objc/OC_PythonDictionary.m",
         "Modules/objc/register.m",
 
     OBJC_LDFLAGS=[
         '-framework', 'Foundation',
+        "-preload",
         ]
 
     FND_LDFLAGS=[
         '-framework', 'Foundation',
+        "-preload",
         ]
 
     APPKIT_LDFLAGS=[
-        '-framework', 'AppKit'
+        '-framework', 'AppKit',
+        "-preload",
         ]
 
     FNDMAP_LDFLAGS=[
         '-framework', 'Foundation',
+        "-preload",
         ]
 
     APPMAP_LDFLAGS=[
-        '-framework', 'AppKit'
+        '-framework', 'AppKit',
+        "-preload",
         ]
 
     ADDRESSBOOK_LDFLAGS=[
-        '-framework', 'AddressBook', '-framework', 'Foundation'
+        '-framework', 'AddressBook', '-framework', 'Foundation',
+        "-preload",
+    ]
+
+    PREFPANES_LDFLAGS=[
+        '-framework', 'PreferencePanes', '-framework', 'Foundation',
+        "-preload",
     ]
 
 else:
         ]
 
     ADDRESSBOOK_LDFLAGS=[]
+    PREFPANES_LDFLAGS=[]
+
+if USE_ADJUST_REFCOUNTS:
+    CFLAGS.append('-DOC_ADJUST_REFCOUNTS')
 
 def IfFrameWork(name, packages, extensions):
     """
                     "-DOBJC_PARANOIA_MODE",
               ] + LIBFFI_CFLAGS + CFLAGS,
               extra_link_args=LIBFFI_LDFLAGS + OBJC_LDFLAGS),
+    Extension("objc.test.testbndl",
+              ["Lib/objc/test/testbndl.m"],
+              extra_compile_args=["-IModules/objc" ] + CFLAGS,
+              extra_link_args=OBJC_LDFLAGS),
     Extension("autoGIL", 
               ["Modules/autoGIL.c"],
               extra_compile_args = CFLAGS,
                       ] + ADDRESSBOOK_LDFLAGS),
         ])
 
+PrefPanesPackages, PrefPanesExtensions = \
+        IfFrameWork('PreferencePanes.framework', [ 'PreferencePanes' ], [
+            Extension('PreferencePanes._PreferencePanes',
+                      [ 'Modules/Cocoa/_PrefPanes.m' ],
+                      extra_compile_args=[
+                        '-IModules/objc',
+                      ] + CFLAGS,
+                      extra_link_args=[
+                      ] + PREFPANES_LDFLAGS),
+        ])
+
+InterfaceBuilderPackages, InterfaceBuilderExtensions = \
+        IfFrameWork('InterfaceBuilder.framework', [ 'InterfaceBuilder' ], [
+            Extension('InterfaceBuilder._InterfaceBuilder',
+                      [ 'Modules/Cocoa/_InterfaceBuilder.m' ],
+                      extra_compile_args=[
+                        '-IModules/objc',
+                      ] + CFLAGS,
+                      extra_link_args=[
+                        '-framework', 'InterfaceBuilder', 
+                        '-framework', 'Foundation'
+                      ]),
+        ])
+
 
 def package_version():
     fp = open('Modules/objc/pyobjc.h', 'r')
     raise ValueError, "Version not found"
 
 
-packages = CorePackages + CocoaPackages + AddressBookPackages
+packages = CorePackages + CocoaPackages + AddressBookPackages + PrefPanesPackages + InterfaceBuilderPackages
 # The following line is needed to allow separate flat modules
 # to be installed from a different folder (needed for the 
 # bundlebuilder test below).
 			     CoreExtensions 
 			   + CocoaExtensions 
 			   + AddressBookExtensions 
+                           + PrefPanesExtensions
+                           + InterfaceBuilderExtensions
 			   ),
 	     packages = packages,
 	     package_dir = package_dir,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.