class Bindgen::Parser::Method

Overview

Describes a method as found by the clang tool.

Included Modules

Defined in:

bindgen/parser/method.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.build(name, return_type : Parser::Type, arguments : Array(Parser::Argument), class_name : String, type = Parser::Method::Type::MemberMethod, access = AccessSpecifier::Public, crystal_name = nil) : self #

Utility method to easily build a Method using a more Crystal-style syntax.


[View source]
def self.new(name : String, class_name : String, return_type : Bindgen::Parser::Type, arguments : Array(Bindgen::Parser::Argument), first_default_argument : Int32 | Nil = nil, access : Bindgen::Parser::AccessSpecifier = AccessSpecifier::Public, type : Bindgen::Parser::Method::Type = Type::MemberMethod, const : Bool = false, virtual : Bool = false, pure : Bool = false, extern_c : Bool = false, builtin : Bool = false, origin : Nil | Bindgen::Parser::Method = nil, crystal_name : Nil | String = nil, binding_name : Nil | String = nil) #

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

[View source]

Class Method Detail

def self.logger #

[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 access : AccessSpecifier #

Visibility of the method.


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

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

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

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

[View source]
def any_default_constructor? : Bool #

Is this a constructor that can take no arguments?


[View source]
def arguments : Array(Argument) #

Arguments of the method.


[View source]
def arguments=(arguments : Array(Argument)) #

Arguments of the method.


[View source]
def binding_method_name #

Name of the method in C++ and Crystal bindings. If an explicit #binding_name name is set, it'll be returned without further processing.


[View source]
def binding_name=(binding_name : String | Nil) #

[View source]
def binding_operator_name #

Name of the unary operator method in C++ and Crystal bindings. Uniquely identifies a C++ operator.


[View source]
def builtin? : Bool #

[View source]
def class_name : String #

[View source]
def const? : Bool #

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

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

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

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

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

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

[View source]
def crystal_name(override : String | Nil = nil) : String #

Turns the method name into something canonical to Crystal. If an explicit #crystal_name name is set, it'll be returned without further processing. If override is not nil, it'll be used over #name. Otherwise, the generated name will be based on #name.


[View source]
def crystal_name=(crystal_name : String | Nil) #

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

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

[View source]
def equals_except_const?(other : Method) : Bool #

Checks if this method is equal to other, except for the const-qualification.


[View source]
def equals_virtually?(other : Method) : Bool #

Checks if this method is equl to other, as is suitable to determine if they're the same for C++ virtual methods between parent- and sub-classes.


[View source]
def explicit_crystal_name? : Bool #

Checks if the #crystal_name was set explicitly (true), or will be generated (false).


[View source]
def extern_c? : Bool #

[View source]
def filtered?(db : TypeDatabase) : Bool #

Is this method filtered out?

TODO Can we move this into Processor::FilterMethods?


[View source]
def first_default_argument : Int32 | Nil #

[View source]
def fix_post_succ_or_pred? : Method | Nil #

Checks if this method is a post-increment or post-decrement method that takes a placeholder int argument. If true, returns a copy of this method with the int argument removed.


[View source]
def function_pointer(name : String | Nil = nil) : String #

Generates a C++ function pointer type matching this methods prototype.


[View source]
def getter?(name = @name) #

Try to deduce if this is a getter.


[View source]
def has_move_semantics? : Bool #

Does this method have move semantics anywhere?


[View source]
def has_result? #

Returns if this method returns something, or not


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

See Object#hash(hasher)


def logger #

[View source]
def mangled_name #

Mangled name for the C++ wrapper method name


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

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

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

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

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

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

[View source]
def merge(other : Method) : Method #

Merges this and the other method with regards to default values and type deductions. Expects that this and other methods point at the same method, but in different classes in the inheritance chain.

Keeps the class name, access, constness, virtuality and type of this method.


[View source]
def merge_args!(other : Method) #

Unify arguments of this and another method.

Modifies the argument list of this method.


[View source]
def name : String #

Name of the method.


[View source]
def needs_instance? #

Returns if this method needs a class instance to be called.


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

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

[View source]
def origin : Method | Nil #

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

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

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

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

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

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

[View source]
def pure? : Bool #

[View source]
def question_getter?(name = @name) #

Try to deduce if this is a getter for a boolean value.


[View source]
def return_type : Parser::Type #

The return type of this method


[View source]
def setter?(name = @name) #

Try to deduce if this is a setter.


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

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

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

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

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

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

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

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

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

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

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

Substitutes all uses of name on the argument and return types of this method with the given type.


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

Performs type substitution on the argument and return types of this method using the given replacements.


[View source]
def superclass_copy : Method #

Returns a non-virtual copy of this method suitable for use in superclass wrapper structs. The bodies of such copies are expected to ignore method overriding.


[View source]
def type : Method::Type #

Type of the method.


[View source]
def variadic? : Bool #

Does this function take a variable amount of arguments?


[View source]
def variants(&) #

Yields all variants of this method, going through an increasing level of default arguments. It will respect exposed default-values.

A C++ method like int foo(int a, int b = 1, std::string c = "foo") would yield two methods like:

  • int foo(int a, int b, std::string c)
  • int foo(int a, int b = 1)

Note that only built-in types (These are: Integers, Floats and Booleans) support an exposed default value. For other types (Like std::string in the example), no default value will be set.

Also see #find_variant_splits for the algorithm.


[View source]
def variants : Array(Method) #

Non-yielding version of #variants.


[View source]
def virtual? : Bool #

[View source]