Sha256: fce3616e0464aa7414888e5d00d4df18c83bb3034a1c807d36a07a3c586e475a

Contents?: true

Size: 1.47 KB

Versions: 31

Compression:

Stored size: 1.47 KB

Contents

//! Common traits and types related to parsing our IR from Clang cursors.
#![deny(clippy::missing_docs_in_private_items)]

use crate::clang;
use crate::ir::context::{BindgenContext, ItemId};

/// Not so much an error in the traditional sense, but a control flow message
/// when walking over Clang's AST with a cursor.
#[derive(Debug)]
pub(crate) enum ParseError {
    /// Recurse down the current AST node's children.
    Recurse,
    /// Continue on to the next sibling AST node, or back up to the parent's
    /// siblings if we've exhausted all of this node's siblings (and so on).
    Continue,
}

/// The result of parsing a Clang AST node.
#[derive(Debug)]
pub(crate) enum ParseResult<T> {
    /// We've already resolved this item before, here is the extant `ItemId` for
    /// it.
    AlreadyResolved(ItemId),

    /// This is a newly parsed item. If the cursor is `Some`, it points to the
    /// AST node where the new `T` was declared.
    New(T, Option<clang::Cursor>),
}

/// An intermediate representation "sub-item" (i.e. one of the types contained
/// inside an `ItemKind` variant) that can be parsed from a Clang cursor.
pub(crate) trait ClangSubItemParser: Sized {
    /// Attempt to parse this type from the given cursor.
    ///
    /// The fact that is a reference guarantees it's held by the context, and
    /// allow returning already existing types.
    fn parse(
        cursor: clang::Cursor,
        context: &mut BindgenContext,
    ) -> Result<ParseResult<Self>, ParseError>;
}

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
wasmtime-30.0.2 ./ext/cargo-vendor/bindgen-0.69.5/parse.rs
wasmtime-29.0.0 ./ext/cargo-vendor/bindgen-0.69.5/parse.rs
wasmtime-28.0.0 ./ext/cargo-vendor/bindgen-0.69.5/parse.rs
wasmtime-27.0.0 ./ext/cargo-vendor/bindgen-0.69.5/parse.rs
wasmtime-26.0.0 ./ext/cargo-vendor/bindgen-0.69.5/parse.rs
wasmtime-25.0.2 ./ext/cargo-vendor/bindgen-0.69.4/parse.rs
wasmtime-25.0.1 ./ext/cargo-vendor/bindgen-0.69.4/parse.rs
wasmtime-25.0.0 ./ext/cargo-vendor/bindgen-0.69.4/parse.rs
wasmtime-24.0.0 ./ext/cargo-vendor/bindgen-0.69.4/parse.rs
wasmtime-23.0.2 ./ext/cargo-vendor/bindgen-0.69.1/parse.rs
wasmtime-22.0.0 ./ext/cargo-vendor/bindgen-0.69.1/parse.rs
wasmtime-21.0.1 ./ext/cargo-vendor/bindgen-0.69.1/parse.rs
wasmtime-20.0.2 ./ext/cargo-vendor/bindgen-0.69.1/parse.rs
wasmtime-20.0.0 ./ext/cargo-vendor/bindgen-0.69.1/parse.rs
wasmtime-18.0.3 ./ext/cargo-vendor/bindgen-0.69.1/parse.rs
wasmtime-17.0.1 ./ext/cargo-vendor/bindgen-0.69.1/parse.rs
wasmtime-17.0.0 ./ext/cargo-vendor/bindgen-0.69.1/parse.rs
wasmtime-16.0.0 ./ext/cargo-vendor/bindgen-0.69.1/parse.rs
wasmtime-15.0.1 ./ext/cargo-vendor/bindgen-0.69.1/parse.rs
wasmtime-15.0.0 ./ext/cargo-vendor/bindgen-0.69.1/parse.rs