![]() |
Gorgon Game Engine
|
Represents a function. More...
Classes | |
class | Overload |
Represents a function overload. More... | |
Public Member Functions | |
Function (const Function &)=delete | |
template<class ... P_> | |
Function (const std::string &name, const std::string &help, const Type *parent, bool keyword, bool isoperator, bool staticmember) | |
Full constructor. More... | |
template<class ... P_> | |
Function (const std::string &name, const std::string &help, const Type *parent, const Containers::Collection< Overload > &overloads, const Containers::Collection< Overload > &methods, Tag tag, P_ ...tags) | |
Regular constructor with both overloads and methods specified a long with at least a single tag. More... | |
template<class ... P_> | |
Function (const std::string &name, const std::string &help, const Type *parent, const Containers::Collection< Overload > &overloads, const Containers::Collection< Overload > &methods=Containers::Collection< Overload >()) | |
Regular constructor with both overloads and methods without any tags. More... | |
template<class ... P_> | |
Function (const std::string &name, const std::string &help, const Type *parent, const Containers::Collection< Overload > &overloads, Tag tag, P_ ...tags) | |
Regular constructor with overloads specified a long with at least a single tag. More... | |
virtual | ~Function () |
virtual void | AddMethod (Overload &overload) |
Adds the given overload as a method to this function after performing necessary checks. More... | |
virtual void | AddMethod (Overload *overload) |
Adds the given overload as a method to this function after performing necessary checks. More... | |
virtual void | AddOverload (Overload &overload) |
Adds the given overload to this function after performing necessary checks. More... | |
virtual void | AddOverload (Overload *overload) |
Adds the given overload to this function after performing necessary checks. More... | |
virtual Data | Get () const override final |
Returns the value of this static member. More... | |
virtual MemberType | GetMemberType () const override |
Returns the type of this member. More... | |
const Type & | GetOwner () const |
If this function is a member function, returns the owner object. More... | |
bool | IsKeyword () const |
Returns if this function is actually a keyword. More... | |
bool | IsMember () const |
Returns if this function is a member function of a type. More... | |
bool | IsOperator () const |
Returns if this function is an operator. More... | |
bool | IsStatic () const |
Returns if this function is static. Only meaningful when the function is a member function. More... | |
virtual void | SetParent (const Member &parent) override final |
Changes the parent of the member. More... | |
![]() | |
StaticMember (const std::string &name, const std::string &help) | |
bool | IsInstanceable () const |
Whether this member can be used to instantiate an object. More... | |
virtual bool | IsInstanceMember () const override final |
Returns if this member is an instance member. More... | |
![]() | |
Member (const std::string &name, const std::string &help) | |
virtual | ~Member () |
std::string | GetHelp () const |
Returns the help string. Help strings may contain markdown notation. More... | |
std::string | GetName () const |
Returns the name of this member. More... | |
const Member * | GetOwner () const |
std::string | GetQualifiedName () const |
Returns the namespace qualified name of this member. More... | |
Public Attributes | |
const Containers::Collection< Overload > & | Methods |
The list of methods this function has. More... | |
const Containers::Collection< Overload > & | Overloads |
The list of overloads this function has. More... | |
Additional Inherited Members | |
![]() | |
enum | MemberType { RegularType, EventType, EnumType, Namespace, DataMember, Function, Constant } |
Possible member types. More... | |
![]() | |
std::string | help |
Help string of the datamember. More... | |
std::string | name |
The name of the datamember. More... | |
const Member * | parent |
Represents a function.
Functions contains overloads that vary in parameters and/or traits. Overloads can be C++ functions or functions that are defined by scripting. Overloads can be added after the object is constructed.
A function can act as a keyword. While keywords do not have special traits they have additional restrictions. Keywords cannot return values and cannot be member functions. Keywords may have special syntax based on the dialect that is effect. For instance, in programming dialect, keywords do not require parenthesis to be called. A function can be marked as a keyword using KeywordTag.
If an owner (or parent) is set, the function will become a member function. Member functions becomes a part of the owner type. A member function can also be static using StaticTag. A static member function do not have this pointer and cannot be accessed from a member of the type. Instead it can be accessed using Type:Fn
syntax. Constructor functions are also marked as static. Member functions can be called either by issuing Object.fn(...)
or fn(Object, ...)
. Latter case is useful for calling member functions on literals.
A member function can act as an operator if OperatorTag is set. Operator functions must have a single parameter and cannot be static. While performing overload resolution, if ambiguity occurs, the overload that has same parameter type as the owner type is favored. This solves cases where the right hand side type do not have a specific overload but can be converted to multiple type that have overloads.
Function | ( | const std::string & | name, |
const std::string & | help, | ||
const Type * | parent, | ||
const Containers::Collection< Overload > & | overloads, | ||
const Containers::Collection< Overload > & | methods, | ||
Tag | tag, | ||
P_ ... | tags | ||
) |
Regular constructor with both overloads and methods specified a long with at least a single tag.
References Function::AddMethod(), Function::AddOverload(), and Gorgon::WindowManager::init().
Function | ( | const std::string & | name, |
const std::string & | help, | ||
const Type * | parent, | ||
const Containers::Collection< Overload > & | overloads, | ||
Tag | tag, | ||
P_ ... | tags | ||
) |
Regular constructor with overloads specified a long with at least a single tag.
References Function::AddOverload(), and Gorgon::WindowManager::init().
Function | ( | const std::string & | name, |
const std::string & | help, | ||
const Type * | parent, | ||
const Containers::Collection< Overload > & | overloads, | ||
const Containers::Collection< Overload > & | methods = Containers::Collection<Overload>() |
||
) |
Regular constructor with both overloads and methods without any tags.
References Function::AddMethod(), Function::AddOverload(), and Gorgon::WindowManager::init().
Function | ( | const std::string & | name, |
const std::string & | help, | ||
const Type * | parent, | ||
bool | keyword, | ||
bool | isoperator, | ||
bool | staticmember | ||
) |
Full constructor.
References Gorgon::WindowManager::init().
|
virtual |
References Collection< T_ >::Destroy().
|
virtual |
Adds the given overload as a method to this function after performing necessary checks.
References ASSERT, Function::Overload::dochecks(), Gorgon::Scripting::Types::Function(), Function::Overload::IsSame(), Member::name, and Function::Overload::parent.
|
virtual |
Adds the given overload as a method to this function after performing necessary checks.
References Function::AddMethod(), ASSERT, and Member::name.
|
virtual |
Adds the given overload to this function after performing necessary checks.
References ASSERT, Function::Overload::dochecks(), Gorgon::Scripting::Types::Function(), Function::Overload::IsSame(), Member::name, Function::Overload::parameters, and Function::Overload::parent.
|
virtual |
Adds the given overload to this function after performing necessary checks.
References Function::AddOverload(), ASSERT, and Member::name.
|
finaloverridevirtual |
Returns the value of this static member.
For types and functions, this function returns type and function objects.
Implements StaticMember.
References Gorgon::Scripting::Types::Function().
|
overridevirtual |
const Type& GetOwner | ( | ) | const |
If this function is a member function, returns the owner object.
If this function is not a member function, this function crashes.
References ASSERT.
bool IsKeyword | ( | ) | const |
Returns if this function is actually a keyword.
bool IsMember | ( | ) | const |
Returns if this function is a member function of a type.
bool IsOperator | ( | ) | const |
Returns if this function is an operator.
bool IsStatic | ( | ) | const |
Returns if this function is static. Only meaningful when the function is a member function.
|
finaloverridevirtual |
Changes the parent of the member.
Subclasses may perform additional checks when the parent is determined. Subclass should always call parent class' SetParent function first
Reimplemented from Member.
References ASSERT, Function::GetMemberType(), Member::IsInstanceMember(), StaticMember::Namespace, and Member::SetParent().
const Containers::Collection<Overload>& Methods |
The list of methods this function has.
const Containers::Collection<Overload>& Overloads |
The list of overloads this function has.