Esempio n. 1
0
        public static void ReturnTypeHelper(CXType resultType, TextWriter tw)
        {
            switch (resultType.kind)
            {
            case CXTypeKind.CXType_Pointer:
                tw.Write(resultType.IsPtrToConstChar() ? "string" : "IntPtr");     // const char* gets special treatment
                break;

            default:
                CommonTypeHandling(resultType, tw);
                break;
            }
        }
Esempio n. 2
0
        public static void WriteReturnType(CXType resultType, TextWriter tw)
        {
            switch (resultType.kind)
            {
            case CXTypeKind.CXType_Pointer:
                // const char* gets special treatment
                var typeString = resultType.IsPtrToConstChar() ? @"string" : resultType.ToPlainTypeString();
                tw.Write(typeString);
                break;

            default:
                WriteCommonType(resultType, tw);
                break;
            }
        }
Esempio n. 3
0
        public static Type ToPlainType(this CXType type)
        {
            switch (type.kind)
            {
            case CXTypeKind.CXType_Pointer:
                return(type.IsPtrToConstChar() ? typeof(string) : typeof(IntPtr));    // const char* gets special treatment

            case CXTypeKind.CXType_Bool:
                return(typeof(bool));

            case CXTypeKind.CXType_UChar:
            case CXTypeKind.CXType_Char_U:
                return(typeof(byte));

            case CXTypeKind.CXType_SChar:
            case CXTypeKind.CXType_Char_S:
                return(typeof(sbyte));

            case CXTypeKind.CXType_UShort:
                return(typeof(ushort));

            case CXTypeKind.CXType_Short:
                return(typeof(short));

            case CXTypeKind.CXType_Float:
                return(typeof(float));

            case CXTypeKind.CXType_Double:
                return(typeof(double));

            case CXTypeKind.CXType_Int:
                return(typeof(int));

            case CXTypeKind.CXType_UInt:
                return(typeof(uint));

            case CXTypeKind.CXType_NullPtr:     // ugh, what else can I do?
                return(typeof(IntPtr));

            case CXTypeKind.CXType_Long:
                return(typeof(int));

            case CXTypeKind.CXType_ULong:
                return(typeof(int));

            case CXTypeKind.CXType_LongLong:
                return(typeof(long));

            case CXTypeKind.CXType_ULongLong:
                return(typeof(ulong));

            case CXTypeKind.CXType_Void:
                return(typeof(void));

            //case CXTypeKind.CXType_IncompleteArray: //TODO: Fix incompleteArray
            //    return TypeTranslate(clang.getArrayElementType(type)) + "[]";
            case CXTypeKind.CXType_Unexposed:
                var canonical = clang.getCanonicalType(type);
                if (canonical.kind == CXTypeKind.CXType_Unexposed)
                {
                    Console.WriteLine("ToType Unexposed:" + canonical);
                    return(typeof(IntPtr));
                }
                return(canonical.ToPlainType());

            default:
                return(typeof(IntPtr));
            }
        }