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 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); }
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()); }
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); }