class Bindgen::TypeDatabase

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.cr

Constant 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

Instance Method Summary

Constructor Detail

def self.new(config : Configuration, cookbook : String | Cpp::Cookbook, with_builtins = true) #

[View source]

Class Method Detail

def self.load_builtins : Configuration #

Helper method to read the built-in type configuration.


[View source]
def self.logger #

[View source]

Instance Method Detail

def [](type : String | Parser::Type) #

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 #[]?.


[View source]
def []?(name : String) #

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.


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

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.


[View source]
def add(name : String, rules : TypeConfig) #

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.


[View source]
def add(name : String, **rules) #

Quickly adds the rules to name. Used for testing purposes.

Also see #get_or_add to add rules from processors.


[View source]
def add_alias(name : String, alias_for aliased : String) #

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.


[View source]
def add_sparse_type(cpp_name : String, crystal_name : String | Nil, kind) #

Adds a type configuration to the type database. If a configuration for this type was set by the user, it's updated - not replaced!


[View source]
def cookbook : Cpp::Cookbook #

[View source]
def each(*args, **options) #

[View source]
def each(*args, **options, &) #

[View source]
def get_or_add(type : Parser::Type | String) : TypeConfig #

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.


[View source]
def logger #

[View source]
def resolve_aliases(type : Parser::Type | String) #

Resolves type aliases referred to by type or the name of a type. Returns a type without aliases.


[View source]
def try_or(type : Parser::Type | String, default, &) #

Helper, equivalent to calling #[type]?.try(&.x) || default


[View source]