private static CachedRules GetCachedRules(CSharpConverter converter) { //var cachedRules = GetCachedRules(converter); var cachedRules = converter.GetTagValueOrDefault <CachedRules>(CachedRulesKey); if (cachedRules == null) { cachedRules = new CachedRules(); foreach (var mappingRule in converter.Options.MappingRules.MacroRules) { cachedRules.MacroRules.Add(mappingRule); } var tempTypedefRules = new Dictionary <TypeRemapKey, CppElementMappingRule>(); foreach (var mappingRule in converter.Options.MappingRules.StandardRules) { cachedRules.StandardRules.Add(mappingRule); if (mappingRule.TypeRemap != null) { tempTypedefRules[new TypeRemapKey(mappingRule.TypeRemap, mappingRule.TypeRemapArraySize)] = mappingRule; } } foreach (var cppElementMappingRule in tempTypedefRules) { cachedRules.TypesToCompile.Add(cppElementMappingRule.Value); } converter.Tags.Add(CachedRulesKey, cachedRules); } return(cachedRules); }
public static ICSharpContainer GetSharpContainer(CSharpConverter converter, CppElement element, CSharpElement context) { var cacheContainer = converter.GetTagValueOrDefault <CacheContainer>(CacheContainerKey); if (cacheContainer == null) { cacheContainer = new CacheContainer { DefaultClass = CreateClassLib(converter) }; converter.Tags[CacheContainerKey] = cacheContainer; } if (converter.Options.DispatchOutputPerInclude) { var isFromSystemIncludes = converter.IsFromSystemIncludes(element); if (!isFromSystemIncludes) { var fileName = Path.GetFileNameWithoutExtension(element.Span.Start.File); if (fileName != null) { if (cacheContainer.IncludeToClass.TryGetValue(fileName, out var csClassLib)) { return(csClassLib); } csClassLib = CreateClassLib(converter, UPath.Combine(UPath.Root, fileName + ".generated.cs")); cacheContainer.IncludeToClass.Add(fileName, csClassLib); return(csClassLib); } } } return(cacheContainer.DefaultClass); }