Port to visual studio + a couple of minor bug fixes. Compiles with only 2 "unreachable code" warnings on /W4 in VC++

This commit is contained in:
Jason Turner 2009-07-09 22:24:11 +00:00
parent 5406d16f0b
commit aa0f54c53f
13 changed files with 399 additions and 93 deletions

View File

@ -9,10 +9,10 @@
#include <boost/function.hpp> #include <boost/function.hpp>
#include <stdexcept> #include <stdexcept>
#include <tr1/memory>
#include <iostream> #include <iostream>
#include <map> #include <map>
#include <fstream> #include <fstream>
#include <boost/shared_ptr.hpp>
#include "dispatchkit.hpp" #include "dispatchkit.hpp"
#include "bootstrap.hpp" #include "bootstrap.hpp"
@ -53,7 +53,7 @@ namespace chaiscript
File_Position() : line(0), column(0) { } File_Position() : line(0), column(0) { }
}; };
typedef std::tr1::shared_ptr<struct Token> TokenPtr; typedef boost::shared_ptr<struct Token> TokenPtr;
/** /**
* The struct that doubles as both a parser token and an AST node * The struct that doubles as both a parser token and an AST node

View File

@ -51,7 +51,7 @@ namespace chaiscript
catch (Eval_Error &ee) { catch (Eval_Error &ee) {
throw Eval_Error("Can not evaluate string: " + val + " reason: " + ee.reason, TokenPtr()); throw Eval_Error("Can not evaluate string: " + val + " reason: " + ee.reason, TokenPtr());
} }
catch (std::exception &e) { catch (std::exception &) {
throw Eval_Error("Can not evaluate string: " + val, TokenPtr()); throw Eval_Error("Can not evaluate string: " + val, TokenPtr());
} }
return evaluate_string(val); return evaluate_string(val);

View File

@ -64,7 +64,7 @@ namespace chaiscript
try { try {
return ss.get_object(node->text); return ss.get_object(node->text);
} }
catch (std::exception &e) { catch (std::exception &) {
throw Eval_Error("Can not find object: " + node->text, node); throw Eval_Error("Can not find object: " + node->text, node);
} }
} }
@ -74,7 +74,7 @@ namespace chaiscript
* Evaluates a floating point number * Evaluates a floating point number
*/ */
template <typename Eval_System> template <typename Eval_System>
dispatchkit::Boxed_Value eval_float(Eval_System &ss, TokenPtr node) { dispatchkit::Boxed_Value eval_float(Eval_System &, TokenPtr node) {
return dispatchkit::Boxed_Value(double(atof(node->text.c_str()))); return dispatchkit::Boxed_Value(double(atof(node->text.c_str())));
} }
@ -82,7 +82,7 @@ namespace chaiscript
* Evaluates an integer * Evaluates an integer
*/ */
template <typename Eval_System> template <typename Eval_System>
dispatchkit::Boxed_Value eval_int(Eval_System &ss, TokenPtr node) { dispatchkit::Boxed_Value eval_int(Eval_System &, TokenPtr node) {
return dispatchkit::Boxed_Value(atoi(node->text.c_str())); return dispatchkit::Boxed_Value(atoi(node->text.c_str()));
} }
@ -90,7 +90,7 @@ namespace chaiscript
* Evaluates a quoted string * Evaluates a quoted string
*/ */
template <typename Eval_System> template <typename Eval_System>
dispatchkit::Boxed_Value eval_quoted_string(Eval_System &ss, TokenPtr node) { dispatchkit::Boxed_Value eval_quoted_string(Eval_System &, TokenPtr node) {
return dispatchkit::Boxed_Value(node->text); return dispatchkit::Boxed_Value(node->text);
} }
@ -98,7 +98,7 @@ namespace chaiscript
* Evaluates a char group * Evaluates a char group
*/ */
template <typename Eval_System> template <typename Eval_System>
dispatchkit::Boxed_Value eval_single_quoted_string(Eval_System &ss, TokenPtr node) { dispatchkit::Boxed_Value eval_single_quoted_string(Eval_System &, TokenPtr node) {
return dispatchkit::Boxed_Value(node->text); return dispatchkit::Boxed_Value(node->text);
} }
@ -125,11 +125,11 @@ namespace chaiscript
try { try {
retval = dispatch(ss.get_function(node->children[i+1]->text), plb); retval = dispatch(ss.get_function(node->children[i+1]->text), plb);
} }
catch(const dispatchkit::dispatch_error &e){ catch(const dispatchkit::dispatch_error &){
throw Eval_Error("Mismatched types in equation", node->children[i+1]); throw Eval_Error("Mismatched types in equation", node->children[i+1]);
} }
} }
catch(const dispatchkit::dispatch_error &e){ catch(const dispatchkit::dispatch_error &){
throw Eval_Error("Can not clone right hand side of equation", node->children[i+1]); throw Eval_Error("Can not clone right hand side of equation", node->children[i+1]);
} }
} }
@ -149,7 +149,7 @@ namespace chaiscript
try { try {
retval = dispatch(ss.get_function(node->children[i+1]->text), plb); retval = dispatch(ss.get_function(node->children[i+1]->text), plb);
} }
catch(const dispatchkit::dispatch_error &e){ catch(const dispatchkit::dispatch_error &){
throw Eval_Error("Can not find appropriate '" + node->children[i+1]->text + "'", node->children[i+1]); throw Eval_Error("Can not find appropriate '" + node->children[i+1]->text + "'", node->children[i+1]);
} }
} }
@ -182,7 +182,7 @@ namespace chaiscript
try { try {
lhs = dispatchkit::boxed_cast<bool &>(retval); lhs = dispatchkit::boxed_cast<bool &>(retval);
} }
catch (std::exception &e) { catch (const dispatchkit::bad_boxed_cast &) {
throw Eval_Error("Condition not boolean", node); throw Eval_Error("Condition not boolean", node);
} }
if (node->children[i]->text == "&&") { if (node->children[i]->text == "&&") {
@ -224,7 +224,7 @@ namespace chaiscript
try { try {
retval = dispatch(ss.get_function(node->children[i]->text), plb); retval = dispatch(ss.get_function(node->children[i]->text), plb);
} }
catch(const dispatchkit::dispatch_error &e){ catch(const dispatchkit::dispatch_error &){
throw Eval_Error("Can not find appropriate '" + node->children[i]->text + "'", node->children[i]); throw Eval_Error("Can not find appropriate '" + node->children[i]->text + "'", node->children[i]);
} }
} }
@ -249,10 +249,10 @@ namespace chaiscript
try { try {
retval = dispatch(ss.get_function("[]"), plb); retval = dispatch(ss.get_function("[]"), plb);
} }
catch(std::out_of_range &oor) { catch(std::out_of_range &) {
throw Eval_Error("Out of bounds exception", node); throw Eval_Error("Out of bounds exception", node);
} }
catch(const dispatchkit::dispatch_error &e){ catch(const dispatchkit::dispatch_error &){
throw Eval_Error("Can not find appropriate array lookup '[]' " + node->children[i]->text, node->children[i]); throw Eval_Error("Can not find appropriate array lookup '[]' " + node->children[i]->text, node->children[i]);
} }
} }
@ -275,7 +275,7 @@ namespace chaiscript
try { try {
return dispatch(ss.get_function("*"), plb); return dispatch(ss.get_function("*"), plb);
} }
catch(std::exception &e){ catch(std::exception &){
throw Eval_Error("Can not find appropriate negation", node->children[0]); throw Eval_Error("Can not find appropriate negation", node->children[0]);
} }
} }
@ -292,7 +292,7 @@ namespace chaiscript
retval = eval_token(ss, node->children[0]); retval = eval_token(ss, node->children[0]);
cond = dispatchkit::boxed_cast<bool &>(retval); cond = dispatchkit::boxed_cast<bool &>(retval);
} }
catch (std::exception) { catch (const dispatchkit::bad_boxed_cast &) {
throw Eval_Error("Boolean not('!') condition not boolean", node->children[0]); throw Eval_Error("Boolean not('!') condition not boolean", node->children[0]);
} }
return dispatchkit::Boxed_Value(!cond); return dispatchkit::Boxed_Value(!cond);
@ -312,7 +312,7 @@ namespace chaiscript
try { try {
return dispatch(ss.get_function(node->children[0]->text), plb); return dispatch(ss.get_function(node->children[0]->text), plb);
} }
catch(std::exception &e){ catch(std::exception &){
throw Eval_Error("Can not find appropriate prefix", node->children[0]); throw Eval_Error("Can not find appropriate prefix", node->children[0]);
} }
} }
@ -333,13 +333,13 @@ namespace chaiscript
dispatchkit::Boxed_Value tmp = eval_token(ss, node->children[0]->children[i]); dispatchkit::Boxed_Value tmp = eval_token(ss, node->children[0]->children[i]);
dispatch(ss.get_function("push_back"), dispatchkit::Param_List_Builder() << retval << tmp); dispatch(ss.get_function("push_back"), dispatchkit::Param_List_Builder() << retval << tmp);
} }
catch (const dispatchkit::dispatch_error &inner_e) { catch (const dispatchkit::dispatch_error &) {
throw Eval_Error("Can not find appropriate 'push_back'", node->children[0]->children[i]); throw Eval_Error("Can not find appropriate 'push_back'", node->children[0]->children[i]);
} }
} }
} }
} }
catch (const dispatchkit::dispatch_error &e) { catch (const dispatchkit::dispatch_error &) {
throw Eval_Error("Can not find appropriate 'Vector()'", node); throw Eval_Error("Can not find appropriate 'Vector()'", node);
} }
@ -356,7 +356,7 @@ namespace chaiscript
<< eval_token(ss, node->children[0]->children[0]->children[0]) << eval_token(ss, node->children[0]->children[0]->children[0])
<< eval_token(ss, node->children[0]->children[0]->children[1])); << eval_token(ss, node->children[0]->children[0]->children[1]));
} }
catch (const dispatchkit::dispatch_error &e) { catch (const dispatchkit::dispatch_error &) {
throw Eval_Error("Unable to generate range vector", node); throw Eval_Error("Unable to generate range vector", node);
} }
} }
@ -377,12 +377,12 @@ namespace chaiscript
dispatchkit::Boxed_Value slot = dispatch(ss.get_function("[]"), dispatchkit::Param_List_Builder() << retval << key); dispatchkit::Boxed_Value slot = dispatch(ss.get_function("[]"), dispatchkit::Param_List_Builder() << retval << key);
dispatch(ss.get_function("="), dispatchkit::Param_List_Builder() << slot << eval_token(ss, node->children[0]->children[i]->children[1])); dispatch(ss.get_function("="), dispatchkit::Param_List_Builder() << slot << eval_token(ss, node->children[0]->children[i]->children[1]));
} }
catch (const dispatchkit::dispatch_error &inner_e) { catch (const dispatchkit::dispatch_error &) {
throw Eval_Error("Can not find appropriate '=' for map init", node->children[0]->children[i]); throw Eval_Error("Can not find appropriate '=' for map init", node->children[0]->children[i]);
} }
} }
} }
catch (const dispatchkit::dispatch_error &e) { catch (const dispatchkit::dispatch_error &) {
throw Eval_Error("Can not find appropriate 'Map()'", node); throw Eval_Error("Can not find appropriate 'Map()'", node);
} }
@ -442,7 +442,7 @@ namespace chaiscript
template <typename Eval_System> template <typename Eval_System>
dispatchkit::Boxed_Value eval_dot_access(Eval_System &ss, TokenPtr node) { dispatchkit::Boxed_Value eval_dot_access(Eval_System &ss, TokenPtr node) {
dispatchkit::Boxed_Value retval; dispatchkit::Boxed_Value retval;
std::vector<std::pair<std::string, dispatchkit::Dispatch_Engine::Function_Map::mapped_type> > fn; std::vector<std::pair<std::string, boost::shared_ptr<dispatchkit::Proxy_Function> > > fn;
dispatchkit::Dispatch_Engine::Stack prev_stack = ss.get_stack(); dispatchkit::Dispatch_Engine::Stack prev_stack = ss.get_stack();
dispatchkit::Dispatch_Engine::Stack new_stack; dispatchkit::Dispatch_Engine::Stack new_stack;
unsigned int i, j; unsigned int i, j;
@ -477,7 +477,7 @@ namespace chaiscript
retval = dispatch(fn, plb); retval = dispatch(fn, plb);
ss.set_stack(prev_stack); ss.set_stack(prev_stack);
} }
catch(const dispatchkit::dispatch_error &e){ catch(const dispatchkit::dispatch_error &){
ss.set_stack(prev_stack); ss.set_stack(prev_stack);
throw Eval_Error("Can not find appropriate '" + fun_name + "'", node); throw Eval_Error("Can not find appropriate '" + fun_name + "'", node);
} }
@ -508,7 +508,7 @@ namespace chaiscript
try { try {
cond = dispatchkit::boxed_cast<bool &>(retval); cond = dispatchkit::boxed_cast<bool &>(retval);
} }
catch (std::exception &e) { catch (const dispatchkit::bad_boxed_cast &) {
throw Eval_Error("If condition not boolean", node->children[0]); throw Eval_Error("If condition not boolean", node->children[0]);
} }
if (cond) { if (cond) {
@ -527,7 +527,7 @@ namespace chaiscript
try { try {
cond = dispatchkit::boxed_cast<bool &>(retval); cond = dispatchkit::boxed_cast<bool &>(retval);
} }
catch (std::exception &e) { catch (const dispatchkit::bad_boxed_cast &) {
throw Eval_Error("Elseif condition not boolean", node->children[i+1]); throw Eval_Error("Elseif condition not boolean", node->children[i+1]);
} }
if (cond) { if (cond) {
@ -554,7 +554,7 @@ namespace chaiscript
try { try {
cond = dispatchkit::boxed_cast<bool &>(retval); cond = dispatchkit::boxed_cast<bool &>(retval);
} }
catch (std::exception) { catch (const dispatchkit::bad_boxed_cast &) {
throw Eval_Error("While condition not boolean", node->children[0]); throw Eval_Error("While condition not boolean", node->children[0]);
} }
while (cond) { while (cond) {
@ -564,11 +564,11 @@ namespace chaiscript
try { try {
cond = dispatchkit::boxed_cast<bool &>(retval); cond = dispatchkit::boxed_cast<bool &>(retval);
} }
catch (std::exception) { catch (const dispatchkit::bad_boxed_cast &) {
throw Eval_Error("While condition not boolean", node->children[0]); throw Eval_Error("While condition not boolean", node->children[0]);
} }
} }
catch (Break_Loop &bl) { catch (Break_Loop &) {
cond = false; cond = false;
} }
} }
@ -595,7 +595,7 @@ namespace chaiscript
} }
cond = dispatchkit::boxed_cast<bool &>(condition); cond = dispatchkit::boxed_cast<bool &>(condition);
} }
catch (std::exception &e) { catch (const dispatchkit::bad_boxed_cast &) {
throw Eval_Error("For condition not boolean", node); throw Eval_Error("For condition not boolean", node);
} }
while (cond) { while (cond) {
@ -613,10 +613,10 @@ namespace chaiscript
cond = dispatchkit::boxed_cast<bool &>(condition); cond = dispatchkit::boxed_cast<bool &>(condition);
} }
catch (std::exception &e) { catch (const dispatchkit::bad_boxed_cast &) {
throw Eval_Error("For condition not boolean", node); throw Eval_Error("For condition not boolean", node);
} }
catch (Break_Loop &bl) { catch (Break_Loop &) {
cond = false; cond = false;
} }
} }
@ -748,7 +748,7 @@ namespace chaiscript
* Evaluates a break statement * Evaluates a break statement
*/ */
template <typename Eval_System> template <typename Eval_System>
dispatchkit::Boxed_Value eval_break(Eval_System &ss, TokenPtr node) { dispatchkit::Boxed_Value eval_break(Eval_System &, TokenPtr node) {
throw Break_Loop(node); throw Break_Loop(node);
} }

