GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
bootstrap.hpp
Go to the documentation of this file.
1// This file is distributed under the BSD License.
2// See "license.txt" for details.
3// Copyright 2009-2012, Jonathan Turner (jonathan@emptycrate.com)
4// Copyright 2009-2017, Jason Turner (jason@emptycrate.com)
5// http://www.chaiscript.com
6
7// This is an open source non-commercial project. Dear PVS-Studio, please check it.
8// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
9
10
11#ifndef CHAISCRIPT_BOOTSTRAP_HPP_
12#define CHAISCRIPT_BOOTSTRAP_HPP_
13
15#include "register_function.hpp"
16
17namespace chaiscript
18{
20 namespace bootstrap
21 {
22 template<typename T, typename = typename std::enable_if<std::is_array<T>::value>::type >
23 void array(const std::string &type, Module& m)
24 {
25 typedef typename std::remove_extent<T>::type ReturnType;
26 m.add(user_type<T>(), type);
27 m.add(fun(
28 [](T& t, size_t index)->ReturnType &{
29 constexpr auto extent = std::extent<T>::value;
30 if (extent > 0 && index >= extent) {
31 throw std::range_error("Array index out of range. Received: " + std::to_string(index) + " expected < " + std::to_string(extent));
32 } else {
33 return t[index];
34 }
35 }
36 ), "[]"
37 );
38
39 m.add(fun(
40 [](const T &t, size_t index)->const ReturnType &{
41 constexpr auto extent = std::extent<T>::value;
42 if (extent > 0 && index >= extent) {
43 throw std::range_error("Array index out of range. Received: " + std::to_string(index) + " expected < " + std::to_string(extent));
44 } else {
45 return t[index];
46 }
47 }
48 ), "[]"
49 );
50
51 m.add(fun(
52 [](const T &) {
53 constexpr auto extent = std::extent<T>::value;
54 return extent;
55 }), "size");
56 }
57
63 template<typename T>
64 void copy_constructor(const std::string &type, Module& m)
65 {
66 m.add(constructor<T (const T &)>(), type);
67 }
68
73 template<typename T>
83
84
85
93 template<typename T>
94 void basic_constructors(const std::string &type, Module& m)
95 {
96 m.add(constructor<T ()>(), type);
97 copy_constructor<T>(type, m);
98 }
99
104 template<typename T>
105 void construct_pod(const std::string &type, Module& m)
106 {
107 m.add(fun([](const Boxed_Number &bn){ return bn.get_as<T>(); }), type);
108 }
109
110
113 template<typename Input>
114 auto parse_string(const std::string &i)
115 -> typename std::enable_if<
116 !std::is_same<Input, wchar_t>::value
117 && !std::is_same<Input, char16_t>::value
118 && !std::is_same<Input, char32_t>::value,
119 Input>::type
120 {
121 std::stringstream ss(i);
122 Input t;
123 ss >> t;
124 return t;
125 }
126
127 template<typename Input>
128 auto parse_string(const std::string &)
129 -> typename std::enable_if<
130 std::is_same<Input, wchar_t>::value
131 || std::is_same<Input, char16_t>::value
132 || std::is_same<Input, char32_t>::value,
133 Input>::type
134 {
135 throw std::runtime_error("Parsing of wide characters is not yet supported");
136 }
137
138
141 template<typename T>
142 void bootstrap_pod_type(const std::string &name, Module& m)
143 {
144 m.add(user_type<T>(), name);
145 m.add(constructor<T()>(), name);
147
148 m.add(fun(&parse_string<T>), "to_" + name);
149 m.add(fun([](const T t){ return t; }), "to_" + name);
150 }
151
152
158 template<typename Type>
159 auto shared_ptr_clone(const std::shared_ptr<Type> &p)
160 {
161 return p;
162 }
163
165 template<typename Type>
166 std::shared_ptr<typename std::remove_const<Type>::type> shared_ptr_unconst_clone(const std::shared_ptr<typename std::add_const<Type>::type> &p)
167 {
168 return std::const_pointer_cast<typename std::remove_const<Type>::type>(p);
169 }
170
171
172
176 template<typename Type>
177 Boxed_Value ptr_assign(Boxed_Value lhs, const std::shared_ptr<Type> &rhs)
178 {
179 if (lhs.is_undef()
181 {
182 lhs.assign(Boxed_Value(rhs));
183 return lhs;
184 } else {
185 throw exception::bad_boxed_cast("type mismatch in pointer assignment");
186 }
187 }
188
192 {
193 private:
195 static Boxed_Value unknown_assign(Boxed_Value lhs, Boxed_Value rhs)
196 {
197 if (lhs.is_undef())
198 {
199 return (lhs.assign(rhs));
200 } else {
201 throw exception::bad_boxed_cast("boxed_value has a set type already");
202 }
203 }
204
205 static void print(const std::string &s)
206 {
207 fwrite(s.c_str(), 1, s.size(), stdout);
208 }
209
210 static void println(const std::string &s)
211 {
212 puts(s.c_str());
213 }
214
215
217 static void opers_arithmetic_pod(Module& m)
218 {
219 m.add(fun(&Boxed_Number::equals), "==");
225
228 m.add(fun(&Boxed_Number::sum), "+");
233 m.add(fun(&Boxed_Number::assign), "=");
249 m.add(fun(&Boxed_Number::product), "*");
252 }
253
256 static Boxed_Value bind_function(const std::vector<Boxed_Value> &params)
257 {
258 if (params.empty()) {
259 throw exception::arity_error(0, 1);
260 }
261
263
264 if (f->get_arity() != -1 && size_t(f->get_arity()) != params.size() - 1)
265 {
266 throw exception::arity_error(static_cast<int>(params.size()), f->get_arity());
267 }
268
269 return Boxed_Value(Const_Proxy_Function(std::make_shared<dispatch::Bound_Function>(std::move(f),
270 std::vector<Boxed_Value>(params.begin() + 1, params.end()))));
271 }
272
273
274 static bool has_guard(const Const_Proxy_Function &t_pf)
275 {
276 auto pf = std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(t_pf);
277 return pf && pf->get_guard();
278 }
279
281 {
282 const auto pf = std::dynamic_pointer_cast<const dispatch::Dynamic_Proxy_Function>(t_pf);
283 if (pf && pf->get_guard())
284 {
285 return pf->get_guard();
286 } else {
287 throw std::runtime_error("Function does not have a guard");
288 }
289 }
290
291 template<typename FunctionType>
292 static std::vector<Boxed_Value> do_return_boxed_value_vector(FunctionType f,
294 {
295 auto v = (b->*f)();
296
297 std::vector<Boxed_Value> vbv;
298
299 for (const auto &o: v)
300 {
301 vbv.push_back(const_var(o));
302 }
303
304 return vbv;
305 }
306
307
308 static bool has_parse_tree(const chaiscript::Const_Proxy_Function &t_pf)
309 {
310 const auto pf = std::dynamic_pointer_cast<const chaiscript::dispatch::Dynamic_Proxy_Function>(t_pf);
311 return bool(pf);
312 }
313
314 static const chaiscript::AST_Node &get_parse_tree(const chaiscript::Const_Proxy_Function &t_pf)
315 {
316 const auto pf = std::dynamic_pointer_cast<const chaiscript::dispatch::Dynamic_Proxy_Function>(t_pf);
317 if (pf)
318 {
319 return pf->get_parse_tree();
320 } else {
321 throw std::runtime_error("Function does not have a parse tree");
322 }
323 }
324
325 template<typename Function>
326 static auto return_boxed_value_vector(const Function &f)
327 {
328 return [f](const dispatch::Proxy_Function_Base *b) {
329 return do_return_boxed_value_vector(f, b);
330 };
331 }
332
333
334 public:
338 static void bootstrap(Module& m)
339 {
340 m.add(user_type<void>(), "void");
341 m.add(user_type<bool>(), "bool");
342 m.add(user_type<Boxed_Value>(), "Object");
343 m.add(user_type<Boxed_Number>(), "Number");
344 m.add(user_type<Proxy_Function>(), "Function");
345 m.add(user_type<dispatch::Assignable_Proxy_Function>(), "Assignable_Function");
346 m.add(user_type<std::exception>(), "exception");
347
349 m.add(fun(&dispatch::Proxy_Function_Base::operator==), "==");
350
351
352 m.add(fun(return_boxed_value_vector(&dispatch::Proxy_Function_Base::get_param_types)), "get_param_types");
353 m.add(fun(return_boxed_value_vector(&dispatch::Proxy_Function_Base::get_contained_functions)), "get_contained_functions");
354
355 m.add(fun([](const std::exception &e){ return std::string(e.what()); }), "what");
356
357 m.add(user_type<std::out_of_range>(), "out_of_range");
358 m.add(user_type<std::logic_error>(), "logic_error");
362
363 m.add(user_type<std::runtime_error>(), "runtime_error");
365
366 m.add(constructor<std::runtime_error (const std::string &)>(), "runtime_error");
367
368 m.add(user_type<dispatch::Dynamic_Object>(), "Dynamic_Object");
369 m.add(constructor<dispatch::Dynamic_Object (const std::string &)>(), "Dynamic_Object");
370 m.add(constructor<dispatch::Dynamic_Object ()>(), "Dynamic_Object");
371 m.add(fun(&dispatch::Dynamic_Object::get_type_name), "get_type_name");
376
377 m.add(fun(static_cast<Boxed_Value & (dispatch::Dynamic_Object::*)(const std::string &)>(&dispatch::Dynamic_Object::get_attr)), "get_attr");
378 m.add(fun(static_cast<const Boxed_Value & (dispatch::Dynamic_Object::*)(const std::string &) const>(&dispatch::Dynamic_Object::get_attr)), "get_attr");
379
380 m.add(fun(static_cast<Boxed_Value & (dispatch::Dynamic_Object::*)(const std::string &)>(&dispatch::Dynamic_Object::method_missing)), "method_missing");
381 m.add(fun(static_cast<const Boxed_Value & (dispatch::Dynamic_Object::*)(const std::string &) const>(&dispatch::Dynamic_Object::method_missing)), "method_missing");
382
383 m.add(fun(static_cast<Boxed_Value & (dispatch::Dynamic_Object::*)(const std::string &)>(&dispatch::Dynamic_Object::get_attr)), "[]");
384 m.add(fun(static_cast<const Boxed_Value & (dispatch::Dynamic_Object::*)(const std::string &) const>(&dispatch::Dynamic_Object::get_attr)), "[]");
385
386 m.eval(R"chaiscript(
387 def Dynamic_Object::clone() {
388 auto &new_o = Dynamic_Object(this.get_type_name());
389 for_each(this.get_attrs(), fun[new_o](x) { new_o.get_attr(x.first) = x.second; } );
390 new_o;
391 }
392
393 def `=`(Dynamic_Object lhs, Dynamic_Object rhs) : lhs.get_type_name() == rhs.get_type_name()
394 {
395 for_each(rhs.get_attrs(), fun[lhs](x) { lhs.get_attr(x.first) = clone(x.second); } );
396 }
397
398 def `!=`(Dynamic_Object lhs, Dynamic_Object rhs) : lhs.get_type_name() == rhs.get_type_name()
399 {
400 var rhs_attrs := rhs.get_attrs();
401 var lhs_attrs := lhs.get_attrs();
402
403 if (rhs_attrs.size() != lhs_attrs.size()) {
404 true;
405 } else {
406 return any_of(rhs_attrs, fun[lhs](x) { !lhs.has_attr(x.first) || lhs.get_attr(x.first) != x.second; } );
407 }
408 }
409
410 def `==`(Dynamic_Object lhs, Dynamic_Object rhs) : lhs.get_type_name() == rhs.get_type_name()
411 {
412 var rhs_attrs := rhs.get_attrs();
413 var lhs_attrs := lhs.get_attrs();
414
415 if (rhs_attrs.size() != lhs_attrs.size()) {
416 false;
417 } else {
418 return all_of(rhs_attrs, fun[lhs](x) { lhs.has_attr(x.first) && lhs.get_attr(x.first) == x.second; } );
419 }
420 }
421 )chaiscript");
422
423 m.add(fun(&has_guard), "has_guard");
424 m.add(fun(&get_guard), "get_guard");
425
426 m.add(fun(&Boxed_Value::is_undef), "is_var_undef");
427 m.add(fun(&Boxed_Value::is_null), "is_var_null");
428 m.add(fun(&Boxed_Value::is_const), "is_var_const");
429 m.add(fun(&Boxed_Value::is_ref), "is_var_reference");
430 m.add(fun(&Boxed_Value::is_pointer), "is_var_pointer");
431 m.add(fun(&Boxed_Value::is_return_value), "is_var_return_value");
432 m.add(fun(&Boxed_Value::reset_return_value), "reset_var_return_value");
433 m.add(fun(&Boxed_Value::is_type), "is_type");
434 m.add(fun(&Boxed_Value::get_attr), "get_var_attr");
435 m.add(fun(&Boxed_Value::copy_attrs), "copy_var_attrs");
436 m.add(fun(&Boxed_Value::clone_attrs), "clone_var_attrs");
437
438 m.add(fun(&Boxed_Value::get_type_info), "get_type_info");
439 m.add(user_type<Type_Info>(), "Type_Info");
440 m.add(constructor<Type_Info (const Type_Info &)>(), "Type_Info");
441
442
444
445 m.add(fun(&Type_Info::is_const), "is_type_const");
446 m.add(fun(&Type_Info::is_reference), "is_type_reference");
447 m.add(fun(&Type_Info::is_void), "is_type_void");
448 m.add(fun(&Type_Info::is_undef), "is_type_undef");
449 m.add(fun(&Type_Info::is_pointer), "is_type_pointer");
450 m.add(fun(&Type_Info::is_arithmetic), "is_type_arithmetic");
451 m.add(fun(&Type_Info::name), "cpp_name");
452 m.add(fun(&Type_Info::bare_name), "cpp_bare_name");
453 m.add(fun(&Type_Info::bare_equal), "bare_equal");
454
455
456 basic_constructors<bool>("bool", m);
460
461 m.add(fun([](const std::string &s) { return s; }), "to_string");
462 m.add(fun([](const bool b) { return std::string(b?"true":"false"); }), "to_string");
463 m.add(fun(&unknown_assign), "=");
464 m.add(fun([](const Boxed_Value &bv) { throw bv; }), "throw");
465
466 m.add(fun([](const char c) { return std::string(1, c); }), "to_string");
467 m.add(fun(&Boxed_Number::to_string), "to_string");
468
469
470 bootstrap_pod_type<double>("double", m);
471 bootstrap_pod_type<long double>("long_double", m);
472 bootstrap_pod_type<float>("float", m);
473 bootstrap_pod_type<int>("int", m);
474 bootstrap_pod_type<long>("long", m);
475 bootstrap_pod_type<unsigned int>("unsigned_int", m);
476 bootstrap_pod_type<unsigned long>("unsigned_long", m);
477 bootstrap_pod_type<long long>("long_long", m);
478 bootstrap_pod_type<unsigned long long>("unsigned_long_long", m);
479 bootstrap_pod_type<size_t>("size_t", m);
480 bootstrap_pod_type<char>("char", m);
481 bootstrap_pod_type<wchar_t>("wchar_t", m);
482 bootstrap_pod_type<char16_t>("char16_t", m);
483 bootstrap_pod_type<char32_t>("char32_t", m);
492
493
495
496 opers_arithmetic_pod(m);
497
498
499 m.add(fun(&Build_Info::version_major), "version_major");
500 m.add(fun(&Build_Info::version_minor), "version_minor");
501 m.add(fun(&Build_Info::version_patch), "version_patch");
502 m.add(fun(&Build_Info::version), "version");
503 m.add(fun(&Build_Info::compiler_version), "compiler_version");
504 m.add(fun(&Build_Info::compiler_name), "compiler_name");
505 m.add(fun(&Build_Info::compiler_id), "compiler_id");
506 m.add(fun(&Build_Info::debug_build), "debug_build");
507
508
509 m.add(fun(&print), "print_string");
510 m.add(fun(&println), "println_string");
511
512 m.add(dispatch::make_dynamic_proxy_function(&bind_function), "bind");
513
515 m.add(fun(&ptr_assign<std::remove_const<dispatch::Proxy_Function_Base>::type>), "=");
516 m.add(fun(&ptr_assign<std::add_const<dispatch::Proxy_Function_Base>::type>), "=");
518 m.add(fun(
519 [](dispatch::Assignable_Proxy_Function &t_lhs, const std::shared_ptr<const dispatch::Proxy_Function_Base> &t_rhs) {
520 t_lhs.assign(t_rhs);
521 }
522 ), "="
523 );
524
525 m.add(fun(&Boxed_Value::type_match), "type_match");
526
527
528 m.add(chaiscript::fun(&has_parse_tree), "has_parse_tree");
529 m.add(chaiscript::fun(&get_parse_tree), "get_parse_tree");
530
533
537
538
539// chaiscript::bootstrap::standard_library::vector_type<std::vector<std::shared_ptr<chaiscript::AST_Node> > >("AST_NodeVector", m);
540
541
542 chaiscript::utility::add_class<chaiscript::exception::eval_error>(m,
543 "eval_error",
544 { },
547 {fun([](const chaiscript::exception::eval_error &t_eval_error) {
548 std::vector<Boxed_Value> retval;
549 std::transform(t_eval_error.call_stack.begin(), t_eval_error.call_stack.end(),
550 std::back_inserter(retval),
552 return retval;
553 }), "call_stack"} }
554 );
555
556
557 chaiscript::utility::add_class<chaiscript::File_Position>(m,
558 "File_Position",
561 { {fun(&File_Position::line), "line"},
562 {fun(&File_Position::column), "column"} }
563 );
564
565
566 chaiscript::utility::add_class<AST_Node>(m,
567 "AST_Node",
568 { },
569 { {fun(&AST_Node::text), "text"},
570 {fun(&AST_Node::identifier), "identifier"},
571 {fun(&AST_Node::filename), "filename"},
572 {fun(&AST_Node::start), "start"},
573 {fun(&AST_Node::end), "end"},
574 {fun(&AST_Node::to_string), "to_string"},
575 {fun([](const chaiscript::AST_Node &t_node) -> std::vector<Boxed_Value> {
576 std::vector<Boxed_Value> retval;
577 const auto children = t_node.get_children();
578 std::transform(children.begin(), children.end(),
579 std::back_inserter(retval),
580 &chaiscript::var<const std::reference_wrapper<chaiscript::AST_Node> &>);
581 return retval;
582 }), "children"}
583 }
584 );
585
586 }
587 };
588 }
589}
590
591#endif
592
Env e
Definition Common.cc:2
bool has_guard() const
Returns true if the function has a guard to it. Always returns false for a conglomerate function.
Function get_guard() const
Returns a function guard as function.
Definition EffectI.hh:11
Represents any numeric type, generically. Used internally for generic operations between POD values.
Definition boxed_number.hpp:66
static bool not_equal(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:757
static Boxed_Number assign(Boxed_Number t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:797
static const Boxed_Number bitwise_complement(const Boxed_Number &t_lhs)
Definition boxed_number.hpp:832
static Boxed_Number assign_bitwise_and(Boxed_Number t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:792
static const Boxed_Number shift_left(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:871
static Boxed_Number pre_increment(Boxed_Number t_lhs)
Definition boxed_number.hpp:767
static Boxed_Number pre_decrement(Boxed_Number t_lhs)
Definition boxed_number.hpp:762
static Boxed_Number assign_product(Boxed_Number t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:847
static bool greater_than(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:742
static bool less_than(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:737
static const Boxed_Number bitwise_or(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:842
static const Boxed_Number unary_plus(const Boxed_Number &t_lhs)
Definition boxed_number.hpp:777
static const Boxed_Number quotient(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:866
static const Boxed_Number unary_minus(const Boxed_Number &t_lhs)
Definition boxed_number.hpp:782
static const Boxed_Number sum(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:772
std::string to_string() const
Definition boxed_number.hpp:686
static Boxed_Number assign_shift_left(Boxed_Number t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:817
static Boxed_Number assign_bitwise_xor(Boxed_Number t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:807
static Boxed_Number assign_difference(Boxed_Number t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:861
static const Boxed_Number bitwise_xor(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:837
static const Boxed_Number shift_right(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:886
static Boxed_Number assign_remainder(Boxed_Number t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:812
static bool greater_than_equal(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:747
static const Boxed_Number bitwise_and(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:827
static const Boxed_Number remainder(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:881
static Boxed_Number assign_sum(Boxed_Number t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:857
static const Boxed_Number product(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:876
static Boxed_Number assign_bitwise_or(Boxed_Number t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:802
static Boxed_Number assign_quotient(Boxed_Number t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:852
static Boxed_Number assign_shift_right(Boxed_Number t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:822
static bool equals(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:732
static bool less_than_equal(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:752
static const Boxed_Number difference(const Boxed_Number &t_lhs, const Boxed_Number &t_rhs)
Definition boxed_number.hpp:787
Boxed_Number get_as(const Type_Info &inp_) const
Definition boxed_number.hpp:543
A wrapper for holding any valid C++ type. All types in ChaiScript are Boxed_Value objects.
Definition boxed_value.hpp:28
bool is_ref() const noexcept
Definition boxed_value.hpp:291
bool is_pointer() const noexcept
Definition boxed_value.hpp:306
Boxed_Value & clone_attrs(const Boxed_Value &t_obj)
Definition boxed_value.hpp:347
bool is_const() const noexcept
Definition boxed_value.hpp:235
Boxed_Value assign(const Boxed_Value &rhs)
Definition boxed_value.hpp:218
bool is_type(const Type_Info &ti) const noexcept
Definition boxed_value.hpp:240
bool is_null() const noexcept
Definition boxed_value.hpp:281
bool is_undef() const noexcept
return true if the object is uninitialized
Definition boxed_value.hpp:230
const Type_Info & get_type_info() const noexcept
Definition boxed_value.hpp:224
void reset_return_value() const noexcept
Definition boxed_value.hpp:301
static bool type_match(const Boxed_Value &l, const Boxed_Value &r) noexcept
Definition boxed_value.hpp:356
Boxed_Value & copy_attrs(const Boxed_Value &t_obj)
Definition boxed_value.hpp:338
bool is_return_value() const noexcept
Definition boxed_value.hpp:296
Boxed_Value get_attr(const std::string &t_name)
Definition boxed_value.hpp:321
Holds a collection of ChaiScript settings which can be applied to the ChaiScript runtime....
Definition dispatchkit.hpp:150
Module & add(Type_Info ti, std::string name)
Definition dispatchkit.hpp:152
Module & eval(const std::string &str)
Definition dispatchkit.hpp:183
Compile time deduced information about a type.
Definition type_info.hpp:34
constexpr bool is_const() const noexcept
Definition type_info.hpp:86
std::string name() const
Definition type_info.hpp:93
constexpr bool is_void() const noexcept
Definition type_info.hpp:88
constexpr bool is_reference() const noexcept
Definition type_info.hpp:87
constexpr bool is_undef() const noexcept
Definition type_info.hpp:90
std::string bare_name() const
Definition type_info.hpp:103
constexpr bool is_arithmetic() const noexcept
Definition type_info.hpp:89
constexpr bool bare_equal(const Type_Info &ti) const noexcept
Definition type_info.hpp:75
constexpr bool is_pointer() const noexcept
Definition type_info.hpp:91
Definition bootstrap.hpp:192
static void bootstrap(Module &m)
perform all common bootstrap functions for std::string, void and POD types
Definition bootstrap.hpp:338
Definition proxy_functions.hpp:668
virtual void assign(const std::shared_ptr< const Proxy_Function_Base > &t_rhs)=0
Definition dynamic_object.hpp:44
Boxed_Value & method_missing(const std::string &t_method_name)
Definition dynamic_object.hpp:98
std::string get_type_name() const
Definition dynamic_object.hpp:63
bool has_attr(const std::string &t_attr_name) const
Definition dynamic_object.hpp:89
std::map< std::string, Boxed_Value > get_attrs() const
Definition dynamic_object.hpp:116
void set_explicit(const bool t_explicit)
Definition dynamic_object.hpp:58
const Boxed_Value & get_attr(const std::string &t_attr_name) const
Definition dynamic_object.hpp:78
bool is_explicit() const
Definition dynamic_object.hpp:53
Definition proxy_functions.hpp:196
int get_arity() const
Definition proxy_functions.hpp:247
virtual std::vector< std::shared_ptr< const Proxy_Function_Base > > get_contained_functions() const
Definition proxy_functions.hpp:225
const std::vector< Type_Info > & get_param_types() const
Definition proxy_functions.hpp:213
Thrown in the event that a Boxed_Value cannot be cast to the desired type.
Definition bad_boxed_cast.hpp:34
iVBORw0KGgoAAAANSUhEUgAAANcAAAB5CAMAAACdtUQZAAAA51BMVEX</div ></div >< div style="padding: 0px 0px; width: 1324px;">< div style="height: 400px; width: 1324px;"></div >< div itemscope itemtype="https: </div><div itemscope itemtype="https:</div >< div itemscope itemtype="https: </div></div><p><div style="padding:0px 0px;width:1324px;"><div></div><div itemscope itemtype="https:< ul >< li >< b > Application name
8AkrcAgqgAs9wqQ0ey2tkAo8gAuuQfeI4hPUH09fXHy8z4+fng4uNKXF/Lz9BzfoAcgpkQMTUAKjAbOT4Qr9AXhJ8Rl7ktMCwTosA...
Definition meshpage.php:1610
void less_than(Module &m)
Definition operators.hpp:120
void assign(Module &m)
Definition operators.hpp:24
void greater_than_equal(Module &m)
Definition operators.hpp:114
void greater_than(Module &m)
Definition operators.hpp:108
void equal(Module &m)
Definition operators.hpp:102
void not_equal(Module &m)
Definition operators.hpp:138
void logical_compliment(Module &m)
Definition operators.hpp:132
void less_than_equal(Module &m)
Definition operators.hpp:126
Classes and functions useful for bootstrapping of ChaiScript and adding of new types.
Definition bootstrap.hpp:21
void array(const std::string &type, Module &m)
Definition bootstrap.hpp:23
auto parse_string(const std::string &i) -> typename std::enable_if< !std::is_same< Input, wchar_t >::value &&!std::is_same< Input, char16_t >::value &&!std::is_same< Input, char32_t >::value, Input >::type
Definition bootstrap.hpp:114
Boxed_Value ptr_assign(Boxed_Value lhs, const std::shared_ptr< Type > &rhs)
Definition bootstrap.hpp:177
void construct_pod(const std::string &type, Module &m)
Adds a constructor for a POD type.
Definition bootstrap.hpp:105
auto shared_ptr_clone(const std::shared_ptr< Type > &p)
Definition bootstrap.hpp:159
std::shared_ptr< typename std::remove_const< Type >::type > shared_ptr_unconst_clone(const std::shared_ptr< typename std::add_const< Type >::type > &p)
Specific version of shared_ptr_clone just for Proxy_Functions.
Definition bootstrap.hpp:166
void copy_constructor(const std::string &type, Module &m)
Adds a copy constructor for the given type to the given Model.
Definition bootstrap.hpp:64
void opers_comparison(Module &m)
Add all comparison operators for the templated type. Used during bootstrap, also available to users.
Definition bootstrap.hpp:74
void bootstrap_pod_type(const std::string &name, Module &m)
Definition bootstrap.hpp:142
void basic_constructors(const std::string &type, Module &m)
Adds default and copy constructors for the given type.
Definition bootstrap.hpp:94
Proxy_Function make_dynamic_proxy_function(Callable &&c, Arg &&... a)
Definition proxy_functions.hpp:504
Namespace chaiscript contains every API call that the average user will be concerned with.
std::shared_ptr< const dispatch::Proxy_Function_Base > Const_Proxy_Function
Const version of Proxy_Function. Points to a const Proxy_Function. This is how most registered functi...
Definition proxy_functions.hpp:321
constexpr Type_Info user_type(const T &)
Creates a Type_Info object representing the type passed in.
Definition type_info.hpp:221
decltype(auto) boxed_cast(const Boxed_Value &bv, const Type_Conversions_State *t_conversions=nullptr)
Function for extracting a value stored in a Boxed_Value object.
Definition boxed_cast.hpp:76
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
Boxed_Value var(T &&t)
Creates a Boxed_Value. If the object passed in is a value type, it is copied. If it is a pointer,...
Definition boxed_value.hpp:387
Type_Conversion base_class(typename std::enable_if< std::is_polymorphic< Base >::value &&std::is_polymorphic< Derived >::value >::type *=nullptr)
Used to register a to / parent class relationship with ChaiScript. Necessary if you want automatic co...
Definition type_conversions.hpp:562
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
double f(const std::string &, double, bool) noexcept
Definition profile_cpp_calls_2.cpp:4
Definition GameApi.h:42
Struct that doubles as both a parser ast_node and an AST node.
Definition chaiscript_common.hpp:497
const std::string text
Definition chaiscript_common.hpp:500
virtual std::vector< std::reference_wrapper< AST_Node > > get_children() const =0
const std::string & filename() const
Definition chaiscript_common.hpp:503
const AST_Node_Type identifier
Definition chaiscript_common.hpp:499
const File_Position & start() const
Definition chaiscript_common.hpp:507
const File_Position & end() const
Definition chaiscript_common.hpp:511
std::string to_string(const std::string &t_prepend="") const
Prints the contents of an AST node, including its children, recursively.
Definition chaiscript_common.hpp:533
static std::string compiler_id()
Definition chaiscript_defines.hpp:127
static bool debug_build()
Definition chaiscript_defines.hpp:147
static std::string compiler_name()
Definition chaiscript_defines.hpp:142
static std::string compiler_version()
Definition chaiscript_defines.hpp:137
static int version_major()
Definition chaiscript_defines.hpp:107
static int version_patch()
Definition chaiscript_defines.hpp:117
static std::string version()
Definition chaiscript_defines.hpp:122
static int version_minor()
Definition chaiscript_defines.hpp:112
int line
Definition chaiscript_common.hpp:92
int column
Definition chaiscript_common.hpp:93
static constexpr Type_Info get()
Definition type_info.hpp:138
Definition proxy_functions_detail.hpp:42
Errors generated during parsing or evaluation.
Definition chaiscript_common.hpp:168
std::string reason
Definition chaiscript_common.hpp:169
std::vector< AST_Node_Trace > call_stack
Definition chaiscript_common.hpp:173
std::string pretty_print() const
Definition chaiscript_common.hpp:204