From 9762e15460be4f8a628c0cc8e131a30e20f8de40 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Tue, 22 Sep 2009 01:23:02 +0000 Subject: [PATCH] Fix some range/retro issues and update the visual studio files --- .../dispatchkit/proxy_functions_detail.hpp | 8 +++--- .../language/chaiscript_prelude.hpp | 28 +++++++++++-------- msvc/chaiscript/chaiscript.vcproj | 8 ++++++ 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp index f1f51c9..c3c18f1 100644 --- a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp @@ -50,7 +50,7 @@ namespace chaiscript template static Boxed_Value go(const boost::function &fun, const std::vector ¶ms) { - return Handle_Return::handle(call_func(fun, params, false)); + return Handle_Return::handle(call_func(fun, params)); } }; @@ -60,7 +60,7 @@ namespace chaiscript template static Boxed_Value go(const boost::function &fun, const std::vector ¶ms) { - call_func(fun, params, false); + call_func(fun, params); return Handle_Return::handle(); }; }; @@ -100,7 +100,7 @@ namespace chaiscript */ template Ret call_func(const boost::function &f, - const std::vector ¶ms, bool t_test) + const std::vector ¶ms) { if (params.size() != n) { @@ -117,7 +117,7 @@ namespace chaiscript */ template bool compare_types_cast(Ret (*)(BOOST_PP_ENUM_PARAMS(n, Param)), - const std::vector ¶ms) + const std::vector & BOOST_PP_IF(n, params, )) { try { BOOST_PP_REPEAT(n, trycast, ~); diff --git a/include/chaiscript/language/chaiscript_prelude.hpp b/include/chaiscript/language/chaiscript_prelude.hpp index 733377d..0f3e559 100644 --- a/include/chaiscript/language/chaiscript_prelude.hpp +++ b/include/chaiscript/language/chaiscript_prelude.hpp @@ -58,27 +58,31 @@ def reverse(container) {\n\ r.pop_back(); \n\ } \n\ retval; \n\ -} \ +} \n\ +# Return a range from a range \n\ +def range(r) : call_exists(empty, r) && call_exists(pop_front, r) && call_exists(pop_back, r) && call_exists(back, r) && call_exists(front, r) { return clone(r); }\n\ # The retro attribute that contains the underlying range \n\ -attr retro::range; \n\ +attr retro::m_range; \n\ # Creates a retro from a retro by returning the original range\n\ -def retro(r) : call_exists(get_type_name, r) && get_type_name(r) == "retro" { clone(r.range) }\n\ +def retro(r) : call_exists(get_type_name, r) && get_type_name(r) == "retro" { clone(r.m_range) }\n\ # Creates a retro range from a range\n\ -def retro::retro(r) : call_exists(empty, r) && call_exists(pop_front, r) && call_exists(pop_back, r) && call_exists(back, r) && call_exists(front, r) { this.range = r; }\n\ +def retro::retro(r) : call_exists(empty, r) && call_exists(pop_front, r) && call_exists(pop_back, r) && call_exists(back, r) && call_exists(front, r) { this.m_range = r; }\n\ # Returns the first value of a retro\n\ -def retro::front() { back(this.range) }\n\ +def retro::front() { back(this.m_range) }\n\ # Returns the last value of a retro\n\ -def retro::back() { front(this.range) }\n\ +def retro::back() { front(this.m_range) }\n\ # Moves the back iterator of a retro towards the front by one \n\ -def retro::pop_back() { pop_front(this.range) }\n\ +def retro::pop_back() { pop_front(this.m_range) }\n\ # Moves the front iterator of a retro towards the back by one \n\ -def retro::pop_front() { pop_back(this.range) } \n\ +def retro::pop_front() { pop_back(this.m_range) } \n\ +# returns true if the retro is out of elements \n\ +def retro::empty() { empty(this.m_range); } \n\ # Performs the second value function over the container first value\n\ def for_each(container, func) : call_exists(range, container) { \n\ - var range = range(container); \n\ - while (!range.empty()) { \n\ - func(range.front()); \n\ - range.pop_front(); \n\ + var t_range = range(container); \n\ + while (!t_range.empty()) { \n\ + func(t_range.front()); \n\ + t_range.pop_front(); \n\ } \n\ } \n\ def back_inserter(container) { \n\ diff --git a/msvc/chaiscript/chaiscript.vcproj b/msvc/chaiscript/chaiscript.vcproj index 4d65979..626f42c 100644 --- a/msvc/chaiscript/chaiscript.vcproj +++ b/msvc/chaiscript/chaiscript.vcproj @@ -221,10 +221,18 @@ RelativePath="..\..\include\chaiscript\language\chaiscript_prelude.hpp" > + + + +