#include <execution_context.hpp>
Public Types | ||||
typedef val(* | val_convert_t )(val &v) | |||
Public Member Functions | ||||
execution_context () | ||||
virtual void | register_all () | |||
bool | point_to_same_obj (val &lhs, val &rhs) const | |||
template<typename DesiredT> | ||||
DesiredT * | extended_val_cast_ptr (val &v) const | |||
template<typename DesiredT> | ||||
DesiredT | extended_val_cast_value (val &v) const | |||
val | val_cast_conversion_string (val &v, const std::string &desired_type, bool can_use_temp) const | |||
val | call (fwrap &f, fwrap_args &args) | |||
val | call_function (const std::string &fn_name, fwrap_args &args) | |||
val | call_method (const std::string &m_name, fwrap_args &args) | |||
val | call_function_or_method (const std::string &name, fwrap_args &args) | |||
val & | get_global (const std::string &name) | |||
| ||||
const val & | get_global (const std::string &name) const | |||
| ||||
void | add_global (const std::string &name, const val &v) | |||
| ||||
val & | operator[] (const std::string &name) | |||
void | clear_globals () | |||
virtual | ~execution_context () | |||
Protected Types | ||||
typedef std::multimap < std::string, fwrap > ::const_iterator | fwrap_it_t | |||
Protected Member Functions | ||||
virtual void | register_functions () | |||
virtual void | register_methods_and_ctors () | |||
virtual void | register_types () | |||
virtual void | register_conversions () | |||
Protected Attributes | ||||
std::multimap< std::string, fwrap > | _functions | |||
std::map< const std::type_info *, detail::object_method_store *, detail::type_info_ptr_compare > | _objects | |||
std::map< std::string, const std::type_info * > | _types | |||
std::map < detail::type_info_conversion_store, val_convert_t > | _ptr_conversions | |||
std::map < detail::type_info_conversion_store, val_convert_t > | _value_conversions | |||
std::map< std::string, val > | _globals | |||
Private Member Functions | ||||
val | val_cast_conversion (val &v, const std::type_info *desired_type, bool can_use_temp) const | |||
std::pair< fwrap, bool > | find_best_match (std::pair< fwrap_it_t, fwrap_it_t > &candidate_range, fwrap_args::iterator args_begin, fwrap_args::iterator args_end, fwrap_args &best_match_args, std::vector< detail::conversion_rank > &best_match_rank) | |||
void | throw_if_match_invalid (const std::string &name, std::pair< fwrap, bool > &best_match, fwrap_args &args) | |||
std::string | type_name (const std::type_info *type) const | |||
std::string | format_fn_call_debug (const std::string &fn_name, fwrap_args &args) const | |||
void | remove_aliasing (val &v, fwrap &f, fwrap_args::iterator orig_arg_it, fwrap_args::iterator actual_arg_it) | |||
execution_context (const execution_context &e) | ||||
prevent copying | ||||
execution_context & | operator= (const execution_context &rhs) | |||
prevent copying | ||||
Private Attributes | ||||
bool | _initialized |
Normally, a subclass, EVAL_EXECUTION_CONTEXT_NAME, is auto-generated from an eval header. A large number of C++ automatic type conversions can then be emulated. Basic overloaded resolution also exists.
typedef val(* eval::execution_context::val_convert_t)(val &v) |
typedef std::multimap<std::string, fwrap>::const_iterator eval::execution_context::fwrap_it_t [protected] |
eval::execution_context::execution_context | ( | ) | [inline] |
eval::execution_context::~execution_context | ( | ) | [inline, virtual] |
eval::execution_context::execution_context | ( | const execution_context & | e | ) | [private] |
prevent copying
virtual void eval::execution_context::register_all | ( | ) | [inline, virtual] |
Registers methods and functions (the actual work is done in a subclass, which is generated specifically for the eval header). Note that it is possible to use the execution context without calling this methods, it just means that function/method lookups will fail and casts will be less useful, but call() may still provide some functionality.
An improved version of val::points_to_same_object_as(), which will attempt to convert the two arguments to the same type, before comparing (upcasts (dynamic casts) or downcasts should work). For this to work well, you must have the appropriate types registered in your eval header file.
DesiredT * eval::execution_context::extended_val_cast_ptr | ( | val & | v | ) | const [inline] |
An improved version of eval::val_cast_ptr, which aims to support upcasts (dynamic casts) and downcasts. For this to work well, you must have the appropriate types registered in your eval header file.
bad_extended_val_cast |
DesiredT eval::execution_context::extended_val_cast_value | ( | val & | v | ) | const [inline] |
Attempt to convert to DesiredT, using available conversion functions/constructors. For this to work well, you must have the appropriate types registered in your eval header file.
bad_extended_val_cast |
val eval::execution_context::val_cast_conversion_string | ( | val & | v, | |
const std::string & | desired_type, | |||
bool | can_use_temp | |||
) | const [inline] |
Attempt to convert to desired_type, either doing a pointer conversion, if can_use_temp
is false, or else doing a value conversion. Note, desired_type must be a simple string naming a type, e.g. "std::string". For this method to work well, you must have the appropriate types registered in your eval header file.
unknown_type_exception | if desired_type is unknown | |
bad_extended_val_cast |
val eval::execution_context::call | ( | fwrap & | f, | |
fwrap_args & | args | |||
) | [inline] |
Removes some of the limitations of eval::fwrap::operator()(). The idea is the same, but we check whether the return val appears to be pointing to one of the arguments passed in. If we can detect this, we return a copy of that argument's val object instead (this will enable reference counting to work properly, depending on the argument's copy strategy).
no_matching_function_exception | if args are inappropriate |
val eval::execution_context::call_function | ( | const std::string & | fn_name, | |
fwrap_args & | args | |||
) | [inline] |
val eval::execution_context::call_method | ( | const std::string & | m_name, | |
fwrap_args & | args | |||
) | [inline] |
no_matching_function_exception | ||
ambiguous_overload_exception | ||
unknown_type_exception | if args[0] is not a known type |
val eval::execution_context::call_function_or_method | ( | const std::string & | name, | |
fwrap_args & | args | |||
) | [inline] |
no_matching_function_exception | ||
ambiguous_overload_exception | ||
unknown_type_exception | if args[0] is not a known type |
val & eval::execution_context::get_global | ( | const std::string & | name | ) |
const val & eval::execution_context::get_global | ( | const std::string & | name | ) | const |
void eval::execution_context::add_global | ( | const std::string & | name, | |
const val & | v | |||
) |
val & eval::execution_context::operator[] | ( | const std::string & | name | ) |
void eval::execution_context::clear_globals | ( | ) |
virtual void eval::execution_context::register_functions | ( | ) | [inline, protected, virtual] |
Reimplemented in EVAL_EXECUTION_CONTEXT_NAME.
virtual void eval::execution_context::register_methods_and_ctors | ( | ) | [inline, protected, virtual] |
Reimplemented in EVAL_EXECUTION_CONTEXT_NAME.
virtual void eval::execution_context::register_types | ( | ) | [inline, protected, virtual] |
Reimplemented in EVAL_EXECUTION_CONTEXT_NAME.
virtual void eval::execution_context::register_conversions | ( | ) | [inline, protected, virtual] |
Reimplemented in EVAL_EXECUTION_CONTEXT_NAME.
val eval::execution_context::val_cast_conversion | ( | val & | v, | |
const std::type_info * | desired_type, | |||
bool | can_use_temp | |||
) | const [inline, private] |
std::pair< fwrap, bool > eval::execution_context::find_best_match | ( | std::pair< fwrap_it_t, fwrap_it_t > & | candidate_range, | |
fwrap_args::iterator | args_begin, | |||
fwrap_args::iterator | args_end, | |||
fwrap_args & | best_match_args, | |||
std::vector< detail::conversion_rank > & | best_match_rank | |||
) | [inline, private] |
void eval::execution_context::throw_if_match_invalid | ( | const std::string & | name, | |
std::pair< fwrap, bool > & | best_match, | |||
fwrap_args & | args | |||
) | [inline, private] |
std::string eval::execution_context::type_name | ( | const std::type_info * | type | ) | const [inline, private] |
std::string eval::execution_context::format_fn_call_debug | ( | const std::string & | fn_name, | |
fwrap_args & | args | |||
) | const [inline, private] |
void eval::execution_context::remove_aliasing | ( | val & | v, | |
fwrap & | f, | |||
fwrap_args::iterator | orig_arg_it, | |||
fwrap_args::iterator | actual_arg_it | |||
) | [inline, private] |
execution_context& eval::execution_context::operator= | ( | const execution_context & | rhs | ) | [private] |
prevent copying
std::multimap<std::string, fwrap> eval::execution_context::_functions [protected] |
std::map<const std::type_info *, detail::object_method_store *, detail::type_info_ptr_compare > eval::execution_context::_objects [protected] |
std::map<std::string, const std::type_info *> eval::execution_context::_types [protected] |
std::map<detail::type_info_conversion_store, val_convert_t> eval::execution_context::_ptr_conversions [protected] |
std::map<detail::type_info_conversion_store, val_convert_t> eval::execution_context::_value_conversions [protected] |
std::map<std::string, val> eval::execution_context::_globals [protected] |
bool eval::execution_context::_initialized [private] |