class Bindgen::TypeDatabase::TypeConfig

Overview

Configuration of types, used in Configuration#types (The types: map in YAML). See TypeDatabase::Configuration.

Included Modules

Defined in:

bindgen/type_database.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(ctx : YAML::ParseContext, node : YAML::Nodes::Node) #

[View source]
def self.new(crystal_type : String | Nil = nil, cpp_type : String | Nil = nil, binding_type : String | Nil = nil, from_cpp : Bindgen::Template::Base = Template::None.new, to_cpp : Bindgen::Template::Base = Template::None.new, converter : Nil | String = nil, from_crystal : Bindgen::Template::Base = Template::None.new, to_crystal : Bindgen::Template::Base = Template::None.new, kind : Bindgen::Parser::Type::Kind = Parser::Type::Kind::Class, ignore : Bool = false, pass_by : Bindgen::TypeDatabase::PassBy = PassBy::Original, wrapper_pass_by : PassBy | Nil = nil, sub_class : Bool = true, copy_structure : Bool = false, bit_fields : Bindgen::TypeDatabase::BitFields = BitFields::Accessors, generate_wrapper : Bool = true, generate_binding : Bool = true, generate_superclass : Bool = true, builtin : Bool = false, ignore_methods : Array(Bindgen::TypeDatabase::MethodPattern) = [] of MethodPattern, declare_methods : Array(String) = [] of String, shadowed_by : Array(String) = [] of String, rename : Hash(Bindgen::TypeDatabase::MethodPattern, String) = {} of MethodPattern => String, nilable : Hash(Bindgen::TypeDatabase::MethodPattern, Array(Int32) | Bool) = {} of MethodPattern => Bool | Array(Int32), out_arguments : Hash(Bindgen::TypeDatabase::MethodPattern, Array(Int32) | Bool) = {} of MethodPattern => Bool | Array(Int32), superclass_ignore_methods : Regex = Util::FAIL_RX, keep_alive : Hash(Regex, Nil | Array(Int32)) = KeepAlive.new, release : Hash(Regex, Nil | Array(Int32)) = KeepAlive.new, depends_on : Hash(Regex, Nil | Array(Int32)) = KeepAlive.new, parent_arguments : Array(String) = [] of String, instance_variables : Hash(Regex, Bindgen::TypeDatabase::InstanceVariableConfig) = InstanceVariableConfig::Collection.new, graph_node : Bindgen::Graph::Node | Nil = nil, container_type : Nil | String = nil, kind_present : Bool = false) #

[View source]

Instance Method Detail

def anonymous? : Bool #

Is this type anonymous?


[View source]
def binding_type : String | Nil #

The type used in Crystal, but only in the lib binding.


[View source]
def binding_type=(binding_type : String | Nil) #

The type used in Crystal, but only in the lib binding.


[View source]

How the lib struct of a copied structure accesses its bit-fields.


[View source]
def bit_fields=(bit_fields : Bindgen::TypeDatabase::BitFields) #

How the lib struct of a copied structure accesses its bit-fields.


[View source]
def builtin=(builtin : Bool) #

Treat this type as built-in type in C++ and Crystal.


[View source]
def builtin? : Bool #

Treat this type as built-in type in C++ and Crystal.


[View source]
def container_type : String | Nil #

The name of the Crystal container module this type includes, if any. Used by CrystalContainerOf.


[View source]
def container_type=(container_type : String | Nil) #

The name of the Crystal container module this type includes, if any. Used by CrystalContainerOf.


[View source]
def converter : String | Nil #

Converter for this type in Crystal. Takes precedence over the #to_crystal and #from_crystal fields.


[View source]
def converter=(converter : String | Nil) #

Converter for this type in Crystal. Takes precedence over the #to_crystal and #from_crystal fields.


[View source]
def copy_structure=(copy_structure : Bool) #

