class
Bindgen::Parser::Method
- Bindgen::Parser::Method
- Reference
- Object
Overview
Describes a method as found by the clang tool.
Included Modules
- JSON::Serializable
Defined in:
bindgen/parser/method.crConstant Summary
-
Log =
::Log.for(self)
Constructors
-
.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
Methodusing a more Crystal-style syntax. - .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, final : 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)
- .new(pull : JSON::PullParser)
Instance Method Summary
-
#==(other : self)
Returns
trueif this reference is the same as other. -
#access : AccessSpecifier
Visibility of the method.
- #aggregate_constructor?(*args, **options)
- #aggregate_constructor?(*args, **options, &)
- #any_constructor?(*args, **options)
- #any_constructor?(*args, **options, &)
-
#any_default_constructor? : Bool
Is this a constructor that can take no arguments?
-
#arguments : Array(Argument)
Arguments of the method.
-
#arguments=(arguments : Array(Argument))
Arguments of the method.
-
#binding_method_name
Name of the method in C++ and Crystal bindings.
-
#binding_name=(binding_name : String | Nil)
Forces the bindings to use the specified name.
-
#binding_operator_name
Name of the unary operator method in C++ and Crystal bindings.
-
#builtin? : Bool
Is this a method implicitly generated by C++?
-
#class_name : String
Fully qualified name of the class in which the method is defined.
-
#const? : Bool
Returns if the method is const-qualified:
std::string getName() const; - #constructor?(*args, **options)
- #constructor?(*args, **options, &)
- #conversion_operator?(*args, **options)
- #conversion_operator?(*args, **options, &)
- #copy_constructor?(*args, **options)
- #copy_constructor?(*args, **options, &)
-
#crystal_name(override : String | Nil = nil) : String
Turns the method name into something canonical to Crystal.
-
#crystal_name=(crystal_name : String | Nil)
Forces the Crystal wrapper to use the specified name.
- #destructor?(*args, **options)
- #destructor?(*args, **options, &)
-
#equals_except_const?(other : Method) : Bool
Checks if this method is equal to other, except for the const-qualification.
-
#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.
-
#explicit_crystal_name? : Bool
Checks if the
#crystal_namewas set explicitly (true), or will be generated (false). -
#extern_c? : Bool
Does this function use the C ABI?
-
#filtered?(db : TypeDatabase) : Bool
Is this method filtered out?
-
#final? : Bool
Is this a
finalvirtual function, which can't be overridden? -
#first_default_argument : Int32 | Nil
The index of the first argument with a default value, if any.
-
#fix_post_succ_or_pred? : Method | Nil
Checks if this method is a post-increment or post-decrement method that takes a placeholder
intargument. -
#function_pointer(name : String | Nil = nil) : String
Generates a C++ function pointer type matching this methods prototype.
-
#getter?(name = @name)
Try to deduce if this is a getter.
-
#has_move_semantics? : Bool
Does this method have move semantics anywhere?
-
#has_result?
Returns if this method returns something, or not
-
#hash(hasher)
See
Object#hash(hasher) - #macro?(*args, **options)
- #macro?(*args, **options, &)
-
#mangled_name
Mangled name for the C++ wrapper method name
- #member_getter?(*args, **options)
- #member_getter?(*args, **options, &)
- #member_method?(*args, **options)
- #member_method?(*args, **options, &)
- #member_setter?(*args, **options)
- #member_setter?(*args, **options, &)
-
#merge(other : Method) : Method
Merges this and the other method with regards to default values and type deductions.
-
#merge_args!(other : Method)
Unify arguments of this and another method.
-
#name : String
Name of the method.
-
#needs_instance?
Returns if this method needs a class instance to be called.
- #operator?(*args, **options)
- #operator?(*args, **options, &)
-
#origin : Method | Nil
The method this method is based on.
- #private?(*args, **options)
- #private?(*args, **options, &)
- #protected?(*args, **options)
- #protected?(*args, **options, &)
- #public?(*args, **options)
- #public?(*args, **options, &)
-
#pure? : Bool
Is this a pure virtual function?
-
#qualified_name : String
Fully qualified name of the method:
class_name::name. -
#question_getter?(name = @name)
Try to deduce if this is a getter for a boolean value.
-
#return_type : Parser::Type
The return type of this method
-
#setter?(name = @name)
Try to deduce if this is a setter.
- #signal?(*args, **options)
- #signal?(*args, **options, &)
- #static?(*args, **options)
- #static?(*args, **options, &)
- #static_getter?(*args, **options)
- #static_getter?(*args, **options, &)
- #static_method?(*args, **options)
- #static_method?(*args, **options, &)
- #static_setter?(*args, **options)
- #static_setter?(*args, **options, &)
-
#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.
-
#substitute_type(replacements : Hash(String, Parser::Type)) : Method
Performs type substitution on the argument and return types of this method using the given replacements.
-
#superclass_copy : Method
Returns a non-virtual copy of this method suitable for use in superclass wrapper structs.
-
#type : Method::Type
Type of the method.
-
#variadic? : Bool
Does this function take a variable amount of arguments?
-
#variants(&)
Yields all variants of this method, going through an increasing level of default arguments.
-
#variants : Array(Method)
Non-yielding version of
#variants. -
#virtual? : Bool
Is this a virtual function?
Constructor Detail
Utility method to easily build a Method using a more Crystal-style
syntax.
Instance Method Detail
Returns true if this reference is the same as other. Invokes same?.
Name of the method in C++ and Crystal bindings. If an explicit
#binding_name name is set, it'll be returned without further
processing.
Name of the unary operator method in C++ and Crystal bindings. Uniquely identifies a C++ operator.
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.
Forces the Crystal wrapper to use the specified name.
Checks if this method is equal to other, except for the const-qualification.
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.
Checks if the #crystal_name was set explicitly (true), or will be
generated (false).
Is this method filtered out?
TODO Can we move this into Processor::FilterMethods?
The index of the first argument with a default value, if any.
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.
Generates a C++ function pointer type matching this methods prototype.
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.
Unify arguments of this and another method.
Modifies the argument list of this method.
The method this method is based on. Used by #variants to indicate
the methods origin when splitting occurs.
Fully qualified name of the method: class_name::name. For a function
in the global scope, it's the #name itself.
Substitutes all uses of name on the argument and return types of this method with the given type.
Performs type substitution on the argument and return types of this method using the given replacements.
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.
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.