diff --git a/chaiscript/chaiscript_prelude.hpp b/chaiscript/chaiscript_prelude.hpp index ab4c7646..c3fbc894 100644 --- a/chaiscript/chaiscript_prelude.hpp +++ b/chaiscript/chaiscript_prelude.hpp @@ -204,6 +204,24 @@ def zip_with(f, x, y) { \ def zip(x, y) { \ zip_with(collate, x, y); \ }\ +def find(str, substr) { \ + return int(find(str, substr, size_t(0))); \ +} \ +def rfind(str, substr) { \ + return int(rfind(str, substr, size_t(-1))); \ +} \ +def find_first_of(str, list) { \ + return int(find_first_of(str, list, size_t(0))); \ +} \ +def find_last_of(str, list) { \ + return int(find_last_of(str, list, size_t(-1))); \ +} \ +def find_first_not_of(str, list) { \ + return int(find_first_not_of(str, list, size_t(0))); \ +} \ +def find_last_not_of(str, list) { \ + return int(find_last_not_of(str, list, size_t(-1))); \ +} \ ) #endif /* CHAISCRIPT_PRELUDE_HPP_ */ diff --git a/dispatchkit/bootstrap.hpp b/dispatchkit/bootstrap.hpp index 5683cee4..9f8f636a 100644 --- a/dispatchkit/bootstrap.hpp +++ b/dispatchkit/bootstrap.hpp @@ -70,6 +70,17 @@ namespace dispatchkit } } + template + P1 construct_pod(Boxed_POD_Value v) + { + if (v.m_isfloat) + { + return (v.d); + } else { + return (v.i); + } + } + template bool equals(P1 p1, P2 p2) @@ -351,6 +362,12 @@ namespace dispatchkit add_copy_constructor(s, type); } + template + void add_construct_pod(Dispatch_Engine &s, const std::string &type) + { + register_function(s, &construct_pod, type); + } + template void add_constructor_overload(Dispatch_Engine &s, const std::string &type) { @@ -398,6 +415,7 @@ namespace dispatchkit add_basic_constructors(s, name); add_oper_assign(s); add_oper_assign_pod(s); + add_construct_pod(s, name); add_opers_arithmetic(s); add_opers_arithmetic_modify_pod(s); register_function(s, &to_string, "to_string"); diff --git a/dispatchkit/bootstrap_stl.hpp b/dispatchkit/bootstrap_stl.hpp index dadb0643..6b2dcfb4 100644 --- a/dispatchkit/bootstrap_stl.hpp +++ b/dispatchkit/bootstrap_stl.hpp @@ -218,6 +218,13 @@ namespace dispatchkit add_opers_comparison(system); bootstrap_random_access_container(system, type); bootstrap_sequence(system, type); + typedef typename String::size_type (String::*find_func)(const String &, typename String::size_type) const; + register_function(system, find_func(&String::find), "find"); + register_function(system, find_func(&String::rfind), "rfind"); + register_function(system, find_func(&String::find_first_of), "find_first_of"); + register_function(system, find_func(&String::find_last_of), "find_last_of"); + register_function(system, find_func(&String::find_first_not_of), "find_first_not_of"); + register_function(system, find_func(&String::find_last_not_of), "find_last_not_of"); } }