struct Bindgen::Cpp::MethodName

Overview

Generator for calling methods by their name.

Included Modules

Defined in:

bindgen/cpp/method_name.cr

Constant Summary

GLOBAL_SCOPE = "::"

Constructors

Instance Method Summary

Instance methods inherited from module Bindgen::TypeHelper

cpp_class_name(class_name : String) : String cpp_class_name, passthrough(type : Parser::Type) passthrough, proc_by_pointer?(type : Parser::Type) : Bool proc_by_pointer?, reconfigure_pass_type(pass_by, is_ref, ptr) reconfigure_pass_type, structure_hosted?(rules : TypeDatabase::TypeConfig) : Bool structure_hosted?, type_copied?(type) : Bool type_copied?, type_pointer_depth(type : Parser::Type) : Int32 type_pointer_depth, variadic_argument : Call::VariadicArgument variadic_argument

Constructor Detail

def self.new(db : TypeDatabase) #

[View source]

Instance Method Detail

def gc_wrapper_class?(class_name : String) : Bool #

Do the constructors of class_name, but an aggregate constructor, allocate a CrystalGCWrapper? Not those of a copied type, a C++ union or a final class.


[View source]
def gc_wrapper_constructor?(method : Parser::Method, type : Parser::Method::Type = method.type) : Bool #

Is method a constructor allocating a CrystalGCWrapper of its class, instead of the class itself? See #generate.


[View source]
def generate(method : Parser::Method, self_var : String, type : Parser::Method::Type | Nil = nil, exact_member = false) #

Generates the C++ method name.

If this kind of method requires an instance, it will use self_var and use -> on it.

If the method is any constructor, and the type is copied, the constructor will be called without .new, effectively returning a value. Otherwise, a normal .new is used to return a pointer. An aggregate constructor allocates the class itself, so that the caller can brace-initialize it. So do the constructors of a C++ union or final class, which can't be wrapped as it can't be inherited from.

If exact_member is true and method is a member method, the qualified method is called, bypassing dynamic lookup.


[View source]