/**
 * Copyright (c) 2016-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */ import * as Code from './code' ; import * as Error from './error' ; import * as FileWriter from './file-writer' ; import * as CLangCommon from './clang-common' ; import * as ObjC from './objc' ; import * as ObjectGeneration from './object-generation' ; import * as ObjectSpec from './object-spec' ; export interface SubtypeAttributeType extends ObjectSpec . AttributeType { } export interface SubtypeAttribute extends ObjectSpec . BaseAttribute { } export enum SubtypeDefinitionType { namedAttributeCollection , singleAttribute } export interface NamedAttributeCollectionSubtype { annotations : ObjectGeneration . AnnotationMap ; name : string ; comments : string [ ] ; attributes : SubtypeAttribute [ ] ; } export class Subtype { private definitionType : SubtypeDefinitionType ; private singleAttribute ? : SubtypeAttribute ; private attributeCollectionSubtype ? : NamedAttributeCollectionSubtype ; constructor ( definitionType , singleAttribute ? , attributeCollectionSubtype ? ) { this . definitionType = definitionType ; this . singleAttribute = singleAttribute ; this . attributeCollectionSubtype = attributeCollectionSubtype ; } static NamedAttributeCollectionDefinition ( namedAttributeCollectionType ) { return new Subtype ( SubtypeDefinitionType . namedAttributeCollection , undefined , namedAttributeCollectionType ) ; } static SingleAttributeSubtypeDefinition ( attribute ) { return new Subtype ( SubtypeDefinitionType . singleAttribute , attribute , undefined ) ; } match < T > ( namedAttributeCollection , singleAttributeSubtype ) { switch ( this . definitionType ) { case SubtypeDefinitionType . namedAttributeCollection : return namedAttributeCollection ( this . attributeCollectionSubtype ! ) ; case SubtypeDefinitionType . singleAttribute : return singleAttributeSubtype ( this . singleAttribute ! ) ; } } } export interface Type { annotations : ObjectGeneration . AnnotationMap ; comments : string [ ] ; includes : string [ ] ; excludes : string [ ] ; libraryName : string | null ; name : string ; typeLookups : ObjectGeneration . TypeLookup [ ] ; subtypes : Subtype [ ] ; } export interface Plugin { additionalFiles : ( algebraicType : Type ) => Code . File [ ] ; transformBaseFile : ( algebraicType : Type , baseFile : Code . File ) => Code . File ; blockTypes : ( algebraicType : Type ) => ObjC . BlockType [ ] ; classMethods : ( algebraicType : Type ) => ObjC . Method [ ] ; enumerations : ( algebraicType : Type ) => ObjC . Enumeration [ ] ; transformFileRequest : ( writeRequest : FileWriter . Request ) => FileWriter . Request ; fileType : ( algebraicType : Type ) => Code . FileType | null ; forwardDeclarations : ( algebraicType : Type ) => ObjC . ForwardDeclaration [ ] ; functions : ( algebraicType : Type ) => ObjC . Function [ ] ; headerComments : ( algebraicType : Type ) => ObjC . Comment [ ] ; implementedProtocols : ( algebraicType : Type ) => ObjC . ImplementedProtocol [ ] ; imports : ( algebraicType : Type ) => ObjC . Import [ ] ; instanceMethods : ( algebraicType : Type ) => ObjC . Method [ ] ; instanceVariables : ( algebraicType : Type ) => ObjC . InstanceVariable [ ] ; macros : ( algebraicType : Type ) => ObjC . Macro [ ] ; requiredIncludesToRun : string [ ] ; staticConstants : ( algebraicType : Type ) => ObjC . Constant [ ] ; globalVariables ? : ( algebraicType : Type ) => ObjC . GlobalVariable [ ] ; validationErrors : ( algebraicType : Type ) => Error . Error [ ] ; nullability : ( algebraicType : Type ) => ObjC . ClassNullability | null ; subclassingRestricted : ( algebraicType : Type ) => boolean ; structs ? : ( algebraicType : Type ) => Code . Struct [ ] ; baseClass ? : ( algebraicType : Type ) => ObjC . BaseClass | null ; }