![]() |
Gorgon Game Engine
|
Represents a function overload. More...
Public Member Functions | |
Overload (const Type *returntype, ParameterList parameters, bool stretchlast, bool repeatlast, bool accessible, bool constant, bool returnsref, bool returnsconst, bool implicit) | |
A full constructor. More... | |
template<class ... P_> | |
Overload (const Type *returntype, ParameterList parameters, P_ ...tags) | |
Regular constructor that can take as many tags as needed. More... | |
virtual | ~Overload () |
virtual Data | Call (bool ismethod, const std::vector< Data > ¶meters) const =0 |
Class the stub for this function. More... | |
const Function & | GetParent () const |
Returns the function this variant belongs. More... | |
const Type & | GetReturnType () const |
Returns the type this variant returns. More... | |
bool | HasReturnType () const |
Returns whether this variant returns a value. More... | |
bool | IsConstant () const |
Returns whether this function is a constant. More... | |
bool | IsImplicit () const |
Returns if this variant can be used as implicit conversion. More... | |
bool | IsSame (const Overload &var) const |
Compares two variants if they have the same signature. More... | |
bool | RepeatLast () const |
Returns if the last parameter of this function should be repeated. More... | |
bool | ReturnsConst () const |
This function variant returns a constant. More... | |
bool | ReturnsRef () const |
This function variant returns a reference to a value rather than the value itself. More... | |
bool | StretchLast () const |
Returns if the last parameter of this function should be stretched. More... | |
Public Attributes | |
const ParameterList & | Parameters |
The parameters of this overload. More... | |
Protected Member Functions | |
virtual void | dochecks (bool ismethod) |
This function should perform validity checks on the variant. More... | |
Protected Attributes | |
bool | accessible |
Only meaningful in class member functions. More... | |
bool | constant |
Makes this function constant. Only works on member functions. More... | |
bool | implicit |
If the parent function is constructor, marks this variant as an implicit type conversion. More... | |
ParameterList | parameters |
Modifiable parameters of this overload. More... | |
Function * | parent |
The parent function of this variant. More... | |
bool | repeatlast |
If true last parameter can be specified any number of times. More... | |
bool | returnsconst |
This function variant returns a constant, useful with references. More... | |
bool | returnsref |
This function variant returns a reference. More... | |
const Type * | returntype |
Return type of this function variant. If nullptr this function does not return a value. More... | |
bool | stretchlast |
If true, in console dialect, spaces in the last parameter are not treated as parameter separator as if it is in quotes. More... | |
Represents a function overload.
Function overloads can either be C++ functions or defined by scripting. A C++ function can be embedded using MapFunction.
Return value of an overload is specified by returntype. A nullptr
value marks the function void. If the overload returns a reference, ReferenceTag must be set. An embedded function can return reference by reference or a pointer. Reference types should always be returned as a reference or pointer. If the returned reference is constant, ReturnsConstTag should be set.
A constructor overload should return the object that is constructed. A constructor that has a single parameter can be used as a casting operator if the variant is marked with ImplicitTag. Otherwise, all constructors should be invoked manually.
If a function is a member function, an overload of this function can be made private using PrivateTag. A private function can only be called from the function of the owner type or any type that is descendant of it. Private overloads are useful in scripting defined types.
A member function overload can be marked as constant by using ConstTag. If an embedded constant overload is a member function, it should be const. If it is a namespace function, it should take this pointer as either const Type *
or const Type &
. It is also possible to use Type
for value types, however, this usage is discouraged.
If an overload is marked with RepeatLastTag, the last parameter can be repeated as many times as needed. However, unless OptionalTag of the last parameter is set, at least a single parameter is required for these repeating overloads. Embedded functions should receive these parameters as either a const reference a normal std::vector of the specified type.
Overload | ( | const Type * | returntype, |
ParameterList | parameters, | ||
P_ ... | tags | ||
) |
Regular constructor that can take as many tags as needed.
References Function::Overload::parameters, and Gorgon::swap().
Overload | ( | const Type * | returntype, |
ParameterList | parameters, | ||
bool | stretchlast, | ||
bool | repeatlast, | ||
bool | accessible, | ||
bool | constant, | ||
bool | returnsref, | ||
bool | returnsconst, | ||
bool | implicit | ||
) |
A full constructor.
References Function::Overload::parameters, and Gorgon::swap().
|
virtual |
Class the stub for this function.
If ismethod parameter is set and method variant exists method variant is called. But if there is no method variant, it simply prints out the return of the function. When ismethod is set, this function will never return a value.
Implemented in RuntimeOverload, and MappedFunction< F_ >.
|
protectedvirtual |
This function should perform validity checks on the variant.
The base function should be called unless similar checks are repeated
Reimplemented in RuntimeOverload.
References ASSERT, Gorgon::String::From(), Member::GetName(), Function::Overload::parameters, Function::Overload::parent, Function::Overload::repeatlast, and Function::Overload::returntype.
const Function& GetParent | ( | ) | const |
Returns the function this variant belongs.
References ASSERT, and Function::Overload::parent.
const Type& GetReturnType | ( | ) | const |
Returns the type this variant returns.
References ASSERT, and Function::Overload::returntype.
bool HasReturnType | ( | ) | const |
Returns whether this variant returns a value.
References Function::Overload::returntype.
bool IsConstant | ( | ) | const |
Returns whether this function is a constant.
References Function::Overload::constant.
bool IsImplicit | ( | ) | const |
Returns if this variant can be used as implicit conversion.
References Function::Overload::implicit.
bool IsSame | ( | const Overload & | var | ) | const |
Compares two variants if they have the same signature.
References Function::Overload::IsConstant(), Function::Overload::Parameters, and Function::Overload::RepeatLast().
bool RepeatLast | ( | ) | const |
Returns if the last parameter of this function should be repeated.
If true last parameter can be specified any number of times. This number can be obtained from data list supplied to function stub. If both StretchTag and RepeatTag is specified, in console dialect stretch is used, while in programming dialect repeat is used.
References Function::Overload::repeatlast.
bool ReturnsConst | ( | ) | const |
This function variant returns a constant.
References Function::Overload::returnsconst.
bool ReturnsRef | ( | ) | const |
This function variant returns a reference to a value rather than the value itself.
References Function::Overload::returnsref.
bool StretchLast | ( | ) | const |
Returns if the last parameter of this function should be stretched.
If true, in console dialect, spaces in the last parameter are not treated as parameter separator as if it is in quotes. Helpful for functions like echo. But also helpful for keywords that requires their own parsing.
References Function::Overload::stretchlast.
|
protected |
Only meaningful in class member functions.
If true this function can be access from outside the type itself
|
protected |
Makes this function constant. Only works on member functions.
|
protected |
If the parent function is constructor, marks this variant as an implicit type conversion.
const ParameterList& Parameters |
The parameters of this overload.
|
protected |
Modifiable parameters of this overload.
|
protected |
The parent function of this variant.
|
protected |
If true last parameter can be specified any number of times.
This number can be obtained from data list supplied to function stub.
|
protected |
This function variant returns a constant, useful with references.
|
protected |
This function variant returns a reference.
|
protected |
Return type of this function variant. If nullptr this function does not return a value.
|
protected |
If true, in console dialect, spaces in the last parameter are not treated as parameter separator as if it is in quotes.
Helpful for functions like echo