class
Bindgen::TypeDatabase
- Bindgen::TypeDatabase
- Reference
- Object
Overview
Database of type mapping data for wrapper-code generation. Configuration for common (and built-in) C/C++ types is automatically loaded and added.
Defined in:
bindgen/type_database.crConstant Summary
-
BUFFER_BASE_TYPES =
["char", "wchar_t", "char8_t", "char16_t", "char32_t"] of ::String -
The C++ types a method takes a buffer of by pointer, not a value to write.
-
BUILTIN_CONFIG_PATH =
"/srv/crystaldoc.info/github-Papierkorb-bindgen-v0.16.2/src/bindgen/../../builtin_types.yml" -
Path to the built-in type configuration. This file defines mappings for most-ish built-in (and other common) types in C++.
-
BYTE_BINDING_TYPES =
["UInt8", "Int8"] of ::String -
The binding types of a byte: a pointer to one is a buffer too, like
uchar *orquint8 *. -
Log =
::Log.for(self)
Constructors
Class Method Summary
-
.load_builtins : Configuration
Helper method to read the built-in type configuration.
Instance Method Summary
-
#[](type : String | Parser::Type)
Look up type in the database.
-
#[]?(name : String)
Look up type in the database with the given name.
-
#[]?(type : Parser::Type)
Look up type in the database.
-
#add(name : String, rules : TypeConfig)
Adds a type rules as name.
-
#add(name : String, **rules)
Quickly adds the rules to name.
-
#add_alias(name : String, alias_for aliased : String)
Adds an alias name that refers to the aliased type.
-
#add_sparse_type(cpp_name : String, crystal_name : String | Nil, kind)
Adds a type configuration to the type database.
-
#array_view?(type : Parser::Type) : Bool
Is type a one-dimensional C array of a wrapped class by value? These are passed as
Binding::CrystalArray, wrapped byBindgenHelper::ArrayViewin Crystal. -
#buffer_argument?(type : Parser::Type) : Bool
Is type a pointer to a byte or character type, like
char *,uchar *orwchar_t *, or tovoid? A method writes a buffer through such a pointer, not a value, so it isn't an out argument unless anout_argumentsentry says so, seeParser::Method#out_arguments. -
#builtin_out_argument?(type : Parser::Type) : Bool
Is type a non-const lvalue reference or single pointer to a built-in type or an enum, like
int &orbool *? Such an argument is passed as a pointer, and is an out argument too in a method with a converted one. -
#builtin_out_arguments=(builtin_out_arguments : Bool)
Is every non-const reference or pointer to a built-in type or enum a method writes through an out argument? See
Configuration#builtin_out_arguments?andParser::Method#out_arguments. -
#builtin_out_arguments? : Bool
Is every non-const reference or pointer to a built-in type or enum a method writes through an out argument? See
Configuration#builtin_out_arguments?andParser::Method#out_arguments. -
#c_array_supported?(type : Parser::Type) : Bool
Can the complete C array type, or a single pointer or reference to one, be passed to Crystal? Its elements have to be built-in types, or enums, copied structures or wrapped classes by value.
-
#converted_out_argument?(type : Parser::Type) : Bool
Is type a converted out argument: a non-const lvalue reference or single pointer to a type passed by value (
pass_by: Value) and converted both ways byto_cppandfrom_cpp, likeQString &orQString *? Such a type only exists in C++ as a temporary made by itsto_cpptemplate, so the C++ glue calls the method on a local and hands the changed value back, seeParser::Method#out_arguments. - #cookbook : Cpp::Cookbook
- #each(*args, **options)
- #each(*args, **options, &)
-
#get_or_add(type : Parser::Type | String) : TypeConfig
Returns the rules for type.
-
#nilable_results=(nilable_results : Bool)
Are pointers to wrapped classes returned as
T?? SeeConfiguration#nilable_results?. -
#nilable_results? : Bool
Are pointers to wrapped classes returned as
T?? SeeConfiguration#nilable_results?. -
#object_argument?(arg : Parser::Argument) : Bool
Is arg an instance of a wrapped class passed by pointer or reference? Wrappers of
kind: Structdon't count, see#selected_object_arguments. -
#object_type?(type : Parser::Type) : Bool
Is type a wrapped class passed by pointer or reference, like an object argument or a result handing an object back?
-
#out_arguments_rule(method : Parser::Method) : Bool | Array(Int32) | Nil
The
out_argumentsrule for the method: the first matching entry of its class, or of the nearest base class with one, seeTypeConfig#out_arguments_for, so an override is wrapped like the method it overrides. -
#resolve_aliases(type : Parser::Type | String)
Resolves type aliases referred to by type or the name of a type.
-
#selected_object_arguments(method : Parser::Method, rules : KeepAlive) : Array(Int32)
Returns the indices of the arguments of method selected by rules, a
keep_alive:ordepends_on:configuration: Those of the patterns matching the method name, narrowed down to instances of wrapped classes passed by pointer or reference. -
#selects_all_arguments?(method : Parser::Method, rules : KeepAlive) : Bool
Does a rule of rules matching the method select all of its arguments?
release:releases the result of such a method too. -
#shadowed_overload?(method : Parser::Method, methods : Enumerable(Parser::Method)) : Bool
Is method an overload shadowed by another of methods, see
TypeConfig#shadowed_by? The other takes a shadowing type in place of each argument of a shadowed type, likeQStringforQStringView, and the same types otherwise: both would take the same Crystal arguments. -
#storage_reference?(type : Parser::Type) : Bool
Is type a non-const reference or pointer to a copied structure passed by value (
pass_by: Value) with a wrapper, likeQPoint &orQPointF *? The wrapper passes a pointer to the structure's storage, so the method writes into it: into the object of a wrapper class hosting the structure (stream >> point), or into the Crystalstructof akind: Structwrapper, taken by pointer (stream >> pointerof(point)). -
#struct_wrapper?(type : Parser::Type) : Bool
Is the wrapper of type a Crystal
struct, see#storage_reference?? -
#try_or(type : Parser::Type | String, default, &)
Helper, equivalent to calling
#[type]?.try(&.x) || default
Constructor Detail
Class Method Detail
Instance Method Detail
Look up type in the database. If type is a Parser::Type, the best
match will be found by gradually decaying the type (See
Parser::Type#decayed).
Prefer passing a Parser::Type over passing a String.
Also see #[]?.
Look up type in the database with the given name. name is expected to
be the base name of a C++ type. If you actually have a full type-name
instead, use Parser::Type.parse first, and pass that instead.
Prefer passing a Parser::Type over passing a String.
Look up type in the database. The best match will be found by gradually
decaying the type (See Parser::Type#decayed). This enables the user
to write rules for int * and int without clashes.
Adds a type rules as name. Overwrites any old rules previously added to the same type name. name must not refer to an existing alias.
Also see #get_or_add to add rules from processors.
Quickly adds the rules to name. Used for testing purposes.
Also see #get_or_add to add rules from processors.
Adds an alias name that refers to the aliased type. name must not refer to an existing type or a different alias. Raises if adding the given alias would result in a recursive alias loop.
Adds a type configuration to the type database. If a configuration for this type was set by the user, it's updated - not replaced!
Is type a one-dimensional C array of a wrapped class by value? These
are passed as Binding::CrystalArray, wrapped by
BindgenHelper::ArrayView in Crystal.
Is type a pointer to a byte or character type, like char *, uchar *
or wchar_t *, or to void? A method writes a buffer through such a
pointer, not a value, so it isn't an out argument unless an
out_arguments entry says so, see Parser::Method#out_arguments. A
reference to one, like char &, is a value.
Is type a non-const lvalue reference or single pointer to a built-in
type or an enum, like int & or bool *? Such an argument is passed as
a pointer, and is an out argument too in a method with a converted one.
Is every non-const reference or pointer to a built-in type or enum a
method writes through an out argument? See
Configuration#builtin_out_arguments? and Parser::Method#out_arguments.
Is every non-const reference or pointer to a built-in type or enum a
method writes through an out argument? See
Configuration#builtin_out_arguments? and Parser::Method#out_arguments.
Can the complete C array type, or a single pointer or reference to one,
be passed to Crystal? Its elements have to be built-in types, or enums,
copied structures or wrapped classes by value. For the latter three only
references to arrays are supported, and for wrapped classes only
one-dimensional arrays. See #array_view?.
Is type a converted out argument: a non-const lvalue reference or
single pointer to a type passed by value (pass_by: Value) and
converted both ways by to_cpp and from_cpp, like QString & or
QString *? Such a type only exists in C++ as a temporary made by its
to_cpp template, so the C++ glue calls the method on a local and hands
the changed value back, see Parser::Method#out_arguments.
Returns the rules for type. If none are found, a new TypeConfig is
inserted, and returned.
This is the method you want to use to add or change rules from within processors.
Important: If type is a Parser::Type, then its #base_name is
used - not the #full_name. If you want to provide configuration for
a specific type, pass the #full_name as string.
Are pointers to wrapped classes returned as T?? See
Configuration#nilable_results?.
Are pointers to wrapped classes returned as T?? See
Configuration#nilable_results?.
Is arg an instance of a wrapped class passed by pointer or reference?
Wrappers of kind: Struct don't count, see #selected_object_arguments.
Is type a wrapped class passed by pointer or reference, like an object argument or a result handing an object back?
The out_arguments rule for the method: the first matching entry of
its class, or of the nearest base class with one, see
TypeConfig#out_arguments_for, so an override is wrapped like the method
it overrides. nil without an entry.
Resolves type aliases referred to by type or the name of a type. Returns a type without aliases.
Returns the indices of the arguments of method selected by rules, a
keep_alive: or depends_on: configuration: Those of the patterns
matching the method name, narrowed down to instances of wrapped classes
passed by pointer or reference. Wrappers of kind: Struct are skipped,
as they are Crystal structs and their pointer arguments stay pointers.
Does a rule of rules matching the method select all of its arguments?
release: releases the result of such a method too.
Is method an overload shadowed by another of methods, see
TypeConfig#shadowed_by? The other takes a shadowing type in place of
each argument of a shadowed type, like QString for QStringView, and
the same types otherwise: both would take the same Crystal arguments.
Is type a non-const reference or pointer to a copied structure passed
by value (pass_by: Value) with a wrapper, like QPoint & or
QPointF *? The wrapper passes a pointer to the structure's storage,
so the method writes into it: into the object of a wrapper class
hosting the structure (stream >> point), or into the Crystal struct
of a kind: Struct wrapper, taken by pointer (stream >> pointerof(point)). A pointer may be null: nil.
Is the wrapper of type a Crystal struct, see #storage_reference??
Helper, equivalent to calling #[type]?.try(&.x) || default