struct Bindgen::Cpp::Pass
- Bindgen::Cpp::Pass
- Struct
- Value
- Object
Overview
Methods for passing data from and to C++.
This is a helper struct: Cheap to create and to pass around.
Included Modules
Defined in:
bindgen/cpp/pass.crConstructors
Instance Method Summary
-
#arguments_from_cpp(list : Enumerable(Parser::Argument))
ditto
-
#arguments_to_cpp(list : Enumerable(Parser::Argument))
Turns the list of arguments into a list of
Call::Argument
s. -
#crystal_proc_name(proc_type : Parser::Type) : String
Returns the type name of proc_type.
-
#passthrough_to_crystal(type : Parser::Type)
Computes a result which is directly usable from C++ code, without changes, and passes it through to crystal using conversion.
-
#through(type : Parser::Type)
Passes the type through without changes.
-
#through_arguments(list : Enumerable(Parser::Argument))
ditto
-
#to_cpp(type : Parser::Type) : Call::Result
Computes a result for passing type from Crystal to C++.
-
#to_crystal(type : Parser::Type, is_constructor = false) : Call::Result
Computes a result for passing type from C++ to Crystal.
Instance methods inherited from module Bindgen::TypeHelper
is_type_copied?(type) : Bool
is_type_copied?,
passthrough(type : Parser::Type)
passthrough,
reconfigure_pass_type(pass_by, is_ref, ptr)
reconfigure_pass_type,
type_pointer_depth(type : Parser::Type) : Int32
type_pointer_depth,
variadic_argument : Call::VariadicArgument
variadic_argument
Constructor Detail
Instance Method Detail
Turns the list of arguments into a list of Call::Argument
s.
Computes a result which is directly usable from C++ code, without changes, and passes it through to crystal using conversion.
The pass rules are similar to #to_crystal
. The primary
difference is that this version has no special handling of constructors.
There is a second major difference: This method always signals the C++
type to the outside, as received by C++ (Thus even ignoring
rules.cpp_type
!). It still follows the passing rules towards Crystal.
Computes a result for passing type from Crystal to C++.
The primary job of this method is to figure out how to pass something of type over to C++. It doesn't matter if this is a result from a method or an argument for this. It also signals how a value of this type shall be handled by the receiver, e.g., if conversions apply (Which?).
The method responsible for the opposite direction is #to_crystal
.
Pass rules:
- The type is a value-type and passed by-value a. The type is copied? Then pass by-value. b. Else, pass by-reference.
- The type is passed by-reference a. Pass by-reference
- The type is passed by-pointer a. Pass by-pointer
Computes a result for passing type from C++ to Crystal.
Also see #pass_to_cpp
for the reverse direction.
See #passthrough_to_crystal
to call Crystal from C++.
Set is_constructor to true
if this is a return-result of a method
and this method is a constructor.
Pass rules:
- If is_constructor and the type is copied
a. Then pass by-value. (See
MethodName#generate
too) - If pass by-reference a. Invoke the types copy-constructor and pass by-pointer.
- If pass by-value but the type is not copied a. Invoke the types copy-constructor and pass by-pointer.
- In all other cases a. Pass by-reference or by-pointer as defined by type.