From acc1d309d20ac4414db230f52cd75d877084b969 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Tue, 15 Nov 2022 16:23:50 -0500 Subject: Add TypePrinter::PrintAllTypes to export C headers --- binaryninjaapi.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'binaryninjaapi.h') diff --git a/binaryninjaapi.h b/binaryninjaapi.h index 8cb0a7b2..c59b554a 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -11766,6 +11766,8 @@ namespace BinaryNinja { static bool GetTypeLinesCallback(void* ctxt, BNType* type, BNBinaryView* data, BNQualifiedName* name, int lineWidth, bool collapsed, BNTokenEscapingType escaping, BNTypeDefinitionLine** result, size_t* resultCount); + static bool PrintAllTypesCallback(void* ctxt, BNQualifiedName* names, BNType** types, size_t typeCount, + BNBinaryView* data, int lineWidth, BNTokenEscapingType escaping, char** result); static void FreeTokensCallback(void* ctxt, BNInstructionTextToken* tokens, size_t count); static void FreeStringCallback(void* ctxt, char* string); static void FreeLinesCallback(void* ctxt, BNTypeDefinitionLine* lines, size_t count); @@ -11890,6 +11892,37 @@ namespace BinaryNinja { bool collapsed = false, BNTokenEscapingType escaping = NoTokenEscapingType ) = 0; + + /*! + Print all types to a single big string, including headers, sections, etc + \param types All types to print + \param data Binary View in which all the types are defined + \param lineWidth Maximum width of lines, in characters + \param escaping Style of escaping literals which may not be parsable + \return All the types in a string + */ + virtual std::string PrintAllTypes( + const std::vector>>& types, + Ref data, + int lineWidth = 80, + BNTokenEscapingType escaping = NoTokenEscapingType + ); + + /*! + Default implementation of PrintAllTypes + Print all types to a single big string, including headers, sections, etc + \param types All types to print + \param data Binary View in which all the types are defined + \param lineWidth Maximum width of lines, in characters + \param escaping Style of escaping literals which may not be parsable + \return All the types in a string + */ + std::string DefaultPrintAllTypes( + const std::vector>>& types, + Ref data, + int lineWidth = 80, + BNTokenEscapingType escaping = NoTokenEscapingType + ); }; /*! @@ -11919,6 +11952,8 @@ namespace BinaryNinja { virtual std::vector GetTypeLines(Ref type, Ref data, const QualifiedName& name, int lineWidth, bool collapsed, BNTokenEscapingType escaping) override; + virtual std::string PrintAllTypes(const std::vector>>& types, + Ref data, int lineWidth, BNTokenEscapingType escaping) override; }; // DownloadProvider -- cgit v1.3.1