Struct rusty_bind_parser::swift::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
impl FunctionHelperVirtual
sourcepub fn from_virtual_function(function: &Function, class_name: &str) -> Self
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(); }
sourcepub fn generate_virtual_declaration(self) -> String
pub fn generate_virtual_declaration(self) -> String
Generates a virtual function declaration that can be used within a class declaration.
sourcepub fn generate_virtual_definition(self) -> String
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.