BinaryNinja::TypeParser Class Referenceabstract

Public Member Functions

virtual bool PreprocessSource (const std::string &source, const std::string &fileName, Ref< Platform > platform, const std::map< QualifiedName, TypeAndId > &existingTypes, const std::vector< std::string > &options, const std::vector< std::string > &includeDirs, std::string &output, std::vector< TypeParserError > &errors)=0
 Preprocess a block of source, returning the source that would be parsed. More...
 
virtual bool ParseTypesFromSource (const std::string &source, const std::string &fileName, Ref< Platform > platform, const std::map< QualifiedName, TypeAndId > &existingTypes, const std::vector< std::string > &options, const std::vector< std::string > &includeDirs, const std::string &autoTypeSource, TypeParserResult &result, std::vector< TypeParserError > &errors)=0
 Parse an entire block of source into types, variables, and functions. More...
 
virtual bool ParseTypeString (const std::string &source, Ref< Platform > platform, const std::map< QualifiedName, TypeAndId > &existingTypes, QualifiedNameAndType &result, std::vector< TypeParserError > &errors)=0
 Parse a single type and name from a string containing their definition. More...
 
- Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNTypeParser >
 StaticCoreRefCountObject ()
 
virtual ~StaticCoreRefCountObject ()
 
BNTypeParser * GetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 

Static Public Member Functions

static void Register (TypeParser *parser)
 
static std::vector< Ref< TypeParser > > GetList ()
 
static Ref< TypeParserGetByName (const std::string &name)
 
static Ref< TypeParserGetDefault ()
 
- Static Public Member Functions inherited from BinaryNinja::StaticCoreRefCountObject< BNTypeParser >
static BNTypeParser * GetObject (StaticCoreRefCountObject *obj)
 

Protected Member Functions

 TypeParser (const std::string &name)
 
 TypeParser (BNTypeParser *parser)
 

Static Protected Member Functions

static bool PreprocessSourceCallback (void *ctxt, const char *source, const char *fileName, BNPlatform *platform, const BNQualifiedNameTypeAndId *existingTypes, size_t existingTypeCount, const char *const *options, size_t optionCount, const char *const *includeDirs, size_t includeDirCount, char **output, BNTypeParserError **errors, size_t *errorCount)
 
static bool ParseTypesFromSourceCallback (void *ctxt, const char *source, const char *fileName, BNPlatform *platform, const BNQualifiedNameTypeAndId *existingTypes, size_t existingTypeCount, const char *const *options, size_t optionCount, const char *const *includeDirs, size_t includeDirCount, const char *autoTypeSource, BNTypeParserResult *result, BNTypeParserError **errors, size_t *errorCount)
 
static bool ParseTypeStringCallback (void *ctxt, const char *source, BNPlatform *platform, const BNQualifiedNameTypeAndId *existingTypes, size_t existingTypeCount, BNQualifiedNameAndType *result, BNTypeParserError **errors, size_t *errorCount)
 
static void FreeStringCallback (void *ctxt, char *result)
 
static void FreeResultCallback (void *ctxt, BNTypeParserResult *result)
 
static void FreeErrorListCallback (void *ctxt, BNTypeParserError *errors, size_t errorCount)
 

Additional Inherited Members

- Public Attributes inherited from BinaryNinja::StaticCoreRefCountObject< BNTypeParser >
std::atomic< int > m_refs
 
BNTypeParser * m_object
 

Constructor & Destructor Documentation

◆ TypeParser() [1/2]

BinaryNinja::TypeParser::TypeParser ( const std::string &  name)
explicitprotected

◆ TypeParser() [2/2]

TypeParser::TypeParser ( BNTypeParser *  parser)
protected

Member Function Documentation

◆ FreeErrorListCallback()

void TypeParser::FreeErrorListCallback ( void *  ctxt,
BNTypeParserError errors,
size_t  errorCount 
)
staticprotected

◆ FreeResultCallback()

void TypeParser::FreeResultCallback ( void *  ctxt,
BNTypeParserResult result 
)
staticprotected

◆ FreeStringCallback()

void TypeParser::FreeStringCallback ( void *  ctxt,
char *  result 
)
staticprotected

◆ GetByName()

Ref< TypeParser > TypeParser::GetByName ( const std::string &  name)
static

◆ GetDefault()

Ref< TypeParser > TypeParser::GetDefault ( )
static

