Ejemplo n.º 1
0
        /// <summary>
        /// Create a type defrinition for the given class file and all inner classes.
        /// </summary>
        public override void CreateType(NetTypeDefinition declaringType, NetModule module, TargetFramework target)
        {
            if (declaringType == null)
            {
                throw new ArgumentNullException("declaringType");
            }
            docClass = target.GetXmlClass(cf);

            var name = NameConverter.UpperCamelCase(inner.IsAnonymous ? cf.Name : inner.Name);

            name = CreateTypeName(declaringType, cf, name, null);

            var finalFullName = parentFullName + "/" + name;

            var attributes = GetAttributes(cf);

            typeDef = new NetTypeDefinition(cf, target, module.Scope)
            {
                Name = name, Attributes = attributes
            };
            typeDef.OriginalJavaClassName = cf.ClassName;
            typeDef.Description           = (docClass != null) ? docClass.Description : null;
            parent.AddNestedType(typeDef, "", module, ref finalFullName);

            // Prepare generics
            CreateGenericParameters(cf, typeDef);

            // Add mapping
            RegisterType(target, cf, typeDef);
            CreateNestedTypes(cf, typeDef, finalFullName, module, target);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a type defrinition for the given class file and all inner classes.
        /// </summary>
        public override void CreateType(NetTypeDefinition declaringType, NetModule module, TargetFramework target)
        {
            if (declaringType != null)
            {
                throw new ArgumentException("Declaring type should be null");
            }
            docClass = target.GetXmlClass(cf);

            var fullName = GetFullName();
            var dotIndex = fullName.LastIndexOf('.');
            var ns       = (dotIndex > 0) ? NameConverter.UpperCamelCase(fullName.Substring(0, dotIndex)) : String.Empty;
            var name     = (dotIndex > 0) ? NameConverter.UpperCamelCase(fullName.Substring(dotIndex + 1)) : fullName;

            name = CreateTypeName(null, cf, name, ns);

            typeDef                        = new NetTypeDefinition(cf, target, module.Scope);
            typeDef.Name                   = name;
            typeDef.Namespace              = ns;
            typeDef.OriginalJavaClassName  = cf.ClassName;
            typeDef.Attributes             = GetAttributes(cf, cf.Fields.Any());
            typeDef.IgnoreGenericArguments = !AddGenericParameters;
            typeDef.Description            = (docClass != null) ? docClass.Description : null;
            module.Types.Add(typeDef);

            // Prepare generics
            CreateGenericParameters(cf, typeDef);

            // Add mapping
            var finalFullName = string.IsNullOrEmpty(ns) ? name : ns + "." + name;

            RegisterType(target, cf, typeDef);
            CreateNestedTypes(cf, typeDef, finalFullName, module, target);
        }
Ejemplo n.º 3
0
 private static string ConvertNamespace(string fullName, int dotIndex)
 {
     foreach (var fixedConv in FixedNamespacePrefixRenames)
     {
         var len = fixedConv[0].Length;
         if (fullName.StartsWith(fixedConv[0]))
         {
             if (fullName.Length == len || fullName[len] == '.')
             {
                 fullName  = fixedConv[1] + fullName.Substring(len);
                 dotIndex += fixedConv[1].Length - len;
                 break;
             }
         }
     }
     return(NameConverter.UpperCamelCase(fullName.Substring(0, dotIndex)));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the name of the given method.
        /// This is the initial name, a direct conversion from java.
        /// </summary>
        internal MethodNameInfo GetMethodName(MethodDefinition method)
        {
            switch (method.Name)
            {
            case "<init>":
                return(new MethodNameInfo(".ctor", true, false));

            case "<clinit>":
                return(new MethodNameInfo(".cctor", true, false));

            case "finalize":
                return(new MethodNameInfo("Finalize", false, true));

            case "hashCode":
                return(new MethodNameInfo("GetHashCode"));

            default:
                return(new MethodNameInfo(NameConverter.UpperCamelCase(method.Name)));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the name of the given field
        /// </summary>
        public virtual string GetFieldName(FieldDefinition field)
        {
            var name = NameConverter.UpperCamelCase(field.Name.Replace('$', '_'));

            return(name);
        }