TypeDeclaration ToClassDeclaration(TypeDefinition definition) { var name = TypeAggregator.RegisterAttributeName(definition) ?? definition.Name; var moduleName = definition.Namespace; TypeAggregator.RemapModuleAndName(platform, ref moduleName, ref name, TypeType.Class); var classDecl = new ClassDeclaration { Name = name, Access = ToAccessibility(definition), Module = ToModuleDeclaration(moduleName), ParentExtension = null, Kind = TypeKind.Class, Members = new List <Member> (), InnerClasses = new List <ClassDeclaration> (), InnerStructs = new List <StructDeclaration> (), InnerEnums = new List <EnumDeclaration> (), IsObjC = true, IsFinal = definition.IsSealed, IsDeprecated = false, IsUnavailable = false, IsImportedBinding = true }; classDecl.Inheritance.AddRange(ToInheritance(definition)); return(classDecl.MakeUnrooted()); }
TypeDeclaration ToProtocolDeclaration(TypeDefinition definition) { var name = TypeAggregator.ProtocolAttributeName(definition) ?? definition.Name; var moduleName = definition.Namespace; // FIXME: these cases don't have a clear resolution // don't know what to do about this, so skip I guess? if (name == "NSDraggingDestination" || name == "NSDraggingInfo") { return(null); } TypeAggregator.RemapModuleAndName(platform, ref moduleName, ref name, TypeType.Interface); var protocolDeclaration = new ProtocolDeclaration { Name = name, Access = ToAccessibility(definition), Module = ToModuleDeclaration(moduleName), ParentExtension = null, Kind = TypeKind.Protocol, Members = new List <Member> (), IsObjC = true, IsFinal = definition.IsSealed, IsDeprecated = false, IsUnavailable = false, IsImportedBinding = true }; protocolDeclaration.Inheritance.AddRange(ToInheritance(definition)); return(protocolDeclaration.MakeUnrooted()); }
TypeDeclaration ToStructDeclaration(TypeDefinition definition) { var name = TypeAggregator.ProtocolAttributeName(definition) ?? definition.Name; var moduleName = definition.Namespace; if (TypeAggregator.FilterModuleAndName(platform, moduleName, ref name)) { TypeAggregator.RemapModuleAndName(platform, ref moduleName, ref name, TypeType.Struct); var module = ToModuleDeclaration(moduleName); var structDeclaration = new StructDeclaration { Name = name, Access = ToAccessibility(definition), Module = module, ParentExtension = null, Kind = TypeKind.Struct, Members = new List <Member> (), IsObjC = true, IsFinal = true, IsDeprecated = false, IsUnavailable = false }; return(structDeclaration.MakeUnrooted()); } return(null); }
EnumDeclaration ToEnumDeclaration(TypeDefinition definition) { var name = definition.Name; var moduleName = definition.Namespace; TypeAggregator.RemapModuleAndName(platform, ref moduleName, ref name, TypeType.Enum); var module = ToModuleDeclaration(moduleName); var enumDeclaration = new EnumDeclaration { Name = name, Access = ToAccessibility(definition), Module = module, ParentExtension = null, Kind = TypeKind.Enum, Members = new List <Member> (), IsObjC = true, IsDeprecated = false, IsUnavailable = false, }; foreach (var field in definition.Fields) { if (field.Name == "value__") { continue; } enumDeclaration.Elements.Add(ToEnumElement(field)); } return(enumDeclaration.MakeUnrooted() as EnumDeclaration); }
bool IsObjCProtocolCandidate(TypeDefinition definition) { if (!definition.IsPublic) { return(false); } if (!definition.IsInterface) { return(false); } if (TypeAggregator.HasProtocolAttribute(definition)) { return(true); } return(ImplementsINativeObject(definition)); }
BindingImporter(string assemblyPath, ErrorHandling errors, TypeDatabase peerDatabase = null) { Ex.ThrowOnNull(assemblyPath, nameof(assemblyPath)); this.errors = Ex.ThrowOnNull(errors, nameof(errors)); this.peerDatabase = peerDatabase; aggregator = new TypeAggregator(assemblyPath); aggregator.IsObjCChecker = (nameSpace, typeName) => { if (peerDatabase == null) { return(false); } var entity = peerDatabase.EntityForDotNetName(new DotNetName(nameSpace, typeName)); if (entity != null) { return(entity.Type.IsObjC); } return(false); }; }
bool IsObjCClassCandidate(TypeDefinition definition) { if (!definition.IsPublic) { return(false); } if (!definition.IsClass || definition.IsValueType) { return(false); } if (TypeAggregator.HasSkipRegistration(definition) == true) { return(false); } if (TypeAggregator.HasModelAttribute(definition)) { return(false); } return(ImplementsINativeObject(definition) || IsNSObject(definition)); }
public BindingImporter(PlatformName platform, ErrorHandling errors, TypeDatabase peerDatabase = null) : this(TypeAggregator.PathForPlatform(platform), errors, peerDatabase) { this.platform = platform; }