GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
chaiscript::detail::Dispatch_Engine Class Reference

#include <dispatchkit.hpp>

Classes

struct  State

Public Types

typedef std::map< std::string, chaiscript::Type_Info > Type_Name_Map
typedef std::vector< std::pair< std::string, Boxed_Value > > Scope
typedef Stack_Holder::StackData StackData

Public Member Functions

 Dispatch_Engine (chaiscript::parser::ChaiScript_Parser_Base &parser)
template<typename Type>
decltype(auto) boxed_cast (const Boxed_Value &bv) const
 casts an object while applying any Dynamic_Conversion available
void add (const Type_Conversion &d)
 Add a new conversion for upcasting to a base class.
void add (const Proxy_Function &f, const std::string &name)
 Add a new named Proxy_Function to the system.
void add (Boxed_Value obj, const std::string &name)
Boxed_Value & add_get_object (const std::string &t_name, Boxed_Value obj, Stack_Holder &t_holder)
void add_object (const std::string &t_name, Boxed_Value obj, Stack_Holder &t_holder)
void add_object (const std::string &name, Boxed_Value obj)
void add_global_const (const Boxed_Value &obj, const std::string &name)
 Adds a new global shared object, between all the threads.
Boxed_Value add_global_no_throw (const Boxed_Value &obj, const std::string &name)
 Adds a new global (non-const) shared object, between all the threads.
void add_global (const Boxed_Value &obj, const std::string &name)
 Adds a new global (non-const) shared object, between all the threads.
void set_global (const Boxed_Value &obj, const std::string &name)
 Updates an existing global shared object or adds a new global shared object if not found.
void new_scope ()
 Adds a new scope to the stack.
void pop_scope ()
 Pops the current scope from the stack.
Boxed_Value get_object (const std::string &name, std::atomic_uint_fast32_t &t_loc, Stack_Holder &t_holder) const
void add (const Type_Info &ti, const std::string &name)
 Registers a new named type.
Type_Info get_type (const std::string &name, bool t_throw=true) const
 Returns the type info for a named type.
std::string get_type_name (const Type_Info &ti) const
std::vector< std::pair< std::string, Type_Info > > get_types () const
 Return all registered types.
std::shared_ptr< std::vector< Proxy_Function > > get_method_missing_functions () const
std::pair< size_t, std::shared_ptr< std::vector< Proxy_Function > > > get_function (const std::string &t_name, const size_t t_hint) const
 Return a function by name.
Boxed_Value get_function_object (const std::string &t_name) const
std::pair< size_t, Boxed_Value > get_function_object_int (const std::string &t_name, const size_t t_hint) const
bool function_exists (const std::string &name) const
 Return true if a function exists.
std::map< std::string, Boxed_Value > get_parent_locals () const
std::map< std::string, Boxed_Value > get_locals () const
void set_locals (const std::map< std::string, Boxed_Value > &t_locals)
 Sets all of the locals for the current thread state.
std::map< std::string, Boxed_Value > get_scripting_objects () const
std::map< std::string, Boxed_Value > get_function_objects () const
std::vector< std::pair< std::string, Proxy_Function > > get_functions () const
 Get a vector of all registered functions.
const Type_Conversions & conversions () const
Boxed_Value call_member (const std::string &t_name, std::atomic_uint_fast32_t &t_loc, const std::vector< Boxed_Value > &params, bool t_has_params, const Type_Conversions_State &t_conversions)
Boxed_Value call_function (const std::string &t_name, std::atomic_uint_fast32_t &t_loc, const std::vector< Boxed_Value > &params, const Type_Conversions_State &t_conversions) const
void dump_object (const Boxed_Value &o) const
 Dump object info to stdout.
void dump_type (const Type_Info &type) const
 Dump type info to stdout.
void dump_function (const std::pair< const std::string, Proxy_Function > &f) const
 Dump function to stdout.
Boxed_Value call_exists (const std::vector< Boxed_Value > &params) const
void dump_system () const
 Dump all system info to stdout.
bool is_type (const Boxed_Value &r, const std::string &user_typename) const
 return true if the Boxed_Value matches the registered type by name
std::string type_name (const Boxed_Value &obj) const
State get_state () const
void set_state (const State &t_state)
void save_function_params (std::initializer_list< Boxed_Value > t_params)
void save_function_params (std::vector< Boxed_Value > &&t_params)
void save_function_params (const std::vector< Boxed_Value > &t_params)
void new_function_call (Stack_Holder &t_s, Type_Conversions::Conversion_Saves &t_saves)
void pop_function_call (Stack_Holder &t_s, Type_Conversions::Conversion_Saves &t_saves)
void new_function_call ()
void pop_function_call ()
Stack_Holder & get_stack_holder ()
const StackData & get_stack_data () const
StackData & get_stack_data ()
parser::ChaiScript_Parser_Base & get_parser ()

