Preprocessor

Struct Preprocessor 

Source
pub struct Preprocessor { /* private fields */ }
Expand description

The main C preprocessor struct

Implementations§

Source§

impl Preprocessor

Source

pub fn new() -> Self

Create a new preprocessor instance

Source

pub fn with_config(config: &PreprocessorConfig) -> Self

Create a preprocessor with the given configuration

Source

pub fn apply_config(&mut self, config: &PreprocessorConfig)

Apply configuration to the preprocessor

Source

pub fn with_include_resolver<F>(self, f: F) -> Self
where F: Fn(&str) -> Option<String> + 'static,

Add a custom include resolver function

Source

pub fn set_recursion_limit(&mut self, limit: usize)

Set the maximum recursion depth for macro expansion

Source

pub fn set_current_file(&mut self, file: String)

Set the current file name for error reporting

Source

pub fn define<S: AsRef<str>>( &mut self, name: S, params: Option<Vec<String>>, body: S, is_variadic: bool, )

Define a preprocessor macro

Source

pub fn undef(&mut self, name: &str)

Remove a macro definition

Source

pub fn get_macros(&self) -> &HashMap<String, Macro>

Get a reference to the defined macros

Source

pub fn is_defined(&self, name: &str) -> bool

Check if a macro is defined

Source

pub fn process(&mut self, input: &str) -> Result<String, PreprocessError>

Process the input C code and return the preprocessed result

§Errors

Returns PreprocessError if there’s a malformed directive, macro recursion limit is exceeded, or conditional blocks are unterminated.

Source

pub fn parse_expression(&self, expr: &str) -> Result<bool, PreprocessError>

Parse a preprocessor expression with full operator support

§Errors

Returns PreprocessError if the expression is malformed or has invalid operators.

Trait Implementations§

Source§

impl Default for Preprocessor

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.