binaryninja::type_parser

Trait TypeParser

source
pub trait TypeParser {
    // Required methods
    fn get_option_text(
        &self,
        option: TypeParserOption,
        value: &str,
    ) -> Option<String>;
    fn preprocess_source(
        &self,
        source: &str,
        file_name: &str,
        platform: &Platform,
        existing_types: &TypeContainer,
        options: &[String],
        include_dirs: &[String],
    ) -> Result<String, Vec<TypeParserError>>;
    fn parse_types_from_source(
        &self,
        source: &str,
        file_name: &str,
        platform: &Platform,
        existing_types: &TypeContainer,
        options: &[String],
        include_dirs: &[String],
        auto_type_source: &str,
    ) -> Result<TypeParserResult, Vec<TypeParserError>>;
    fn parse_type_string(
        &self,
        source: &str,
        platform: &Platform,
        existing_types: &TypeContainer,
    ) -> Result<QualifiedNameAndType, Vec<TypeParserError>>;
}

Required Methods§

source

fn get_option_text( &self, option: TypeParserOption, value: &str, ) -> Option<String>

Get the string representation of an option for passing to parse_type_*. Returns a string representing the option if the parser supports it, otherwise None

  • option - Option type
  • value - Option value
source

fn preprocess_source( &self, source: &str, file_name: &str, platform: &Platform, existing_types: &TypeContainer, options: &[String], include_dirs: &[String], ) -> Result<String, Vec<TypeParserError>>

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

  • source - Source code to process
  • file_name - Name of the file containing the source (does not need to exist on disk)
  • platform - Platform to assume the source is relevant to
  • existing_types - Optional collection of all existing types to use for parsing context
  • options - Optional string arguments to pass as options, e.g. command line arguments
  • include_dirs - Optional list of directories to include in the header search path
source

fn parse_types_from_source( &self, source: &str, file_name: &str, platform: &Platform, existing_types: &TypeContainer, options: &[String], include_dirs: &[String], auto_type_source: &str, ) -> Result<TypeParserResult, Vec<TypeParserError>>

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

  • source - Source code to parse
  • file_name - Name of the file containing the source (optional: exists on disk)
  • platform - Platform to assume the types are relevant to
  • existing_types - Optional container of all existing types to use for parsing context
  • options - Optional string arguments to pass as options, e.g. command line arguments
  • include_dirs - Optional list of directories to include in the header search path
  • auto_type_source - Optional source of types if used for automatically generated types
source

fn parse_type_string( &self, source: &str, platform: &Platform, existing_types: &TypeContainer, ) -> Result<QualifiedNameAndType, Vec<TypeParserError>>

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

  • source - Source code to parse
  • platform - Platform to assume the types are relevant to
  • existing_types - Optional container of all existing types to use for parsing context

Implementors§