Initial check in of support for upcasting during function invocation. No examples or tests are checked in yet. Some reorg was necessary to get things compiling in the right order. Is not currently thread safe and probably does not work properly across module boundaries

This commit is contained in:
Jason Turner
2010-08-02 01:38:25 +00:00
parent b971ee44ad
commit edee892cad
12 changed files with 873 additions and 526 deletions

View File

@@ -0,0 +1,56 @@
// This file is distributed under the BSD License.
// See "license.txt" for details.
// Copyright 2009-2010, Jonathan Turner (jturner@minnow-lang.org)
// and Jason Turner (lefticus@gmail.com)
// http://www.chaiscript.com
#ifndef __bad_boxed_cast_hpp__
#define __bad_boxed_cast_hpp__
#include "type_info.hpp"
namespace chaiscript
{
/**
* class that is thrown in the event of a bad_boxed_cast. That is,
* in the case that a Boxed_Value cannot be cast to the desired type
*/
class bad_boxed_cast : public std::bad_cast
{
public:
bad_boxed_cast(const Type_Info &t_from, const std::type_info &t_to,
const std::string &what)
: from(t_from), to(&t_to), m_what(what)
{
}
bad_boxed_cast(const Type_Info &t_from, const std::type_info &t_to) throw()
: from(t_from), to(&t_to), m_what("Cannot perform boxed_cast")
{
}
bad_boxed_cast(const std::string &w) throw()
: m_what(w)
{
}
virtual ~bad_boxed_cast() throw() {}
virtual const char * what () throw()
{
return m_what.c_str();
}
Type_Info from;
const std::type_info *to;
private:
std::string m_what;
};
}
#endif