Static Public Member Functions

static void new_scope (Stack_Holder &t_holder)
 Adds a new scope to the stack.
static void pop_scope (Stack_Holder &t_holder)
 Pops the current scope from the stack.
static void new_stack (Stack_Holder &t_holder)
 Pushes a new stack on to the list of stacks.
static void pop_stack (Stack_Holder &t_holder)
static bool is_attribute_call (const std::vector< Proxy_Function > &t_funs, const std::vector< Boxed_Value > &t_params, bool t_has_params, const Type_Conversions_State &t_conversions)
static void save_function_params (Stack_Holder &t_s, std::initializer_list< Boxed_Value > t_params)
static void save_function_params (Stack_Holder &t_s, std::vector< Boxed_Value > &&t_params)
static void save_function_params (Stack_Holder &t_s, const std::vector< Boxed_Value > &t_params)
static StackData & get_stack_data (Stack_Holder &t_holder)

Detailed Description

Main class for the dispatchkit. Handles management of the object stack, functions and registered types.

Member Typedef Documentation

◆ Scope

typedef std::vector<std::pair<std::string, Boxed_Value> > chaiscript::detail::Dispatch_Engine::Scope

◆ StackData

◆ Type_Name_Map

Constructor & Destructor Documentation

◆ Dispatch_Engine()

chaiscript::detail::Dispatch_Engine::Dispatch_Engine ( chaiscript::parser::ChaiScript_Parser_Base & parser)
inlineexplicit
Here is the caller graph for this function:

Member Function Documentation

◆ add() [1/4]

void chaiscript::detail::Dispatch_Engine::add ( Boxed_Value obj,
const std::string & name )
inline

Set the value of an object, by name. If the object is not available in the current scope it is created

◆ add() [2/4]

void chaiscript::detail::Dispatch_Engine::add ( const Proxy_Function & f,
const std::string & name )
inline

Add a new named Proxy_Function to the system.

◆ add() [3/4]

void chaiscript::detail::Dispatch_Engine::add ( const Type_Conversion & d)
inline

Add a new conversion for upcasting to a base class.

Here is the caller graph for this function:

◆ add() [4/4]

void chaiscript::detail::Dispatch_Engine::add ( const Type_Info & ti,
const std::string & name )
inline

Registers a new named type.

◆ add_get_object()

Boxed_Value & chaiscript::detail::Dispatch_Engine::add_get_object ( const std::string & t_name,
Boxed_Value obj,
Stack_Holder & t_holder )
inline

Adds a named object to the current scope

Warning
This version does not check the validity of the name it is meant for internal use only

◆ add_global()

void chaiscript::detail::Dispatch_Engine::add_global ( const Boxed_Value & obj,
const std::string & name )
inline

Adds a new global (non-const) shared object, between all the threads.

◆ add_global_const()

void chaiscript::detail::Dispatch_Engine::add_global_const ( const Boxed_Value & obj,
const std::string & name )
inline

Adds a new global shared object, between all the threads.

Here is the caller graph for this function:

◆ add_global_no_throw()

Boxed_Value chaiscript::detail::Dispatch_Engine::add_global_no_throw ( const Boxed_Value & obj,
const std::string & name )
inline

Adds a new global (non-const) shared object, between all the threads.

Here is the caller graph for this function:

◆ add_object() [1/2]

void chaiscript::detail::Dispatch_Engine::add_object ( const std::string & name,
Boxed_Value obj )
inline

Adds a named object to the current scope

Warning
This version does not check the validity of the name it is meant for internal use only

◆ add_object() [2/2]

void chaiscript::detail::Dispatch_Engine::add_object ( const std::string & t_name,
Boxed_Value obj,
Stack_Holder & t_holder )
inline

Adds a named object to the current scope

Warning
This version does not check the validity of the name it is meant for internal use only
Here is the caller graph for this function:

◆ boxed_cast()

template<typename Type>
decltype(auto) chaiscript::detail::Dispatch_Engine::boxed_cast ( const Boxed_Value & bv) const
inline

casts an object while applying any Dynamic_Conversion available

Here is the caller graph for this function:

◆ call_exists()

Boxed_Value chaiscript::detail::Dispatch_Engine::call_exists ( const std::vector< Boxed_Value > & params) const
inline

Returns true if a call can be made that consists of the first parameter (the function) with the remaining parameters as its arguments.

◆ call_function()

Boxed_Value chaiscript::detail::Dispatch_Engine::call_function ( const std::string & t_name,
std::atomic_uint_fast32_t & t_loc,
const std::vector< Boxed_Value > & params,
const Type_Conversions_State & t_conversions ) const
inline
Here is the caller graph for this function:

◆ call_member()

