Skip to main content

FileModel

Struct FileModel 

Source
pub struct FileModel {
    pub path: PathBuf,
    pub top_level_items: Vec<TopLevelItem>,
    pub source: Arc<Vec<u8>>,
}
Expand description

Model of a single file (header or C file)

Fields§

§path: PathBuf§top_level_items: Vec<TopLevelItem>

Top-level items in source order (preserves structure like #ifdef blocks)

§source: Arc<Vec<u8>>

The raw source code of this file - available for detailed pattern matching

Implementations§

Source§

impl FileModel

Source

pub fn new(path: PathBuf) -> Self

Source

pub fn iter_all_includes( &self, ) -> impl Iterator<Item = (&str, bool, SourceLocation)> + '_

Iterate through all includes in the file (including those in #ifdef blocks)

Source

pub fn iter_function_definitions( &self, ) -> impl Iterator<Item = &FunctionDefItem> + '_

Iterate through all function definitions in the file (including those in #ifdef blocks)

Source

pub fn iter_class_init_functions( &self, ) -> impl Iterator<Item = &FunctionDefItem> + '_

Iterate through class_init functions

Source

pub fn iter_function_declarations( &self, ) -> impl Iterator<Item = &FunctionDeclItem> + '_

Iterate through all function declarations in the file (including those in #ifdef blocks)

Source

pub fn iter_all_function_names(&self) -> impl Iterator<Item = &str> + '_

Iterate through all functions (both declarations and definitions), returning function names

Source

pub fn iter_all_gobject_types(&self) -> impl Iterator<Item = &GObjectType> + '_

Iterate through all GObject type declarations (including those in #ifdef blocks)

Source

pub fn find_class_struct_for( &self, gobject_type: &GObjectType, ) -> Option<&TypeDefItem>

Find the class or interface struct for a given GObjectType. Returns None for final types (no class struct) and when the struct was not found in this file.

Source

pub fn iter_class_structs(&self) -> impl Iterator<Item = &TypeDefItem> + '_

Iterate through all class structs (structs ending with Class or Interface that have at least one vfunc).

Source

pub fn iter_defines( &self, ) -> impl Iterator<Item = (&str, Option<&DefineValue>)> + '_

Source

pub fn iter_comments(&self) -> impl Iterator<Item = &Comment> + '_

Iterate through all standalone comments (including those in #ifdef blocks)

Source

pub fn iter_all_enums(&self) -> impl Iterator<Item = &EnumInfo> + '_

Iterate through all enum definitions (including those in #ifdef blocks)

Source

pub fn iter_property_enums(&self) -> impl Iterator<Item = &EnumInfo> + '_

Iterate through property enums (enums that appear to define GObject properties) Filters for enums where first member starts with PROP_ or ends with _PROP_0

Source

pub fn find_gobject_type_for_signal_enum( &self, enum_info: &EnumInfo, ) -> Option<&GObjectType>

Find the GObjectType whose class_init installs signals from the given signal enum.

Source

pub fn find_typed_arrays( &self, base_type: &str, is_pointer: bool, sentinel_name: Option<&str>, ) -> Vec<&VariableDecl>

Find array declarations of a specific type, optionally filtered by sentinel

If sentinel_name is None, returns ALL arrays of that type.

Examples:

  • find_typed_arrays("GParamSpec", true, Some("N_PROPS")) finds GParamSpec *props[N_PROPS]
  • find_typed_arrays("GParamSpec", true, None) finds ALL GParamSpec *[] arrays
  • find_typed_arrays("guint", false, Some("N_SIGNALS")) finds guint signals[N_SIGNALS]
Source

pub fn find_gobject_type_for_property_enum( &self, enum_info: &EnumInfo, ) -> Option<&GObjectType>

Find the GObjectType whose properties match the given property enum.

Source

pub fn resolve_class_init_vfuncs<'a>( &'a self, gobject_type: &GObjectType, ) -> HashMap<(String, &'a str), &'a str>

Extract all vfunc assignments from a class_init function body. Returns a map of (class_type, field) → func_name, e.g. ("GObjectClass", "dispose") → "my_obj_dispose".

For klass->field = func, the class type is resolved from the class_init parameter type. For G_OBJECT_CLASS(klass)->field = func, it is derived from the cast macro name.

Source

pub fn resolve_property_enum_context( &self, enum_info: &EnumInfo, ) -> Option<PropertyEnumContext<'_>>

Source

pub fn iter_all_items(&self) -> impl Iterator<Item = &TopLevelItem> + '_

Iterate through all top-level items recursively (including items inside #ifdef/#if and G_BEGIN_DECLS blocks). Conditional container items themselves are also yielded before their children.

Source

pub fn has_declarations(&self) -> bool

Source

pub fn iter_typedef_pairs(&self) -> impl Iterator<Item = (&str, &TypeInfo)> + '_

Iterate typedef forward-alias declarations of the form typedef [struct|union] _Foo Foo (i.e., typedefs that have no inline struct body). Yields (typedef_name, target_TypeInfo) so callers can inspect target_type.base_type, .is_struct, and .is_union.

Source

pub fn resolve_gobject_types(&mut self, defines: &HashMap<String, DefineValue>)

Populate properties and signals on each GObjectType by finding the matching *_class_init function and extracting param_spec assignments and signal registrations from it.

Source

pub fn iter_all_items_with_parent( &self, ) -> impl Iterator<Item = (&TopLevelItem, Option<&TopLevelItem>)> + '_

Trait Implementations§

Source§

impl Clone for FileModel

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for FileModel

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_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§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more