reoxide 0.7.0

Rust-bindings for the ReOxide decompiler extension framework
Documentation
mod bindings;
mod enums;
mod opaque;
mod wrappers;
mod vectors;

use core::ptr::NonNull;
pub use enums::*;
pub use opaque::*;

/// We have the fields of the C++ implementation here only so that
/// the struct gets the correct size. They are protected in C++ and
/// therefore not accessable publicly anyways. However, this also
/// means we can write some of the functions in Rust instead of
/// having to call into C++.
#[repr(C)]
pub struct Address {
    base: Option<NonNull<AddrSpace>>,
    offset: u64,
}

impl Address {
    pub fn new(base: Option<&AddrSpace>, offset: u64) -> Address {
        Address { base: base.map(|a| a.into()), offset }
    }

    pub fn get_space(&self) -> Option<&AddrSpace> {
        // SAFETY: If it is non-zero, then the base pointer should
        // point to a heap allocated object on the C++ side, thus
        // being aligned. In the C++ code, this is actually a
        // mutable reference, but pretty much all functions on
        // AddrSpace are const.
        self.base.map(|p| unsafe { p.as_ref() })
    }
}

#[repr(C)]
pub struct CSEHashPair {
    pub hash: u32,
    pub op: NonNull<PcodeOp>
}

#[repr(C)]
pub struct PieceNode {
    op: NonNull<PcodeOp>,
    slot: i32,
    type_offset: i32,
    leaf: bool
}