pub struct FileModel {
pub path: PathBuf,
pub top_level_items: Vec<TopLevelItem>,
pub source: 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: Vec<u8>The raw source code of this file - available for detailed pattern matching
Implementations§
Source§impl FileModel
impl FileModel
pub fn new(path: PathBuf) -> Self
Sourcepub fn iter_all_includes(
&self,
) -> impl Iterator<Item = (&str, bool, SourceLocation)> + '_
pub fn iter_all_includes( &self, ) -> impl Iterator<Item = (&str, bool, SourceLocation)> + '_
Iterate through all includes in the file (including those in #ifdef blocks)
Sourcepub fn iter_function_definitions(
&self,
) -> impl Iterator<Item = &FunctionDefItem> + '_
pub fn iter_function_definitions( &self, ) -> impl Iterator<Item = &FunctionDefItem> + '_
Iterate through all function definitions in the file (including those in #ifdef blocks)
Sourcepub fn iter_class_init_functions(
&self,
) -> impl Iterator<Item = &FunctionDefItem> + '_
pub fn iter_class_init_functions( &self, ) -> impl Iterator<Item = &FunctionDefItem> + '_
Iterate through class_init functions
Sourcepub fn iter_function_declarations(
&self,
) -> impl Iterator<Item = &FunctionDeclItem> + '_
pub fn iter_function_declarations( &self, ) -> impl Iterator<Item = &FunctionDeclItem> + '_
Iterate through all function declarations in the file (including those in #ifdef blocks)
Sourcepub fn iter_all_function_names(&self) -> impl Iterator<Item = &str> + '_
pub fn iter_all_function_names(&self) -> impl Iterator<Item = &str> + '_
Iterate through all functions (both declarations and definitions), returning function names
Sourcepub fn iter_all_gobject_types(&self) -> impl Iterator<Item = &GObjectType> + '_
pub fn iter_all_gobject_types(&self) -> impl Iterator<Item = &GObjectType> + '_
Iterate through all GObject type declarations (including those in #ifdef blocks)
Sourcepub fn find_class_struct_for(
&self,
gobject_type: &GObjectType,
) -> Option<&TypeDefItem>
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.
Sourcepub fn iter_class_structs(&self) -> impl Iterator<Item = &TypeDefItem> + '_
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).
Sourcepub fn iter_comments(&self) -> impl Iterator<Item = &Comment> + '_
pub fn iter_comments(&self) -> impl Iterator<Item = &Comment> + '_
Iterate through all standalone comments (including those in #ifdef blocks)
Sourcepub fn iter_all_enums(&self) -> impl Iterator<Item = &EnumInfo> + '_
pub fn iter_all_enums(&self) -> impl Iterator<Item = &EnumInfo> + '_
Iterate through all enum definitions (including those in #ifdef blocks)
Sourcepub fn iter_property_enums(&self) -> impl Iterator<Item = &EnumInfo> + '_
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
Sourcepub fn find_gobject_type_for_signal_enum(
&self,
enum_info: &EnumInfo,
) -> Option<&GObjectType>
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.
Sourcepub fn find_typed_arrays(
&self,
base_type: &str,
is_pointer: bool,
sentinel_name: Option<&str>,
) -> Vec<&VariableDecl>
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"))findsGParamSpec *props[N_PROPS]find_typed_arrays("GParamSpec", true, None)finds ALLGParamSpec *[]arraysfind_typed_arrays("guint", false, Some("N_SIGNALS"))findsguint signals[N_SIGNALS]
Sourcepub fn find_gobject_type_for_property_enum(
&self,
enum_info: &EnumInfo,
) -> Option<&GObjectType>
pub fn find_gobject_type_for_property_enum( &self, enum_info: &EnumInfo, ) -> Option<&GObjectType>
Find the GObjectType whose properties match the given property enum.
Sourcepub fn iter_all_items(&self) -> impl Iterator<Item = &TopLevelItem> + '_
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.
Sourcepub fn iter_typedef_pairs(&self) -> impl Iterator<Item = (&str, &TypeInfo)> + '_
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.
Sourcepub fn resolve_gobject_types(&mut self)
pub fn resolve_gobject_types(&mut self)
Populate properties and signals on each GObjectType by finding
the matching *_class_init function and extracting param_spec
assignments and signal registrations from it.