Exemplo n.º 1
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public CodeTypeReferenceBuilder(NetTypeDefinition context, bool useShortTypeNames, bool useShortNestedTypeNames, bool allowVoid, TypeNameMap typeNameMap)
 {
     this.context                 = context;
     this.useShortTypeNames       = useShortTypeNames;
     this.useShortNestedTypeNames = useShortNestedTypeNames;
     this.allowVoid               = allowVoid;
     this.typeNameMap             = typeNameMap;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public TargetFramework(ITypeMapResolver resolver, AssemblyClassLoader assemblyClassLoader, DocModel xmlModel, Action <string> missingParamTypeReport, bool importAsStubs, bool importPublicOnly, IEnumerable <string> excludedPackages)
 {
     this.missingParamTypeReport = missingParamTypeReport;
     this.importAsStubs          = importAsStubs;
     this.importPublicOnly       = importPublicOnly;
     XmlModel              = xmlModel;
     typeNameMap           = new TypeNameMap(resolver, assemblyClassLoader);
     this.excludedPackages = new HashSet <string>(excludedPackages);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public TargetFramework(ITypeMapResolver resolver, AssemblyClassLoader assemblyClassLoader, DocModel xmlModel, Action<string> missingParamTypeReport, bool importAsStubs, bool importPublicOnly, IEnumerable<string> excludedPackages)
 {
     this.missingParamTypeReport = missingParamTypeReport;
     this.importAsStubs = importAsStubs;
     this.importPublicOnly = importPublicOnly;
     XmlModel = xmlModel;
     typeNameMap = new TypeNameMap(resolver, assemblyClassLoader);
     this.excludedPackages = new HashSet<string>(excludedPackages);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Try to resolve the given NET name.
        /// </summary>
        void ITypeMapResolver.TryResolve(Type netType, TypeNameMap typeNameMap)
        {
            // Auto create a typedef.
            var typeDef = new NetTypeDefinition(ClassFile.Empty, target, AttributeConstants.Dot42Scope)
            {
                Namespace = netType.Namespace, Name = netType.Name
            };

            typeNameMap.Add(netType.FullName, typeDef);
        }
 /// <summary>
 /// Default ctor
 /// </summary>
 public NetTypeImplementationBuilder(TypeNameMap typeNameMap, ClassFile classFile, NetTypeDefinition typeDef, AssemblyClassLoader.DexImport dexImport,
                                     List <AssemblyClassLoader.DexImportMethod> dexMethods,
                                     Func <TypeDefinition, AssemblyClassLoader.DexImport> type2DexImport)
 {
     this.typeNameMap    = typeNameMap;
     this.classFile      = classFile;
     this.typeDef        = typeDef;
     this.dexMethods     = dexMethods;
     this.type2DexImport = type2DexImport;
     this.dexImport      = dexImport;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Try to resolve the given java class name.
 /// </summary>
 void ITypeMapResolver.TryResolve(string javaClassName, TypeNameMap typeNameMap)
 {
     // Do nothing
 }
Exemplo n.º 7
0
        /// <summary>
        /// Create type attributes
        /// </summary>
        private static MethodAttributes GetAttributes(NetTypeDefinition declaringType, NetMethodDefinition method, MethodDefinition javaMethod, string methodName, TypeNameMap typeNameMap)
        {
            var result   = (MethodAttributes)0;
            var isStatic = javaMethod.IsStatic;

            if (javaMethod.IsPublic)
            {
                result |= MethodAttributes.Public;
            }
            else if (javaMethod.IsProtected)
            {
                result |= MethodAttributes.FamORAssem;
            }
            else if (javaMethod.IsPrivate)
            {
                result |= MethodAttributes.Private;
            }
            else if (javaMethod.IsPackagePrivate)
            {
                result |= MethodAttributes.Assembly;
            }

            if (isStatic)
            {
                result |= MethodAttributes.Static;
            }
            if (javaMethod.IsAbstract)
            {
                result |= MethodAttributes.Abstract;
            }
            if (declaringType.IsInterface)
            {
                result |= MethodAttributes.Abstract;
            }

            if ((!javaMethod.IsFinal) && !isStatic && (methodName != ".ctor") && (!declaringType.IsStruct))
            {
                result |= MethodAttributes.Virtual;
            }
            else
            {
                result |= MethodAttributes.Final;
            }

            if (methodName == ".cctor")
            {
                result |= MethodAttributes.Static;
            }

            if (declaringType.IsSealed)
            {
                result &= ~MethodAttributes.Virtual;
            }

            return(result);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Create type attributes
        /// </summary>
        private static MethodAttributes GetAttributes(NetTypeDefinition declaringType, NetMethodDefinition method, MethodDefinition javaMethod, string methodName, TypeNameMap typeNameMap)
        {
            var result = (MethodAttributes) 0;
            var isStatic = javaMethod.IsStatic;

            if (javaMethod.IsPublic) result |= MethodAttributes.Public;
            else if (javaMethod.IsProtected) result |= MethodAttributes.FamORAssem;
            else if (javaMethod.IsPrivate) result |= MethodAttributes.Private;
            else if (javaMethod.IsPackagePrivate) result |= MethodAttributes.Assembly;

            if (isStatic) result |= MethodAttributes.Static;
            if (javaMethod.IsAbstract) result |= MethodAttributes.Abstract;
            if (declaringType.IsInterface) result |= MethodAttributes.Abstract;

            if ((!javaMethod.IsFinal) && !isStatic && (methodName != ".ctor") && (!declaringType.IsStruct))
            {
                result |= MethodAttributes.Virtual;
            }
            else
            {
                result |= MethodAttributes.Final;
            }

            if (methodName == ".cctor")
            {
                result |= MethodAttributes.Static;
            }

            if (declaringType.IsSealed)
            {
                result &= ~MethodAttributes.Virtual;
            }

            return result;
        }
Exemplo n.º 9
0
 /// <summary>
 /// Try to resolve the given NET name.
 /// </summary>
 void ITypeMapResolver.TryResolve(Type netType, TypeNameMap typeNameMap)
 {
     // Auto create a typedef.
     var typeDef = new NetTypeDefinition(ClassFile.Empty, target, AttributeConstants.Dot42Scope) { Namespace = netType.Namespace, Name = netType.Name};
     typeNameMap.Add(netType.FullName, typeDef);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Try to resolve the given java class name.
 /// </summary>
 void ITypeMapResolver.TryResolve(string javaClassName, TypeNameMap typeNameMap)
 {
     // Do nothing
 }
Exemplo n.º 11
0
 /// <summary>
 /// Default ctor
 /// </summary>
 public Resolver(INetGenericParameterProvider context, TypeNameMap typeNameMap)
 {
     this.context     = context;
     this.typeNameMap = typeNameMap;
 }
Exemplo n.º 12
0
 /// <summary>
 /// Resolve all generic parameters in the given type in the given context.
 /// </summary>
 internal static bool TryResolve(NetTypeReference type, INetGenericParameterProvider context, TypeNameMap typeNameMap, out NetTypeReference result)
 {
     result = null;
     if (type == null)
     {
         return(false);
     }
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     result = type.Accept(new Resolver(context, typeNameMap), 0);
     return(result != null);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Resolve all generic parameters in the given type in the given context.
        /// </summary>
        internal static NetTypeReference Resolve(NetTypeReference type, INetGenericParameterProvider context, TypeNameMap typeNameMap)
        {
            if (type == null)
            {
                return(null);
            }
            NetTypeReference result;

            if (!TryResolve(type, context, typeNameMap, out result))
            {
                throw new ArgumentException(string.Format("Cannot resolve {0} in context of {1}", type, context));
            }
            return(result);
        }