◆ GetList()

vector< Ref< TypeParser > > TypeParser::GetList ( )
static

◆ ParseTypesFromSource()

virtual bool BinaryNinja::TypeParser::ParseTypesFromSource ( const std::string &  source,
const std::string &  fileName,
Ref< Platform platform,
const std::map< QualifiedName, TypeAndId > &  existingTypes,
const std::vector< std::string > &  options,
const std::vector< std::string > &  includeDirs,
const std::string &  autoTypeSource,
TypeParserResult result,
std::vector< TypeParserError > &  errors 
)
pure virtual

Parse an entire block of source into types, variables, and functions.

Parameters
sourceSource code to parse
fileNameName of the file containing the source (optional: exists on disk)
platformPlatform to assume the types are relevant to
existingTypesMap of all existing types to use for parsing context
optionsString arguments to pass as options, e.g. command line arguments
includeDirsList of directories to include in the header search path
autoTypeSourceOptional source of types if used for automatically generated types
resultReference to structure into which the results will be written
errorsReference to a list into which any parse errors will be written
Returns
True if parsing was successful

Implemented in BinaryNinja::CoreTypeParser.

◆ ParseTypesFromSourceCallback()

bool TypeParser::ParseTypesFromSourceCallback ( void *  ctxt,
const char *  source,
const char *  fileName,
BNPlatform *  platform,
const BNQualifiedNameTypeAndId existingTypes,
size_t  existingTypeCount,
const char *const *  options,
size_t  optionCount,
const char *const *  includeDirs,
size_t  includeDirCount,
const char *  autoTypeSource,
BNTypeParserResult result,
BNTypeParserError **  errors,
size_t *  errorCount 
)
staticprotected

◆ ParseTypeString()

virtual bool BinaryNinja::TypeParser::ParseTypeString ( const std::string &  source,
Ref< Platform platform,
const std::map< QualifiedName, TypeAndId > &  existingTypes,
QualifiedNameAndType result,
std::vector< TypeParserError > &  errors 
)
pure virtual

Parse a single type and name from a string containing their definition.

Parameters
sourceSource code to parse
platformPlatform to assume the types are relevant to
existingTypesMap of all existing types to use for parsing context
resultReference into which the resulting type and name will be written
errorsReference to a list into which any parse errors will be written
Returns
True if parsing was successful

Implemented in BinaryNinja::CoreTypeParser.

◆ ParseTypeStringCallback()

bool TypeParser::ParseTypeStringCallback ( void *  ctxt,
const char *  source,
BNPlatform *  platform,
const BNQualifiedNameTypeAndId existingTypes,
size_t  existingTypeCount,
BNQualifiedNameAndType result,
BNTypeParserError **  errors,
size_t *  errorCount 
)
staticprotected

◆ PreprocessSource()

virtual bool BinaryNinja::TypeParser::PreprocessSource ( const std::string &  source,
const std::string &  fileName,
Ref< Platform platform,
const std::map< QualifiedName, TypeAndId > &  existingTypes,
const std::vector< std::string > &  options,
const std::vector< std::string > &  includeDirs,
std::string &  output,
std::vector< TypeParserError > &  errors 
)
pure virtual

Preprocess a block of source, returning the source that would be parsed.

Parameters
sourceSource code to process
fileNameName of the file containing the source (does not need to exist on disk)
platformPlatform to assume the source is relevant to
existingTypesMap of all existing types to use for parsing context
optionsString arguments to pass as options, e.g. command line arguments
includeDirsList of directories to include in the header search path
outputReference to a string into which the preprocessed source will be written
errorsReference to a list into which any parse errors will be written
Returns
True if preprocessing was successful

Implemented in BinaryNinja::CoreTypeParser.

◆ PreprocessSourceCallback()

bool TypeParser::PreprocessSourceCallback ( void *  ctxt,
const char *  source,
const char *  fileName,
BNPlatform *  platform,
const BNQualifiedNameTypeAndId existingTypes,
size_t  existingTypeCount,
const char *const *  options,
size_t  optionCount,
const char *const *  includeDirs,
size_t  includeDirCount,
char **  output,
BNTypeParserError **  errors,
size_t *  errorCount 
)
staticprotected

◆ Register()

void TypeParser::Register ( TypeParser parser)
static

The documentation for this class was generated from the following files: