diff --git a/include/chaiscript/dispatchkit/bootstrap.hpp b/include/chaiscript/dispatchkit/bootstrap.hpp index 8b2a886..bcf59b8 100644 --- a/include/chaiscript/dispatchkit/bootstrap.hpp +++ b/include/chaiscript/dispatchkit/bootstrap.hpp @@ -422,20 +422,17 @@ namespace chaiscript } /** - * Add a copy constructor for type T, also creates the standard - * function "clone" for the type. "clone" is a synonym for - * the copy constructor. + * Add a copy constructor for type T */ template ModulePtr copy_constructor(const std::string &type, ModulePtr m = ModulePtr(new Module())) { m->add(constructor(), type); - m->add(constructor(), "clone"); return m; } /** - * Add default and copy constructors (including "clone") for type T + * Add default and copy constructors for type T */ template ModulePtr basic_constructors(const std::string &type, ModulePtr m = ModulePtr(new Module())) diff --git a/include/chaiscript/dispatchkit/bootstrap_stl.hpp b/include/chaiscript/dispatchkit/bootstrap_stl.hpp index 8e74115..2408309 100644 --- a/include/chaiscript/dispatchkit/bootstrap_stl.hpp +++ b/include/chaiscript/dispatchkit/bootstrap_stl.hpp @@ -121,6 +121,9 @@ namespace chaiscript m->add(user_type > >(), type + "_Retro_Range"); m->add(user_type(), type+"_Iterator"); + copy_constructor >(type + "_Range", m); + copy_constructor > >(type + "_Retro_Range", m); + m->add(constructor (ContainerType &)>(), "range"); m->add(constructor (typename ContainerType::iterator)>(), "range"); @@ -145,8 +148,6 @@ namespace chaiscript m->add(constructor > (const Bidir_Range &)>(), "retro"); - m->add(constructor (const Bidir_Range &)>(), "clone"); - m->add(constructor > (const Retro > &)>(), "clone"); return m; } @@ -358,9 +359,7 @@ namespace chaiscript m->add(fun(&PairType::first), "first"); m->add(fun(&PairType::second), "second"); - m->add(constructor(), type); - m->add(constructor(), type); - m->add(constructor(), "clone"); + basic_constructors(type, m); m->add(constructor(), type); return m; diff --git a/include/chaiscript/language/chaiscript_prelude.hpp b/include/chaiscript/language/chaiscript_prelude.hpp index e7b23e1..e3bb76b 100644 --- a/include/chaiscript/language/chaiscript_prelude.hpp +++ b/include/chaiscript/language/chaiscript_prelude.hpp @@ -13,6 +13,7 @@ #define chaiscript_prelude CODE_STRING(\ def new(x) { eval(type_name(x))(); } \ +def clone(x) { eval(type_name(x))(x); } \ # to_string for Pair()\n\ def to_string(x) : call_exists(first, x) && call_exists(second, x) { \ "<" + x.first.to_string() + ", " + x.second.to_string() + ">"; \