Movatterモバイル変換


[0]ホーム

URL:


Docs.rs

StructParser

Source
pub struct Parser<'tu> {/* private fields */ }
Expand description

Parses translation units.

Implementations§

Source§

impl<'tu>Parser<'tu>

Source

pub fncache_completion_results( &mut self, cache_completion_results:bool,) -> &mutParser<'tu>

Sets whether certain code completion results will be cached when the translation unit isreparsed.

This option increases the time it takes to reparse the translation unit but improvescode completion performance.

Source

pub fndetailed_preprocessing_record( &mut self, detailed_preprocessing_record:bool,) -> &mutParser<'tu>

Sets whether a detailed preprocessing record will be constructed which tracks all macrodefinitions and instantiations.

Source

pub fnbriefs_in_completion_results( &mut self, briefs_in_completion_results:bool,) -> &mutParser<'tu>

Sets whether documentation comment briefs will be included in code completion results.

Source

pub fnincomplete(&mut self, incomplete:bool) -> &mutParser<'tu>

Sets whether the translation unit will be considered incomplete.

This option suppresses certain semantic analyses and is typically used when parsingheaders with the intent of creating a precompiled header.

Source

pub fnskip_function_bodies( &mut self, skip_function_bodies:bool,) -> &mutParser<'tu>

Sets whether function and method bodies will be skipped.

Source

pub fnkeep_going(&mut self, keep_going:bool) -> &mutParser<'tu>

Sets whether processing will continue after a fatal error is encountered.

Source

pub fnsingle_file_parse(&mut self, single_file_parse:bool) -> &mutParser<'tu>

Sets whether incremental processing will be used.

Source

pub fnlimit_skip_function_bodies_to_preamble( &mut self, limit_skip_function_bodies_to_preamble:bool,) -> &mutParser<'tu>

Sets whether function bodies will only be skipped in the preamble.

Used in conjunction withskip_function_bodies.

Source

pub fninclude_attributed_types( &mut self, include_attributed_types:bool,) -> &mutParser<'tu>

Sets whether attributed types should be included.

Source

pub fnvisit_implicit_attributes( &mut self, visit_implicit_attributes:bool,) -> &mutParser<'tu>

Sets whether implicit attributes should be visited.

Source

pub fnignore_non_errors_from_included_files( &mut self, ignore_non_errors_from_included_files:bool,) -> &mutParser<'tu>

Indicates that non-errors (e.g. warnings) from included files should be ignored.

Source

pub fnretain_excluded_conditional_blocks( &mut self, retain_excluded_conditional_blocks:bool,) -> &mutParser<'tu>

Sets whether the preprocessor will retain excluded conditional blocks.

Source§

impl<'tu>Parser<'tu>

Source

pub fnarguments<S:AsRef<str>>(&mut self, arguments: &[S]) -> &mutParser<'tu>

Sets the compiler arguments to provide tolibclang.

Any compiler argument that could be supplied toclang may be supplied to thisfunction. However, the following arguments are ignored:

  • -c
  • -emit-ast
  • -fsyntax-only
  • -o and the following<output>
Source

pub fnunsaved(&mut self, unsaved: &[Unsaved]) -> &mutParser<'tu>

Sets the unsaved files to use.

Source

pub fnparse(&self) ->Result<TranslationUnit<'tu>,SourceError>

Parses a translation unit.

§Failures
  • an error occurs while deserializing an AST file
  • libclang crashes
  • an unknown error occurs
Examples found in repository?
examples/structs.rs (line 13)
5fnmain() {6// Acquire an instance of `Clang`7letclang = Clang::new().unwrap();89// Create a new `Index`10letindex = Index::new(&clang,false,false);1112// Parse a source file into a translation unit13lettu = index.parser("examples/structs.c").parse().unwrap();1415// Get the structs in this translation unit16letstructs = tu.get_entity().get_children().into_iter().filter(|e| {17        e.get_kind() == EntityKind::StructDecl18    }).collect::<Vec<_>>();1920// Print information about the structs21forstruct_instructs {22lettype_ =  struct_.get_type().unwrap();23letsize = type_.get_sizeof().unwrap();24println!("struct: {:?} (size: {} bytes)", struct_.get_name().unwrap(), size);2526forfieldinstruct_.get_children() {27letname = field.get_name().unwrap();28letoffset = type_.get_offsetof(&name).unwrap();29println!("    field: {:?} (offset: {} bits)", name, offset);30        }31    }32}

Trait Implementations§

Source§

impl<'tu>Clone forParser<'tu>

Source§

fnclone(&self) ->Parser<'tu>

Returns a duplicate of the value.Read more
1.0.0 ·Source§

fnclone_from(&mut self, source: &Self)

Performs copy-assignment fromsource.Read more
Source§

impl<'tu>Debug forParser<'tu>

Source§

fnfmt(&self, f: &mutFormatter<'_>) ->Result

Formats the value using the given formatter.Read more

Auto Trait Implementations§

§

impl<'tu>Freeze forParser<'tu>

§

impl<'tu>RefUnwindSafe forParser<'tu>

§

impl<'tu> !Send forParser<'tu>

§

impl<'tu> !Sync forParser<'tu>

§

impl<'tu>Unpin forParser<'tu>

§

impl<'tu>UnwindSafe forParser<'tu>

Blanket Implementations§

Source§

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

Source§

fntype_id(&self) ->TypeId

Gets theTypeId ofself.Read more
Source§

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

Source§

fnborrow(&self) ->&T

Immutably borrows from an owned value.Read more
Source§

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

Source§

fnborrow_mut(&mut self) ->&mut T

Mutably borrows from an owned value.Read more
Source§

impl<T>CloneToUninit for T
where T:Clone,

Source§

unsafe fnclone_to_uninit(&self, dest:*mutu8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment fromself todest.Read more
Source§

impl<T>From<T> for T

Source§

fnfrom(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fninto(self) -> U

CallsU::from(self).

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

Source§

impl<T>ToOwned for T
where T:Clone,

Source§

typeOwned = T

The resulting type after obtaining ownership.
Source§

fnto_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning.Read more
Source§

fnclone_into(&self, target:&mut T)

Uses borrowed data to replace owned data, usually by cloning.Read more
Source§

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

Source§

typeError =Infallible

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

fntry_from(value: U) ->Result<T, <T asTryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

typeError = <U asTryFrom<T>>::Error

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

fntry_into(self) ->Result<U, <U asTryFrom<T>>::Error>

Performs the conversion.

[8]ページ先頭

©2009-2025 Movatter.jp