protected static string MapType(ObjectModel objects, string type) { type = objects.MapType(type); // note that this is word to word with no spaces in the words switch (type) { case "BOOL": case "Boolean": return "bool"; case "unsigned char": case "uint8_t": return "byte"; case "unichar": return "char"; case "CFTimeInterval": case "double": return "double"; case "CGFloat": case "float": return "float"; case "AEReturnID": case "AESendPriority": case "OSErr": case "short": return "Int16"; case "AESendMode": case "AETransactionID": case "GLint": case "GLsizei": case "int": case "int32_t": case "long": case "NSComparisonResult": case "NSInteger": case "OSStatus": case "pid_t": case "ptrdiff_t": // TODO: some of these types are not 64-bit safe (but mono isn't either...) case "SInt32": case "SRefCon": return "Int32"; case "int64_t": case "long long": return "Int64"; case "CFAllocatorRef": case "CFArrayRef": case "CFAttributedStringRef": case "CFBagRef": case "CFBinaryHeapRef": case "CFBitVectorRef": case "CFBooleanRef": case "CFBundleRef": case "CFCalendarRef": case "CFCharacterSetRef": case "CFDataRef": case "CFDateFormatterRef": case "CFDateRef": case "CFDictionaryRef": case "CFErrorRef": case "CFFileDescriptorRef": case "CFLocaleRef": case "CFMachPortRef": case "CFMessagePortRef": case "CFMutableAttributedStringRef": case "CFMutableBagRef": case "CFMutableBitVectorRef": case "CFMutableCharacterSetRef": case "CFMutableDataRef": case "CFMutableDictionaryRef": case "CFMutableSetRef": case "CFNotificationCenterRef": case "CFNumberFormatterRef": case "CFNumberRef": case "CFPlugInRef": case "CFReadStreamRef": case "CFRunLoopObserverRef": case "CFRunLoopRef": case "CFRunLoopSourceRef": case "CFRunLoopTimerRef": case "CFSetRef": case "CFSocketRef": case "CFStringTokenizerRef": case "CFTreeRef": case "CFURLRef": case "CFUserNotificationRef": case "CFWriteStreamRef": case "CFXMLNodeRef": case "CFXMLParserRef": case "CFXMLTreeRef": case "CGColorRef": case "CGColorSpaceRef": case "CGContextRef": case "CGEventRef": case "CGImageRef": case "CGLayerRef": case "CGLContextObj": case "CGLPBufferObj": case "CGLPixelFormatObj": case "CGLRendererInfoObj": case "CVBufferRef": case "CVImageBufferRef": case "char *": case "const NSGlyph *": case "const void *": case "id *": case "IconRef": case "NSAppleEventManagerSuspensionID": case "NSComparator": case "NSDistantObject *": case "NSGlyph *": case "NSModalSession": case "NSPointArray": case "NSPointPointer": case "NSRangePointer": case "NSRectArray": case "NSRectPointer": case "NSSizeArray": case "NSZone *": case "unichar *": case "va_list": case "void *": return "IntPtr"; case "CIColor *": case "CIImage *": case "id": case "NSEntityDescription *": case "NSFetchRequest *": case "NSManagedObjectContext *": return "NSObject"; case "CGPoint": return "NSPoint"; case "CGRect": return "NSRect"; case "CGSize": return "NSSize"; case "AEArrayType": case "signed char": return "sbyte"; case "SEL": return "Selector"; case "const char *": case "const unichar *": return "string"; case "uint16_t": case "unsigned short": return "UInt16"; case "AEEventClass": case "AEEventID": case "AEKeyword": case "DescType": case "FourCharCode": case "GLbitfield": case "GLenum": case "NSAttributeType": case "NSGlyph": case "NSUInteger": case "NSSortOptions": case "OSType": case "ResType": case "size_t": case "uint32_t": case "unsigned": case "unsigned int": case "UTF32Char": return "UInt32"; case "CFIndex": case "CFOptionFlags": case "CFTypeID": case "LSLaunchFlags": case "OptionBits": case "unsigned long": case "unsigned long long": case "uint64_t": return "UInt64"; default: if (type.StartsWith("const ")) type = type.Substring("const ".Length, type.Length - "const ".Length).Trim(); if (type.EndsWith("**") || type.StartsWith("inout ") || type.Contains("[")) { return "IntPtr"; } else if (type.Contains("<") && type.Contains(">")) { return "NSObject"; // TODO: should probably add interfaces for protocols } else if (type.EndsWith("*")) { type = type.Substring(0, type.Length - 1).Trim(); type = objects.MapType(type); if (objects.KnownType(type)) { return type; } else { return "IntPtr"; } } else { type = objects.MapType(type); return type; } } }