Boxed_Value chaiscript::detail::Dispatch_Engine::call_member ( const std::string & t_name,
std::atomic_uint_fast32_t & t_loc,
const std::vector< Boxed_Value > & params,
bool t_has_params,
const Type_Conversions_State & t_conversions )
inline
Here is the caller graph for this function:

◆ conversions()

const Type_Conversions & chaiscript::detail::Dispatch_Engine::conversions ( ) const
inline

◆ dump_function()

void chaiscript::detail::Dispatch_Engine::dump_function ( const std::pair< const std::string, Proxy_Function > & f) const
inline

Dump function to stdout.

Here is the caller graph for this function:

◆ dump_object()

void chaiscript::detail::Dispatch_Engine::dump_object ( const Boxed_Value & o) const
inline

Dump object info to stdout.

◆ dump_system()

void chaiscript::detail::Dispatch_Engine::dump_system ( ) const
inline

Dump all system info to stdout.

◆ dump_type()

void chaiscript::detail::Dispatch_Engine::dump_type ( const Type_Info & type) const
inline

Dump type info to stdout.

Here is the caller graph for this function:

◆ function_exists()

bool chaiscript::detail::Dispatch_Engine::function_exists ( const std::string & name) const
inline

Return true if a function exists.

◆ get_function()

std::pair< size_t, std::shared_ptr< std::vector< Proxy_Function > > > chaiscript::detail::Dispatch_Engine::get_function ( const std::string & t_name,
const size_t t_hint ) const
inline

Return a function by name.

Here is the caller graph for this function:

◆ get_function_object()

Boxed_Value chaiscript::detail::Dispatch_Engine::get_function_object ( const std::string & t_name) const
inline
Returns
a function object (Boxed_Value wrapper) if it exists
Exceptions
std::range_errorif it does not

◆ get_function_object_int()

std::pair< size_t, Boxed_Value > chaiscript::detail::Dispatch_Engine::get_function_object_int ( const std::string & t_name,
const size_t t_hint ) const
inline
Returns
a function object (Boxed_Value wrapper) if it exists
Exceptions
std::range_errorif it does not \warn does not obtain a mutex lock.
See also
get_function_object for public version
Here is the caller graph for this function:

◆ get_function_objects()

std::map< std::string, Boxed_Value > chaiscript::detail::Dispatch_Engine::get_function_objects ( ) const
inline

Get a map of all functions that can be seen from a scripting context

◆ get_functions()

std::vector< std::pair< std::string, Proxy_Function > > chaiscript::detail::Dispatch_Engine::get_functions ( ) const
inline

Get a vector of all registered functions.

Here is the caller graph for this function:

◆ get_locals()

std::map< std::string, Boxed_Value > chaiscript::detail::Dispatch_Engine::get_locals ( ) const
inline
Returns
All values in the local thread state, added through the add() function

◆ get_method_missing_functions()

std::shared_ptr< std::vector< Proxy_Function > > chaiscript::detail::Dispatch_Engine::get_method_missing_functions ( ) const
inline
Here is the caller graph for this function:

◆ get_object()

Boxed_Value chaiscript::detail::Dispatch_Engine::get_object ( const std::string & name,
std::atomic_uint_fast32_t & t_loc,
Stack_Holder & t_holder ) const
inline

Searches the current stack for an object of the given name includes a special overload for the _ place holder object to ensure that it is always in scope.

◆ get_parent_locals()

std::map< std::string, Boxed_Value > chaiscript::detail::Dispatch_Engine::get_parent_locals ( ) const
inline
Returns
All values in the local thread state in the parent scope, or if it doesn't exist, the current scope.

◆ get_parser()

parser::ChaiScript_Parser_Base & chaiscript::detail::Dispatch_Engine::get_parser ( )
inline
Here is the caller graph for this function:

◆ get_scripting_objects()

std::map< std::string, Boxed_Value > chaiscript::detail::Dispatch_Engine::get_scripting_objects ( ) const
inline

Get a map of all objects that can be seen from the current scope in a scripting context

◆ get_stack_data() [1/3]

StackData & chaiscript::detail::Dispatch_Engine::get_stack_data ( )
inline

◆ get_stack_data() [2/3]

const StackData & chaiscript::detail::Dispatch_Engine::get_stack_data ( ) const
inline

Returns the current stack make const/non const versions

Here is the caller graph for this function:

◆ get_stack_data() [3/3]

StackData & chaiscript::detail::Dispatch_Engine::get_stack_data ( Stack_Holder & t_holder)
inlinestatic

◆ get_stack_holder()

Stack_Holder & chaiscript::detail::Dispatch_Engine::get_stack_holder ( )
inline
Here is the caller graph for this function:

◆ get_state()

State chaiscript::detail::Dispatch_Engine::get_state ( ) const
inline

◆ get_type()

Type_Info chaiscript::detail::Dispatch_Engine::get_type ( const std::string & name,
bool t_throw = true ) const
inline

