class Bindgen::Parser::Argument

Overview

Describes a method argument.

Included Modules

Defined in:

bindgen/parser/argument.cr

Constant Summary

STD_FUNCTION = "std::function"

The name of a std::function class template.

Constructors

Instance Method Summary

Instance methods inherited from class Bindgen::Parser::Type

==(other : self) ==, array_element : Type array_element, array_pointer : Int32 array_pointer, base_name : String base_name, builtin? : Bool builtin?, builtin_array_pointer? : Bool builtin_array_pointer?, c_array? c_array?, c_complete_array? c_complete_array?, const? : Bool const?, decayed : Type | Nil decayed, dereferenced : Type dereferenced, desugared : String | Nil desugared, equals_except_nil?(other : Type) equals_except_nil?, extents : Array(UInt64) extents, full_name : String full_name, function? : Bool function?, hash(hasher) hash, kind : Bindgen::Parser::Type::Kind kind, make_pointer_nilable : Type | Nil make_pointer_nilable, mangled_name mangled_name, move? : Bool move?, never_nil : Type never_nil, never_nil=(never_nil : Bool) never_nil=, never_nil? : Bool never_nil?, nilable? : Bool nilable?, pointee_array : Type pointee_array, pointer : Int32 pointer, pointer_to_c_array? : Bool pointer_to_c_array?, pure_void? pure_void?, reference? : Bool reference?, reference_to_c_array? : Bool reference_to_c_array?, remove_all_extents : Type remove_all_extents, std_function? : Bool std_function?, substitute(name : String, with type : Type) : Type
substitute(replacements : Hash(String, Type)) : Type
substitute(replacements : Tuple(String, Type)) : Type
substitute
, template : Template | Nil template, template_arguments : Array(Type) template_arguments, typedefs : Array(String) | Nil typedefs, uses_typename?(name : String) uses_typename?, void? : Bool void?, with_nilable(nilable : Bool) : self with_nilable

Constructor methods inherited from class Bindgen::Parser::Type

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, extents : Array(UInt64) = Array(UInt64).new, array_pointer : Int32 = 0, desugared : Nil | String = nil, typedefs : Nil | Array(String) = nil, never_nil : Bool = false)
new(pull : JSON::PullParser)
new

Class methods inherited from class Bindgen::Parser::Type

builtin_type(cpp_name : String, pointer = 0, reference = false) builtin_type, parse(type_name : String, pointer_depth = 0) parse, proc(return_type : Type, arguments : Enumerable(Type)) proc

Constructor Detail

def self.new(name : String, base_name, full_name, const, reference, move, builtin, void, pointer, template, kind = Type::Kind::Class, has_default : Bool = false, value : Bool | Float64 | Int64 | String | UInt64 | Nil = nil, nilable = false, variadic : Bool = false, extents = Array(UInt64).new, array_pointer = 0, desugared = nil, never_nil = false, typedefs = nil) #

[View source]
def self.new(name : String, type : Type, has_default : Bool = false, value : Bool | Float64 | Int64 | String | UInt64 | Nil = nil) #

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

Describes a method argument.


[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 after_initialize #

A std::function<R (Args...)> argument becomes a Kind::Function type like Type.proc builds: a Proc or block in Crystal, a CrystalProc in the binding, which the C++ glue wraps into the std::function. See Type#std_function? and SPEC.md ยง2.2.6.


[View source]
def defaults_to_nil? : Bool #

If this is a pointer-type, does it default to nullptr in C++?


[View source]
def has_default? : Bool #

Does this argument have a default value?


[View source]
def has_exposed_default? #

Does this argument have an exposed default value?


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def merge(other : Argument) #

Merges this argument with other. Only merges the name, defaultness, its value and nil-ability. For the value, this argument takes precedence over other. The name is taken from other, as Crystal expects the arguments of an overriding method to be named like those of the overridden one. Unnamed arguments are named by their position.


[View source]
def name : String #

Name of this argument.


[View source]
def named(name : String) : Argument #

Returns a copy of this argument named name.


[View source]
def nilable? : Bool #

Assume that if the argument defaults to nullptr, that it is nilable.


[View source]
def substitute_type(name : String, with type : Type) : Argument #

Substitutes all uses of name on the type part of this argument with the given type.


[View source]
def substitute_type(replacements : Hash(String, Type)) : Argument #

Performs type substitution on the type part of this argument using the given replacements.


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

Checks if the type-part of this equals the type-part of other.


[View source]
def value : DefaultValueTypes | Nil #

Default value for this argument, if an initializer literal is found.


[View source]
def variadic? : Bool #

Is this the vararg (...) argument?


[View source]
def without_default : Argument #

Returns a copy of this argument without a default value.


[View source]