MCPcopy Create free account
hub / github.com/ChaiScript/ChaiScript / Boxed_Value

Class Boxed_Value

include/chaiscript/dispatchkit/boxed_value.hpp:27–370  ·  view source on GitHub ↗

\brief A wrapper for holding any valid C++ type. All types in ChaiScript are Boxed_Value objects \sa chaiscript::boxed_cast

Source from the content-addressed store, hash-verified

25 /// \brief A wrapper for holding any valid C++ type. All types in ChaiScript are Boxed_Value objects
26 /// \sa chaiscript::boxed_cast
27 class Boxed_Value
28 {
29 public:
30 /// used for explicitly creating a "void" object
31 struct Void_Type
32 {
33 };
34
35 private:
36 /// structure which holds the internal state of a Boxed_Value
37 /// \todo Get rid of Any and merge it with this, reducing an allocation in the process
38 struct Data
39 {
40 Data(const Type_Info &ti,
41 chaiscript::detail::Any to,
42 bool is_ref,
43 const void *t_void_ptr,
44 bool t_return_value)
45 : m_type_info(ti), m_obj(std::move(to)), m_data_ptr(ti.is_const()?nullptr:const_cast<void *>(t_void_ptr)), m_const_data_ptr(t_void_ptr),
46 m_is_ref(is_ref), m_return_value(t_return_value)
47 {
48 }
49
50 Data &operator=(const Data &rhs)
51 {
52 m_type_info = rhs.m_type_info;
53 m_obj = rhs.m_obj;
54 m_is_ref = rhs.m_is_ref;
55 m_data_ptr = rhs.m_data_ptr;
56 m_const_data_ptr = rhs.m_const_data_ptr;
57 m_return_value = rhs.m_return_value;
58
59 if (rhs.m_attrs)
60 {
61 m_attrs = std::make_unique<std::map<std::string, std::shared_ptr<Data>>>(*rhs.m_attrs);
62 }
63
64 return *this;
65 }
66
67 Data(const Data &) = delete;
68
69 Data(Data &&) = default;
70 Data &operator=(Data &&rhs) = default;
71
72
73 Type_Info m_type_info;
74 chaiscript::detail::Any m_obj;
75 void *m_data_ptr;
76 const void *m_const_data_ptr;
77 std::unique_ptr<std::map<std::string, std::shared_ptr<Data>>> m_attrs;
78 bool m_is_ref;
79 bool m_return_value;
80 };
81
82 struct Object_Data
83 {
84 static auto get(Boxed_Value::Void_Type, bool t_return_value)

Callers 15

ptr_assignFunction · 0.70
bind_functionMethod · 0.70
Boxed_NumberMethod · 0.70
bitwise_complementMethod · 0.70
call_matchMethod · 0.70
do_callMethod · 0.70
handleMethod · 0.70
handleMethod · 0.70
handleMethod · 0.70
handleMethod · 0.70
handleMethod · 0.70
handleMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected