public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null); base.PrintTo(printer, logPrinter, flags); PrintNameTo(typeName, indirections, printer, flags); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null && signature != null); if (hasForwardDeclaration) { printer.Print(OutputType.Keyword, "struct"); printer.Print(OutputType.Other, " "); printer.PrintLn(OutputType.Identifier, Name); printer.Indent(); printer.PrintLn(OutputType.Operator, "{"); // will print "ret_type (call_conv *ptr)(params)" signature.PrintTo(printer, logPrinter, flags); printer.Unindent(); printer.PrintLn(); printer.Print(OutputType.Operator, "};"); } else { printer.Print(OutputType.Keyword, "typedef"); printer.Print(OutputType.Other, " "); // will print "ret_type (call_conv *name)(params)" signature.PrintTo(printer, logPrinter, flags); } }
public PrintContext(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null); this.printer = printer; this.logPrinter = logPrinter; this.flags = flags; }
public override void PrintPostIdentifierTo(ICodePrinter printer, PrintFlags flags) { if (fixedLength.HasValue) { printer.Print(OutputType.Operator, "["); printer.Print(OutputType.Literal, fixedLength.Value.ToString()); printer.Print(OutputType.Operator, "]"); } }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null); base.PrintTo(printer, logPrinter, flags); switch (arrayKind) { case ArrayKind.Invalid: { // void */PVOID PrimitiveNativeType.PrintNameTo(TypeName.Void, 1, printer, flags); break; } case ArrayKind.SafeArray: { // prefix with const if in-only if (isInOnly) { printer.Print(OutputType.Keyword, "const"); printer.Print(OutputType.Other, " "); } // SAFEARRAY * or LPSAFEARRAY if ((flags & PrintFlags.UsePlainC) == PrintFlags.UsePlainC) { TypeName.PrintTo(printer, TypeName.SafeArray.PlainC); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Operator, "*"); } else { TypeName.PrintTo(printer, "LP" + TypeName.SafeArray.WinApi); } break; } default: { elementType.PrintTo(printer, logPrinter, flags); break; } } if (indirections > 0) { // We'll suppress the [] suffix in this case; one indirection will be provided by the // element itself because the ByRefParam flag has been inherited by it. int stars = indirections; while (stars-- > 0) { printer.Print(OutputType.Operator, "*"); } } }
public override void PrintLog(ILogPrinter logPrinter, PrintFlags flags, string messagePrefix) { base.PrintLog(logPrinter, flags, messagePrefix); if (arrayKind != ArrayKind.Invalid) { elementType.PrintLog(logPrinter, flags, messagePrefix); } }
public override ListerResult Print(object control, string fileToPrint, string defPrinter, PrintFlags printFlags, PrintMargins pMargins) { WpfListerControl lc = (WpfListerControl)control; PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog().GetValueOrDefault(false)) { MessageBox.Show("WPF Form print stub"); } return(ListerResult.OK); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null); if (isUndefined && (flags & PrintFlags.UseDefinedComInterfaces) == PrintFlags.UseDefinedComInterfaces) { PrintNameTo(TypeName.IUnknown, indirections - 1, printer, flags); } else { PrintNameTo(typeName, indirections, printer, flags); } }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); if (logPrinter == null) throw new ArgumentNullException(nameof(logPrinter)); Debug.Assert(fields != null); printer.Print(OutputType.Keyword, "enum"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.TypeName, name); printer.Print(OutputType.Other, " "); // always explicitly print the underlying type printer.Print(OutputType.Operator, ":"); printer.Print(OutputType.Other, " "); underlyingType.PrintTo(printer, logPrinter, flags); printer.PrintLn(); printer.Indent(); printer.Print(OutputType.Operator, "{"); try { decimal next_value = 0; for (int i = 0; i < fields.Length; i++) { // field name [ = field value ][,] printer.PrintLn(); if (isFlagsEnum) { // explicitly list all field values for [Flags] enums next_value = Decimal.MaxValue; } fields[i].PrintTo(printer, flags, ref next_value); if (i < fields.Length - 1) { // comma after all but the last field printer.Print(OutputType.Operator, ","); } } } finally { printer.Unindent(); printer.PrintLn(); printer.Print(OutputType.Operator, "};"); } }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null && fields != null); printer.Print(OutputType.Keyword, "enum"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.TypeName, name); printer.Print(OutputType.Other, " "); // always explicitly print the underlying type printer.Print(OutputType.Operator, ":"); printer.Print(OutputType.Other, " "); underlyingType.PrintTo(printer, logPrinter, flags); printer.PrintLn(); printer.Indent(); printer.Print(OutputType.Operator, "{"); try { decimal next_value = 0; for (int i = 0; i < fields.Length; i++) { // field name [ = field value ][,] printer.PrintLn(); if (isFlagsEnum) { // explicitly list all field values for [Flags] enums next_value = Decimal.MaxValue; } fields[i].PrintTo(printer, flags, ref next_value); if (i < fields.Length - 1) { // comma after all but the last field printer.Print(OutputType.Operator, ","); } } } finally { printer.Unindent(); printer.PrintLn(); printer.Print(OutputType.Operator, "};"); } }
public static int PrintW(IntPtr listWin, [MarshalAs(UnmanagedType.LPWStr)] string fileToPrint, [MarshalAs(UnmanagedType.LPWStr)] string defPrinter, int flags, PrintMargins margins) { ListerResult result = ListerResult.Error; PrintFlags printFlags = (PrintFlags)flags; callSignature = String.Format("Print ({0}, {1}, {2}, {3})", listWin.ToString(), fileToPrint, defPrinter, printFlags.ToString()); try { object listerControl = TcHandles.GetObject(listWin); result = Plugin.Print(listerControl, fileToPrint, defPrinter, printFlags, margins); TcHandles.UpdateHandle(listWin, listerControl); TraceCall(TraceLevel.Warning, result.ToString()); } catch (Exception ex) { ProcessException(ex); } return((int)result); }
public override ListerResult Print(object control, string fileToPrint, string defPrinter, PrintFlags printFlags, PrintMargins pMargins) { ListerControl lc = (ListerControl)control; PrintDialog dialog = new PrintDialog { PrinterSettings = { PrinterName = defPrinter } }; if (dialog.ShowDialog().Equals(DialogResult.OK)) { PrinterSettings printerSettings = dialog.PrinterSettings; //Margins margins = new Margins(pMargins.left, pMargins.right, pMargins.top, pMargins.bottom); //printerSettings.DefaultPageSettings.Margins = margins; lc.Print(printerSettings); } return(ListerResult.OK); }
/// <summary> /// Prints a native signature to the provided printers according to the current settings. /// </summary> private void PrintSignature(SignatureGenerator.NativeSignature nativeSig, ICodePrinter printer, ILogPrinter logPrinter, bool printDefs, bool defsFirst) { PrintFlags p_flags = PrintFlags.None; if (plainCTypesToolStripMenuItem.Checked) { p_flags |= PrintFlags.UsePlainC; } if (marshalDirectionAnnotationsToolStripMenuItem.Checked) { p_flags |= PrintFlags.PrintMarshalDirection; } if (!defsFirst) { nativeSig.PrintTo(printer, logPrinter, p_flags); } if (printDefs) { foreach (NativeTypeDefinition def in nativeSig.GetDefinitions()) { if (defsFirst) { def.PrintTo(printer, logPrinter, p_flags); } printer.PrintLn(); printer.PrintLn(); if (!defsFirst) { def.PrintTo(printer, logPrinter, p_flags); } } } if (defsFirst) { nativeSig.PrintTo(printer, logPrinter, p_flags); } }
private static void PrintNativeSignature(NativeSignature nativeSig) { PrintFlags p_flags = PrintFlags.None; if (options.UsePlainCDataTypes) { p_flags |= PrintFlags.UsePlainC; } if (options.PrintMarshalDirection) { p_flags |= PrintFlags.PrintMarshalDirection; } LogMemoryPrinter log_mem_printer = new LogMemoryPrinter(); // print definitions first if (!options.SuppressTypeDefinitions) { foreach (NativeTypeDefinition def in nativeSig.GetDefinitions()) { def.PrintTo(codePrinter, log_mem_printer, p_flags); codePrinter.PrintLn(); codePrinter.PrintLn(); } } // and then the method signature nativeSig.PrintTo(codePrinter, log_mem_printer, p_flags); codePrinter.PrintLn(); codePrinter.PrintLn(); // flush the log_mem_printer to the real log printer if (!options.SuppressMessages) { log_mem_printer.ReplayTo(logPrinter); logPrinter.Separate(); } }
public void PrintTo(ICodePrinter printer, PrintFlags flags, ref decimal nextValue) { if ((flags & PrintFlags.MangleEnumFields) == PrintFlags.MangleEnumFields) { printer.Print(OutputType.Identifier, "_" + Guid.NewGuid().ToString("N") + "_"); } printer.Print(OutputType.Identifier, Name); if (Value != nextValue) { printer.Print(OutputType.Other, " "); printer.Print(OutputType.Operator, "="); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Literal, Value.ToString()); nextValue = Value; } unchecked { nextValue++; } }
public override void PrintPostIdentifierTo(ICodePrinter printer, PrintFlags flags) { switch (arrayKind) { case ArrayKind.Invalid: case ArrayKind.SafeArray: { // no post identifier output break; } case ArrayKind.NativeArray: { if (indirections == 0) { // We can only use the [] suffix when this array is not indirected with a byref. In // that case, we use two stars prefix instead, because // <element_type> (*array)[] is NOT a pointer to array! // empty brackets "[]" printer.Print(OutputType.Operator, "[]"); } break; } case ArrayKind.ByValArray: { // length-denoting brackets "[n]" printer.Print(OutputType.Operator, "["); printer.Print(OutputType.Literal, length.ToString()); printer.Print(OutputType.Operator, "]"); break; } } base.PrintPostIdentifierTo(printer, flags); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); if (logPrinter == null) throw new ArgumentNullException(nameof(logPrinter)); base.PrintTo(printer, logPrinter, flags); PrintNameTo(typeName, indirections, printer, flags); }
public virtual ListerResult Print(object control, string fileToPrint, string defPrinter, PrintFlags printFlags, PrintMargins margins) { return(ListerResult.Error); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); if (logPrinter == null) throw new ArgumentNullException(nameof(logPrinter)); if (isUndefined && (flags & PrintFlags.UseDefinedComInterfaces) == PrintFlags.UseDefinedComInterfaces) { PrintNameTo(TypeName.IUnknown, indirections - 1, printer, flags); } else { PrintNameTo(typeName, indirections, printer, flags); } }
protected internal static void PrintNameTo(TypeName typeName, int indirections, ICodePrinter printer, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); string output; if ((flags & PrintFlags.UsePlainC) == PrintFlags.UsePlainC) { output = typeName.PlainC; } else { output = typeName.WinApi; if (indirections > 0) { switch (typeName.PointerPrefix) { case TypeName.PtrPrefix.P_Prefix: { output = "P" + output; indirections--; break; } case TypeName.PtrPrefix.LP_Prefix: { output = "LP" + output; indirections--; break; } } } } TypeName.PrintTo(printer, output); if (indirections > 0) { if (!output.EndsWith("*")) printer.Print(OutputType.Other, " "); while (indirections-- > 0) { printer.Print(OutputType.Operator, "*"); } } }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); base.PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Keyword, "struct"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, Name); printer.Print(OutputType.Operator, ";"); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { printer.Print(OutputType.Identifier, "MIDL_INTERFACE"); printer.Print(OutputType.Operator, "("); printer.Print(OutputType.Literal, Utility.StringToLiteral("FB6AB00F-5096-3AF8-A33D-D7885A5FA829")); printer.PrintLn(OutputType.Operator, ")"); printer.Print(OutputType.TypeName, InterfaceName); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Operator, ":"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Keyword, "public"); printer.Print(OutputType.Other, " "); printer.PrintLn(OutputType.TypeName, "IDispatch"); printer.PrintLn(OutputType.Operator, "{"); printer.Print(OutputType.Keyword, "public"); printer.PrintLn(OutputType.Operator, ":"); printer.Print(OutputType.Other, " "); printer.PrintLn(OutputType.Comment, "// methods omitted"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Keyword, "virtual"); printer.Print(OutputType.Other, " "); new PrimitiveNativeType(TypeName.Error, platform64bit).PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Other, " "); if ((flags & PrintFlags.UsePlainC) == PrintFlags.UsePlainC) { printer.Print(OutputType.Keyword, "__stdcall"); } else { printer.Print(OutputType.TypeName, "STDMETHODCALLTYPE"); } printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, "DynamicInvoke"); printer.Print(OutputType.Operator, "("); new PrimitiveNativeType(TypeName.SafeArray, 1, platform64bit).PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, "args"); printer.Print(OutputType.Operator, ","); printer.Print(OutputType.Other, " "); new PrimitiveNativeType(TypeName.Variant, 1, platform64bit).PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, "pRetVal"); printer.Print(OutputType.Operator, ")"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Operator, "="); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Literal, "0"); printer.PrintLn(OutputType.Operator, ";"); printer.Print(OutputType.Operator, "};"); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); printer.Print(OutputType.Identifier, "MIDL_INTERFACE"); printer.Print(OutputType.Operator, "("); printer.Print(OutputType.Literal, Utility.StringToLiteral("FB6AB00F-5096-3AF8-A33D-D7885A5FA829")); printer.PrintLn(OutputType.Operator, ")"); printer.Print(OutputType.TypeName, InterfaceName); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Operator, ":"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Keyword, "public"); printer.Print(OutputType.Other, " "); printer.PrintLn(OutputType.TypeName, "IDispatch"); printer.PrintLn(OutputType.Operator, "{"); printer.Print(OutputType.Keyword, "public"); printer.PrintLn(OutputType.Operator, ":"); printer.Print(OutputType.Other, " "); printer.PrintLn(OutputType.Comment, "// methods omitted"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Keyword, "virtual"); printer.Print(OutputType.Other, " "); new PrimitiveNativeType(TypeName.Error, platform64bit).PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Other, " "); if ((flags & PrintFlags.UsePlainC) == PrintFlags.UsePlainC) printer.Print(OutputType.Keyword, "__stdcall"); else printer.Print(OutputType.TypeName, "STDMETHODCALLTYPE"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, "DynamicInvoke"); printer.Print(OutputType.Operator, "("); new PrimitiveNativeType(TypeName.SafeArray, 1, platform64bit).PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, "args"); printer.Print(OutputType.Operator, ","); printer.Print(OutputType.Other, " "); new PrimitiveNativeType(TypeName.Variant, 1, platform64bit).PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, "pRetVal"); printer.Print(OutputType.Operator, ")"); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Operator, "="); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Literal, "0"); printer.PrintLn(OutputType.Operator, ";"); printer.Print(OutputType.Operator, "};"); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); if (logPrinter == null) throw new ArgumentNullException(nameof(logPrinter)); Debug.Assert(signature != null); if (hasForwardDeclaration) { printer.Print(OutputType.Keyword, "struct"); printer.Print(OutputType.Other, " "); printer.PrintLn(OutputType.Identifier, Name); printer.Indent(); printer.PrintLn(OutputType.Operator, "{"); // will print "ret_type (call_conv *ptr)(params)" signature.PrintTo(printer, logPrinter, flags); printer.Unindent(); printer.PrintLn(); printer.Print(OutputType.Operator, "};"); } else { printer.Print(OutputType.Keyword, "typedef"); printer.Print(OutputType.Other, " "); // will print "ret_type (call_conv *name)(params)" signature.PrintTo(printer, logPrinter, flags); } }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null); base.PrintTo(printer, logPrinter, flags); PrintContext context = new PrintContext(printer, logPrinter, flags); if (unalignedSizeOrOffsets) { // the size of the structure or field offsets is "odd" -> need to pragma pack (1) it context.SetPack(1, true); } else { context.SetPack(DefaultPack, true); } if (!isUnion) { printer.PrintLn(); printer.Print(OutputType.Keyword, "struct"); PrintIdentifierAndSize(context); printer.Print(OutputType.Operator, "{"); printer.Indent(); } try { if (!isInvalid) { int current_offset = 0; for (int i = 0; i < fields.Length; i++) { if (isExplicitLayout) { // this may in fact print more fields in a union, so i is passed byref PrintExplicitlyLaidOutField(context, ref i, ref current_offset); } else { PrintSequentiallyLaidOutField(context, i, ref current_offset); } } int tmp_offset = current_offset; if (!context.UsedNonDefaultPack) { // if we never used a pack different from the default (8), we are sure // about the implicit padding at the end of the structure AlignSelf(ref tmp_offset); } if (size != tmp_offset) { // add final padding to the end of the structure to make its size exactly as requested context.PrintPadding(size - current_offset, context.UsedNonDefaultPack); } } } finally { if (!isUnion) { printer.Unindent(); printer.PrintLn(); printer.Print(OutputType.Operator, "};"); } context.SetDefaultPack(); } }
/// <summary> /// Is called when click print button /// </summary> /// <param name="control"></param> /// <param name="fileToPrint"></param> /// <param name="defPrinter"></param> /// <param name="printFlags"></param> /// <param name="margins"></param> /// <returns></returns> public override ListerResult Print(object control, string fileToPrint, string defPrinter, PrintFlags printFlags, PrintMargins margins) { TraceProc(System.Diagnostics.TraceLevel.Info, "Print fileToPrint:" + fileToPrint + ", defPrinter: " + defPrinter); ViewerControl viewerControl = (ViewerControl)control; viewerControl.webBrowser1.ShowPrintDialog(); return(ListerResult.OK); }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { base.PrintTo(printer, logPrinter, flags); printer.Print(OutputType.Keyword, (definition.isUnion ? "union" : "struct")); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Identifier, Name); printer.Print(OutputType.Operator, ";"); }
protected internal static void PrintNameTo(TypeName typeName, int indirections, ICodePrinter printer, PrintFlags flags) { string output; if ((flags & PrintFlags.UsePlainC) == PrintFlags.UsePlainC) { output = typeName.PlainC; } else { output = typeName.WinApi; if (indirections > 0) { switch (typeName.PointerPrefix) { case TypeName.PtrPrefix.P_Prefix: { output = "P" + output; indirections--; break; } case TypeName.PtrPrefix.LP_Prefix: { output = "LP" + output; indirections--; break; } } } } TypeName.PrintTo(printer, output); if (indirections > 0) { if (!output.EndsWith("*")) { printer.Print(OutputType.Other, " "); } while (indirections-- > 0) { printer.Print(OutputType.Operator, "*"); } } }
public override void PrintPostIdentifierTo(ICodePrinter printer, PrintFlags flags) { if (printer == null) throw new ArgumentNullException(nameof(printer)); if (fixedLength.HasValue) { printer.Print(OutputType.Operator, "["); printer.Print(OutputType.Literal, fixedLength.Value.ToString()); printer.Print(OutputType.Operator, "]"); } }
public override void PrintTo(ICodePrinter printer, ILogPrinter logPrinter, PrintFlags flags) { Debug.Assert(printer != null && logPrinter != null); base.PrintTo(printer, logPrinter, flags); switch (arrayKind) { case ArrayKind.Invalid: { // void */PVOID PrimitiveNativeType.PrintNameTo(TypeName.Void, 1, printer, flags); break; } case ArrayKind.SafeArray: { // prefix with const if in-only if (isInOnly) { printer.Print(OutputType.Keyword, "const"); printer.Print(OutputType.Other, " "); } // SAFEARRAY * or LPSAFEARRAY if ((flags & PrintFlags.UsePlainC) == PrintFlags.UsePlainC) { TypeName.PrintTo(printer, TypeName.SafeArray.PlainC); printer.Print(OutputType.Other, " "); printer.Print(OutputType.Operator, "*"); } else { TypeName.PrintTo(printer, "LP" + TypeName.SafeArray.WinApi); } break; } default: { elementType.PrintTo(printer, logPrinter, flags); break; } } if (indirections > 0) { // We'll suppress the [] suffix in this case; one indirection will be provided by the // element itself because the ByRefParam flag has been inherited by it. int stars = indirections; while (stars-- > 0) printer.Print(OutputType.Operator, "*"); } }