class Bindgen::Parser::Type
- Bindgen::Parser::Type
- Reference
- Object
Overview
Stores information about a specific C++ type.
Included Modules
- JSON::Serializable
Direct Known Subclasses
Defined in:
bindgen/parser/type.crbindgen/parser/type/cpp_type_parser.cr
Constant Summary
-
CRYSTAL_PROC =
"CrystalProc" -
Name of the
CrystalProcC++ and Crystal type. This type is a template type in C++, and astructin Crystal. -
EMPTY =
new(const: false, move: false, reference: false, builtin: true, void: false, pointer: 0, base_name: "", full_name: "", template: nil, nilable: false) -
Empty type, as is returned by the parser for constructors. Only valid as a return type of a constructor method.
-
VOID =
new(const: false, move: false, reference: false, builtin: true, void: true, pointer: 0, base_name: "void", full_name: "void", template: nil, nilable: false) -
Voidtype
Constructors
- .new(base_name : String, full_name : String, const : Bool, reference : Bool, pointer : Int32, move : Bool = false, builtin : Bool = false, void : Bool = false, kind : Bindgen::Parser::Type::Kind = Kind::Class, template : Nil | Bindgen::Parser::Template = nil, nilable : Bool = false)
- .new(pull : JSON::PullParser)
Class Method Summary
-
.builtin_type(cpp_name : String, pointer = 0, reference = false)
Returns a
Typeof a C++ built-in type cpp_name. -
.parse(type_name : String, pointer_depth = 0)
Returns a
Typeof a fully qualified C++ typename type_name. -
.proc(return_type : Type, arguments : Enumerable(Type))
Creates a
Typedescribing a CrystalProctype, which returns a return_type using arguments.
Instance Method Summary
-
#==(other : self)
Returns
trueif this reference is the same as other. - #base_name : String
- #builtin? : Bool
- #const? : Bool
-
#decayed : Type | Nil
Decays the type.
-
#equals_except_nil?(other : Type)
Checks if this type equals the other type, except for nil-ability.
- #full_name : String
-
#hash(hasher)
See
Object#hash(hasher) -
#kind : Bindgen::Parser::Type::Kind
Type kind.
-
#make_pointer_nilable : Type | Nil
If the type is a pointer and not a reference, returns a copy of this type that is nilable, otherwise returns
nil. -
#mangled_name
The mangled type name for C++ bindings.
- #move? : Bool
- #nilable? : Bool
-
#pointer : Int32
Total number of indirections from pointers and lvalue references.
-
#pure_void?
Returns
trueif this type isvoid, and nothing else. - #reference? : Bool
-
#substitute(name : String, with type : Type) : Type
Substitutes all uses of name with the given type.
-
#substitute(replacements : Hash(String, Type)) : Type
Performs type substitution with the given replacements.
-
#substitute(replacements : Tuple(String, Type)) : Type
Substitutes all uses of name with the given type.
-
#template : Template | Nil
Template information, if this type is a template type.
-
#uses_typename?(name : String)
Checks whether this type uses name in its base name or any of its template arguments.
- #void? : Bool
Constructor Detail
Class Method Detail
Returns a Type of a C++ built-in type cpp_name.
Returns a Type of a fully qualified C++ typename type_name. Extra
pointer indirections can be set by pointer_depth.
Creates a Type describing a Crystal Proc type, which returns a
return_type using arguments.
The generated type will be considered a built-in type.
Instance Method Detail
Returns true if this reference is the same as other. Invokes same?.
Decays the type. This means that a single "layer" of information is removed from this type. Each rule is tried in the following order. The first winning rule returns a new type.
- If
#const?, remove const (const int &->int &) - If
#reference?, pointer-ize (int &->int *) - If
#pointer > 0, remove one (int *->int) - Else, it's the base-type already. Return
nil.
Checks if this type equals the other type, except for nil-ability.
If the type is a pointer and not a reference, returns a copy of this
type that is nilable, otherwise returns nil.
Substitutes all uses of name with the given type.
Performs type substitution with the given replacements.
Substitution is performed if this type's base name is exactly one of the type arguments, but not if the type is a templated type of the same name. Substitution is applied recursively on template type arguments. All substitutions are applied simultaneously.
Substitutes all uses of name with the given type.
Template information, if this type is a template type.
Checks whether this type uses name in its base name or any of its template arguments. Does not check for template names.