View File

@ -10,6 +10,8 @@ void print_help() {
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
std::string input; std::string input;
chaiscript::ChaiScript_Engine chai; chaiscript::ChaiScript_Engine chai;
@ -29,13 +31,11 @@ int main(int argc, char *argv[]) {
val = chai.evaluate_string(input); val = chai.evaluate_string(input);
if (val.get_type_info().m_bare_type_info && *(val.get_type_info().m_bare_type_info) != typeid(void)) { if (val.get_type_info().m_bare_type_info && *(val.get_type_info().m_bare_type_info) != typeid(void)) {
try { try {
dispatchkit::dispatch(chai.get_eval_engine().get_function("print"), dispatchkit::Param_List_Builder() << val); dispatchkit::dispatch(chai.get_eval_engine().get_function("print"), dispatchkit::Param_List_Builder() << val);
} catch (const std::runtime_error &e) { } catch (const std::runtime_error &e) {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
} }
} }
} }
@ -48,7 +48,7 @@ int main(int argc, char *argv[]) {
try { try {
dispatchkit::Boxed_Value val = chai.evaluate_file(argv[i]); dispatchkit::Boxed_Value val = chai.evaluate_file(argv[i]);
} }
catch (std::exception &e) { catch (std::exception &) {
std::cerr << "Could not open: " << argv[i] << std::endl; std::cerr << "Could not open: " << argv[i] << std::endl;
exit(1); exit(1);
} }

View File

@ -152,9 +152,9 @@ namespace dispatchkit
{ {
if (v.m_isfloat) if (v.m_isfloat)
{ {
return (p1 = v.d); return (p1 = P1(v.d));
} else { } else {
return (p1 = v.i); return (p1 = P1(v.i));
} }
} }
@ -163,9 +163,9 @@ namespace dispatchkit
{ {
if (v.m_isfloat) if (v.m_isfloat)
{ {
return (v.d); return P1(v.d);
} else { } else {
return (v.i); return P1(v.i);
} }
} }
@ -174,9 +174,9 @@ namespace dispatchkit
{ {
if (r.m_isfloat) if (r.m_isfloat)
{ {
return (p1 *= r.d); return p1 *= P1(r.d);
} else { } else {
return (p1 *= r.i); return p1 *= P1(r.i);
} }
} }
@ -185,9 +185,9 @@ namespace dispatchkit
{ {
if (r.m_isfloat) if (r.m_isfloat)
{ {
return (p1 /= r.d); return p1 /= P1(r.d);
} else { } else {
return (p1 /= r.i); return p1 /= P1(r.i);
} }
} }
@ -196,9 +196,9 @@ namespace dispatchkit
{ {
if (r.m_isfloat) if (r.m_isfloat)
{ {
return (p1 += r.d); return p1 += P1(r.d);
} else { } else {
return (p1 += r.i); return p1 += P1(r.i);
} }
} }
@ -207,9 +207,9 @@ namespace dispatchkit
{ {
if (r.m_isfloat) if (r.m_isfloat)
{ {
return (p1 -= r.d); return p1 -= P1(r.d);
} else { } else {
return (p1 -= r.i); return p1 -= P1(r.i);
} }
} }
@ -548,7 +548,7 @@ namespace dispatchkit
bootstrap_pod_type<int>(s, "int"); bootstrap_pod_type<int>(s, "int");
bootstrap_pod_type<size_t>(s, "size_t"); bootstrap_pod_type<size_t>(s, "size_t");
bootstrap_pod_type<char>(s, "char"); bootstrap_pod_type<char>(s, "char");
bootstrap_pod_type<int64_t>(s, "int64_t"); bootstrap_pod_type<boost::int64_t>(s, "int64_t");
add_opers_comparison_pod(s); add_opers_comparison_pod(s);
add_opers_arithmetic_pod(s); add_opers_arithmetic_pod(s);

View File

@ -76,7 +76,7 @@ namespace dispatchkit
} }
template<typename ContainerType> template<typename ContainerType>
void bootstrap_reversible_container(Dispatch_Engine &system, const std::string &type) void bootstrap_reversible_container(Dispatch_Engine &/*system*/, const std::string &/*type*/)
{ {
} }

