GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
type_conversions.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_DYNAMIC_CAST_CONVERSION_HPP_
12#define CHAISCRIPT_DYNAMIC_CAST_CONVERSION_HPP_
13
14#include <atomic>
15#include <memory>
16#include <set>
17#include <stdexcept>
18#include <string>
19#include <type_traits>
20#include <typeinfo>
21
23#include "bad_boxed_cast.hpp"
24#include "boxed_cast_helper.hpp"
25#include "boxed_value.hpp"
26#include "type_info.hpp"
27
28namespace chaiscript
29{
30 namespace exception
31 {
33 {
34 public:
35 bad_boxed_dynamic_cast(const Type_Info &t_from, const std::type_info &t_to,
36 const std::string &t_what) noexcept
37 : bad_boxed_cast(t_from, t_to, t_what)
38 {
39 }
40
41 bad_boxed_dynamic_cast(const Type_Info &t_from, const std::type_info &t_to) noexcept
42 : bad_boxed_cast(t_from, t_to)
43 {
44 }
45
46 explicit bad_boxed_dynamic_cast(const std::string &w) noexcept
48 {
49 }
50
52
53 ~bad_boxed_dynamic_cast() noexcept override = default;
54 };
55
57 {
58 public:
59 bad_boxed_type_cast(const Type_Info &t_from, const std::type_info &t_to,
60 const std::string &t_what) noexcept
61 : bad_boxed_cast(t_from, t_to, t_what)
62 {
63 }
64
65 bad_boxed_type_cast(const Type_Info &t_from, const std::type_info &t_to) noexcept
66 : bad_boxed_cast(t_from, t_to)
67 {
68 }
69
70 explicit bad_boxed_type_cast(const std::string &w) noexcept
72 {
73 }
74
76
77 ~bad_boxed_type_cast() noexcept override = default;
78 };
79 }
80
81
82 namespace detail
83 {
85 {
86 public:
87 virtual Boxed_Value convert(const Boxed_Value &from) const = 0;
88 virtual Boxed_Value convert_down(const Boxed_Value &to) const = 0;
89
90 const Type_Info &to() const
91 {
92 return m_to;
93 }
94 const Type_Info &from() const
95 {
96 return m_from;
97 }
98
99 virtual bool bidir() const
100 {
101 return true;
102 }
103
104 virtual ~Type_Conversion_Base() = default;
105
106 protected:
108 : m_to(std::move(t_to)), m_from(std::move(t_from))
109 {
110 }
111
112
113 private:
114 const Type_Info m_to;
115 const Type_Info m_from;
116
117 };
118
119 template<typename From, typename To>
121 {
122 public:
123 static Boxed_Value cast(const Boxed_Value &t_from)
124 {
126 {
127 if (t_from.is_pointer())
128 {
129 // Dynamic cast out the contained boxed value, which we know is the type we want
130 if (t_from.is_const())
131 {
132 return Boxed_Value(
133 [&](){
134 if (auto data = std::static_pointer_cast<const To>(detail::Cast_Helper<std::shared_ptr<const From> >::cast(t_from, nullptr)))
135 {
136 return data;
137 } else {
138 throw std::bad_cast();
139 }
140 }()
141 );
142 } else {
143 return Boxed_Value(
144 [&](){
145 if (auto data = std::static_pointer_cast<To>(detail::Cast_Helper<std::shared_ptr<From> >::cast(t_from, nullptr)))
146 {
147 return data;
148 } else {
149 throw std::bad_cast();
150 }
151 }()
152 );
153 }
154 } else {
155 // Pull the reference out of the contained boxed value, which we know is the type we want
156 if (t_from.is_const())
157 {
158 const From &d = detail::Cast_Helper<const From &>::cast(t_from, nullptr);
159 const To &data = static_cast<const To &>(d);
160 return Boxed_Value(std::cref(data));
161 } else {
162 From &d = detail::Cast_Helper<From &>::cast(t_from, nullptr);
163 To &data = static_cast<To &>(d);
164 return Boxed_Value(std::ref(data));
165 }
166 }
167 } else {
168 throw chaiscript::exception::bad_boxed_dynamic_cast(t_from.get_type_info(), typeid(To), "Unknown dynamic_cast_conversion");
169 }
170 }
171
172 };
173
174
175 template<typename From, typename To>
177 {
178 public:
179 static Boxed_Value cast(const Boxed_Value &t_from)
180 {
182 {
183 if (t_from.is_pointer())
184 {
185 // Dynamic cast out the contained boxed value, which we know is the type we want
186 if (t_from.is_const())
187 {
188 return Boxed_Value(
189 [&](){
190 if (auto data = std::dynamic_pointer_cast<const To>(detail::Cast_Helper<std::shared_ptr<const From> >::cast(t_from, nullptr)))
191 {
192 return data;
193 } else {
194 throw std::bad_cast();
195 }
196 }()
197 );
198 } else {
199 return Boxed_Value(
200 [&](){
201 if (auto data = std::dynamic_pointer_cast<To>(detail::Cast_Helper<std::shared_ptr<From> >::cast(t_from, nullptr)))
202 {
203 return data;
204 } else {
205#ifdef CHAISCRIPT_LIBCPP
207 if (std::string(typeid(To).name()).find("Assignable_Proxy_Function") != std::string::npos) {
208 auto from = detail::Cast_Helper<std::shared_ptr<From> >::cast(t_from, nullptr);
209 if (std::string(typeid(*from).name()).find("Assignable_Proxy_Function_Impl") != std::string::npos) {
210 return std::static_pointer_cast<To>(from);
211 }
212 }
213#endif
214 throw std::bad_cast();
215 }
216 }()
217 );
218 }
219 } else {
220 // Pull the reference out of the contained boxed value, which we know is the type we want
221 if (t_from.is_const())
222 {
223 const From &d = detail::Cast_Helper<const From &>::cast(t_from, nullptr);
224 const To &data = dynamic_cast<const To &>(d);
225 return Boxed_Value(std::cref(data));
226 } else {
227 From &d = detail::Cast_Helper<From &>::cast(t_from, nullptr);
228 To &data = dynamic_cast<To &>(d);
229 return Boxed_Value(std::ref(data));
230 }
231 }
232 } else {
233 throw chaiscript::exception::bad_boxed_dynamic_cast(t_from.get_type_info(), typeid(To), "Unknown dynamic_cast_conversion");
234 }
235 }
236
237 };
238
239
240 template<typename Base, typename Derived>
242 {
243 public:
248
249 Boxed_Value convert_down(const Boxed_Value &t_base) const override
250 {
252 }
253
254 Boxed_Value convert(const Boxed_Value &t_derived) const override
255 {
256 return Static_Caster<Derived, Base>::cast(t_derived);
257 }
258 };
259
260 template<typename Base, typename Derived>
262 {
263 public:
268
269 Boxed_Value convert_down(const Boxed_Value &t_base) const override
270 {
271 throw chaiscript::exception::bad_boxed_dynamic_cast(t_base.get_type_info(), typeid(Derived),
272 "Unable to cast down inheritance hierarchy with non-polymorphic types");
273 }
274
275 bool bidir() const override
276 {
277 return false;
278 }
279
280 Boxed_Value convert(const Boxed_Value &t_derived) const override
281 {
282 return Static_Caster<Derived, Base>::cast(t_derived);
283 }
284 };
285
286
287
288 template<typename Callable>
290 {
291 public:
292 Type_Conversion_Impl(Type_Info t_from, Type_Info t_to, Callable t_func)
293 : Type_Conversion_Base(t_to, t_from),
294 m_func(std::move(t_func))
295 {
296 }
297
298 Boxed_Value convert_down(const Boxed_Value &) const override
299 {
300 throw chaiscript::exception::bad_boxed_type_cast("No conversion exists");
301 }
302
303 Boxed_Value convert(const Boxed_Value &t_from) const override
304 {
306 return m_func(t_from);
307 }
308
309 bool bidir() const override
310 {
311 return false;
312 }
313
314
315 private:
316 Callable m_func;
317 };
318 }
319
321 {
322 public:
324 {
325 bool enabled = false;
326 std::vector<Boxed_Value> saves;
327 };
328
330 {
331 bool operator()(const std::type_info *t_lhs, const std::type_info *t_rhs) const
332 {
333 return *t_lhs != *t_rhs && t_lhs->before(*t_rhs);
334 }
335 };
336
338 : m_mutex(),
339 m_conversions(),
340 m_convertableTypes(),
341 m_num_types(0)
342 {
343 }
344
345 Type_Conversions(const Type_Conversions &t_other) = delete;
347
350
351 const std::set<const std::type_info *, Less_Than> &thread_cache() const
352 {
353 auto &cache = *m_thread_cache;
354 if (cache.size() != m_num_types)
355 {
357 cache = m_convertableTypes;
358 }
359
360 return cache;
361 }
362
363 void add_conversion(const std::shared_ptr<detail::Type_Conversion_Base> &conversion)
364 {
367 m_conversions.insert(conversion);
368 m_convertableTypes.insert({conversion->to().bare_type_info(), conversion->from().bare_type_info()});
369 m_num_types = m_convertableTypes.size();
370 }
371
372 template<typename T>
373 bool convertable_type() const
374 {
375 return thread_cache().count(user_type<T>().bare_type_info()) != 0;
376 }
377
378 template<typename To, typename From>
379 bool converts() const
380 {
382 }
383
384 bool converts(const Type_Info &to, const Type_Info &from) const
385 {
386 const auto &types = thread_cache();
387 if (types.count(to.bare_type_info()) != 0 && types.count(from.bare_type_info()) != 0)
388 {
389 return has_conversion(to, from);
390 } else {
391 return false;
392 }
393 }
394
395 template<typename To>
397 {
398 return boxed_type_conversion(user_type<To>(), t_saves, from);
399 }
400
401 template<typename From>
403 {
404 return boxed_type_down_conversion(user_type<From>(), t_saves, to);
405 }
406
407
409 {
410 try {
411 Boxed_Value ret = get_conversion(to, from.get_type_info())->convert(from);
412 if (t_saves.enabled) { t_saves.saves.push_back(ret); }
413 return ret;
414 } catch (const std::out_of_range &) {
415 throw exception::bad_boxed_dynamic_cast(from.get_type_info(), *to.bare_type_info(), "No known conversion");
416 } catch (const std::bad_cast &) {
417 throw exception::bad_boxed_dynamic_cast(from.get_type_info(), *to.bare_type_info(), "Unable to perform dynamic_cast operation");
418 }
419 }
420
422 {
423 try {
424 Boxed_Value ret = get_conversion(to.get_type_info(), from)->convert_down(to);
425 if (t_saves.enabled) { t_saves.saves.push_back(ret); }
426 return ret;
427 } catch (const std::out_of_range &) {
428 throw exception::bad_boxed_dynamic_cast(to.get_type_info(), *from.bare_type_info(), "No known conversion");
429 } catch (const std::bad_cast &) {
430 throw exception::bad_boxed_dynamic_cast(to.get_type_info(), *from.bare_type_info(), "Unable to perform dynamic_cast operation");
431 }
432 }
433
434 static void enable_conversion_saves(Conversion_Saves &t_saves, bool t_val)
435 {
436 t_saves.enabled = t_val;
437 }
438
439 std::vector<Boxed_Value> take_saves(Conversion_Saves &t_saves)
440 {
441 std::vector<Boxed_Value> ret;
442 std::swap(ret, t_saves.saves);
443 return ret;
444 }
445
446 bool has_conversion(const Type_Info &to, const Type_Info &from) const
447 {
449 return find_bidir(to, from) != m_conversions.end();
450 }
451
452 std::shared_ptr<detail::Type_Conversion_Base> get_conversion(const Type_Info &to, const Type_Info &from) const
453 {
455
456 const auto itr = find(to, from);
457
458 if (itr != m_conversions.end())
459 {
460 return *itr;
461 } else {
462 throw std::out_of_range("No such conversion exists from " + from.bare_name() + " to " + to.bare_name());
463 }
464 }
465
467 return *m_conversion_saves;
468 }
469
470 private:
471 std::set<std::shared_ptr<detail::Type_Conversion_Base> >::const_iterator find_bidir(
472 const Type_Info &to, const Type_Info &from) const
473 {
474 return std::find_if(m_conversions.begin(), m_conversions.end(),
475 [&to, &from](const std::shared_ptr<detail::Type_Conversion_Base> &conversion) -> bool
476 {
477 return (conversion->to().bare_equal(to) && conversion->from().bare_equal(from))
478 || (conversion->bidir() && conversion->from().bare_equal(to) && conversion->to().bare_equal(from));
479 }
480 );
481 }
482
483 std::set<std::shared_ptr<detail::Type_Conversion_Base> >::const_iterator find(
484 const Type_Info &to, const Type_Info &from) const
485 {
486 return std::find_if(m_conversions.begin(), m_conversions.end(),
487 [&to, &from](const std::shared_ptr<detail::Type_Conversion_Base> &conversion)
488 {
489 return conversion->to().bare_equal(to) && conversion->from().bare_equal(from);
490 }
491 );
492 }
493
494 std::set<std::shared_ptr<detail::Type_Conversion_Base>> get_conversions() const
495 {
497
498 return m_conversions;
499 }
500
501
502
504 std::set<std::shared_ptr<detail::Type_Conversion_Base>> m_conversions;
505 std::set<const std::type_info *, Less_Than> m_convertableTypes;
506 std::atomic_size_t m_num_types;
507 mutable chaiscript::detail::threading::Thread_Storage<std::set<const std::type_info *, Less_Than>> m_thread_cache;
508 mutable chaiscript::detail::threading::Thread_Storage<Conversion_Saves> m_conversion_saves;
509 };
510
512 {
513 public:
516 : m_conversions(t_conversions),
517 m_saves(t_saves)
518 {
519 }
520
522 return &m_conversions.get();
523 }
524
525 const Type_Conversions *get() const {
526 return &m_conversions.get();
527 }
528
530 return m_saves;
531 }
532
533 private:
534 std::reference_wrapper<const Type_Conversions> m_conversions;
535 std::reference_wrapper<Type_Conversions::Conversion_Saves> m_saves;
536 };
537
538 typedef std::shared_ptr<chaiscript::detail::Type_Conversion_Base> Type_Conversion;
539
561 template<typename Base, typename Derived>
562 Type_Conversion base_class(typename std::enable_if<std::is_polymorphic<Base>::value && std::is_polymorphic<Derived>::value>::type* = nullptr)
563 {
564 //Can only be used with related polymorphic types
565 //may be expanded some day to support conversions other than child -> parent
566 static_assert(std::is_base_of<Base,Derived>::value, "Classes are not related by inheritance");
567
569 }
570
571 template<typename Base, typename Derived>
572 Type_Conversion base_class(typename std::enable_if<!std::is_polymorphic<Base>::value || !std::is_polymorphic<Derived>::value>::type* = nullptr)
573 {
574 //Can only be used with related polymorphic types
575 //may be expanded some day to support conversions other than child -> parent
576 static_assert(std::is_base_of<Base,Derived>::value, "Classes are not related by inheritance");
577
579 }
580
581
582 template<typename Callable>
584 const Callable &t_func)
585 {
587 }
588
589 template<typename From, typename To, typename Callable>
590 Type_Conversion type_conversion(const Callable &t_function)
591 {
592 auto func = [t_function](const Boxed_Value &t_bv) -> Boxed_Value {
593 // not even attempting to call boxed_cast so that we don't get caught in some call recursion
594 return chaiscript::Boxed_Value(t_function(detail::Cast_Helper<const From &>::cast(t_bv, nullptr)));
595 };
596
598 }
599
600 template<typename From, typename To>
602 {
603 static_assert(std::is_convertible<From, To>::value, "Types are not automatically convertible");
604 auto func = [](const Boxed_Value &t_bv) -> Boxed_Value {
605 // not even attempting to call boxed_cast so that we don't get caught in some call recursion
607 };
608
610 }
611
612 template<typename To>
614 {
615 auto func = [](const Boxed_Value &t_bv) -> Boxed_Value {
616 const std::vector<Boxed_Value> &from_vec = detail::Cast_Helper<const std::vector<Boxed_Value> &>::cast(t_bv, nullptr);
617
618 To vec;
619 vec.reserve(from_vec.size());
620 for (const Boxed_Value &bv : from_vec) {
621 vec.push_back(detail::Cast_Helper<typename To::value_type>::cast(bv, nullptr));
622 }
623
624 return Boxed_Value(std::move(vec));
625 };
626
628 }
629
630 template<typename To>
632 {
633 auto func = [](const Boxed_Value &t_bv) -> Boxed_Value {
634 const std::map<std::string, Boxed_Value> &from_map = detail::Cast_Helper<const std::map<std::string, Boxed_Value> &>::cast(t_bv, nullptr);
635
636 To map;
637 for (const std::pair<std::string, Boxed_Value> &p : from_map) {
638 map.insert(std::make_pair(p.first, detail::Cast_Helper<typename To::mapped_type>::cast(p.second, nullptr)));
639 }
640
641 return Boxed_Value(std::move(map));
642 };
643
644 return chaiscript::make_shared<detail::Type_Conversion_Base, detail::Type_Conversion_Impl<decltype(func)>>(user_type<std::map<std::string, Boxed_Value>>(), user_type<To>(), func);
645 }
646}
647
648
649#endif
P func(int c, EveryApi &ev)
Definition test.cpp:59
void * find(int i)
Definition ui.cc:347
A wrapper for holding any valid C++ type. All types in ChaiScript are Boxed_Value objects.
Definition boxed_value.hpp:28
bool is_pointer() const noexcept
Definition boxed_value.hpp:306
bool is_const() const noexcept
Definition boxed_value.hpp:235
const Type_Info & get_type_info() const noexcept
Definition boxed_value.hpp:224
const Type_Conversions * operator->() const
Definition type_conversions.hpp:521
const Type_Conversions * get() const
Definition type_conversions.hpp:525
Type_Conversions_State(const Type_Conversions &t_conversions, Type_Conversions::Conversion_Saves &t_saves)
Definition type_conversions.hpp:514
Type_Conversions::Conversion_Saves & saves() const
Definition type_conversions.hpp:529
Definition type_conversions.hpp:321
std::vector< Boxed_Value > take_saves(Conversion_Saves &t_saves)
Definition type_conversions.hpp:439
bool converts(const Type_Info &to, const Type_Info &from) const
Definition type_conversions.hpp:384
bool converts() const
Definition type_conversions.hpp:379
void add_conversion(const std::shared_ptr< detail::Type_Conversion_Base > &conversion)
Definition type_conversions.hpp:363
Boxed_Value boxed_type_down_conversion(const Type_Info &from, Conversion_Saves &t_saves, const Boxed_Value &to) const
Definition type_conversions.hpp:421
Type_Conversions(Type_Conversions &&)=default
Boxed_Value boxed_type_conversion(Conversion_Saves &t_saves, const Boxed_Value &from) const
Definition type_conversions.hpp:396
bool convertable_type() const
Definition type_conversions.hpp:373
Type_Conversions & operator=(const Type_Conversions &)=delete
Type_Conversions(const Type_Conversions &t_other)=delete
Boxed_Value boxed_type_down_conversion(Conversion_Saves &t_saves, const Boxed_Value &to) const
Definition type_conversions.hpp:402
Boxed_Value boxed_type_conversion(const Type_Info &to, Conversion_Saves &t_saves, const Boxed_Value &from) const
Definition type_conversions.hpp:408
static void enable_conversion_saves(Conversion_Saves &t_saves, bool t_val)
Definition type_conversions.hpp:434
const std::set< const std::type_info *, Less_Than > & thread_cache() const
Definition type_conversions.hpp:351
Type_Conversions & operator=(Type_Conversions &&)=default
Conversion_Saves & conversion_saves() const
Definition type_conversions.hpp:466
bool has_conversion(const Type_Info &to, const Type_Info &from) const
Definition type_conversions.hpp:446
std::shared_ptr< detail::Type_Conversion_Base > get_conversion(const Type_Info &to, const Type_Info &from) const
Definition type_conversions.hpp:452
Type_Conversions()
Definition type_conversions.hpp:337
Compile time deduced information about a type.
Definition type_info.hpp:34
constexpr bool bare_equal(const Type_Info &ti) const noexcept
Definition type_info.hpp:75
Definition type_conversions.hpp:177
static Boxed_Value cast(const Boxed_Value &t_from)
Definition type_conversions.hpp:179
Dynamic_Conversion_Impl()
Definition type_conversions.hpp:244
Boxed_Value convert_down(const Boxed_Value &t_base) const override
Definition type_conversions.hpp:249
Boxed_Value convert(const Boxed_Value &t_derived) const override
Definition type_conversions.hpp:254
Definition type_conversions.hpp:121
static Boxed_Value cast(const Boxed_Value &t_from)
Definition type_conversions.hpp:123
bool bidir() const override
Definition type_conversions.hpp:275
Boxed_Value convert(const Boxed_Value &t_derived) const override
Definition type_conversions.hpp:280
Static_Conversion_Impl()
Definition type_conversions.hpp:264
Boxed_Value convert_down(const Boxed_Value &t_base) const override
Definition type_conversions.hpp:269
Definition type_conversions.hpp:85
virtual Boxed_Value convert_down(const Boxed_Value &to) const =0
virtual Boxed_Value convert(const Boxed_Value &from) const =0
virtual bool bidir() const
Definition type_conversions.hpp:99
Type_Conversion_Base(Type_Info t_to, Type_Info t_from)
Definition type_conversions.hpp:107
const Type_Info & to() const
Definition type_conversions.hpp:90
const Type_Info & from() const
Definition type_conversions.hpp:94
Definition type_conversions.hpp:290
Boxed_Value convert(const Boxed_Value &t_from) const override
Definition type_conversions.hpp:303
bool bidir() const override
Definition type_conversions.hpp:309
Type_Conversion_Impl(Type_Info t_from, Type_Info t_to, Callable t_func)
Definition type_conversions.hpp:292
Boxed_Value convert_down(const Boxed_Value &) const override
Definition type_conversions.hpp:298
bad_boxed_cast(Type_Info t_from, const std::type_info &t_to, std::string t_what) noexcept
Definition bad_boxed_cast.hpp:36
Definition type_conversions.hpp:33
bad_boxed_dynamic_cast(const bad_boxed_dynamic_cast &)=default
bad_boxed_dynamic_cast(const Type_Info &t_from, const std::type_info &t_to) noexcept
Definition type_conversions.hpp:41
bad_boxed_dynamic_cast(const std::string &w) noexcept
Definition type_conversions.hpp:46
bad_boxed_dynamic_cast(const Type_Info &t_from, const std::type_info &t_to, const std::string &t_what) noexcept
Definition type_conversions.hpp:35
~bad_boxed_dynamic_cast() noexcept override=default
Definition type_conversions.hpp:57
bad_boxed_type_cast(const bad_boxed_type_cast &)=default
~bad_boxed_type_cast() noexcept override=default
bad_boxed_type_cast(const Type_Info &t_from, const std::type_info &t_to, const std::string &t_what) noexcept
Definition type_conversions.hpp:59
bad_boxed_type_cast(const Type_Info &t_from, const std::type_info &t_to) noexcept
Definition type_conversions.hpp:65
bad_boxed_type_cast(const std::string &w) noexcept
Definition type_conversions.hpp:70
ret($return)
Definition mesh_login_result.php:5
d
Definition meshpage.php:3895
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
lazy data
Definition meshpage.php:1583
std::unique_lock< T > shared_lock
Definition chaiscript_threading.hpp:52
std::mutex shared_mutex
Definition chaiscript_threading.hpp:58
std::unique_lock< T > unique_lock
Definition chaiscript_threading.hpp:49
Classes and functions reserved for internal use. Items in this namespace are not supported.
Classes which may be thrown during error cases when ChaiScript is executing.
Definition bad_boxed_cast.hpp:27
Namespace chaiscript contains every API call that the average user will be concerned with.
constexpr Type_Info user_type(const T &)
Creates a Type_Info object representing the type passed in.
Definition type_info.hpp:221
std::shared_ptr< chaiscript::detail::Type_Conversion_Base > Type_Conversion
Definition type_conversions.hpp:538
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
std::shared_ptr< B > make_shared(Arg &&... arg)
Definition chaiscript_defines.hpp:87
Type_Conversion map_conversion()
Definition type_conversions.hpp:631
Type_Conversion type_conversion()
Definition type_conversions.hpp:601
Type_Conversion vector_conversion()
Definition type_conversions.hpp:613
STL namespace.
Definition type_conversions.hpp:324
bool enabled
Definition type_conversions.hpp:325
std::vector< Boxed_Value > saves
Definition type_conversions.hpp:326
Definition type_conversions.hpp:330
bool operator()(const std::type_info *t_lhs, const std::type_info *t_rhs) const
Definition type_conversions.hpp:331
The exposed Cast_Helper object that by default just calls the Cast_Helper_Inner.
Definition boxed_cast_helper.hpp:313
static decltype(auto) cast(const Boxed_Value &ob, const Type_Conversions_State *t_conversions)
Definition boxed_cast_helper.hpp:314