/// <summary> /// </summary> /// <param name="type"> /// </param> /// <param name="writer"> /// </param> public static void WriteRttiClassInfoDeclaration(this IType type, IndentedTextWriter writer) { var interfaces = type.GetInterfaces(); var anyInterface = interfaces.Any(); var onlyInterface = interfaces.Count() == 1; if (type.BaseType == null && !anyInterface) { RttiClassWithNoBaseAndNoInterfaces.WriteRttiClassInfoDeclaration(type, writer); return; } if (type.BaseType == null && onlyInterface) { RttiClassWithNoBaseAndSingleInterface.WriteRttiClassInfoDeclaration(type, writer); return; } if (anyInterface) { RttiClassWithBaseAndInterfaces.WriteRttiClassInfoDeclaration(type, writer); return; } RttiClassWithBaseAndNoInterfaces.WriteRttiClassInfoDeclaration(type, writer); }
/// <summary> /// </summary> /// <param name="type"> /// </param> /// <param name="llvmWriter"> /// </param> public static void WriteRttiClassInfoDefinition(this IType type, LlvmWriter llvmWriter) { var interfaces = type.GetInterfaces(); var anyInterface = interfaces.Any(); var onlyInterface = interfaces.Count() == 1; if (type.BaseType == null && !anyInterface) { RttiClassWithNoBaseAndNoInterfaces.WriteRttiClassInfoDefinition(type, llvmWriter); return; } if (type.BaseType != null) { llvmWriter.AddRequiredRttiDeclaration(type.BaseType); } if (anyInterface) { foreach (var @interface in type.GetInterfaces()) { llvmWriter.AddRequiredRttiDeclaration(@interface); } if (type.BaseType == null && onlyInterface) { RttiClassWithNoBaseAndSingleInterface.WriteRttiClassInfoDefinition(type, llvmWriter); return; } RttiClassWithBaseAndInterfaces.WriteRttiClassInfoDefinition(type, llvmWriter); return; } RttiClassWithBaseAndNoInterfaces.WriteRttiClassInfoDefinition(type, llvmWriter); }