View File

@ -8,6 +8,7 @@
#include <boost/function.hpp> #include <boost/function.hpp>
#include <boost/ref.hpp> #include <boost/ref.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <boost/cstdint.hpp>
#include <boost/type_traits/add_const.hpp> #include <boost/type_traits/add_const.hpp>
namespace dispatchkit namespace dispatchkit
@ -436,20 +437,20 @@ namespace dispatchkit
i = boxed_cast<long>(v); i = boxed_cast<long>(v);
} else if (inp_ == typeid(unsigned long)) { } else if (inp_ == typeid(unsigned long)) {
i = boxed_cast<unsigned long>(v); i = boxed_cast<unsigned long>(v);
} else if (inp_ == typeid(int8_t)) { } else if (inp_ == typeid(boost::int8_t)) {
i = boxed_cast<int8_t>(v); i = boxed_cast<boost::int8_t>(v);
} else if (inp_ == typeid(int16_t)) { } else if (inp_ == typeid(boost::int16_t)) {
i = boxed_cast<int16_t>(v); i = boxed_cast<boost::int16_t>(v);
} else if (inp_ == typeid(int32_t)) { } else if (inp_ == typeid(boost::int32_t)) {
i = boxed_cast<int32_t>(v); i = boxed_cast<boost::int32_t>(v);
} else if (inp_ == typeid(int64_t)) { } else if (inp_ == typeid(boost::int64_t)) {
i = boxed_cast<int64_t>(v); i = boxed_cast<boost::int64_t>(v);
} else if (inp_ == typeid(uint8_t)) { } else if (inp_ == typeid(boost::uint8_t)) {
i = boxed_cast<uint8_t>(v); i = boxed_cast<boost::uint8_t>(v);
} else if (inp_ == typeid(uint16_t)) { } else if (inp_ == typeid(boost::uint16_t)) {
i = boxed_cast<uint16_t>(v); i = boxed_cast<boost::uint16_t>(v);
} else if (inp_ == typeid(uint32_t)) { } else if (inp_ == typeid(boost::uint32_t)) {
i = boxed_cast<uint32_t>(v); i = boxed_cast<boost::uint32_t>(v);
} else { } else {
throw boost::bad_any_cast(); throw boost::bad_any_cast();
} }
@ -527,7 +528,7 @@ namespace dispatchkit
} }
double d; double d;
int64_t i; boost::int64_t i;
bool m_isfloat; bool m_isfloat;
}; };

