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
-
BUILTIN_CONFIG_PATH =
"/srv/crystaldoc.info/github-Papierkorb-bindgen-master/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++.
Constructors
Class Method Summary
-
.load_builtins : Configuration
Helper method to read the built-in type configuration.
- .logger
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.
- #cookbook : Cpp::Cookbook
- #each(*args, **options)
- #each(*args, **options, &)
-
#get_or_add(type : Parser::Type | String) : TypeConfig
Returns the rules for type.
- #logger
-
#resolve_aliases(type : Parser::Type | String)
Resolves type aliases referred to by type or the name of a type.
-
#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!
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.
Resolves type aliases referred to by type or the name of a type. Returns a type without aliases.
Helper, equivalent to calling #[type]?.try(&.x) || default