Gorgon Game Engine
Function::Overload Class Referenceabstract

Represents a function overload. More...

Inheritance diagram for Function::Overload:
[legend]

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 > &parameters) const =0
 Class the stub for this function. More...
 
const FunctionGetParent () const
 Returns the function this variant belongs. More...
 
const TypeGetReturnType () 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 ParameterListParameters
 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...
 
Functionparent
 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 Typereturntype
 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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Overload() [1/2]

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() [2/2]

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().

◆ ~Overload()

virtual ~Overload ( )
virtual

Member Function Documentation

◆ Call()

virtual Data Call ( bool  ismethod,
const std::vector< Data > &  parameters 
) const
pure 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_ >.

◆ dochecks()

void dochecks ( bool  ismethod)
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.

◆ GetParent()

const Function& GetParent ( ) const

Returns the function this variant belongs.

References ASSERT, and Function::Overload::parent.

◆ GetReturnType()

const Type& GetReturnType ( ) const

Returns the type this variant returns.

References ASSERT, and Function::Overload::returntype.

◆ HasReturnType()

bool HasReturnType ( ) const

Returns whether this variant returns a value.

References Function::Overload::returntype.

◆ IsConstant()

bool IsConstant ( ) const

Returns whether this function is a constant.

References Function::Overload::constant.

◆ IsImplicit()

bool IsImplicit ( ) const

Returns if this variant can be used as implicit conversion.

References Function::Overload::implicit.

◆ IsSame()

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().

◆ 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.

◆ ReturnsConst()

bool ReturnsConst ( ) const

This function variant returns a constant.

References Function::Overload::returnsconst.

◆ ReturnsRef()

bool ReturnsRef ( ) const

This function variant returns a reference to a value rather than the value itself.

References Function::Overload::returnsref.

◆ StretchLast()

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.

Member Data Documentation

◆ accessible

bool accessible
protected

Only meaningful in class member functions.

If true this function can be access from outside the type itself

◆ constant

bool constant
protected

Makes this function constant. Only works on member functions.

◆ implicit

bool implicit
protected

If the parent function is constructor, marks this variant as an implicit type conversion.

◆ Parameters

const ParameterList& Parameters

The parameters of this overload.

◆ parameters

ParameterList parameters
protected

Modifiable parameters of this overload.

◆ parent

Function* parent
protected

The parent function of this variant.

◆ repeatlast

bool repeatlast
protected

If true last parameter can be specified any number of times.

This number can be obtained from data list supplied to function stub.

◆ returnsconst

bool returnsconst
protected

This function variant returns a constant, useful with references.

◆ returnsref

bool returnsref
protected

This function variant returns a reference.

◆ returntype

const Type* returntype
protected

Return type of this function variant. If nullptr this function does not return a value.

◆ stretchlast

bool stretchlast
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


The documentation for this class was generated from the following files: