Lines Matching +full:copy +full:- +full:item

34 /// A trait to get the canonical name from an item.
45 /// Get the canonical name for this item.
46 fn canonical_name(&self, ctx: &BindgenContext) -> String; in canonical_name()
49 /// The same, but specifies the path that needs to be followed to reach an item.
62 /// Get the namespace-aware canonical path for this item. This means that if
63 /// namespaces are disabled, you'll get a single item, and otherwise you get
68 ) -> Vec<String>; in namespace_aware_canonical_path()
70 /// Get the canonical path for this item.
71 fn canonical_path(&self, ctx: &BindgenContext) -> Vec<String>; in canonical_path()
82 fn is_opaque(&self, ctx: &BindgenContext, extra: &Self::Extra) -> bool; in is_opaque()
88 fn has_type_param_in_array(&self, ctx: &BindgenContext) -> bool; in has_type_param_in_array()
94 fn has_float(&self, ctx: &BindgenContext) -> bool; in has_float()
97 /// A trait for iterating over an item and its parents and up its ancestor chain
100 /// Get an iterable over this item's ancestors.
101 fn ancestors<'a>(&self, ctx: &'a BindgenContext) -> ItemAncestorsIter<'a>; in ancestors()
112 fn new() -> Self { in new()
116 fn contains(&self, _id: &ItemId) -> bool { in contains()
123 /// An iterator over an item and its ancestors.
125 item: ItemId, field
131 fn new<Id: Into<ItemId>>(ctx: &'a BindgenContext, id: Id) -> Self { in new()
133 item: id.into(), in new()
141 type Item = ItemId; typedef
143 fn next(&mut self) -> Option<Self::Item> { in next() argument
144 let item = self.ctx.resolve_item(self.item); in next() localVariable
146 if item.parent_id() == self.item { in next()
149 self.item = item.parent_id(); in next()
151 extra_assert!(!self.seen.contains(&item.id())); in next()
152 self.seen.insert(item.id()); in next()
154 Some(item.id()) in next()
161 T: Copy + Into<ItemId>,
169 ) -> Option<TypeId> { in as_template_param()
174 impl AsTemplateParam for Item { implementation
181 ) -> Option<TypeId> { in as_template_param()
187 type Extra = Item;
192 item: &Item, in as_template_param() argument
193 ) -> Option<TypeId> { in as_template_param()
195 ItemKind::Type(ref ty) => ty.as_template_param(ctx, item), in as_template_param()
205 T: Copy + Into<ItemId>,
207 fn canonical_name(&self, ctx: &BindgenContext) -> String { in canonical_name()
218 T: Copy + Into<ItemId>,
223 ) -> Vec<String> { in namespace_aware_canonical_path()
231 fn canonical_path(&self, ctx: &BindgenContext) -> Vec<String> { in canonical_path()
242 T: Copy + Into<ItemId>,
244 fn ancestors<'a>(&self, ctx: &'a BindgenContext) -> ItemAncestorsIter<'a> { in ancestors()
249 impl ItemAncestors for Item { implementation
250 fn ancestors<'a>(&self, ctx: &'a BindgenContext) -> ItemAncestorsIter<'a> { in ancestors()
257 Id: Copy + Into<ItemId>,
269 impl Trace for Item { implementation
276 // Even if this item is blocklisted/hidden, we want to trace it. It is in trace()
303 // Module -> children edges are "weak", and we do not want to in trace()
308 // TODO: make a new edge kind for module -> children edges and in trace()
315 impl CanDeriveDebug for Item { implementation
316 fn can_derive_debug(&self, ctx: &BindgenContext) -> bool { in can_derive_debug()
321 impl CanDeriveDefault for Item { implementation
322 fn can_derive_default(&self, ctx: &BindgenContext) -> bool { in can_derive_default()
327 impl CanDeriveCopy for Item { implementation
328 fn can_derive_copy(&self, ctx: &BindgenContext) -> bool { in can_derive_copy()
333 impl CanDeriveHash for Item { implementation
334 fn can_derive_hash(&self, ctx: &BindgenContext) -> bool { in can_derive_hash()
339 impl CanDerivePartialOrd for Item { implementation
340 fn can_derive_partialord(&self, ctx: &BindgenContext) -> bool { in can_derive_partialord()
345 impl CanDerivePartialEq for Item { implementation
346 fn can_derive_partialeq(&self, ctx: &BindgenContext) -> bool { in can_derive_partialeq()
351 impl CanDeriveEq for Item { implementation
352 fn can_derive_eq(&self, ctx: &BindgenContext) -> bool { in can_derive_eq()
357 impl CanDeriveOrd for Item { implementation
358 fn can_derive_ord(&self, ctx: &BindgenContext) -> bool { in can_derive_ord()
363 /// An item is the base of the bindgen representation, it can be either a
367 /// Items refer to each other by `ItemId`. Every item has its parent's
368 /// id. Depending on the kind of item this is, it may also refer to other items,
369 /// such as a compound type item referring to other types. Collectively, these
372 /// The entry-point to this graph is the "root module": a meta-item used to hold
373 /// all top-level items.
375 /// An item may have a comment, and annotations (see the `annotations` module).
378 /// all of them apply to every item. Those rules are described in the
381 pub struct Item { struct
382 /// This item's id.
385 /// The item's local id, unique only amongst its siblings. Only used for
397 /// A cached copy of the canonical name, as returned by `canonical_name`.
403 /// The path to use for allowlisting and other name-based checks, as
407 /// A doc comment over the item, if any.
412 /// An item's parent id. This will most likely be a class where this item
418 /// The item kind.
422 impl AsRef<ItemId> for Item { argument
423 fn as_ref(&self) -> &ItemId { in as_ref()
428 impl Item { impl
429 /// Construct a new `Item`.
436 ) -> Self { in new()
438 Item { in new()
451 /// Construct a new opaque item type.
456 ) -> TypeId { in new_opaque_type()
460 ctx.add_item(Item::new(with_id, None, None, parent, kind), None, None); in new_opaque_type()
464 /// Get this `Item`'s identifier.
465 pub fn id(&self) -> ItemId { in id()
469 /// Get this `Item`'s parent's identifier.
472 pub fn parent_id(&self) -> ItemId { in parent_id()
476 /// Set this item's parent id.
483 /// Returns the depth this item is indented to.
486 pub fn codegen_depth(&self, ctx: &BindgenContext) -> usize { in codegen_depth()
502 /// Get this `Item`'s comment, if it has any, already preprocessed and with
504 pub fn comment(&self, ctx: &BindgenContext) -> Option<String> { in comment()
514 /// What kind of item is this?
515 pub fn kind(&self) -> &ItemKind { in kind()
519 /// Get a mutable reference to this item's kind.
520 pub fn kind_mut(&mut self) -> &mut ItemKind { in kind_mut()
524 /// Get an identifier that differentiates this item from its siblings.
527 /// below this item's lexical scope, meaning that this can be useful for
529 pub fn local_id(&self, ctx: &BindgenContext) -> usize { in local_id()
536 /// Get an identifier that differentiates a child of this item of other
542 pub fn next_child_local_id(&self) -> usize { in next_child_local_id()
548 /// Returns whether this item is a top-level item, from the point of view of
560 /// `var` would be a toplevel item if namespaces are disabled, but won't if
564 /// `codegen` on an item, since any item that is not top-level will be
566 pub fn is_toplevel(&self, ctx: &BindgenContext) -> bool { in is_toplevel()
579 Some(item) => item, in is_toplevel()
595 /// Get a reference to this item's underlying `Type`. Panic if this is some
596 /// other kind of item.
597 pub fn expect_type(&self) -> &Type { in expect_type()
601 /// Get a reference to this item's underlying `Type`, or `None` if this is
602 /// some other kind of item.
603 pub fn as_type(&self) -> Option<&Type> { in as_type()
607 /// Get a reference to this item's underlying `Function`. Panic if this is
608 /// some other kind of item.
609 pub fn expect_function(&self) -> &Function { in expect_function()
613 /// Is this item a module?
614 pub fn is_module(&self) -> bool { in is_module()
621 /// Get this item's annotations.
622 pub fn annotations(&self) -> &Annotations { in annotations()
626 /// Whether this item should be blocklisted.
629 pub fn is_blocklisted(&self, ctx: &BindgenContext) -> bool { in is_blocklisted()
655 pub fn is_type_ref(&self) -> bool { in is_type_ref()
659 /// Is this item a var type?
660 pub fn is_var(&self) -> bool { in is_var()
667 /// Take out item NameOptions
668 pub fn name<'a>(&'a self, ctx: &'a BindgenContext) -> NameOptions<'a> { in name()
672 /// Get the target item id for name generation.
673 fn name_target(&self, ctx: &BindgenContext) -> ItemId { in name_target()
675 let mut item = self; in name_target() localVariable
678 extra_assert!(!targets_seen.contains(&item.id())); in name_target()
679 targets_seen.insert(item.id()); in name_target()
685 match *item.kind() { in name_target()
688 item = ctx.resolve_item(inner); in name_target()
691 item = ctx.resolve_item(inst.template_definition()); in name_target()
693 _ => return item.id(), in name_target()
695 _ => return item.id(), in name_target()
700 /// Create a fully disambiguated name for an item, including template
702 pub fn full_disambiguated_name(&self, ctx: &BindgenContext) -> String { in full_disambiguated_name()
732 /// Get this function item's name, or `None` if this item is not a function.
733 fn func_name(&self) -> Option<&str> { in func_name()
742 fn overload_index(&self, ctx: &BindgenContext) -> Option<usize> { in overload_index()
757 let item = ctx.resolve_item(m.signature()); in overload_index() localVariable
758 let func = item.expect_function(); in overload_index()
770 /// Get this item's base name (aka non-namespaced name).
771 fn base_name(&self, ctx: &BindgenContext) -> String { in base_name()
802 fn is_anon(&self) -> bool { in is_anon()
824 /// name is the inner most non-anonymous name plus all the anonymous base names
830 ) -> String { in real_canonical_name()
833 // Short-circuit if the target has an override, and just use that. in real_canonical_name()
855 // Stop iterating ancestors once we reach a non-inline namespace in real_canonical_name()
890 // Concatenate this item's ancestors' names together. in real_canonical_name()
894 let item = ctx.resolve_item(id); in real_canonical_name() localVariable
895 let target = ctx.resolve_item(item.name_target(ctx)); in real_canonical_name()
921 /// given item.
922 pub fn exposed_id(&self, ctx: &BindgenContext) -> String { in exposed_id()
936 // between the global id and the local id of an item with the same in exposed_id()
941 /// Get a reference to this item's `Module`, or `None` if this is not a
942 /// `Module` item.
943 pub fn as_module(&self) -> Option<&Module> { in as_module()
950 /// Get a mutable reference to this item's `Module`, or `None` if this is
951 /// not a `Module` item.
952 pub fn as_module_mut(&mut self) -> Option<&mut Module> { in as_module_mut()
959 /// Returns whether the item is a constified module enum
960 fn is_constified_enum_module(&self, ctx: &BindgenContext) -> bool { in is_constified_enum_module()
963 let item = self.id.into_resolver().through_type_refs().resolve(ctx); in is_constified_enum_module() localVariable
964 let type_ = match *item.kind() { in is_constified_enum_module()
978 let name = item.canonical_name(ctx); in is_constified_enum_module()
990 /// Is this item of a kind that is enabled for code generation?
991 pub fn is_enabled_for_codegen(&self, ctx: &BindgenContext) -> bool { in is_enabled_for_codegen()
1016 /// doesn't include user-mangling.
1017 pub fn path_for_allowlisting(&self, ctx: &BindgenContext) -> &Vec<String> { in path_for_allowlisting()
1026 ) -> Vec<String> { in compute_path()
1039 .filter(|item| { in compute_path()
1040 item.id() == target.id() || in compute_path()
1041 item.as_module().map_or(false, |module| { in compute_path()
1046 .map(|item| { in compute_path()
1047 ctx.resolve_item(item.name_target(ctx)) in compute_path()
1061 T: Copy + Into<ItemId>,
1065 fn is_opaque(&self, ctx: &BindgenContext, _: &()) -> bool { in is_opaque()
1074 impl IsOpaque for Item { implementation
1077 fn is_opaque(&self, ctx: &BindgenContext, _: &()) -> bool { in is_opaque()
1090 T: Copy + Into<ItemId>,
1092 fn has_vtable(&self, ctx: &BindgenContext) -> bool { in has_vtable()
1101 fn has_vtable_ptr(&self, ctx: &BindgenContext) -> bool { in has_vtable_ptr()
1111 impl HasVtable for Item { implementation
1112 fn has_vtable(&self, ctx: &BindgenContext) -> bool { in has_vtable()
1116 fn has_vtable_ptr(&self, ctx: &BindgenContext) -> bool { in has_vtable_ptr()
1123 T: Copy + Into<ItemId>,
1125 fn sizedness(&self, ctx: &BindgenContext) -> SizednessResult { in sizedness()
1132 impl Sizedness for Item { implementation
1133 fn sizedness(&self, ctx: &BindgenContext) -> SizednessResult { in sizedness()
1140 T: Copy + Into<ItemId>,
1142 fn has_type_param_in_array(&self, ctx: &BindgenContext) -> bool { in has_type_param_in_array()
1151 impl HasTypeParamInArray for Item { implementation
1152 fn has_type_param_in_array(&self, ctx: &BindgenContext) -> bool { in has_type_param_in_array()
1163 T: Copy + Into<ItemId>,
1165 fn has_float(&self, ctx: &BindgenContext) -> bool { in has_float()
1174 impl HasFloat for Item { implementation
1175 fn has_float(&self, ctx: &BindgenContext) -> bool { in has_float()
1187 impl DotAttributes for Item { implementation
1192 ) -> io::Result<()> in dot_attributes()
1214 T: Copy + Into<ItemId>,
1216 fn self_template_params(&self, ctx: &BindgenContext) -> Vec<TypeId> { in self_template_params()
1218 .map_or(vec![], |item| item.self_template_params(ctx)) in self_template_params()
1222 impl TemplateParameters for Item { implementation
1223 fn self_template_params(&self, ctx: &BindgenContext) -> Vec<TypeId> { in self_template_params()
1229 fn self_template_params(&self, ctx: &BindgenContext) -> Vec<TypeId> { in self_template_params()
1250 ) -> clang_sys::CXChildVisitResult { in visit_child()
1256 *result = Item::from_ty_with_id(id, ty, cur, parent_id, ctx); in visit_child()
1268 impl ClangItemParser for Item { implementation
1273 ) -> TypeId { in builtin_type()
1287 Item::new(id, None, None, module, ItemKind::Type(ty)), in builtin_type()
1298 ) -> Result<ItemId, ParseError> { in parse()
1315 Ok(ParseResult::New(item, declaration)) => { in parse()
1319 Item::new( in parse()
1324 ItemKind::$what(item), in parse()
1362 return Ok(Item::from_ty_or_ref( in parse()
1377 match Item::from_ty( in parse()
1446 ) -> TypeId { in from_ty_or_ref()
1467 ) -> TypeId { in from_ty_or_ref_with_id()
1475 return Item::from_ty_with_id( in from_ty_or_ref_with_id()
1482 .unwrap_or_else(|_| Item::new_opaque_type(potential_id, &ty, ctx)); in from_ty_or_ref_with_id()
1502 Item::new( in from_ty_or_ref_with_id()
1520 ) -> Result<TypeId, ParseError> { in from_ty()
1522 Item::from_ty_with_id(id, ty, location, parent_id, ctx) in from_ty()
1530 /// critical some times to obtain information, an optional parent item id,
1539 ) -> Result<TypeId, ParseError> { in from_ty_with_id()
1543 "Item::from_ty_with_id: {:?}\n\ in from_ty_with_id()
1555 return Ok(Item::new_opaque_type(id, ty, ctx)); in from_ty_with_id()
1558 if let Some(param_id) = Item::type_param(None, location, ctx) { in from_ty_with_id()
1619 Ok(ParseResult::New(item, declaration)) => { in from_ty_with_id()
1621 Item::new( in from_ty_with_id()
1626 ItemKind::Type(item), in from_ty_with_id()
1635 debug!("Item::from_ty recursing in the ast"); in from_ty_with_id()
1670 Item::type_param(Some(id), location, ctx) in from_ty_with_id()
1694 ) -> Option<TypeId> { in type_param()
1698 "Item::type_param:\n\ in type_param()
1759 // "type-parameter-x-y". That is probably a better approach long-term, in type_param()
1761 // the whole libclang -> IR parsing code. in type_param()
1766 ) -> bool { in type_param()
1769 regex::Regex::new(r"^type\-parameter\-\d+\-\d+$").unwrap(); in type_param()
1853 let item = Item::new( in type_param() localVariable
1860 ctx.add_type_param(item, definition); in type_param()
1865 impl ItemCanonicalName for Item { implementation
1866 fn canonical_name(&self, ctx: &BindgenContext) -> String { in canonical_name()
1886 impl ItemCanonicalPath for Item { implementation
1890 ) -> Vec<String> { in namespace_aware_canonical_path()
1897 // Only keep the last item in path in namespace_aware_canonical_path()
1898 let split_idx = path.len() - 1; in namespace_aware_canonical_path()
1901 // Ignore first item "root" in namespace_aware_canonical_path()
1912 fn canonical_path(&self, ctx: &BindgenContext) -> Vec<String> { in canonical_path()
1917 /// Whether to use the user-mangled name (mangled by the `item_name` callback or
1922 #[derive(Copy, Clone, Debug, PartialEq)]
1932 item: &'a Item, field
1940 pub fn new(item: &'a Item, ctx: &'a BindgenContext) -> Self { in new() argument
1942 item: item, in new()
1949 /// Construct the name without the item's containing C++ namespaces mangled
1950 /// into it. In other words, the item's name within the item's namespace.
1951 pub fn within_namespaces(&mut self) -> &mut Self { in within_namespaces()
1956 fn user_mangled(&mut self, user_mangled: UserMangled) -> &mut Self { in user_mangled()
1962 pub fn get(&self) -> String { in get()
1963 self.item.real_canonical_name(self.ctx, self) in get()