class Bindgen::Parser::Type

Overview

Stores information about a specific C++ type.

Direct Known Subclasses

Defined in:

bindgen/parser/type.cr

Constant Summary

CRYSTAL_PROC = "CrystalProc"

Name of the CrystalProc C++ and Crystal type. This type is a template type in C++, and a struct in Crystal.

EMPTY = new(isConst: false, isMove: false, isReference: false, isBuiltin: true, isVoid: false, pointer: 0, baseName: "", fullName: "", 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(isConst: false, isMove: false, isReference: false, isBuiltin: true, isVoid: true, pointer: 0, baseName: "void", fullName: "void", template: nil, nilable: false)

Void type

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(baseName : String, fullName : String, isConst : Bool, isReference : Bool, pointer : Int32, isMove : Bool = false, isBuiltin : Bool = false, isVoid : Bool = false, kind : Bindgen::Parser::Type::Kind = Kind::Class, template : Template | Nil = nil, nilable : Bool = false) #

[View source]
def self.new(__temp_44 : JSON::PullParser) #

Class Method Detail

def self.builtin_type(cpp_name : String, pointer = 0, reference = false) #

Returns a Type of a C++ built-in type cpp_name.


[View source]
def self.parse(type_name : String, pointer_depth = 0) #

Parser for qualified C++ type-names. It's really stupid though.


[View source]
def self.proc(return_type : Type, arguments : Enumerable(Type)) #

Creates a Type describing a Crystal Proc type, which returns a return_type using arguments.

The generated type will use CrystalProc as base type.


[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def base_name : String #

Unqualified base name for easier mapping to Crystal.

E.g., the base name of const QWidget *& is QWidget.


[View source]
def baseName : String #

def baseName=(_baseName : String) #

def builtin? : Bool #

Is this type a C++ built-in type?


[View source]
def const? : Bool #

Is this type constant?


[View source]
def decayed : Type | Nil #

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.

  1. If #const?, remove const (const int & -> int &)
  2. If #reference?, pointer-ize (int & -> int *)
  3. If #pointer > 0, remove one (int * -> int)
  4. Else, it's the base-type already. Return nil.

[View source]
def equals_except_nil?(other : Type) #

Checks if this type equals the other type, except for nil-ability.


[View source]
def full_name : String #

Fully qualified, full name, for the C++ bindings.


[View source]
def fullName : String #

def fullName=(_fullName : String) #

def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def isBuiltin : Bool #

def isBuiltin=(_isBuiltin : Bool) #

def isConst : Bool #

def isConst=(_isConst : Bool) #

def isMove : Bool #

def isMove=(_isMove : Bool) #

def isReference : Bool #

def isReference=(_isReference : Bool) #

def isVoid : Bool #

def isVoid=(_isVoid : Bool) #

def kind : Kind #

def kind=(_kind : Kind) #

def mangled_name #

The mangled type name for C++ bindings.


[View source]
def move? : Bool #

Does the type use move-semantics?


[View source]
def nilable : Bool #

def nilable=(_nilable : Bool) #

def nilable? : Bool #

Is this type nilable? For compatibility with Argument.


[View source]
def pointer : Int32 #

def pointer=(_pointer : Int32) #

def pure_void? #

Returns true if this type is void, and nothing else.


[View source]
def reference? : Bool #

Is this a C++ reference type?


[View source]
def template : Template | Nil #

def template=(_template : Template | Nil) #

def to_json(json : JSON::Builder) #

def void? : Bool #

Is it C++ void? Note that void * is also void. See also #pure_void?


[View source]