If the structure (as in, its non-static fields) shall be tried to replicated in Crystal. Implies instance_variables: false, unless a wrapper class hosts the structure (see TypeHelper#structure_hosted?). This doesn't support inheritance!


[View source]
def copy_structure? : Bool #

If the structure (as in, its non-static fields) shall be tried to replicated in Crystal. Implies instance_variables: false, unless a wrapper class hosts the structure (see TypeHelper#structure_hosted?). This doesn't support inheritance!


[View source]
def cpp_type : String | Nil #

The C++ type to pass it around.


[View source]
def cpp_type=(cpp_type : String | Nil) #

The C++ type to pass it around.


[View source]
def crystal_pass_by : PassBy #

Pass-by configuration in wrapper code. Prefers the #wrapper_pass_by value, and falls back to #pass_by.


[View source]
def crystal_type : String | Nil #

The crystal name of this type.


[View source]
def crystal_type=(crystal_type : String | Nil) #

The crystal name of this type.


[View source]
def declare_methods : Array(String) #

C++ declarations of methods the parser doesn't report, like the instantiations of template members: QMenu *menu() const, void setMenu(QMenu *menu). Parsed by Parser::Method.from_signature and added to the class, the C++ glue calls them like any method.


[View source]
def declare_methods=(declare_methods : Array(String)) #

C++ declarations of methods the parser doesn't report, like the instantiations of template members: QMenu *menu() const, void setMenu(QMenu *menu). Parsed by Parser::Method.from_signature and added to the class, the C++ glue calls them like any method.


[View source]
def depends_on : Hash(Regex, Array(Int32)?) #

Constructors whose object refers to some of its arguments from memory the GC doesn't scan, and uses them when destroyed. The C++ glue stores these in the object, so the GC destroys it first. Same format as #keep_alive.


[View source]
def depends_on=(depends_on : Hash(Regex, Nil | Array(Int32))) #

Constructors whose object refers to some of its arguments from memory the GC doesn't scan, and uses them when destroyed. The C++ glue stores these in the object, so the GC destroys it first. Same format as #keep_alive.


[View source]
def from_cpp : Template::Base #

Template code ran to turn the real C++ type into the crystal type.


[View source]
def from_cpp=(from_cpp : Template::Base) #

Template code ran to turn the real C++ type into the crystal type.


[View source]
def from_crystal : Template::Base #

Template code ran to turn the Crystal type for the binding.


[View source]
def from_crystal=(from_crystal : Template::Base) #

Template code ran to turn the Crystal type for the binding.


[View source]
def generate_binding=(generate_binding : Bool) #

If to generate bindings in C++ and Crystal.


[View source]
def generate_binding? : Bool #

If to generate bindings in C++ and Crystal.


[View source]
def generate_superclass=(generate_superclass : Bool) #

If to generate a superclass wrapper in Crystal.


[View source]
def generate_superclass? : Bool #

If to generate a superclass wrapper in Crystal.


[View source]
def generate_wrapper=(generate_wrapper : Bool) #

If to generate a wrapper in Crystal.


[View source]
def generate_wrapper? : Bool #

If to generate a wrapper in Crystal.


[View source]
def graph_node : Graph::Node | Nil #

The node this type is represented by in the graph, if any


[View source]
def graph_node=(graph_node : Graph::Node | Nil) #

The node this type is represented by in the graph, if any


[View source]
def ignore=(ignore : Bool) #

Ignore any and all methods using this type anywhere.


[View source]
def ignore? : Bool #

Ignore any and all methods using this type anywhere.


[View source]
def ignore_method?(method : Parser::Method) : Bool #

Does an entry of #ignore_methods match the method?


[View source]
def ignore_methods : Array(Bindgen::TypeDatabase::MethodPattern) #

Which methods to filter out, by name, signature or regular expression. See MethodPattern.


[View source]
def ignore_methods=(ignore_methods : Array(Bindgen::TypeDatabase::MethodPattern)) #

Which methods to filter out, by name, signature or regular expression. See MethodPattern.


[View source]
def instance_variables : Hash(Regex, Bindgen::TypeDatabase::InstanceVariableConfig) #

Instance variable configuration. Each hash key is a regex used to match instance variable names.


[View source]
def instance_variables=(instance_variables : Hash(Regex, Bindgen::TypeDatabase::InstanceVariableConfig)) #

Instance variable configuration. Each hash key is a regex used to match instance variable names.


[View source]
def keep_alive : Hash(Regex, Array(Int32)?) #

Methods whose object arguments are kept alive by BindgenHelper.keep_alive, as C++ keeps a pointer to them. Each key is a regex matched against the method name.


[View source]
def keep_alive=(keep_alive : Hash(Regex, Nil | Array(Int32))) #

Methods whose object arguments are kept alive by BindgenHelper.keep_alive, as C++ keeps a pointer to them. Each key is a regex matched against the method name.


[View source]

Semantics of the type (Kind overwrite)


[View source]
def kind=(kind : Bindgen::Parser::Type::Kind) #

Semantics of the type (Kind overwrite)


[View source]
def kind_present? : Bool #

Whether kind: was given in the YAML configuration.


[View source]
def lib_type : String | Nil #

Type name to use in the Crystal lib block. Namespace operators (::) are automatically converted into underscores for types defined in lib Binding.


[View source]
def merge(other : self) : self #

Merges the other rules with these rules. If a rule is set in both rule-sets, the value from other wins.


[View source]
def nilable : Hash(Bindgen::TypeDatabase::MethodPattern, Array(Int32) | Bool) #

Nilability of the pointer result and arguments of methods, by MethodPattern entries: true or false makes the result T? or T, regardless of nilable_results, and a list of argument indices makes those arguments accept nil, like one defaulting to nullptr does: menuBar: false, setModel: [0].


[View source]
def nilable=(nilable : Hash(Bindgen::TypeDatabase::MethodPattern, Array(Int32) | Bool)) #

Nilability of the pointer result and arguments of methods, by MethodPattern entries: true or false makes the result T? or T, regardless of nilable_results, and a list of argument indices makes those arguments accept nil, like one defaulting to nullptr does: menuBar: false, setModel: [0].


[View source]
def nilable_arguments(method : Parser::Method) : Array(Int32) #

The indices of the arguments of the method #nilable makes accept nil.


[View source]
def nilable_result?(method : Parser::Method) : Bool | Nil #

Is the result of the method nilable by #nilable? nil if no entry says.


[View source]
def out_arguments : Hash(Bindgen::TypeDatabase::MethodPattern, Array(Int32) | Bool) #

Which arguments of methods are out arguments (SPEC.md §2.2.5), by the entries of #ignore_methods: true makes every non-const reference and single pointer to a converted value type, a built-in type or an enum one, a pointer to a byte or character type included, false none, and a list of argument indices those among them: copyTo: false, readByte: true, two: [1]. Without an entry, see Parser::Method#out_arguments.


[View source]
def out_arguments=(out_arguments : Hash(Bindgen::TypeDatabase::MethodPattern, Array(Int32) | Bool)) #

Which arguments of methods are out arguments (SPEC.md §2.2.5), by the entries of #ignore_methods: true makes every non-const reference and single pointer to a converted value type, a built-in type or an enum one, a pointer to a byte or character type included, false none, and a list of argument indices those among them: copyTo: false, readByte: true, two: [1]. Without an entry, see Parser::Method#out_arguments.


[View source]
def out_arguments_for(method : Parser::Method) : Bool | Array(Int32) | Nil #

The #out_arguments entry for the method, if any: the first matching.


[View source]
def parent_arguments : Array(String) #

Names of the constructor arguments giving the object a parent, which owns and deletes it, like QTreeWidgetItem(QTreeWidget *treeview). The Qt processor keeps the object alive while it has one, like the children of a QObject. Applies to the subclasses too.


[View source]
def parent_arguments=(parent_arguments : Array(String)) #

Names of the constructor arguments giving the object a parent, which owns and deletes it, like QTreeWidgetItem(QTreeWidget *treeview). The Qt processor keeps the object alive while it has one, like the children of a QObject. Applies to the subclasses too.


[View source]

How to pass this type to C++?


[View source]
def pass_by=(pass_by : Bindgen::TypeDatabase::PassBy) #

How to pass this type to C++?


[View source]
def release : Hash(Regex, Array(Int32)?) #

Methods handing an object back, which C++ stops using: their selected object arguments, and their object result if all arguments are selected, are passed to BindgenHelper.release. Same format as #keep_alive.


[View source]
def release=(release : Hash(Regex, Nil | Array(Int32))) #

Methods handing an object back, which C++ stops using: their selected object arguments, and their object result if all arguments are selected, are passed to BindgenHelper.release. Same format as #keep_alive.


[View source]
def rename : Hash(Bindgen::TypeDatabase::MethodPattern, String) #

Crystal names of methods, by MethodPattern entries like #ignore_methods: raise: raise_. The first matching entry names the method, and all of its overloads if it's a plain name.


[View source]
def rename=(rename : Hash(Bindgen::TypeDatabase::MethodPattern, String)) #

Crystal names of methods, by MethodPattern entries like #ignore_methods: raise: raise_. The first matching entry names the method, and all of its overloads if it's a plain name.


[View source]
def rename_for(method : Parser::Method) : String | Nil #

The Crystal name #rename gives the method, if any.


[View source]
def shadowed_by : Array(String) #

Types whose overloads shadow those taking this type: an overload of a method taking this type is dropped where another overload takes one of these types in its place, with the other arguments equal. For a view type converted like the type it views: QStringView next to QString, which both take a Crystal String.


[View source]
def shadowed_by=(shadowed_by : Array(String)) #

Types whose overloads shadow those taking this type: an overload of a method taking this type is dropped where another overload takes one of these types in its place, with the other arguments equal. For a view type converted like the type it views: QStringView next to QString, which both take a Crystal String.


[View source]
def sub_class=(sub_class : Bool) #

If sub-classing of this type is allowed, if it's wrapped and has virtual methods.


[View source]
def sub_class? : Bool #

If sub-classing of this type is allowed, if it's wrapped and has virtual methods.


[View source]
def superclass_ignore_methods : Regex #

Which methods to filter out in the superclass wrapper. A method is ignored if it matches any of the regex patterns specified.


[View source]
def superclass_ignore_methods=(superclass_ignore_methods : Regex) #

Which methods to filter out in the superclass wrapper. A method is ignored if it matches any of the regex patterns specified.


[View source]
def to_cpp : Template::Base #

Template code ran to turn the crystal type into the real C++ type.


[View source]
def to_cpp=(to_cpp : Template::Base) #

Template code ran to turn the crystal type into the real C++ type.


[View source]
def to_crystal : Template::Base #

Template code ran to turn the binding type to Crystal.


[View source]
def to_crystal=(to_crystal : Template::Base) #

Template code ran to turn the binding type to Crystal.


[View source]
def wrapper_pass_by : Bindgen::TypeDatabase::PassBy | Nil #

How to pass this type from Crystal? Defaults to #pass_by.


[View source]
def wrapper_pass_by=(wrapper_pass_by : Bindgen::TypeDatabase::PassBy | Nil) #

How to pass this type from Crystal? Defaults to #pass_by.


[View source]
def wrapper_type : String | Nil #

Type name to use in the Crystal wrapper.


[View source]