SourceForge.net Logo

eval::execution_context Class Reference

Stores methods/constructors/functions, types and global variables for an eval program. More...

#include <execution_context.hpp>

Inheritance diagram for eval::execution_context:

Inheritance graph
[legend]
Collaboration diagram for eval::execution_context:

Collaboration graph
[legend]

List of all members.

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)
valget_global (const std::string &name)
 
Exceptions:
undefined_global_exception if name is not defined

const valget_global (const std::string &name) const
 
Exceptions:
undefined_global_exception if name is not defined

void add_global (const std::string &name, const val &v)
 
Exceptions:
redefined_global_exception if name is already defined

valoperator[] (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_contextoperator= (const execution_context &rhs)
 prevent copying

Private Attributes

bool _initialized


Detailed Description

Stores methods/constructors/functions, types and global variables for an eval program.

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.


Member Typedef Documentation

typedef std::multimap<std::string, fwrap>::const_iterator eval::execution_context::fwrap_it_t [protected]


Constructor & Destructor Documentation

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


Member Function Documentation

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.

bool eval::execution_context::point_to_same_obj ( val lhs,
val rhs 
) const [inline]

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.

template<typename DesiredT>
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.

Exceptions:
bad_extended_val_cast 

template<typename DesiredT>
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.

Exceptions:
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.

Exceptions:
unknown_type_exception if desired_type is unknown
bad_extended_val_cast 
Warning:
If a pointer conversion is done, the returned val object will not share ownership with the original (i.e. it will contain an unmanaged pointer).

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).

Exceptions:
no_matching_function_exception if args are inappropriate
See also:
point_to_same_obj()

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]

Exceptions:
no_matching_function_exception 
ambiguous_overload_exception 
unknown_type_exception if args[0] is not a known type
Precondition:
args.size() >= 1

val eval::execution_context::call_function_or_method ( const std::string &  name,
fwrap_args args 
) [inline]

Exceptions:
no_matching_function_exception 
ambiguous_overload_exception 
unknown_type_exception if args[0] is not a known type
Precondition:
args.size() >= 1

val & eval::execution_context::get_global ( const std::string &  name  ) 

Exceptions:
undefined_global_exception if name is not defined

const val & eval::execution_context::get_global ( const std::string &  name  )  const

Exceptions:
undefined_global_exception if name is not defined

void eval::execution_context::add_global ( const std::string &  name,
const val v 
)

Exceptions:
redefined_global_exception if name is already defined

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]

Returns:
the best match (possibly null) and whether that match was ambiguous.

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


Member Data Documentation

std::multimap<std::string, fwrap> eval::execution_context::_functions [protected]

std::map<std::string, const std::type_info *> eval::execution_context::_types [protected]

std::map<std::string, val> eval::execution_context::_globals [protected]


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

Generated on Sat Sep 20 20:02:34 2008 for eval by  doxygen 1.5.6