ArkScript
A small, lisp-inspired, functional scripting language
Ark::Procedure Class Reference

Storage class to hold custom functions. More...

#include <Procedure.hpp>

Public Types

using PointerType = Value (*)(std::vector<Value>&, VM*)
 
using CallbackType = std::function<Value(std::vector<Value>&, VM*)>
 

Public Member Functions

template<typename T >
 Procedure (T &&cb)
 Create a new procedure.
 
 Procedure (PointerType c_ptr)
 Create a new procedure from a stateless C function pointer.
 
Value operator() (std::vector< Value > &, VM *) const
 
bool operator< (const Procedure &other) const noexcept
 
bool operator== (const Procedure &other) const noexcept
 

Private Attributes

CallbackType m_procedure
 

Detailed Description

Storage class to hold custom functions.

Definition at line 25 of file Procedure.hpp.

Member Typedef Documentation

◆ CallbackType

using Ark::Procedure::CallbackType = std::function<Value(std::vector<Value>&, VM*)>

Definition at line 29 of file Procedure.hpp.

◆ PointerType

using Ark::Procedure::PointerType = Value (*)(std::vector<Value>&, VM*)

Definition at line 28 of file Procedure.hpp.

Constructor & Destructor Documentation

◆ Procedure() [1/2]

template<typename T >
Ark::Procedure::Procedure ( T && cb)
inline

Create a new procedure.

Due to clang (sometimes) rejecting forward declared types in templates (Value causes issues), we have to implement the constructor for the actual CallbackType using SFINAE and a templated constructor, such that when clang encounters the constructor, it knows the actual declaration of Value.

Definition at line 43 of file Procedure.hpp.

◆ Procedure() [2/2]

Ark::Procedure::Procedure ( PointerType c_ptr)

Create a new procedure from a stateless C function pointer.

Definition at line 13 of file Procedure.cpp.

References m_procedure.

Member Function Documentation

◆ operator()()

Value Ark::Procedure::operator() ( std::vector< Value > & args,
VM * vm ) const

Definition at line 8 of file Procedure.cpp.

References m_procedure.

◆ operator<()

bool Ark::Procedure::operator< ( const Procedure & other) const
noexcept

Definition at line 18 of file Procedure.cpp.

◆ operator==()

bool Ark::Procedure::operator== ( const Procedure & other) const
noexcept

Definition at line 23 of file Procedure.cpp.

Member Data Documentation

◆ m_procedure

CallbackType Ark::Procedure::m_procedure
private

Definition at line 59 of file Procedure.hpp.

Referenced by operator()(), and Procedure().


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