Beispiel #1
0
        public override TypePrinterResult VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals)
        {
            // Mapping Enums to Number type
            if (type.Description.StartsWith("E"))
            {
                return(NodeV8IsNumber);
            }
            if (type.Description.EndsWith("Enums"))
            {
                return(NodeV8IsNumber);
            }

            // Search for known objects
            if (Context.ASTContext.TranslationUnits.GetGenerated().ToList().Exists(u => NamingHelper.GenerateTrimmedClassName(u.FileNameWithoutExtension).ToLower().Equals(NamingHelper.GenerateTrimmedClassName(type.Description).ToLower())))
            {
                return(NodeV8IsObject);
            }

            // Mapping special Windows types
            if (type.Description.StartsWith("wchar_t"))
            {
                return(NodeV8IsString);
            }

            // Map other unknown always as buffer type
            return(NodeV8IsTypedBuffer);
        }
Beispiel #2
0
        public virtual bool VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals)
        {
            if (!VisitType(type, quals))
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
        public override string VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals)
        {
            // Generate type name and modifiers
            string result = type.Description;

            result += (quals.IsConst ? " const" : string.Empty);

            return(result);
        }
Beispiel #4
0
 public bool VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals)
 {
     throw new NotImplementedException();
 }
 public CSharpTypePrinterResult VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals)
 {
     throw new NotImplementedException();
 }
 public override TypePrinterResult VisitUnsupportedType(UnsupportedType type,
                                                        TypeQualifiers quals)
 {
     return(type.Description);
 }
Beispiel #7
0
 public override bool VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals)
 {
     Ignore();
     return(false);
 }
        QualifiedType VisitType(IKVM.Reflection.Type managedType)
        {
            var isString = managedType.HasElementType && IKVM.Reflection.Type.GetTypeCode(
                managedType.GetElementType()) == TypeCode.String;

            if (managedType.IsByRef && isString)
            {
                managedType = managedType.GetElementType();
            }

            // If true type is an array, a pointer, or is passed by reference.
            if (managedType.HasElementType)
            {
                var managedElementType = managedType.GetElementType();
                var elementType        = VisitType(managedElementType);

                if (managedType.IsByRef || managedType.IsPointer)
                {
                    var ptrType = new PointerType(elementType)
                    {
                        Modifier = (Options.GeneratorKind == GeneratorKind.CPlusPlus) ?
                                   PointerType.TypeModifier.LVReference :
                                   PointerType.TypeModifier.Pointer
                    };

                    return(new QualifiedType(ptrType));
                }
                else if (managedType.IsArray)
                {
                    var array = new ArrayType
                    {
                        SizeType      = ArrayType.ArraySize.Variable,
                        QualifiedType = elementType
                    };

                    return(new QualifiedType(array));
                }

                throw new NotImplementedException();
            }

            CppSharp.AST.Type type       = null;
            TypeQualifiers    qualifiers = new TypeQualifiers();

            switch (IKVM.Reflection.Type.GetTypeCode(managedType))
            {
            case TypeCode.Empty:
                type = new BuiltinType(PrimitiveType.Null);
                break;

            case TypeCode.Object:
            case TypeCode.Decimal:
            case TypeCode.DateTime:
                if (managedType.FullName == "System.Void")
                {
                    type = new BuiltinType(PrimitiveType.Void);
                    break;
                }
                var currentUnit = GetTranslationUnit(CurrentAssembly);
                if (managedType.Assembly.GetName().Name != currentUnit.FileNameWithoutExtension ||
                    managedType.IsGenericType)
                {
                    type = new UnsupportedType {
                        Description = managedType.FullName
                    };
                    break;
                }
                var decl = Visit(managedType.GetTypeInfo());
                type = new TagType(decl);
                break;

            case TypeCode.DBNull:
                throw new NotSupportedException();

            case TypeCode.Boolean:
                type = new BuiltinType(PrimitiveType.Bool);
                break;

            case TypeCode.Char:
                type = new BuiltinType(PrimitiveType.WideChar);
                break;

            case TypeCode.SByte:
                type = new BuiltinType(PrimitiveType.Char);
                break;

            case TypeCode.Byte:
                type = new BuiltinType(PrimitiveType.UChar);
                break;

            case TypeCode.Int16:
                type = new BuiltinType(PrimitiveType.Short);
                break;

            case TypeCode.UInt16:
                type = new BuiltinType(PrimitiveType.UShort);
                break;

            case TypeCode.Int32:
                type = new BuiltinType(PrimitiveType.Int);
                break;

            case TypeCode.UInt32:
                type = new BuiltinType(PrimitiveType.UInt);
                break;

            case TypeCode.Int64:
                type = new BuiltinType(PrimitiveType.LongLong);
                break;

            case TypeCode.UInt64:
                type = new BuiltinType(PrimitiveType.ULongLong);
                break;

            case TypeCode.Single:
                type = new BuiltinType(PrimitiveType.Float);
                break;

            case TypeCode.Double:
                type = new BuiltinType(PrimitiveType.Double);
                break;

            case TypeCode.String:
                type = new CILType(typeof(string));
                break;
            }

            return(new QualifiedType(type, qualifiers));
        }
Beispiel #9
0
 public override string VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals)
 {
     return(type.Description);
 }
Beispiel #10
0
 public override TypePrinterResult VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals)
 {
     return(string.Empty);
 }
Beispiel #11
0
 public override bool VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals)
 {
     Ignore();
     return false;
 }
Beispiel #12
0
 public bool VisitUnsupportedType(UnsupportedType type, TypeQualifiers quals)
 {
     return(false);
 }