module Bindgen::TypeHelper

Overview

Helper functionality for working with types. Useful for all platforms.

TODO Turn into a struct?

Direct including types

Defined in:

bindgen/type_helper.cr

Instance Method Summary

Instance Method Detail

def cpp_class_name(class_name : String) : String #

Returns the name of the class class_name in C++ code. An anonymous class can only be named through the typedef added by Processor::InstanceProperties.


[View source]
def passthrough(type : Parser::Type) #

Builds a result passing-through type without modifications.


[View source]
def proc_by_pointer?(type : Parser::Type) : Bool #

Is type a structure passed by value? A CrystalProc passes it by pointer instead, as a Crystal Proc doesn't follow the C ABI: the C ABI passes a structure larger than 16 bytes indirectly, which a Proc taking it by value reads as garbage. This covers copied structures and built-in kind: Struct types, like the CrystalVariant behind QVariant.


[View source]
def reconfigure_pass_type(pass_by, is_ref, ptr) #

Helper for #to_X, configuring the type according to user-specified rules.


[View source]
def structure_hosted?(rules : TypeDatabase::TypeConfig) : Bool #

Does the Crystal wrapper class of the type described by rules host a copy of the structure, instead of a pointer to it? Its #to_unsafe returns a pointer to the hosted structure then.

This is not the case for a kind: Struct type, whose wrapper is a Crystal struct returning the structure itself.


[View source]
def type_copied?(type) : Bool #

Is type available in Crystal? It will be if any of:

  1. The structure will be copied
  2. It's a built-in type
  3. It's an enumeration type

Otherwise, false is returned. If the type is not configured in the type database, it defaults to false.


[View source]
def type_pointer_depth(type : Parser::Type) : Int32 #

Returns the pointer-depth without a reference of type.


[View source]
def variadic_argument : Call::VariadicArgument #

Builds a Call::VariadicArgument. This is only applicable to directly bound functions.


[View source]