internal string GetTypeNameAndType(Type type, out bool isJavaType) { Module mod = type.Module; int moduleIndex = -1; for (int i = 0; i < modules.Length; i++) { if (modules[i] == mod) { moduleIndex = i; break; } } if (isJavaModule[moduleIndex]) { isJavaType = true; if (AttributeHelper.IsHideFromJava(type)) { return(null); } return(CompiledTypeWrapper.GetName(type)); } else { isJavaType = false; if (!DotNetTypeWrapper.IsAllowedOutside(type)) { return(null); } return(DotNetTypeWrapper.GetName(type)); } }
internal TypeWrapper CreateWrapperForAssemblyType(Type type) { Module mod = type.Module; int moduleIndex = -1; for (int i = 0; i < modules.Length; i++) { if (modules[i] == mod) { moduleIndex = i; break; } } string name; if (isJavaModule[moduleIndex]) { name = CompiledTypeWrapper.GetName(type); } else { name = DotNetTypeWrapper.GetName(type); } if (name == null) { return(null); } if (isJavaModule[moduleIndex]) { if (AttributeHelper.IsHideFromJava(type)) { return(null); } // since this type was compiled from Java source, we have to look for our // attributes return(CompiledTypeWrapper.newInstance(name, type)); } else { if (!DotNetTypeWrapper.IsAllowedOutside(type)) { return(null); } // since this type was not compiled from Java source, we don't need to // look for our attributes, but we do need to filter unrepresentable // stuff (and transform some other stuff) return(DotNetTypeWrapper.Create(type, name)); } }
internal TypeWrapper DoLoad(string name) { for (int i = 0; i < modules.Length; i++) { if (isJavaModule[i]) { Type type = GetJavaType(modules[i], name); if (type != null) { // check the name to make sure that the canonical name was used if (CompiledTypeWrapper.GetName(type) == name) { return(CompiledTypeWrapper.newInstance(name, type)); } } } else { // TODO should we catch ArgumentException and prohibit array, pointer and byref here? Type type = GetType(modules[i], DotNetTypeWrapper.DemangleTypeName(name)); if (type != null && DotNetTypeWrapper.IsAllowedOutside(type)) { // check the name to make sure that the canonical name was used if (DotNetTypeWrapper.GetName(type) == name) { return(DotNetTypeWrapper.Create(type, name)); } } } } if (hasDotNetModule) { // for fake types, we load the declaring outer type (the real one) and // let that generated the manufactured nested classes // (note that for generic outer types, we need to duplicate this in ClassLoaderWrapper.LoadGenericClass) TypeWrapper outer = null; if (name.EndsWith(DotNetTypeWrapper.DelegateInterfaceSuffix)) { outer = DoLoad(name.Substring(0, name.Length - DotNetTypeWrapper.DelegateInterfaceSuffix.Length)); } else if (name.EndsWith(DotNetTypeWrapper.AttributeAnnotationSuffix)) { outer = DoLoad(name.Substring(0, name.Length - DotNetTypeWrapper.AttributeAnnotationSuffix.Length)); } else if (name.EndsWith(DotNetTypeWrapper.AttributeAnnotationReturnValueSuffix)) { outer = DoLoad(name.Substring(0, name.Length - DotNetTypeWrapper.AttributeAnnotationReturnValueSuffix.Length)); } else if (name.EndsWith(DotNetTypeWrapper.AttributeAnnotationMultipleSuffix)) { outer = DoLoad(name.Substring(0, name.Length - DotNetTypeWrapper.AttributeAnnotationMultipleSuffix.Length)); } else if (name.EndsWith(DotNetTypeWrapper.EnumEnumSuffix)) { outer = DoLoad(name.Substring(0, name.Length - DotNetTypeWrapper.EnumEnumSuffix.Length)); } if (outer != null && outer.IsFakeTypeContainer) { foreach (TypeWrapper tw in outer.InnerClasses) { if (tw.Name == name) { return(tw); } } } } return(null); }