internal static void InternalWriteHeader( CodeTextWriter twHeader, TranslateContext translateContext, PreparedInformations prepared, bool includeAssemblyHeader) { IExtractContext extractContext = translateContext; var assemblyName = Utilities.GetMangledName(extractContext.Assembly.FriendlyName); twHeader.WriteLine("#ifndef __{0}_H__", assemblyName); twHeader.WriteLine("#define __{0}_H__", assemblyName); twHeader.SplitLine(); twHeader.WriteLine("#pragma once"); twHeader.SplitLine(); twHeader.WriteLine("#include <il2c.h>"); if (includeAssemblyHeader) { twHeader.SplitLine(); foreach (var fileName in extractContext.EnumerateRequiredIncludeFileNames()) { twHeader.WriteLine("#include <{0}>", fileName); } } // All types exclude privates PrototypeWriter.InternalConvertToPrototypes( twHeader, prepared.Types, type => type.IsCLanguagePublicScope, field => field.IsPublic || field.IsFamily || field.IsFamilyOrAssembly, method => (method.IsPublic || method.IsFamily || method.IsFamilyOrAssembly) && prepared.Functions.ContainsKey(method)); twHeader.SplitLine(); twHeader.WriteLine("#endif"); twHeader.SplitLine(); }
public static void WriteHeader( TextWriter twHeader, TranslateContext translateContext, PreparedFunctions preparedFunctions, string indent) { IExtractContext extractContext = translateContext; var assemblyName = extractContext.Assembly.Name.Name; var safeSymbolName = assemblyName.Replace('.', '_').Replace('-', '_'); twHeader.WriteLine("#ifndef __MODULE_{0}__", safeSymbolName); twHeader.WriteLine("#define __MODULE_{0}__", safeSymbolName); twHeader.WriteLine(); foreach (var fileName in extractContext.EnumerateRequiredIncludeFileNames()) { twHeader.WriteLine("#include <{0}>", fileName); } var types = extractContext.Assembly.Modules .SelectMany(module => module.Types) .SelectMany(type => new[] { type }.Concat(type.NestedTypes)) // All types exclude privates .Where(type => type.IsValidDefinition() && (type.IsPublic || type.IsNestedPublic || type.IsNestedFamily || type.IsNestedFamilyOrAssembly)) .ToArray(); InternalConvertToPrototypes( twHeader, types, extractContext, preparedFunctions, method => method.IsPublic || method.IsFamily || method.IsFamilyOrAssembly, indent); twHeader.WriteLine(); twHeader.WriteLine("#endif"); }