pub struct FunctionHelperVirtual {
    pub function_name: String,
    pub generated_args: String,
    pub generated_function_body: Vec<String>,
    pub generated_virtual_function_signature: String,
    pub return_type: Option<WrapperType>,
    pub arg_names: Vec<String>,
    /* private fields */
}

Fields§

§function_name: String§generated_args: String§generated_function_body: Vec<String>§generated_virtual_function_signature: String§return_type: Option<WrapperType>§arg_names: Vec<String>

Implementations§

source§

impl FunctionHelperVirtual

source

pub fn from_virtual_function(function: &Function, class_name: &str) -> Self

Translates the intermediate form of a parsed function into the elements ready-to-use in the C++ code generation process. It prepares code for a C++ virtual method declaration and extern “C” function that calls the virtual method. Due to this, Rust code can call virtual C++ methods like trait functions.

Pseudocode:

Rust: SomeTrait { method_a(); }

Swift: Class SomeTrait { method_a(); }

@_cdecl __method_a(AnyType obj) { (obj as SomeTrait).method_a(); }

source

pub fn generate_virtual_declaration(self) -> String

Generates a virtual function declaration that can be used within a class declaration.

source

pub fn generate_virtual_definition(self) -> String

Generates an extern function that calls the virtual method on a swift trait object that can be mapped to some Rust trait object.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.