diff --git a/typelesscpp/scripting_object.hpp b/typelesscpp/boxed_value.hpp similarity index 79% rename from typelesscpp/scripting_object.hpp rename to typelesscpp/boxed_value.hpp index a852677..755f2b3 100644 --- a/typelesscpp/scripting_object.hpp +++ b/typelesscpp/boxed_value.hpp @@ -1,39 +1,39 @@ -#ifndef __scripting_object_hpp__ -#define __scripting_object_hpp__ +#ifndef __boxed_value_hpp__ +#define __boxed_value_hpp__ -#include "scripting_type_info.hpp" +#include "type_info.hpp" #include #include #include -class Scripting_Object +class Boxed_Value { public: template - explicit Scripting_Object(boost::shared_ptr obj) + explicit Boxed_Value(boost::shared_ptr obj) : m_type_info(Get_Type_Info()()), m_obj(obj), m_is_ref(false) { } template - explicit Scripting_Object(boost::reference_wrapper obj) + explicit Boxed_Value(boost::reference_wrapper obj) : m_type_info(Get_Type_Info()()), m_obj(obj), m_is_ref(true) { } template - explicit Scripting_Object(const T& t) + explicit Boxed_Value(const T& t) : m_type_info(Get_Type_Info()()), m_obj(boost::shared_ptr(new T(t))), m_is_ref(false) { } - Scripting_Object(const Scripting_Object &t_so) + Boxed_Value(const Boxed_Value &t_so) : m_type_info(t_so.m_type_info), m_obj(t_so.m_obj), m_is_ref(t_so.m_is_ref) { } - Scripting_Object() + Boxed_Value() : m_type_info(Get_Type_Info()()), m_is_ref(false) { } @@ -64,7 +64,7 @@ class Scripting_Object template struct Cast_Helper { - typename boost::reference_wrapper::type > operator()(Scripting_Object ob) + typename boost::reference_wrapper::type > operator()(Boxed_Value ob) { if (ob.is_ref()) { @@ -78,7 +78,7 @@ struct Cast_Helper template struct Cast_Helper { - typename boost::reference_wrapper::type > operator()(Scripting_Object ob) + typename boost::reference_wrapper::type > operator()(Boxed_Value ob) { if (ob.is_ref()) { @@ -92,7 +92,7 @@ struct Cast_Helper template struct Cast_Helper { - Result *operator()(Scripting_Object ob) + Result *operator()(Boxed_Value ob) { if (ob.is_ref()) { @@ -106,7 +106,7 @@ struct Cast_Helper template struct Cast_Helper { - typename boost::reference_wrapper operator()(Scripting_Object ob) + typename boost::reference_wrapper operator()(Boxed_Value ob) { if (ob.is_ref()) { diff --git a/typelesscpp/scripting_system.hpp b/typelesscpp/boxedcpp.hpp similarity index 60% rename from typelesscpp/scripting_system.hpp rename to typelesscpp/boxedcpp.hpp index 0530105..7e63f9b 100644 --- a/typelesscpp/scripting_system.hpp +++ b/typelesscpp/boxedcpp.hpp @@ -8,9 +8,9 @@ #include #include -#include "scripting_object.hpp" -#include "scripting_functions.hpp" -#include "scripting_constructors.hpp" +#include "boxed_value.hpp" +#include "proxy_functions.hpp" +#include "proxy_constructors.hpp" class Scripting_System { @@ -18,18 +18,18 @@ class Scripting_System template void register_function(const Function &func, const std::string &name) { - m_functions.insert(std::make_pair(name, boost::shared_ptr(new Function_Handler_Impl(func)))); + m_functions.insert(std::make_pair(name, boost::shared_ptr(new Proxy_Function_Impl(func)))); } template void add_object(const std::string &name, const Class &obj) { - m_objects.insert(std::make_pair(name, Scripting_Object(obj))); + m_objects.insert(std::make_pair(name, Boxed_Value(obj))); } - Scripting_Object get_object(const std::string &name) const + Boxed_Value get_object(const std::string &name) const { - std::map::const_iterator itr = m_objects.find(name); + std::map::const_iterator itr = m_objects.find(name); if (itr != m_objects.end()) { return itr->second; @@ -44,9 +44,9 @@ class Scripting_System m_types.insert(std::make_pair(name, &typeid(Type))); } - boost::shared_ptr get_function(const std::string &t_name) + boost::shared_ptr get_function(const std::string &t_name) { - std::map >::const_iterator itr = m_functions.find(t_name); + std::map >::const_iterator itr = m_functions.find(t_name); if (itr != m_functions.end()) { return itr->second; @@ -56,9 +56,9 @@ class Scripting_System } private: - std::map m_objects; + std::map m_objects; std::map m_types; - std::map > m_functions; + std::map > m_functions; }; #endif diff --git a/typelesscpp/scripting_constructors.hpp b/typelesscpp/proxy_constructors.hpp similarity index 90% rename from typelesscpp/scripting_constructors.hpp rename to typelesscpp/proxy_constructors.hpp index 8979f0a..b86c5ff 100644 --- a/typelesscpp/scripting_constructors.hpp +++ b/typelesscpp/proxy_constructors.hpp @@ -1,8 +1,8 @@ #include #ifndef BOOST_PP_IS_ITERATING -#ifndef __scripting_constructors_hpp__ -#define __scripting_constructors_hpp__ +#ifndef __proxy_constructors_hpp__ +#define __proxy_constructors_hpp__ #include #include @@ -22,7 +22,7 @@ boost::function ()> build_constructor() } #define BOOST_PP_ITERATION_LIMITS ( 1, 10 ) -#define BOOST_PP_FILENAME_1 "scripting_constructors.hpp" +#define BOOST_PP_FILENAME_1 "proxy_constructors.hpp" #include BOOST_PP_ITERATE() # endif #else diff --git a/typelesscpp/scripting_functions.hpp b/typelesscpp/proxy_functions.hpp similarity index 64% rename from typelesscpp/scripting_functions.hpp rename to typelesscpp/proxy_functions.hpp index 16ad365..bcc1ebd 100644 --- a/typelesscpp/scripting_functions.hpp +++ b/typelesscpp/proxy_functions.hpp @@ -5,11 +5,11 @@ #ifndef BOOST_PP_IS_ITERATING -#ifndef __scripting_functions_hpp__ -#define __scripting_functions_hpp__ +#ifndef __proxy_functions_hpp__ +#define __proxy_functions_hpp__ -#include "scripting_object.hpp" -#include "scripting_type_info.hpp" +#include "boxed_value.hpp" +#include "type_info.hpp" #include #include #include @@ -20,28 +20,28 @@ template struct Handle_Return { - Scripting_Object operator()(const boost::function &f) + Boxed_Value operator()(const boost::function &f) { - return Scripting_Object(f()); + return Boxed_Value(f()); } }; template struct Handle_Return { - Scripting_Object operator()(const boost::function &f) + Boxed_Value operator()(const boost::function &f) { - return Scripting_Object(boost::ref(f())); + return Boxed_Value(boost::ref(f())); } }; template<> struct Handle_Return { - Scripting_Object operator()(const boost::function &f) + Boxed_Value operator()(const boost::function &f) { f(); - return Scripting_Object(); + return Boxed_Value(); } }; @@ -57,7 +57,7 @@ std::vector build_param_type_list(const boost::function &f) // call_func implementations (variadic) template -Scripting_Object call_func(const boost::function &f, const std::vector ¶ms) +Boxed_Value call_func(const boost::function &f, const std::vector ¶ms) { if (params.size() != 0) { @@ -70,7 +70,7 @@ Scripting_Object call_func(const boost::function &f, const std::vector Param_List_Builder &operator<<(T t) { - objects.push_back(Scripting_Object(t)); + objects.push_back(Boxed_Value(t)); return *this; } - operator const std::vector &() const + operator const std::vector &() const { return objects; } - std::vector objects; + std::vector objects; }; #define BOOST_PP_ITERATION_LIMITS ( 1, 10 ) -#define BOOST_PP_FILENAME_1 "scripting_functions.hpp" +#define BOOST_PP_FILENAME_1 "proxy_functions.hpp" #include BOOST_PP_ITERATE() -class Function_Handler +class Proxy_Function { public: - virtual Scripting_Object operator()(const std::vector ¶ms) = 0; + virtual Boxed_Value operator()(const std::vector ¶ms) = 0; virtual std::vector get_param_types() = 0; }; template -class Function_Handler_Impl : public Function_Handler +class Proxy_Function_Impl : public Proxy_Function { public: - Function_Handler_Impl(const Func &f) + Proxy_Function_Impl(const Func &f) : m_f(f) { } - virtual Scripting_Object operator()(const std::vector ¶ms) + virtual Boxed_Value operator()(const std::vector ¶ms) { return call_func(m_f, params); } @@ -146,8 +146,8 @@ std::vector build_param_type_list(const boost::function -Scripting_Object call_func(const boost::function &f, - const std::vector ¶ms) +Boxed_Value call_func(const boost::function &f, + const std::vector ¶ms) { if (params.size() != n) { diff --git a/typelesscpp/test.cpp b/typelesscpp/test.cpp index d0b2505..0745b51 100644 --- a/typelesscpp/test.cpp +++ b/typelesscpp/test.cpp @@ -4,7 +4,7 @@ #include #include -#include "scripting_system.hpp" +#include "boxedcpp.hpp" struct Test { @@ -69,14 +69,14 @@ int main() ss.add_object("d", boost::shared_ptr(new double(10.2))); ss.add_object("str", std::string("Hello World")); - std::vector sos; + std::vector sos; sos.push_back(ss.get_object("testobj")); sos.push_back(ss.get_object("d")); - boost::shared_ptr method1(ss.get_function("method")); + boost::shared_ptr method1(ss.get_function("method")); (*method1)(sos); (*method1)(sos); - Scripting_Object o = (*method1)(sos); + Boxed_Value o = (*method1)(sos); (*ss.get_function("print"))(Param_List_Builder() << ss.get_object("str")); @@ -85,13 +85,13 @@ int main() std::cout << Cast_Helper()(o) << std::endl; - (*ss.get_function("voidfunc"))(std::vector()); + (*ss.get_function("voidfunc"))(std::vector()); - std::vector sos3; + std::vector sos3; sos3.push_back(ss.get_object("testobj2")); (*ss.get_function("show_message"))(sos3); - Scripting_Object stringref = (*ss.get_function("get_message"))(sos3); + Boxed_Value stringref = (*ss.get_function("get_message"))(sos3); std::string &sr = Cast_Helper()(stringref); sr = "Bob Updated The message"; diff --git a/typelesscpp/scripting_type_info.hpp b/typelesscpp/type_info.hpp similarity index 92% rename from typelesscpp/scripting_type_info.hpp rename to typelesscpp/type_info.hpp index a8e65ce..1689224 100644 --- a/typelesscpp/scripting_type_info.hpp +++ b/typelesscpp/type_info.hpp @@ -1,5 +1,5 @@ -#ifndef __scripting_type_info_hpp__ -#define __scripting_type_info_hpp__ +#ifndef __type_info_hpp__ +#define __type_info_hpp__ #include