Beispiel #1
0
        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;
                    }
            }
        }
Beispiel #2
0
        private static string DoMapArgType(ObjectModel objects, string inType)
        {
            string type = objects.MapType(inType);				// note that this is word to word with no spaces in the words

            switch (type)
            {
                case "BOOL *":
                case "Boolean *":
                    return "out bool";

                case "unsigned char *":
                case "uint8_t *":
                    return "out byte";

                case "unichar *":
                    return "out char";

                case "double *":
                    return "out double";

                case "CGFloat *":
                case "float *":
                    return "out float";

                case "short *":
                    return "out Int16";

                case "GLint *":
                case "GLsizei *":
                case "int *":
                case "int32_t *":
                case "long *":
                case "NSInteger *":
                case "SInt32 *":
                    return "out Int32";

                case "int64_t *":
                case "long long *":
                    return "out Int64";

                case "NSRange *":
                case "NSRangePointer":
                    return "out NSRange";

                case "NSError **":
                    return "out NSError";

                case "NSString **":
                    return "out NSString";

                case "NSStringEncoding *":
                    return "out UInt32";

                case "signed char *":
                    return "out sbyte";

                case "uint16_t *":
                case "unsigned short *":
                    return "out UInt16";

                case "uint32_t *":
                case "unsigned *":
                case "unsigned int *":
                case "UTF32Char *":
                    return "out UInt32";

                case "unsigned long *":
                case "unsigned long long *":
                    return "out UInt64";

                case "SEL":
                    return "string";

                default:
                    return MapType(objects, inType);
            }
        }