Fix problem with method specifiers for bad_dynamic_boxed_cast exception. Add support for operators to Utility.hpp

This commit is contained in:
Jason Turner
2011-03-11 17:54:55 -07:00
parent d9a92a5148
commit 46a669dab1
6 changed files with 21 additions and 11 deletions

View File

@@ -21,7 +21,7 @@ namespace chaiscript
{
public:
bad_boxed_cast(const Type_Info &t_from, const std::type_info &t_to,
const std::string &what)
const std::string &what) throw()
: from(t_from), to(&t_to), m_what(what)
{
}

View File

@@ -21,7 +21,7 @@ namespace chaiscript
{
public:
bad_boxed_dynamic_cast(const Type_Info &t_from, const std::type_info &t_to,
const std::string &t_what)
const std::string &t_what) throw()
: bad_boxed_cast(t_from, t_to, t_what)
{
}
@@ -35,6 +35,8 @@ namespace chaiscript
: bad_boxed_cast(w)
{
}
virtual ~bad_boxed_dynamic_cast() throw() {}
};
}

View File

@@ -53,10 +53,10 @@ namespace chaiscript
{
inline std::string class_name_translator(const std::string &t_name)
{
size_t colon = t_name.find_last_of("::");
size_t colon = t_name.rfind("::");
if (colon != std::string::npos)
{
return t_name.substr(colon+1, std::string::npos);
return t_name.substr(colon+2, std::string::npos);
} else {
return t_name;
}
@@ -64,13 +64,16 @@ namespace chaiscript
inline std::string method_name_translator(const std::string &t_name)
{
size_t colon = t_name.find_last_of("::");
if (colon != std::string::npos)
size_t namestart = t_name.rfind("operator");
namestart = (namestart == std::string::npos)?0:namestart+strlen("operator");
if (namestart == 0)
{
return t_name.substr(colon+1, std::string::npos);
} else {
return t_name;
}
namestart = t_name.rfind("::");
namestart = (namestart == std::string::npos)?0:namestart+strlen("::");
}
return t_name.substr(namestart, std::string::npos);
}
}
}