Gorgon Game Engine
Function Class Reference

Represents a function. More...

Inheritance diagram for Function:
[legend]

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 TypeGetOwner () 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...
 
- Public Member Functions inherited from StaticMember
 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...
 
- Public Member Functions inherited from Member
 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 MemberGetOwner () 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

- Public Types inherited from StaticMember
enum  MemberType {
  RegularType, EventType, EnumType, Namespace,
  DataMember, Function, Constant
}
 Possible member types. More...
 
- Protected Attributes inherited from Member
std::string help
 Help string of the datamember. More...
 
std::string name
 The name of the datamember. More...
 
const Memberparent
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Function() [1/5]

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

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

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

Function ( const std::string &  name,
const std::string &  help,
const Type parent,
bool  keyword,
bool  isoperator,
bool  staticmember 
)

Full constructor.

References Gorgon::WindowManager::init().

◆ Function() [5/5]

Function ( const Function )
delete

◆ ~Function()

virtual ~Function ( )
virtual

Member Function Documentation

◆ AddMethod() [1/2]

virtual void AddMethod ( Overload overload)
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.

◆ AddMethod() [2/2]

virtual void AddMethod ( Overload overload)
virtual

Adds the given overload as a method to this function after performing necessary checks.

References Function::AddMethod(), ASSERT, and Member::name.

◆ AddOverload() [1/2]

virtual void AddOverload ( Overload overload)
virtual

◆ AddOverload() [2/2]

virtual void AddOverload ( Overload overload)
virtual

Adds the given overload to this function after performing necessary checks.

References Function::AddOverload(), ASSERT, and Member::name.

◆ Get()

Data Get ( ) const
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().

◆ GetMemberType()

virtual MemberType GetMemberType ( ) const
overridevirtual

Returns the type of this member.

Implements StaticMember.

References StaticMember::Function.

◆ GetOwner()

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.

◆ IsKeyword()

bool IsKeyword ( ) const

Returns if this function is actually a keyword.

◆ IsMember()

bool IsMember ( ) const

Returns if this function is a member function of a type.

◆ IsOperator()

bool IsOperator ( ) const

Returns if this function is an operator.

◆ IsStatic()

bool IsStatic ( ) const

Returns if this function is static. Only meaningful when the function is a member function.

◆ SetParent()

void SetParent ( const Member parent)
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().

Member Data Documentation

◆ Methods

The list of methods this function has.

◆ Overloads

const Containers::Collection<Overload>& Overloads

The list of overloads this function has.


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