View File

@ -4,6 +4,7 @@
#include <typeinfo> #include <typeinfo>
#include <string> #include <string>
#include <map> #include <map>
#include <set>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#include <stdexcept> #include <stdexcept>
@ -26,7 +27,7 @@ namespace dispatchkit
{ {
} }
virtual bool operator==(const Proxy_Function &f) const virtual bool operator==(const Proxy_Function &) const
{ {
return false; return false;
} }
@ -76,8 +77,7 @@ namespace dispatchkit
class Dispatch_Engine class Dispatch_Engine
{ {
public: public:
typedef std::multimap<std::string, boost::shared_ptr<Proxy_Function> > Function_Map; typedef std::map<std::string, dispatchkit::Type_Info> Type_Name_Map;
typedef std::map<std::string, Type_Info> Type_Name_Map;
typedef std::map<std::string, Boxed_Value> Scope; typedef std::map<std::string, Boxed_Value> Scope;
typedef std::deque<Scope> Stack; typedef std::deque<Scope> Stack;
@ -143,7 +143,7 @@ namespace dispatchkit
Stack set_stack(Stack s) Stack set_stack(Stack s)
{ {
swap(s, m_scopes); std::swap(s, m_scopes);
return s; return s;
} }
@ -164,7 +164,7 @@ namespace dispatchkit
} }
} }
std::vector<std::pair<std::string, Function_Map::mapped_type> > funcs = get_function_impl(name, false); std::vector<std::pair<std::string, std::multimap<std::string, boost::shared_ptr<Proxy_Function> >::mapped_type> > funcs = get_function_impl(name, false);
if (funcs.empty()) if (funcs.empty())
{ {
@ -180,15 +180,17 @@ namespace dispatchkit
m_types.insert(std::make_pair(name, Get_Type_Info<Type>::get())); m_types.insert(std::make_pair(name, Get_Type_Info<Type>::get()));
} }
Type_Info get_type(const std::string &name) const Type_Info get_type(const std::string &name) const
{ {
Type_Name_Map::const_iterator itr = m_types.find(name); Type_Name_Map::const_iterator itr = m_types.find(name);
if (itr != m_types.end()) if (itr != m_types.end())
{ {
return itr->second; return itr->second;
} else {
throw std::range_error("Type Not Known");
} }
throw std::range_error("Type Not Known");
} }
std::string get_type_name(const Type_Info &ti) const std::string get_type_name(const Type_Info &ti) const
@ -206,51 +208,51 @@ namespace dispatchkit
return ti.m_bare_type_info->name(); return ti.m_bare_type_info->name();
} }
std::vector<Type_Name_Map::value_type> get_types() const std::vector<std::pair<std::string, Type_Info> > get_types() const
{ {
return std::vector<Type_Name_Map::value_type>(m_types.begin(), m_types.end()); return std::vector<std::pair<std::string, Type_Info> >(m_types.begin(), m_types.end());
} }
std::vector<std::pair<std::string, Function_Map::mapped_type> > std::vector<std::pair<std::string, std::multimap<std::string, boost::shared_ptr<Proxy_Function> >::mapped_type> >
get_function_impl(const std::string &t_name, bool include_objects) const get_function_impl(const std::string &t_name, bool include_objects) const
{ {
std::vector<std::pair<std::string, Function_Map::mapped_type> > funcs; std::vector<std::pair<std::string, std::multimap<std::string, boost::shared_ptr<Proxy_Function> >::mapped_type> > funcs;
if (include_objects) if (include_objects)
{ {
try { try {
funcs.insert(funcs.end(), funcs.insert(funcs.end(),
Function_Map::value_type( std::make_pair(
t_name, t_name,
boxed_cast<Function_Map::mapped_type>(get_object(t_name))) boxed_cast<std::multimap<std::string, boost::shared_ptr<Proxy_Function> >::mapped_type>(get_object(t_name)))
); );
} catch (const bad_boxed_cast &) { } catch (const bad_boxed_cast &) {
} catch (const std::range_error &) { } catch (const std::range_error &) {
} }
} }
std::pair<Function_Map::const_iterator, Function_Map::const_iterator> range std::pair<std::multimap<std::string, boost::shared_ptr<Proxy_Function> >::const_iterator, std::multimap<std::string, boost::shared_ptr<Proxy_Function> >::const_iterator> range
= m_functions.equal_range(t_name); = m_functions.equal_range(t_name);
funcs.insert(funcs.end(), range.first, range.second); funcs.insert(funcs.end(), range.first, range.second);
return funcs; return funcs;
} }
std::vector<std::pair<std::string, Function_Map::mapped_type> > std::vector<std::pair<std::string, std::multimap<std::string, boost::shared_ptr<Proxy_Function> >::mapped_type> >
get_function(const std::string &t_name) const get_function(const std::string &t_name) const
{ {
return get_function_impl(t_name, true); return get_function_impl(t_name, true);
} }
std::vector<Function_Map::value_type> get_functions() const std::vector<std::pair<std::string, boost::shared_ptr<Proxy_Function> > > get_functions() const
{ {
return std::vector<Function_Map::value_type>(m_functions.begin(), m_functions.end()); return std::vector<std::pair<std::string, boost::shared_ptr<Proxy_Function> > >(m_functions.begin(), m_functions.end());
} }
private: private:
bool add_function(const boost::shared_ptr<Proxy_Function> &f, const std::string &t_name) bool add_function(const boost::shared_ptr<Proxy_Function> &f, const std::string &t_name)
{ {
std::pair<Function_Map::const_iterator, Function_Map::const_iterator> range std::pair<std::multimap<std::string, boost::shared_ptr<Proxy_Function> >::const_iterator, std::multimap<std::string, boost::shared_ptr<Proxy_Function> >::const_iterator> range
= m_functions.equal_range(t_name); = m_functions.equal_range(t_name);
while (range.first != range.second) while (range.first != range.second)
@ -268,7 +270,7 @@ namespace dispatchkit
std::deque<Scope> m_scopes; std::deque<Scope> m_scopes;
Function_Map m_functions; std::multimap<std::string, boost::shared_ptr<Proxy_Function> > m_functions;
Type_Name_Map m_types; Type_Name_Map m_types;
Boxed_Value m_place_holder; Boxed_Value m_place_holder;
}; };
@ -283,7 +285,7 @@ namespace dispatchkit
std::cout << e.get_type_name(type); std::cout << e.get_type_name(type);
} }
void dump_function(const Dispatch_Engine::Function_Map::value_type &f, const Dispatch_Engine &e) void dump_function(const std::pair<const std::string, boost::shared_ptr<Proxy_Function> > &f, const Dispatch_Engine &e)
{ {
std::vector<Type_Info> params = f.second->get_param_types(); std::vector<Type_Info> params = f.second->get_param_types();
std::string annotation = f.second->annotation(); std::string annotation = f.second->annotation();
@ -314,8 +316,8 @@ namespace dispatchkit
void dump_system(const Dispatch_Engine &s) void dump_system(const Dispatch_Engine &s)
{ {
std::cout << "Registered Types: " << std::endl; std::cout << "Registered Types: " << std::endl;
std::vector<Dispatch_Engine::Type_Name_Map::value_type> types = s.get_types(); std::vector<std::pair<std::string, Type_Info> > types = s.get_types();
for (std::vector<Dispatch_Engine::Type_Name_Map::value_type>::const_iterator itr = types.begin(); for (std::vector<std::pair<std::string, Type_Info> >::const_iterator itr = types.begin();
itr != types.end(); itr != types.end();
++itr) ++itr)
{ {
@ -325,10 +327,11 @@ namespace dispatchkit
} }
std::cout << std::endl; std::vector<Dispatch_Engine::Function_Map::value_type> funcs = s.get_functions(); std::cout << std::endl;
std::vector<std::pair<std::string, boost::shared_ptr<Proxy_Function> > > funcs = s.get_functions();
std::cout << "Functions: " << std::endl; std::cout << "Functions: " << std::endl;
for (std::vector<Dispatch_Engine::Function_Map::value_type>::const_iterator itr = funcs.begin(); for (std::vector<std::pair<std::string, boost::shared_ptr<Proxy_Function> > >::const_iterator itr = funcs.begin();
itr != funcs.end(); itr != funcs.end();
++itr) ++itr)
{ {

View File

@ -148,7 +148,7 @@ namespace dispatchkit
{ {
} }
virtual bool operator==(const Proxy_Function &f) const virtual bool operator==(const Proxy_Function &) const
{ {
return false; return false;
} }
@ -238,7 +238,7 @@ namespace dispatchkit
{ {
} }
virtual bool operator==(const Proxy_Function &f) const virtual bool operator==(const Proxy_Function &) const
{ {
return false; return false;
} }
@ -398,7 +398,7 @@ namespace dispatchkit
{ {
template<typename Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param) > template<typename Ret BOOST_PP_COMMA_IF(n) BOOST_PP_ENUM_PARAMS(n, typename Param) >
std::vector<Type_Info> build_param_type_list(const boost::function<Ret (BOOST_PP_ENUM_PARAMS(n, Param))> &f) std::vector<Type_Info> build_param_type_list(const boost::function<Ret (BOOST_PP_ENUM_PARAMS(n, Param))> &)
{ {
std::vector<Type_Info> ti; std::vector<Type_Info> ti;
ti.push_back(Get_Type_Info<Ret>::get()); ti.push_back(Get_Type_Info<Ret>::get());

View File

@ -17,6 +17,7 @@ namespace dispatchkit
Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void, Type_Info(bool t_is_const, bool t_is_reference, bool t_is_pointer, bool t_is_void,
const std::type_info *t_ti, const std::type_info *t_bareti) const std::type_info *t_ti, const std::type_info *t_bareti)
: m_is_const(t_is_const), m_is_reference(t_is_reference), m_is_pointer(t_is_pointer), : m_is_const(t_is_const), m_is_reference(t_is_reference), m_is_pointer(t_is_pointer),
m_is_void(t_is_void),
m_type_info(t_ti), m_bare_type_info(t_bareti), m_type_info(t_ti), m_bare_type_info(t_bareti),
m_is_unknown(false) m_is_unknown(false)
{ {
@ -29,6 +30,14 @@ namespace dispatchkit
{ {
} }
Type_Info(const Type_Info &ti)
: m_is_const(ti.m_is_const), m_is_reference(ti.m_is_reference),
m_is_pointer(ti.m_is_pointer),
m_is_void(ti.m_is_void), m_type_info(ti.m_type_info),
m_bare_type_info(ti.m_bare_type_info),
m_is_unknown(ti.m_is_unknown)
{
}
Type_Info &operator=(const Type_Info &ti) Type_Info &operator=(const Type_Info &ti)
{ {
m_is_const = ti.m_is_const; m_is_const = ti.m_is_const;
@ -40,6 +49,10 @@ namespace dispatchkit
m_is_unknown = ti.m_is_unknown; m_is_unknown = ti.m_is_unknown;
return *this; return *this;
} }
bool operator<(const Type_Info &ti) const
{
return m_type_info < ti.m_type_info;
}
bool operator==(const Type_Info &ti) const bool operator==(const Type_Info &ti) const
{ {

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="Boost"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;C:\Programming\Boost\include\boost-1_38&quot;"
/>
</VisualStudioPropertySheet>

View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chaiscript", "chaiscript.vcproj", "{46FD9DC7-2DA9-4C17-ADE4-E3A18C46E87B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{46FD9DC7-2DA9-4C17-ADE4-E3A18C46E87B}.Debug|Win32.ActiveCfg = Debug|Win32
{46FD9DC7-2DA9-4C17-ADE4-E3A18C46E87B}.Debug|Win32.Build.0 = Debug|Win32
{46FD9DC7-2DA9-4C17-ADE4-E3A18C46E87B}.Release|Win32.ActiveCfg = Release|Win32
{46FD9DC7-2DA9-4C17-ADE4-E3A18C46E87B}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,258 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="chaiscript"
ProjectGUID="{46FD9DC7-2DA9-4C17-ADE4-E3A18C46E87B}"
RootNamespace="chaiscript"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets=".\Boost.vsprops"
UseOfMFC="2"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
UseUnicodeResponseFiles="false"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(ProjectDir)\..\..\dispatchkit&quot;;&quot;$(ProjectDir)\..\..\chaiscript&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
DisableLanguageExtensions="true"
TreatWChar_tAsBuiltInType="false"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="4"
CompileAs="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets=".\Boost.vsprops"
CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="3"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="&quot;$(ProjectDir)\..\..\dispatchkit&quot;;&quot;$(ProjectDir)\..\..\chaiscript&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\chaiscript\main.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\dispatchkit\bootstrap.hpp"
>
</File>
<File
RelativePath="..\..\dispatchkit\bootstrap_stl.hpp"
>
</File>
<File
RelativePath="..\..\dispatchkit\boxed_value.hpp"
>
</File>
<File
RelativePath="..\..\chaiscript\chaiscript.hpp"
>
</File>
<File
RelativePath="..\..\chaiscript\chaiscript_engine.hpp"
>
</File>
<File
RelativePath="..\..\chaiscript\chaiscript_eval.hpp"
>
</File>
<File
RelativePath="..\..\chaiscript\chaiscript_parser.hpp"
>
</File>
<File
RelativePath="..\..\chaiscript\chaiscript_prelude.hpp"
>
</File>
<File
RelativePath="..\..\dispatchkit\dispatchkit.hpp"
>
</File>
<File
RelativePath="..\..\dispatchkit\function_call.hpp"
>
</File>
<File
RelativePath="..\..\dispatchkit\proxy_constructors.hpp"
>
</File>
<File
RelativePath="..\..\dispatchkit\proxy_functions.hpp"
>
</File>
<File
RelativePath="..\..\dispatchkit\register_function.hpp"
>
</File>
<File
RelativePath="..\..\dispatchkit\type_info.hpp"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>