Returns the type info for a named type.

Here is the caller graph for this function:

◆ get_type_name()

std::string chaiscript::detail::Dispatch_Engine::get_type_name ( const Type_Info & ti) const
inline

Returns the registered name of a known type_info object compares the "bare_type_info" for the broadest possible match

Here is the caller graph for this function:

◆ get_types()

std::vector< std::pair< std::string, Type_Info > > chaiscript::detail::Dispatch_Engine::get_types ( ) const
inline

Return all registered types.

Here is the caller graph for this function:

◆ is_attribute_call()

bool chaiscript::detail::Dispatch_Engine::is_attribute_call ( const std::vector< Proxy_Function > & t_funs,
const std::vector< Boxed_Value > & t_params,
bool t_has_params,
const Type_Conversions_State & t_conversions )
inlinestatic
Here is the caller graph for this function:

◆ is_type()

bool chaiscript::detail::Dispatch_Engine::is_type ( const Boxed_Value & r,
const std::string & user_typename ) const
inline

return true if the Boxed_Value matches the registered type by name

◆ new_function_call() [1/2]

void chaiscript::detail::Dispatch_Engine::new_function_call ( )
inline

◆ new_function_call() [2/2]

void chaiscript::detail::Dispatch_Engine::new_function_call ( Stack_Holder & t_s,
Type_Conversions::Conversion_Saves & t_saves )
inline
Here is the caller graph for this function:

◆ new_scope() [1/2]

void chaiscript::detail::Dispatch_Engine::new_scope ( )
inline

Adds a new scope to the stack.

Here is the caller graph for this function:

◆ new_scope() [2/2]

void chaiscript::detail::Dispatch_Engine::new_scope ( Stack_Holder & t_holder)
inlinestatic

Adds a new scope to the stack.

◆ new_stack()

void chaiscript::detail::Dispatch_Engine::new_stack ( Stack_Holder & t_holder)
inlinestatic

Pushes a new stack on to the list of stacks.

◆ pop_function_call() [1/2]

void chaiscript::detail::Dispatch_Engine::pop_function_call ( )
inline

◆ pop_function_call() [2/2]

void chaiscript::detail::Dispatch_Engine::pop_function_call ( Stack_Holder & t_s,
Type_Conversions::Conversion_Saves & t_saves )
inline
Here is the caller graph for this function:

◆ pop_scope() [1/2]

void chaiscript::detail::Dispatch_Engine::pop_scope ( )
inline

Pops the current scope from the stack.

Here is the caller graph for this function:

◆ pop_scope() [2/2]

void chaiscript::detail::Dispatch_Engine::pop_scope ( Stack_Holder & t_holder)
inlinestatic

Pops the current scope from the stack.

◆ pop_stack()

void chaiscript::detail::Dispatch_Engine::pop_stack ( Stack_Holder & t_holder)
inlinestatic

◆ save_function_params() [1/6]

void chaiscript::detail::Dispatch_Engine::save_function_params ( const std::vector< Boxed_Value > & t_params)
inline

◆ save_function_params() [2/6]

void chaiscript::detail::Dispatch_Engine::save_function_params ( Stack_Holder & t_s,
const std::vector< Boxed_Value > & t_params )
inlinestatic

◆ save_function_params() [3/6]

void chaiscript::detail::Dispatch_Engine::save_function_params ( Stack_Holder & t_s,
std::initializer_list< Boxed_Value > t_params )
inlinestatic
Here is the caller graph for this function:

◆ save_function_params() [4/6]

void chaiscript::detail::Dispatch_Engine::save_function_params ( Stack_Holder & t_s,
std::vector< Boxed_Value > && t_params )
inlinestatic

◆ save_function_params() [5/6]

void chaiscript::detail::Dispatch_Engine::save_function_params ( std::initializer_list< Boxed_Value > t_params)
inline

◆ save_function_params() [6/6]

void chaiscript::detail::Dispatch_Engine::save_function_params ( std::vector< Boxed_Value > && t_params)
inline

◆ set_global()

void chaiscript::detail::Dispatch_Engine::set_global ( const Boxed_Value & obj,
const std::string & name )
inline

Updates an existing global shared object or adds a new global shared object if not found.

◆ set_locals()

void chaiscript::detail::Dispatch_Engine::set_locals ( const std::map< std::string, Boxed_Value > & t_locals)
inline

Sets all of the locals for the current thread state.

Parameters
[in]t_localsThe map<name, value> set of variables to replace the current state with

Any existing locals are removed and the given set of variables is added

◆ set_state()

void chaiscript::detail::Dispatch_Engine::set_state ( const State & t_state)
inline

◆ type_name()

std::string chaiscript::detail::Dispatch_Engine::type_name ( const Boxed_Value & obj) const
inline
Here is the caller graph for this function:

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