Ronald Oussoren avatar Ronald Oussoren committed e6b8996

- Don't disable the wrapper for initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel: in _AppKitMapping_NSBitmapImageRep.m
- Remove unused variable in OC_PythonObject.m
- Add support for type bool in objc_support.[hm].

Comments (0)

Files changed (4)

pyobjc/Modules/AppKit/_AppKitMapping_NSBitmapImageRep.m

 		return -1;
 	}
 
+#if 0
 	if (PyObjC_RegisterMethodMapping(class_NSBitmapImageRep, 
 		@selector(initWithBitmapDataPlanes:pixelsWide:pixelsHigh:bitsPerSample:samplesPerPixel:hasAlpha:isPlanar:colorSpaceName:bytesPerRow:bitsPerPixel:),
 		PyObjCUnsupportedMethod_Caller,
 
 		return -1;
 	}
+#endif
 
 	return 0;
 }

pyobjc/Modules/objc/OC_PythonObject.m

 	PyObject* keyName;
 	PyObject* pyValue;
 	PyObject* val;
-	id res;
 
 	if (setKeyFunc == NULL) {
 		PyObject* name;

pyobjc/Modules/objc/objc_support.h

 #define _C_ONEWAY   'V'
 #define _C_LNGLNG   'q'
 #define _C_ULNGLNG   'Q'
+#define _C_BOOL	'B'		/* (Objective-)C++ 'bool' */
 
 
 /* Return a number that is likely to change when the method list changes,

pyobjc/Modules/objc/objc_support.m

 	       *type == _C_ONEWAY) {
 			type++;
 	}
+	while (isdigit(*type)) type++;
 	return type;
 }
 
 	type = PyObjCRT_SkipTypeQualifiers (type);
 
 	switch (*type) {
-	case 'B':	
-		/* This turned up on Panther, without documentation */
-		NSLog(@"Parsing typespec containing unsupported code 'B'");
-		type++;
-		break;
-
 	/* The following are one character type codes */
 	case _C_UNDEF:
 	case _C_ID:
 #ifdef _C_ATOM
 	case _C_ATOM:
 #endif
+#ifdef _C_BOOL
+	case _C_BOOL:
+#endif
 	case _C_SHT:
 	case _C_USHT:
 	case _C_INT:
 	default:
 		ObjCErr_Set(ObjCExc_internal_error,
 			"PyObjCRT_SkipTypeSpec: Unhandled type '%#x'", *type); 
+		abort();
 		return NULL;
 	}
 
 	case _C_UCHR:  return __alignof__ (unsigned char);
 	case _C_SHT:   return __alignof__ (short);
 	case _C_USHT:  return __alignof__ (unsigned short);
+#ifdef _C_BOOL
+	case _C_BOOL:   return __alignof__ (bool);
+#endif
 	case _C_INT:   return __alignof__ (int);
 	case _C_UINT:  return __alignof__ (unsigned int);
 	case _C_LNG:   return __alignof__ (long);
       
 	case _C_STRUCT_B:
 	{
-		/* The align of a struct is the largest alignment of one of 
-		 * its members
+		/* The alignment of a struct is the alignment of it's first
+		 * member
 		 */
 		struct { int x; double y; } fooalign;
 		while(*type != _C_STRUCT_E && *type++ != '=') /* do nothing */;
 		if (*type != _C_STRUCT_E) {
-			int    item_align;
-			int    maxalign = 0;
-			while (*type != _C_STRUCT_E) {
-				item_align = objc_alignof_type(type);
-				if (item_align == -1) return -1;
-				type = PyObjCRT_SkipTypeSpec(type);
-				maxalign = MAX(item_align, maxalign);
-			}
-			return maxalign;
+			return objc_alignof_type(type);
 		} else {
 			return __alignof__ (fooalign);
 		}
 	case _C_UCHR:    return sizeof(unsigned char);
 	case _C_SHT:     return sizeof(short);
 	case _C_USHT:    return sizeof(unsigned short);
+#ifdef _C_BOOL
+	case _C_BOOL:    return sizeof(bool);
+#endif
 	case _C_INT:     return sizeof(int);
 	case _C_UINT:    return sizeof(unsigned int);
 	case _C_LNG:     return sizeof(long);
 		break;
 	}
 
+#ifdef _C_BOOL
+	case _C_BOOL:
+		retobject = (PyObject *) PyInt_FromLong (*(bool*) datum);
+		break;
+#endif
+
 	case _C_INT:
 		retobject = (PyObject *) PyInt_FromLong (*(int*) datum);
 		break;
 		}
 		return r;
 
+#ifdef _C_BOOL:
+	case _C_BOOL:
+		*(bool*)datum = PyObject_IsTrue(argument);
+		return 0;
+#endif
+
 	case _C_INT:
 		r = depythonify_signed_int_value(argument, "int",
 			&temp, INT_MIN, INT_MAX);
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.