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§
sourcefn get_option_text(
&self,
option: TypeParserOption,
value: &str,
) -> Option<String>
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 typevalue
- Option value
sourcefn preprocess_source(
&self,
source: &str,
file_name: &str,
platform: &Platform,
existing_types: &TypeContainer,
options: &[String],
include_dirs: &[String],
) -> Result<String, Vec<TypeParserError>>
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 processfile_name
- Name of the file containing the source (does not need to exist on disk)platform
- Platform to assume the source is relevant toexisting_types
- Optional collection of all existing types to use for parsing contextoptions
- Optional string arguments to pass as options, e.g. command line argumentsinclude_dirs
- Optional list of directories to include in the header search path
sourcefn 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_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 parsefile_name
- Name of the file containing the source (optional: exists on disk)platform
- Platform to assume the types are relevant toexisting_types
- Optional container of all existing types to use for parsing contextoptions
- Optional string arguments to pass as options, e.g. command line argumentsinclude_dirs
- Optional list of directories to include in the header search pathauto_type_source
- Optional source of types if used for automatically generated types
sourcefn parse_type_string(
&self,
source: &str,
platform: &Platform,
existing_types: &TypeContainer,
) -> Result<QualifiedNameAndType, Vec<TypeParserError>>
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 parseplatform
- Platform to assume the types are relevant toexisting_types
- Optional container of all existing types to use for parsing context