Struct FunctionHelperVirtual

Source
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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.