11#ifndef CHAISCRIPT_UTILITY_UTILITY_HPP_
12#define CHAISCRIPT_UTILITY_UTILITY_HPP_
52 template<
typename Class,
typename ModuleType>
53 void add_class(ModuleType &t_module,
54 const std::string &t_class_name,
55 const std::vector<chaiscript::Proxy_Function> &t_constructors,
56 const std::vector<std::pair<chaiscript::Proxy_Function, std::string>> &t_funcs)
62 t_module.add(ctor, t_class_name);
65 for(
const auto &
fun: t_funcs)
67 t_module.add(
fun.first,
fun.second);
71 template<
typename Enum,
typename ModuleType>
72 typename std::enable_if<std::is_enum<Enum>::value,
void>::type
73 add_class(ModuleType &t_module,
74 const std::string &t_class_name,
75 const std::vector<std::pair<
typename std::underlying_type<Enum>::type, std::string>> &t_constants
83 using namespace chaiscript::bootstrap::operators;
84 equal<Enum>(t_module);
85 not_equal<Enum>(t_module);
86 assign<Enum>(t_module);
88 t_module.add(
chaiscript::fun([](
const Enum &
e,
const int &i) {
return e == i; }),
"==");
89 t_module.add(
chaiscript::fun([](
const int &i,
const Enum &
e) {
return i ==
e; }),
"==");
91 for (
const auto &constant : t_constants)
97 template<
typename EnumClass,
typename ModuleType>
98 typename std::enable_if<std::is_enum<EnumClass>::value,
void>::type
99 add_class(ModuleType &t_module,
100 const std::string &t_class_name,
101 const std::vector<std::pair<EnumClass, std::string>> &t_constants
109 using namespace chaiscript::bootstrap::operators;
110 equal<EnumClass>(t_module);
111 not_equal<EnumClass>(t_module);
112 assign<EnumClass>(t_module);
114 for (
const auto &constant : t_constants)
Env e
Definition Common.cc:2
Namespace chaiscript contains every API call that the average user will be concerned with.
std::shared_ptr< dispatch::Proxy_Function_Base > Proxy_Function
Common typedef used for passing of any registered function in ChaiScript.
Definition proxy_functions.hpp:317
Proxy_Function constructor()
Generates a constructor function for use with ChaiScript.
Definition proxy_constructors.hpp:47
Proxy_Function fun(const T &t)
Creates a new Proxy_Function object from a free function, member function or data member.
Definition register_function.hpp:43
constexpr Type_Info user_type()
Creates a Type_Info object representing the templated type.
Definition type_info.hpp:236
Boxed_Value const_var(const T &t)
Takes an object and returns an immutable Boxed_Value. If the object is a std::reference or pointer ty...
Definition boxed_value.hpp:461