Commits

Ronald Oussoren committed e9d51c9

This seems to fix the intel problems for me.

Be warned though that the changes to ffi_darwin.c are a crude hack at best.
The real problem is that darwin.S (in the same directory as ffi_darwin.c)
doesn't ensure that the stack aligned properly (16-byte alignment is required
by the ABI).

  • Participants
  • Parent commits 9e00379
  • Branches pyobjc-ancient

Comments (0)

Files changed (7)

Lib/AppKit/_AppKitSignatures.py

 setSignatureForSelector("NSPSMatrix", "transform:", "@@:N^{_NSPoint=ff}")
 setSignatureForSelector("NSButton", "getPeriodicDelay:interval:", "v@:o^fo^f")
 #setSignatureForSelector("NSView", "addToolTipRect:owner:userData:", "i28@4:8{_NSRect={_NSPoint=ff}{_NSSize=ff}}12@28i32")
-#setSignatureForSelector("NSView", "addTrackingRect:owner:userData:assumeInside:", "i@:{_NSRect={_NSPoint=ff}{_NSSize=ff}}@ic")
+setSignatureForSelector("NSView", "addTrackingRect:owner:userData:assumeInside:", "i@:{_NSRect={_NSPoint=ff}{_NSSize=ff}}@ic")
 #setSignatureForSelector("NSAlert", "didEndSheet:returnCode:contextInfo:", "v16@4:8@12i16i20")
 #setSignatureForSelector("NSSavePanel", "_runModalForDirectory:file:relativeToWindow:modalDelegate:didEndSelector:contextInfo:", "v28@4:8@12@16@20@24:28i32")
 #setSignatureForSelector("NSSavePanel", "beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:", "v28@4:8@12@16@20@24:28i32")

Lib/AppKit/test/test_nsimage.py

 import AppKit
 
 class TestNSImage (unittest.TestCase):
-    def test_getTIFFCompressionTypes(self):
+    def test_compositePoint(self):
         # comes straight from ReSTedit.  Works on PPC, not on Intel (as of r1791)
         ws = AppKit.NSWorkspace.sharedWorkspace()
         txtIcon = ws.iconForFileType_("txt")
         htmlIcon = ws.iconForFileType_("html")
         htmlIcon.setSize_( (16,16) )
         
-        comboIcon = AppKit.NSImage.alloc().initWithSize_( (16,16) )
+        comboIcon = AppKit.NSImage.alloc().initWithSize_( (100,100) )
         comboIcon.lockFocus()
-        txtIcon.compositeToPoint_fromRect_operation_((0,0), ((0,0),(8,16)), AppKit.NSCompositeCopy)
+        txtIcon.compositeToPoint_fromRect_operation_((0,0), ((0,0),(16,16)), AppKit.NSCompositeCopy)
         htmlIcon.compositeToPoint_fromRect_operation_((8,0), ((8,0),(8,16)), AppKit.NSCompositeCopy)
         comboIcon.unlockFocus()
 

Lib/objc/test/test_regr.py

         self.assertRaises(TypeError, SelfIsNone.f, None)
 
 
+    def testStructArgs (self):
+        # Like AppKit.test.test_nsimage.TestNSImage.test_compositePoint
+        # unlike that this one doesn't crash on darwin/x86, makeing it less
+        # likely that libffi is at fault
+        from objc.test.structargs import StructArgClass
+
+        o = StructArgClass.alloc().init()
+        v = o.compP_aRect_anOp_((1,2), ((3,4),(5,6)), 7)
+        self.assertEquals(v, u"aP:{1, 2} aR:{{3, 4}, {5, 6}} anO:7")
+
 if __name__ == '__main__':
     unittest.main()

Modules/objc/libffi_support.m

  * Linux/GNUstep we need a slightly different function.
  */
 #ifdef MACOSX
+
+#ifdef __ppc__
 #define arg_signature_to_ffi_type signature_to_ffi_type
 
 #else
+static inline ffi_type*
+arg_signature_to_ffi_type(const char* argtype)
+{
+	/* NOTE: This is the minimal change to pass the unittests, it is not
+	 * based on analysis of the calling conventions.
+	 */
+	switch (*argtype) {
+	case _C_CHR: return &ffi_type_sint;
+	case _C_UCHR: return &ffi_type_uint;
+	case _C_SHT: return &ffi_type_sint;
+	case _C_USHT: return &ffi_type_uint;
+	default: return signature_to_ffi_type(argtype);
+	}
+}
+#endif
+
+#else
 
 static inline ffi_type*
 arg_signature_to_ffi_type(const char* argtype)

Modules/objc/test/structargs.m

+/*
+ */
+#include "Python.h"
+#include "pyobjc-api.h"
+
+#import <Cocoa/Cocoa.h>
+
+@interface StructArgClass : NSObject 
+{
+}
+-(NSString*)compP:(NSPoint)aPoint aRect:(NSRect)aRect anOp:(int)op;
+-(unsigned)stackPtr;
+@end
+
+@implementation StructArgClass
+-(NSString*)compP:(NSPoint)aPoint aRect:(NSRect)aRect anOp:(int)op
+{
+	return [NSString stringWithFormat:@"aP:%@ aR:%@ %anO:%d",
+			NSStringFromPoint(aPoint),
+			NSStringFromRect(aRect),
+			op];
+}
+-(unsigned)stackPtr
+{
+	char c;
+
+	return (&c)+1;
+}
+@end
+
+static PyMethodDef NULL_methods[] = {
+	                { 0, 0, 0, 0 }
+};
+
+void initstructargs(void);
+void initstructargs(void)
+{
+	PyObject* m;
+
+	m = Py_InitModule4("structargs", NULL_methods,
+		NULL, NULL, PYTHON_API_VERSION);
+
+	if (PyObjC_ImportAPI(m) < 0) return;
+
+	PyModule_AddObject(m, "StructArgClass",
+		PyObjCClass_New([StructArgClass class]));
+}
+
+
+

libffi-src/src/x86/ffi_darwin.c

     {
     case FFI_SYSV:
       /*@-usedef@*/
-      ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, 
+      /* FIXME: we should pass in cif->bytes, the actual code below seems to
+       * work for correctly aligning the stack, but is something that should
+       * be done in the assembly code.
+       */
+      ffi_call_SYSV(ffi_prep_args, &ecif, ALIGN(cif->bytes, 16)+8, 
 		    flags, ecif.rvalue, fn);
       /*@=usedef@*/
       break;

libffi-src/testsuite/lib/libffi-dg.exp

     global libffi_link_flags
     global tool_root_dir
 
-    set blddirffi [lookfor_file [get_multilibs] libffi]
+    #set blddirffi [lookfor_file [get_multilibs] libffi]
+    set blddirffi "/Users/ronald/Projects/pyobjc-trunk/pyobjc/libffi-src/build"
     verbose "libffi $blddirffi"
     set blddircxx [lookfor_file [get_multilibs] libstdc++-v3]
     verbose "libstdc++ $blddircxx"