in src/objc-renderer.ts [961:1043]
export function renderHeader(file: Code.File): string | null {
const commentsStr = file.comments.map(toCommentString).join('\n');
const commentsSection = codeSectionForCodeString(commentsStr);
const imports = file.imports.filter(isPublicImport).map(toImportString);
const importStr = arrayWithDuplicatesRemoved(imports).join('\n');
const importsSection = codeSectionForCodeString(importStr);
const declarations = file.forwardDeclarations.map(toDeclarationString);
const declarationsStr = arrayWithDuplicatesRemoved(declarations).join('\n');
const declarationsSection = codeSectionForCodeString(declarationsStr);
const macros = fileMacros(file);
const prefixMacrosSection: string = codeSectionForCodeString(
macros.map(toPrefixMacroString).join('\n'),
);
const enumerationsStr: string = file.enumerations
.filter(enumerationIsPublic(true))
.map(toNSEnumDeclaration)
.join('\n');
const enumerationsSection: string = codeSectionForCodeString(enumerationsStr);
const blocksStr: string = file.blockTypes
.filter(blockTypeIsPublic(true))
.map(toBlockTypeDeclarationWithMacros)
.join('\n');
const blocksSection: string = codeSectionForCodeString(blocksStr);
const functionsSection = codeSectionForCodeString(
headerFunctionsSection(
file.functions.concat(
FunctionUtils.flatMap(
file.classes,
(classInfo) => classInfo.functions || [],
),
),
),
);
const protocols = file.protocols;
const protocolsSection =
protocols != null
? codeSectionForCodeString(
protocols.map((protocol) => protocolSection(protocol)).join('\n\n'),
)
: '';
const classSection = codeSectionForCodeString(
file.classes.map((cls) => headerClassSection(cls)).join('\n\n'),
);
const structsStr = file.structs.map(toStructContents).join('\n');
const structsSection = codeSectionForCodeString(structsStr);
const cppClassesStr = file.cppClasses.map(toCppClassDeclaration).join('\n');
const cppClassesSection = codeSectionForCodeString(cppClassesStr);
const namespacesStr: string = file.namespaces
.map(toNamespaceContents)
.join('\n');
const namespacesSection: string = codeSectionForCodeString(namespacesStr);
const postfixMacrosSection: string = codeSectionForCodeString(
macros.map(toPostfixMacroString).join('\n'),
);
const contents: string =
commentsSection +
importsSection +
declarationsSection +
prefixMacrosSection +
enumerationsSection +
blocksSection +
namespacesSection +
protocolsSection +
classSection +
structsSection +
cppClassesSection +
functionsSection +
postfixMacrosSection;
return contents.trim() + '\n';
}