ChaiScript / ChaiScript
Showing 60 of 82 files from the diff.

@@ -4,13 +4,11 @@
Loading
4 4
5 5
Multi_Test_Module::Multi_Test_Module() noexcept = default;
6 6
7 -
int Multi_Test_Module::get_module_value()
8 -
{
7 +
int Multi_Test_Module::get_module_value() {
9 8
  return 0;
10 9
}
11 10
12 -
chaiscript::ModulePtr Multi_Test_Module::get_module()
13 -
{
11 +
chaiscript::ModulePtr Multi_Test_Module::get_module() {
14 12
  chaiscript::ModulePtr module(new chaiscript::Module());
15 13
16 14
  module->add(chaiscript::fun(&Multi_Test_Module::get_module_value), "get_module_value");

@@ -7,236 +7,204 @@
Loading
7 7
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
8 8
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
9 9
10 -
11 10
#ifndef CHAISCRIPT_TYPE_INFO_HPP_
12 11
#define CHAISCRIPT_TYPE_INFO_HPP_
13 12
14 13
#include <memory>
14 +
#include <string>
15 15
#include <type_traits>
16 16
#include <typeinfo>
17 -
#include <string>
18 17
19 -
namespace chaiscript
20 -
{
21 -
22 -
  namespace detail
23 -
  {
18 +
namespace chaiscript {
19 +
  namespace detail {
24 20
    template<typename T>
25 -
      struct Bare_Type
26 -
      {
27 -
        using type = typename std::remove_cv<typename std::remove_pointer<typename std::remove_reference<T>::type>::type>::type;
28 -
      };
29 -
  }
30 -
21 +
    struct Bare_Type {
22 +
      using type = typename std::remove_cv<typename std::remove_pointer<typename std::remove_reference<T>::type>::type>::type;
23 +
    };
24 +
  } // namespace detail
31 25
32 26
  /// \brief Compile time deduced information about a type
33 -
  class Type_Info
34 -
  {
35 -
    public:
36 -
      constexpr Type_Info(const bool t_is_const, const bool t_is_reference, const bool t_is_pointer, const bool t_is_void, 
37 -
          const bool t_is_arithmetic, const std::type_info *t_ti, const std::type_info *t_bare_ti) noexcept
38 -
        : m_type_info(t_ti), m_bare_type_info(t_bare_ti),
39 -
          m_flags((static_cast<unsigned int>(t_is_const) << is_const_flag)
40 -
                + (static_cast<unsigned int>(t_is_reference) << is_reference_flag)
41 -
                + (static_cast<unsigned int>(t_is_pointer) << is_pointer_flag)
42 -
                + (static_cast<unsigned int>(t_is_void) << is_void_flag)
43 -
                + (static_cast<unsigned int>(t_is_arithmetic) << is_arithmetic_flag))
44 -
      {
45 -
      }
46 -
47 -
      constexpr Type_Info() noexcept = default;
48 -
49 -
      bool operator<(const Type_Info &ti) const noexcept
50 -
      {
51 -
        return m_type_info->before(*ti.m_type_info);
52 -
      }
53 -
54 -
      constexpr bool operator!=(const Type_Info &ti) const noexcept
55 -
      {
56 -
        return !(operator==(ti));
57 -
      }
58 -
59 -
      constexpr bool operator!=(const std::type_info &ti) const noexcept
60 -
      {
61 -
        return !(operator==(ti));
62 -
      }
63 -
64 -
      constexpr bool operator==(const Type_Info &ti) const noexcept
65 -
      {
66 -
        return ti.m_type_info == m_type_info
67 -
           || *ti.m_type_info == *m_type_info;
68 -
      }
69 -
70 -
      constexpr bool operator==(const std::type_info &ti) const noexcept
71 -
      {
72 -
        return !is_undef() && (*m_type_info) == ti;
27 +
  class Type_Info {
28 +
  public:
29 +
    constexpr Type_Info(const bool t_is_const,
30 +
                        const bool t_is_reference,
31 +
                        const bool t_is_pointer,
32 +
                        const bool t_is_void,
33 +
                        const bool t_is_arithmetic,
34 +
                        const std::type_info *t_ti,
35 +
                        const std::type_info *t_bare_ti) noexcept
36 +
        : m_type_info(t_ti)
37 +
        , m_bare_type_info(t_bare_ti)
38 +
        , m_flags((static_cast<unsigned int>(t_is_const) << is_const_flag) + (static_cast<unsigned int>(t_is_reference) << is_reference_flag)
39 +
                  + (static_cast<unsigned int>(t_is_pointer) << is_pointer_flag) + (static_cast<unsigned int>(t_is_void) << is_void_flag)
40 +
                  + (static_cast<unsigned int>(t_is_arithmetic) << is_arithmetic_flag)) {
41 +
    }
42 +
43 +
    constexpr Type_Info() noexcept = default;
44 +
45 +
    bool operator<(const Type_Info &ti) const noexcept { return m_type_info->before(*ti.m_type_info); }
46 +
47 +
    constexpr bool operator!=(const Type_Info &ti) const noexcept { return !(operator==(ti)); }
48 +
49 +
    constexpr bool operator!=(const std::type_info &ti) const noexcept { return !(operator==(ti)); }
50 +
51 +
    constexpr bool operator==(const Type_Info &ti) const noexcept {
52 +
      return ti.m_type_info == m_type_info || *ti.m_type_info == *m_type_info;
53 +
    }
54 +
55 +
    constexpr bool operator==(const std::type_info &ti) const noexcept { return !is_undef() && (*m_type_info) == ti; }
56 +
57 +
    constexpr bool bare_equal(const Type_Info &ti) const noexcept {
58 +
      return ti.m_bare_type_info == m_bare_type_info || *ti.m_bare_type_info == *m_bare_type_info;
59 +
    }
60 +
61 +
    constexpr bool bare_equal_type_info(const std::type_info &ti) const noexcept { return !is_undef() && (*m_bare_type_info) == ti; }
62 +
63 +
    constexpr bool is_const() const noexcept { return (m_flags & (1 << is_const_flag)) != 0; }
64 +
    constexpr bool is_reference() const noexcept { return (m_flags & (1 << is_reference_flag)) != 0; }
65 +
    constexpr bool is_void() const noexcept { return (m_flags & (1 << is_void_flag)) != 0; }
66 +
    constexpr bool is_arithmetic() const noexcept { return (m_flags & (1 << is_arithmetic_flag)) != 0; }
67 +
    constexpr bool is_undef() const noexcept { return (m_flags & (1 << is_undef_flag)) != 0; }
68 +
    constexpr bool is_pointer() const noexcept { return (m_flags & (1 << is_pointer_flag)) != 0; }
69 +
70 +
    const char *name() const noexcept {
71 +
      if (!is_undef()) {
72 +
        return m_type_info->name();
73 +
      } else {
74 +
        return "";
73 75
      }
76 +
    }
74 77
75 -
      constexpr bool bare_equal(const Type_Info &ti) const noexcept
76 -
      {
77 -
        return ti.m_bare_type_info == m_bare_type_info
78 -
           || *ti.m_bare_type_info == *m_bare_type_info;
78 +
    const char *bare_name() const noexcept {
79 +
      if (!is_undef()) {
80 +
        return m_bare_type_info->name();
81 +
      } else {
82 +
        return "";
79 83
      }
80 -
81 -
      constexpr bool bare_equal_type_info(const std::type_info &ti) const noexcept
82 -
      {
83 -
        return !is_undef() && (*m_bare_type_info) == ti;
84 -
      }
85 -
86 -
      constexpr bool is_const() const noexcept { return (m_flags & (1 << is_const_flag)) != 0; }
87 -
      constexpr bool is_reference() const noexcept { return (m_flags & (1 << is_reference_flag)) != 0; }
88 -
      constexpr bool is_void() const noexcept { return (m_flags & (1 << is_void_flag)) != 0; }
89 -
      constexpr bool is_arithmetic() const noexcept { return (m_flags & (1 << is_arithmetic_flag)) != 0; }
90 -
      constexpr bool is_undef() const noexcept { return (m_flags & (1 << is_undef_flag)) != 0; }
91 -
      constexpr bool is_pointer() const noexcept { return (m_flags & (1 << is_pointer_flag)) != 0; }
92 -
93 -
      const char * name() const noexcept
94 -
      {
95 -
        if (!is_undef())
96 -
        {
97 -
          return m_type_info->name();
98 -
        } else {
99 -
          return "";
100 -
        }
101 -
      }
102 -
103 -
      const char * bare_name() const noexcept
104 -
      {
105 -
        if (!is_undef())
106 -
        {
107 -
          return m_bare_type_info->name();
108 -
        } else {
109 -
          return "";
110 -
        }
111 -
      }
112 -
113 -
      constexpr const std::type_info *bare_type_info() const noexcept
114 -
      {
115 -
        return m_bare_type_info;
116 -
      }
117 -
118 -
    private:
119 -
      struct Unknown_Type {};
120 -
121 -
      const std::type_info *m_type_info = &typeid(Unknown_Type);
122 -
      const std::type_info *m_bare_type_info = &typeid(Unknown_Type);
123 -
      static const int is_const_flag = 0;
124 -
      static const int is_reference_flag = 1;
125 -
      static const int is_pointer_flag = 2;
126 -
      static const int is_void_flag = 3;
127 -
      static const int is_arithmetic_flag = 4;
128 -
      static const int is_undef_flag = 5;
129 -
      unsigned int m_flags = (1 << is_undef_flag);
84 +
    }
85 +
86 +
    constexpr const std::type_info *bare_type_info() const noexcept { return m_bare_type_info; }
87 +
88 +
  private:
89 +
    struct Unknown_Type {
90 +
    };
91 +
92 +
    const std::type_info *m_type_info = &typeid(Unknown_Type);
93 +
    const std::type_info *m_bare_type_info = &typeid(Unknown_Type);
94 +
    static const int is_const_flag = 0;
95 +
    static const int is_reference_flag = 1;
96 +
    static const int is_pointer_flag = 2;
97 +
    static const int is_void_flag = 3;
98 +
    static const int is_arithmetic_flag = 4;
99 +
    static const int is_undef_flag = 5;
100 +
    unsigned int m_flags = (1 << is_undef_flag);
130 101
  };
131 102
132 -
  namespace detail
133 -
  {
103 +
  namespace detail {
134 104
    /// Helper used to create a Type_Info object
135 105
    template<typename T>
136 -
      struct Get_Type_Info
137 -
      {
138 -
        constexpr static Type_Info get() noexcept
139 -
        {
140 -
          return Type_Info(std::is_const<typename std::remove_pointer<typename std::remove_reference<T>::type>::type>::value, 
141 -
              std::is_reference<T>::value, std::is_pointer<T>::value, 
142 -
              std::is_void<T>::value,
143 -
              (std::is_arithmetic<T>::value || std::is_arithmetic<typename std::remove_reference<T>::type>::value)
144 -
                && !std::is_same<typename std::remove_const<typename std::remove_reference<T>::type>::type, bool>::value,
145 -
              &typeid(T),
146 -
              &typeid(typename Bare_Type<T>::type));
147 -
        }
148 -
      };
106 +
    struct Get_Type_Info {
107 +
      constexpr static Type_Info get() noexcept {
108 +
        return Type_Info(std::is_const<typename std::remove_pointer<typename std::remove_reference<T>::type>::type>::value,
109 +
                         std::is_reference<T>::value,
110 +
                         std::is_pointer<T>::value,
111 +
                         std::is_void<T>::value,
112 +
                         (std::is_arithmetic<T>::value || std::is_arithmetic<typename std::remove_reference<T>::type>::value)
113 +
                             && !std::is_same<typename std::remove_const<typename std::remove_reference<T>::type>::type, bool>::value,
114 +
                         &typeid(T),
115 +
                         &typeid(typename Bare_Type<T>::type));
116 +
      }
117 +
    };
149 118
150 119
    template<typename T>
151 -
      struct Get_Type_Info<std::shared_ptr<T> >
152 -
      {
153 -
        constexpr static Type_Info get() noexcept
154 -
        {
155 -
          return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value, 
156 -
              std::is_void<T>::value,
157 -
              std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<typename std::remove_reference<T>::type>::type, bool>::value,
158 -
              &typeid(std::shared_ptr<T> ), 
159 -
              &typeid(typename Bare_Type<T>::type));
160 -
        }
161 -
      };
120 +
    struct Get_Type_Info<std::shared_ptr<T>> {
121 +
      constexpr static Type_Info get() noexcept {
122 +
        return Type_Info(std::is_const<T>::value,
123 +
                         std::is_reference<T>::value,
124 +
                         std::is_pointer<T>::value,
125 +
                         std::is_void<T>::value,
126 +
                         std::is_arithmetic<T>::value
127 +
                             && !std::is_same<typename std::remove_const<typename std::remove_reference<T>::type>::type, bool>::value,
128 +
                         &typeid(std::shared_ptr<T>),
129 +
                         &typeid(typename Bare_Type<T>::type));
130 +
      }
131 +
    };
162 132
163 133
    template<typename T>
164 -
      struct Get_Type_Info<std::shared_ptr<T> &> : Get_Type_Info<std::shared_ptr<T>>
165 -
      {
166 -
      };
134 +
    struct Get_Type_Info<std::shared_ptr<T> &> : Get_Type_Info<std::shared_ptr<T>> {
135 +
    };
167 136
168 137
    template<typename T>
169 -
      struct Get_Type_Info<const std::shared_ptr<T> &>
170 -
      {
171 -
        constexpr static Type_Info get() noexcept
172 -
        {
173 -
          return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value, 
174 -
              std::is_void<T>::value,
175 -
              std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<typename std::remove_reference<T>::type>::type, bool>::value,
176 -
              &typeid(const std::shared_ptr<T> &), 
177 -
              &typeid(typename Bare_Type<T>::type));
178 -
        }
179 -
      };
138 +
    struct Get_Type_Info<const std::shared_ptr<T> &> {
139 +
      constexpr static Type_Info get() noexcept {
140 +
        return Type_Info(std::is_const<T>::value,
141 +
                         std::is_reference<T>::value,
142 +
                         std::is_pointer<T>::value,
143 +
                         std::is_void<T>::value,
144 +
                         std::is_arithmetic<T>::value
145 +
                             && !std::is_same<typename std::remove_const<typename std::remove_reference<T>::type>::type, bool>::value,
146 +
                         &typeid(const std::shared_ptr<T> &),
147 +
                         &typeid(typename Bare_Type<T>::type));
148 +
      }
149 +
    };
180 150
181 151
    template<typename T>
182 -
      struct Get_Type_Info<std::reference_wrapper<T> >
183 -
      {
184 -
        constexpr static Type_Info get() noexcept
185 -
        {
186 -
          return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value, 
187 -
              std::is_void<T>::value,
188 -
              std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<typename std::remove_reference<T>::type>::type, bool>::value,
189 -
              &typeid(std::reference_wrapper<T> ), 
190 -
              &typeid(typename Bare_Type<T>::type));
191 -
        }
192 -
      };
152 +
    struct Get_Type_Info<std::reference_wrapper<T>> {
153 +
      constexpr static Type_Info get() noexcept {
154 +
        return Type_Info(std::is_const<T>::value,
155 +
                         std::is_reference<T>::value,
156 +
                         std::is_pointer<T>::value,
157 +
                         std::is_void<T>::value,
158 +
                         std::is_arithmetic<T>::value
159 +
                             && !std::is_same<typename std::remove_const<typename std::remove_reference<T>::type>::type, bool>::value,
160 +
                         &typeid(std::reference_wrapper<T>),
161 +
                         &typeid(typename Bare_Type<T>::type));
162 +
      }
163 +
    };
193 164
194 165
    template<typename T>
195 -
      struct Get_Type_Info<const std::reference_wrapper<T> &>
196 -
      {
197 -
        constexpr static Type_Info get() noexcept
198 -
        {
199 -
          return Type_Info(std::is_const<T>::value, std::is_reference<T>::value, std::is_pointer<T>::value, 
200 -
              std::is_void<T>::value,
201 -
              std::is_arithmetic<T>::value && !std::is_same<typename std::remove_const<typename std::remove_reference<T>::type>::type, bool>::value,
202 -
              &typeid(const std::reference_wrapper<T> &), 
203 -
              &typeid(typename Bare_Type<T>::type));
204 -
        }
205 -
      };
166 +
    struct Get_Type_Info<const std::reference_wrapper<T> &> {
167 +
      constexpr static Type_Info get() noexcept {
168 +
        return Type_Info(std::is_const<T>::value,
169 +
                         std::is_reference<T>::value,
170 +
                         std::is_pointer<T>::value,
171 +
                         std::is_void<T>::value,
172 +
                         std::is_arithmetic<T>::value
173 +
                             && !std::is_same<typename std::remove_const<typename std::remove_reference<T>::type>::type, bool>::value,
174 +
                         &typeid(const std::reference_wrapper<T> &),
175 +
                         &typeid(typename Bare_Type<T>::type));
176 +
      }
177 +
    };
206 178
207 -
  }
179 +
  } // namespace detail
208 180
209 181
  /// \brief Creates a Type_Info object representing the type passed in
210 182
  /// \tparam T Type of object to get a Type_Info for, derived from the passed in parameter
211 183
  /// \return Type_Info for T
212 -
  /// 
184 +
  ///
213 185
  /// \b Example:
214 186
  /// \code
215 187
  /// int i;
216 188
  /// chaiscript::Type_Info ti = chaiscript::user_type(i);
217 189
  /// \endcode
218 190
  template<typename T>
219 -
  constexpr Type_Info user_type(const T &/*t*/) noexcept
220 -
  {
191 +
  constexpr Type_Info user_type(const T & /*t*/) noexcept {
221 192
    return detail::Get_Type_Info<T>::get();
222 193
  }
223 194
224 -
225 195
  /// \brief Creates a Type_Info object representing the templated type
226 196
  /// \tparam T Type of object to get a Type_Info for
227 197
  /// \return Type_Info for T
228 -
  /// 
198 +
  ///
229 199
  /// \b Example:
230 200
  /// \code
231 201
  /// chaiscript::Type_Info ti = chaiscript::user_type<int>();
232 202
  /// \endcode
233 203
  template<typename T>
234 -
  constexpr Type_Info user_type() noexcept
235 -
  {
204 +
  constexpr Type_Info user_type() noexcept {
236 205
    return detail::Get_Type_Info<T>::get();
237 206
  }
238 207
239 -
}
208 +
} // namespace chaiscript
240 209
241 210
#endif
242 -

@@ -1,8 +1,6 @@
Loading
1 1
#include "../include/chaiscript/chaiscript_stdlib.hpp"
2 2
#include "chaiscript_stdlib.hpp"
3 3
4 -
std::shared_ptr<chaiscript::Module> create_chaiscript_stdlib()
5 -
{
4 +
std::shared_ptr<chaiscript::Module> create_chaiscript_stdlib() {
6 5
  return chaiscript::Std_Lib::library();
7 6
}
8 -

@@ -3,138 +3,121 @@
Loading
3 3
#include <chaiscript/dispatchkit/bootstrap.hpp>
4 4
#include <string>
5 5
6 +
class TestBaseType {
7 +
public:
8 +
  TestBaseType()
9 +
      : val(10)
10 +
      , const_val(15)
11 +
      , mdarray{} {
12 +
  }
13 +
  TestBaseType(int)
14 +
      : val(10)
15 +
      , const_val(15)
16 +
      , mdarray{} {
17 +
  }
18 +
  TestBaseType(int *)
19 +
      : val(10)
20 +
      , const_val(15)
21 +
      , mdarray{} {
22 +
  }
23 +
24 +
  TestBaseType(const TestBaseType &other)
25 +
      : val(other.val)
26 +
      , const_val(other.const_val)
27 +
      , const_val_ptr(&const_val)
28 +
      , func_member(other.func_member) {
29 +
  }
30 +
31 +
  TestBaseType(TestBaseType &&other)
32 +
      : val(other.val)
33 +
      , const_val(other.const_val)
34 +
      , const_val_ptr(&const_val)
35 +
      , func_member(std::move(other.func_member)) {
36 +
  }
37 +
38 +
  TestBaseType &operator=(TestBaseType &&) = delete;
39 +
  TestBaseType &operator=(const TestBaseType &) = delete;
40 +
41 +
  virtual ~TestBaseType() = default;
42 +
  virtual int func() { return 0; }
43 +
44 +
  int base_only_func() { return -9; }
45 +
46 +
  const TestBaseType &constMe() const { return *this; }
47 +
48 +
  int val;
49 +
  const int const_val;
50 +
  const int *const_val_ptr = &const_val;
51 +
52 +
  const int *get_const_val_ptr() { return const_val_ptr; }
53 +
54 +
  int mdarray[2][3][5];
55 +
  std::function<int(int)> func_member;
56 +
57 +
  void set_string_val(std::string &t_str) { t_str = "42"; }
58 +
};
6 59
60 +
class Type2 {
61 +
public:
62 +
  Type2(TestBaseType t_bt)
63 +
      : m_bt(std::move(t_bt))
64 +
      , m_str("Hello World") {
65 +
  }
7 66
8 -
class TestBaseType
9 -
{
10 -
  public:
11 -
    TestBaseType() : val(10), const_val(15), mdarray{} { }
12 -
    TestBaseType(int) : val(10), const_val(15), mdarray{} { }
13 -
    TestBaseType(int *) : val(10), const_val(15), mdarray{} { }
14 -
15 -
    TestBaseType(const TestBaseType &other)
16 -
      : val(other.val), const_val(other.const_val), const_val_ptr(&const_val),
17 -
        func_member(other.func_member)
18 -
    {
19 -
    }
20 -
21 -
    TestBaseType(TestBaseType &&other)
22 -
      : val(other.val), const_val(other.const_val), const_val_ptr(&const_val),
23 -
        func_member(std::move(other.func_member))
24 -
    {
25 -
    }
26 -
27 -
28 -
    TestBaseType &operator=(TestBaseType &&) = delete;
29 -
    TestBaseType &operator=(const TestBaseType &) = delete;
30 -
31 -
    virtual ~TestBaseType() = default;
32 -
    virtual int func() { return 0; }
33 -
34 -
    int base_only_func() { return -9; }
35 -
36 -
    const TestBaseType &constMe() const { return *this; }
37 -
38 -
    int val;
39 -
    const int const_val;
40 -
    const int *const_val_ptr = &const_val;
41 -
42 -
    const int *get_const_val_ptr() {
43 -
      return const_val_ptr;
44 -
    }
45 -
46 -
    int mdarray[2][3][5];
47 -
    std::function<int (int)> func_member;
48 -
49 -
    void set_string_val(std::string &t_str)
50 -
    {
51 -
      t_str = "42";
52 -
    }
67 +
  int get_val() const { return m_bt.val; }
53 68
54 -
};
69 +
  const char *get_str() const { return m_str.c_str(); }
55 70
56 -
class Type2
57 -
{
58 -
  public:
59 -
    Type2(TestBaseType t_bt)
60 -
      : m_bt(std::move(t_bt)),
61 -
        m_str("Hello World")
62 -
    {
63 -
    }
64 -
65 -
    int get_val() const
66 -
    {
67 -
      return m_bt.val;
68 -
    }
69 -
70 -
71 -
    const char *get_str() const
72 -
    {
73 -
      return m_str.c_str();
74 -
    }
75 -
76 -
  private:
77 -
    TestBaseType m_bt;
78 -
    std::string m_str;
71 +
private:
72 +
  TestBaseType m_bt;
73 +
  std::string m_str;
79 74
};
80 75
81 -
enum TestEnum
82 -
{
76 +
enum TestEnum {
83 77
  TestValue1 = 1
84 78
};
85 79
86 -
int to_int(TestEnum t)
87 -
{
80 +
int to_int(TestEnum t) {
88 81
  return t;
89 82
}
90 83
91 -
class TestDerivedType : public TestBaseType
92 -
{
93 -
  public:
94 -
    int func() override { return 1; }
95 -
    int derived_only_func() { return 19; }
96 -
84 +
class TestDerivedType : public TestBaseType {
85 +
public:
86 +
  int func() override { return 1; }
87 +
  int derived_only_func() { return 19; }
97 88
};
98 89
99 -
class TestMoreDerivedType : public TestDerivedType
100 -
{
101 -
  public:
90 +
class TestMoreDerivedType : public TestDerivedType {
91 +
public:
102 92
};
103 93
104 -
std::shared_ptr<TestBaseType> derived_type_factory()
105 -
{
94 +
std::shared_ptr<TestBaseType> derived_type_factory() {
106 95
  return std::make_shared<TestDerivedType>();
107 96
}
108 97
109 -
std::shared_ptr<TestBaseType> more_derived_type_factory()
110 -
{
98 +
std::shared_ptr<TestBaseType> more_derived_type_factory() {
111 99
  return std::make_shared<TestMoreDerivedType>();
112 100
}
113 101
114 -
std::shared_ptr<TestBaseType> null_factory()
115 -
{
102 +
std::shared_ptr<TestBaseType> null_factory() {
116 103
  return std::shared_ptr<TestBaseType>();
117 104
}
118 105
119 -
void update_shared_ptr(std::shared_ptr<TestBaseType> &ptr)
120 -
{
106 +
void update_shared_ptr(std::shared_ptr<TestBaseType> &ptr) {
121 107
  ptr = std::make_shared<TestDerivedType>();
122 108
}
123 109
124 -
void nullify_shared_ptr(std::shared_ptr<TestBaseType> &ptr)
125 -
{
110 +
void nullify_shared_ptr(std::shared_ptr<TestBaseType> &ptr) {
126 111
  ptr = nullptr;
127 112
}
128 113
129 -
std::string hello_world()
130 -
{
114 +
std::string hello_world() {
131 115
  return "Hello World";
132 116
}
133 117
134 118
static int global_i = 1;
135 119
136 -
int *get_new_int()
137 -
{
120 +
int *get_new_int() {
138 121
  return &global_i;
139 122
}
140 123
@@ -150,8 +133,7 @@
Loading
150 133
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
151 134
#endif
152 135
153 -
CHAISCRIPT_MODULE_EXPORT  chaiscript::ModulePtr create_chaiscript_module_test_module()
154 -
{
136 +
CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test_module() {
155 137
  chaiscript::ModulePtr m(new chaiscript::Module());
156 138
157 139
  m->add(chaiscript::fun(hello_world), "hello_world");
@@ -161,16 +143,16 @@
Loading
161 143
  m->add(chaiscript::user_type<TestMoreDerivedType>(), "TestMoreDerivedType");
162 144
  m->add(chaiscript::user_type<Type2>(), "Type2");
163 145
164 -
  m->add(chaiscript::constructor<TestBaseType ()>(), "TestBaseType");
165 -
//  m->add(chaiscript::constructor<TestBaseType (int)>(), "TestBaseType");
166 -
  m->add(chaiscript::constructor<TestBaseType (const TestBaseType &)>(), "TestBaseType");
167 -
  m->add(chaiscript::constructor<TestBaseType (int *)>(), "TestBaseType");
146 +
  m->add(chaiscript::constructor<TestBaseType()>(), "TestBaseType");
147 +
  //  m->add(chaiscript::constructor<TestBaseType (int)>(), "TestBaseType");
148 +
  m->add(chaiscript::constructor<TestBaseType(const TestBaseType &)>(), "TestBaseType");
149 +
  m->add(chaiscript::constructor<TestBaseType(int *)>(), "TestBaseType");
168 150
169 -
  m->add(chaiscript::constructor<TestDerivedType ()>(), "TestDerivedType");
170 -
  m->add(chaiscript::constructor<TestDerivedType (const TestDerivedType &)>(), "TestDerivedType");
151 +
  m->add(chaiscript::constructor<TestDerivedType()>(), "TestDerivedType");
152 +
  m->add(chaiscript::constructor<TestDerivedType(const TestDerivedType &)>(), "TestDerivedType");
171 153
172 -
  m->add(chaiscript::constructor<TestMoreDerivedType ()>(), "TestMoreDerivedType");
173 -
  m->add(chaiscript::constructor<TestMoreDerivedType (const TestMoreDerivedType &)>(), "TestMoreDerivedType");
154 +
  m->add(chaiscript::constructor<TestMoreDerivedType()>(), "TestMoreDerivedType");
155 +
  m->add(chaiscript::constructor<TestMoreDerivedType(const TestMoreDerivedType &)>(), "TestMoreDerivedType");
174 156
175 157
  /// \todo automatic chaining of base classes?
176 158
  m->add(chaiscript::base_class<TestBaseType, TestDerivedType>());
@@ -202,7 +184,6 @@
Loading
202 184
  m->add(chaiscript::fun(&TestBaseType::func_member), "func_member");
203 185
  m->add(chaiscript::fun(&get_new_int), "get_new_int");
204 186
205 -
206 187
  m->add_global_const(chaiscript::const_var(TestValue1), "TestValue1");
207 188
208 189
  m->add(chaiscript::user_type<TestEnum>(), "TestEnum");
@@ -215,16 +196,14 @@
Loading
215 196
  m->add(chaiscript::fun(&Type2::get_val), "get_val");
216 197
  m->add(chaiscript::fun(&Type2::get_str), "get_str");
217 198
  m->add(chaiscript::type_conversion<const char *, std::string>());
218 -
  m->add(chaiscript::constructor<Type2 (const TestBaseType &)>(), "Type2");
199 +
  m->add(chaiscript::constructor<Type2(const TestBaseType &)>(), "Type2");
219 200
220 201
  m->add(chaiscript::fun(&update_shared_ptr), "update_shared_ptr");
221 202
  m->add(chaiscript::fun(&nullify_shared_ptr), "nullify_shared_ptr");
222 203
223 -
224 204
  return m;
225 205
}
226 206
227 -
228 207
#ifdef __llvm__
229 208
#pragma clang diagnostic pop
230 209
#endif

@@ -7,63 +7,55 @@
Loading
7 7
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
8 8
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
9 9
10 -
11 10
#ifndef CHAISCRIPT_REGISTER_FUNCTION_HPP_
12 11
#define CHAISCRIPT_REGISTER_FUNCTION_HPP_
13 12
14 13
#include <type_traits>
15 14
16 15
#include "bind_first.hpp"
17 -
#include "proxy_functions.hpp"
18 16
#include "function_signature.hpp"
17 +
#include "proxy_functions.hpp"
19 18
20 -
namespace chaiscript
21 -
{
22 -
  namespace dispatch::detail
23 -
  {
24 -
    template<typename Obj, typename Param1, typename ... Rest>
25 -
      Param1 get_first_param(Function_Params<Param1, Rest...>, Obj &&obj)
26 -
      {
27 -
        return static_cast<Param1>(std::forward<Obj>(obj));
28 -
      }
19 +
namespace chaiscript {
20 +
  namespace dispatch::detail {
21 +
    template<typename Obj, typename Param1, typename... Rest>
22 +
    Param1 get_first_param(Function_Params<Param1, Rest...>, Obj &&obj) {
23 +
      return static_cast<Param1>(std::forward<Obj>(obj));
24 +
    }
29 25
30 -
    template<typename Func, bool Is_Noexcept, bool Is_Member, bool Is_MemberObject, bool Is_Object, typename Ret, typename ... Param>
31 -
      auto make_callable_impl(Func &&func, Function_Signature<Ret, Function_Params<Param...>, Is_Noexcept, Is_Member, Is_MemberObject, Is_Object>)
32 -
      {
33 -
        if constexpr (Is_MemberObject) {
34 -
          // we now that the Param pack will have only one element, so we are safe expanding it here
35 -
          return Proxy_Function(chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Attribute_Access<Ret, std::decay_t<Param>...>>(std::forward<Func>(func)));
36 -
        } else if constexpr (Is_Member) {
37 -
		  // TODO some kind of bug is preventing forwarding of this noexcept for the lambda
38 -
          auto call = [func = std::forward<Func>(func)](auto && obj, auto && ... param) /* noexcept(Is_Noexcept) */ -> decltype(auto) {
39 -
            return (( get_first_param(Function_Params<Param...>{}, obj).*func )(std::forward<decltype(param)>(param)...));
40 -
          };
41 -
          return Proxy_Function(
42 -
              chaiscript::make_shared<dispatch::Proxy_Function_Base, 
43 -
              dispatch::Proxy_Function_Callable_Impl<Ret (Param...), decltype(call)>>(std::move(call))
44 -
              );
45 -
        } else {
46 -
          return Proxy_Function(
47 -
              chaiscript::make_shared<dispatch::Proxy_Function_Base, 
48 -
              dispatch::Proxy_Function_Callable_Impl<Ret (Param...), std::decay_t<Func>>>(std::forward<Func>(func))
49 -
              );
50 -
        }
26 +
    template<typename Func, bool Is_Noexcept, bool Is_Member, bool Is_MemberObject, bool Is_Object, typename Ret, typename... Param>
27 +
    auto make_callable_impl(Func &&func, Function_Signature<Ret, Function_Params<Param...>, Is_Noexcept, Is_Member, Is_MemberObject, Is_Object>) {
28 +
      if constexpr (Is_MemberObject) {
29 +
        // we now that the Param pack will have only one element, so we are safe expanding it here
30 +
        return Proxy_Function(chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Attribute_Access<Ret, std::decay_t<Param>...>>(
31 +
            std::forward<Func>(func)));
32 +
      } else if constexpr (Is_Member) {
33 +
        // TODO some kind of bug is preventing forwarding of this noexcept for the lambda
34 +
        auto call = [func = std::forward<Func>(func)](auto &&obj, auto &&...param) /* noexcept(Is_Noexcept) */ -> decltype(auto) {
35 +
          return ((get_first_param(Function_Params<Param...>{}, obj).*func)(std::forward<decltype(param)>(param)...));
36 +
        };
37 +
        return Proxy_Function(
38 +
            chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Proxy_Function_Callable_Impl<Ret(Param...), decltype(call)>>(
39 +
                std::move(call)));
40 +
      } else {
41 +
        return Proxy_Function(
42 +
            chaiscript::make_shared<dispatch::Proxy_Function_Base, dispatch::Proxy_Function_Callable_Impl<Ret(Param...), std::decay_t<Func>>>(
43 +
                std::forward<Func>(func)));
51 44
      }
45 +
    }
52 46
53 47
    // this version peels off the function object itself from the function signature, when used
54 48
    // on a callable object
55 -
    template<typename Func, typename Ret, typename Object, typename ... Param, bool Is_Noexcept>
56 -
      auto make_callable(Func &&func, Function_Signature<Ret, Function_Params<Object, Param...>, Is_Noexcept, false, false, true>)
57 -
      {
58 -
        return make_callable_impl(std::forward<Func>(func), Function_Signature<Ret, Function_Params<Param...>, Is_Noexcept, false, false, true>{});
59 -
      } 
49 +
    template<typename Func, typename Ret, typename Object, typename... Param, bool Is_Noexcept>
50 +
    auto make_callable(Func &&func, Function_Signature<Ret, Function_Params<Object, Param...>, Is_Noexcept, false, false, true>) {
51 +
      return make_callable_impl(std::forward<Func>(func), Function_Signature<Ret, Function_Params<Param...>, Is_Noexcept, false, false, true>{});
52 +
    }
60 53
61 -
    template<typename Func, typename Ret, typename ... Param, bool Is_Noexcept, bool Is_Member, bool Is_MemberObject>
62 -
      auto make_callable(Func &&func, Function_Signature<Ret, Function_Params<Param...>, Is_Noexcept, Is_Member, Is_MemberObject, false> fs)
63 -
      {
64 -
        return make_callable_impl(std::forward<Func>(func), fs);
65 -
      }
66 -
  }
54 +
    template<typename Func, typename Ret, typename... Param, bool Is_Noexcept, bool Is_Member, bool Is_MemberObject>
55 +
    auto make_callable(Func &&func, Function_Signature<Ret, Function_Params<Param...>, Is_Noexcept, Is_Member, Is_MemberObject, false> fs) {
56 +
      return make_callable_impl(std::forward<Func>(func), fs);
57 +
    }
58 +
  } // namespace dispatch::detail
67 59
68 60
  /// \brief Creates a new Proxy_Function object from a free function, member function or data member
69 61
  /// \param[in] t Function / member to expose
@@ -77,22 +69,19 @@
Loading
77 69
  ///     void memberfunction();
78 70
  ///     int memberdata;
79 71
  /// };
80 -
  /// 
72 +
  ///
81 73
  /// chaiscript::ChaiScript chai;
82 74
  /// chai.add(fun(&myfunction), "myfunction");
83 75
  /// chai.add(fun(&MyClass::memberfunction), "memberfunction");
84 76
  /// chai.add(fun(&MyClass::memberdata), "memberdata");
85 77
  /// \endcode
86 -
  /// 
78 +
  ///
87 79
  /// \sa \ref adding_functions
88 80
  template<typename T>
89 -
    Proxy_Function fun(T &&t)
90 -
    {
91 -
      return dispatch::detail::make_callable(std::forward<T>(t), dispatch::detail::function_signature(t));
92 -
    }
93 -
81 +
  Proxy_Function fun(T &&t) {
82 +
    return dispatch::detail::make_callable(std::forward<T>(t), dispatch::detail::function_signature(t));
83 +
  }
94 84
95 -
  
96 85
  /// \brief Creates a new Proxy_Function object from a free function, member function or data member and binds the first parameter of it
97 86
  /// \param[in] t Function / member to expose
98 87
  /// \param[in] q Value to bind to first parameter
@@ -103,24 +92,19 @@
Loading
103 92
  /// {
104 93
  ///   void memberfunction(int);
105 94
  /// };
106 -
  /// 
95 +
  ///
107 96
  /// MyClass obj;
108 97
  /// chaiscript::ChaiScript chai;
109 98
  /// // Add function taking only one argument, an int, and permanently bound to "obj"
110 -
  /// chai.add(fun(&MyClass::memberfunction, std::ref(obj)), "memberfunction"); 
99 +
  /// chai.add(fun(&MyClass::memberfunction, std::ref(obj)), "memberfunction");
111 100
  /// \endcode
112 -
  /// 
101 +
  ///
113 102
  /// \sa \ref adding_functions
114 103
  template<typename T, typename Q>
115 -
    Proxy_Function fun(T &&t, const Q &q)
116 -
    {
117 -
      return fun(detail::bind_first(std::forward<T>(t), q));
118 -
    }
119 -
120 -
121 -
122 -
}
104 +
  Proxy_Function fun(T &&t, const Q &q) {
105 +
    return fun(detail::bind_first(std::forward<T>(t), q));
106 +
  }
123 107
108 +
} // namespace chaiscript
124 109
125 110
#endif
126 -

@@ -19,219 +19,185 @@
Loading
19 19
#include "boxed_cast.hpp"
20 20
#include "boxed_cast_helper.hpp"
21 21
#include "boxed_value.hpp"
22 +
#include "dynamic_object.hpp"
22 23
#include "proxy_functions.hpp"
23 24
#include "type_info.hpp"
24 -
#include "dynamic_object.hpp"
25 25
26 26
namespace chaiscript {
27 -
class Type_Conversions;
28 -
namespace dispatch {
29 -
class Proxy_Function_Base;
30 -
}  // namespace dispatch
31 -
}  // namespace chaiscript
32 -
33 -
namespace chaiscript
34 -
{
35 -
  namespace dispatch
36 -
  {
37 -
    namespace detail
38 -
    {
27 +
  class Type_Conversions;
28 +
  namespace dispatch {
29 +
    class Proxy_Function_Base;
30 +
  } // namespace dispatch
31 +
} // namespace chaiscript
32 +
33 +
namespace chaiscript {
34 +
  namespace dispatch {
35 +
    namespace detail {
39 36
      /// A Proxy_Function implementation designed for calling a function
40 37
      /// that is automatically guarded based on the first param based on the
41 38
      /// param's type name
42 -
      class Dynamic_Object_Function final : public Proxy_Function_Base
43 -
      {
44 -
        public:
45 -
          Dynamic_Object_Function(
46 -
              std::string t_type_name,
47 -
              const Proxy_Function &t_func,
48 -
              bool t_is_attribute = false)
49 -
            : Proxy_Function_Base(t_func->get_param_types(), t_func->get_arity()),
50 -
              m_type_name(std::move(t_type_name)), m_func(t_func), m_doti(user_type<Dynamic_Object>()),
51 -
              m_is_attribute(t_is_attribute)
52 -
          {
53 -
            assert( (t_func->get_arity() > 0 || t_func->get_arity() < 0)
54 -
                && "Programming error, Dynamic_Object_Function must have at least one parameter (this)");
55 -
          }
56 -
57 -
          Dynamic_Object_Function(
58 -
              std::string t_type_name,
59 -
              const Proxy_Function &t_func,
60 -
              const Type_Info &t_ti,
61 -
              bool t_is_attribute = false)
62 -
            : Proxy_Function_Base(build_param_types(t_func->get_param_types(), t_ti), t_func->get_arity()),
63 -
              m_type_name(std::move(t_type_name)), m_func(t_func), m_ti(t_ti.is_undef()?nullptr:new Type_Info(t_ti)), m_doti(user_type<Dynamic_Object>()),
64 -
              m_is_attribute(t_is_attribute)
65 -
          {
66 -
            assert( (t_func->get_arity() > 0 || t_func->get_arity() < 0)
67 -
                && "Programming error, Dynamic_Object_Function must have at least one parameter (this)");
68 -
          }
69 -
70 -
71 -
          Dynamic_Object_Function &operator=(const Dynamic_Object_Function) = delete;
72 -
          Dynamic_Object_Function(Dynamic_Object_Function &) = delete;
73 -
74 -
          bool operator==(const Proxy_Function_Base &f) const noexcept override
75 -
          {
76 -
            if (const auto *df = dynamic_cast<const Dynamic_Object_Function *>(&f))
77 -
            {
78 -
              return df->m_type_name == m_type_name && (*df->m_func) == (*m_func);
79 -
            } else {
80 -
              return false;
81 -
            }
82 -
          }
83 -
84 -
          bool is_attribute_function() const noexcept override { return m_is_attribute; } 
85 -
86 -
          bool call_match(const chaiscript::Function_Params &vals, const Type_Conversions_State &t_conversions) const noexcept override
87 -
          {
88 -
            if (dynamic_object_typename_match(vals, m_type_name, m_ti, t_conversions))
89 -
            {
90 -
              return m_func->call_match(vals, t_conversions);
91 -
            } else {
92 -
              return false;
93 -
            }
94 -
          }
95 -
96 -
          std::vector<Const_Proxy_Function> get_contained_functions() const override
97 -
          {
98 -
            return {m_func};
39 +
      class Dynamic_Object_Function final : public Proxy_Function_Base {
40 +
      public:
41 +
        Dynamic_Object_Function(std::string t_type_name, const Proxy_Function &t_func, bool t_is_attribute = false)
42 +
            : Proxy_Function_Base(t_func->get_param_types(), t_func->get_arity())
43 +
            , m_type_name(std::move(t_type_name))
44 +
            , m_func(t_func)
45 +
            , m_doti(user_type<Dynamic_Object>())
46 +
            , m_is_attribute(t_is_attribute) {
47 +
          assert((t_func->get_arity() > 0 || t_func->get_arity() < 0)
48 +
                 && "Programming error, Dynamic_Object_Function must have at least one parameter (this)");
49 +
        }
50 +
51 +
        Dynamic_Object_Function(std::string t_type_name, const Proxy_Function &t_func, const Type_Info &t_ti, bool t_is_attribute = false)
52 +
            : Proxy_Function_Base(build_param_types(t_func->get_param_types(), t_ti), t_func->get_arity())
53 +
            , m_type_name(std::move(t_type_name))
54 +
            , m_func(t_func)
55 +
            , m_ti(t_ti.is_undef() ? nullptr : new Type_Info(t_ti))
56 +
            , m_doti(user_type<Dynamic_Object>())
57 +
            , m_is_attribute(t_is_attribute) {
58 +
          assert((t_func->get_arity() > 0 || t_func->get_arity() < 0)
59 +
                 && "Programming error, Dynamic_Object_Function must have at least one parameter (this)");
60 +
        }
61 +
62 +
        Dynamic_Object_Function &operator=(const Dynamic_Object_Function) = delete;
63 +
        Dynamic_Object_Function(Dynamic_Object_Function &) = delete;
64 +
65 +
        bool operator==(const Proxy_Function_Base &f) const noexcept override {
66 +
          if (const auto *df = dynamic_cast<const Dynamic_Object_Function *>(&f)) {
67 +
            return df->m_type_name == m_type_name && (*df->m_func) == (*m_func);
68 +
          } else {
69 +
            return false;
99 70
          }
71 +
        }
100 72
101 -
        protected:
102 -
          Boxed_Value do_call(const chaiscript::Function_Params &params, const Type_Conversions_State &t_conversions) const override
103 -
          {
104 -
            if (dynamic_object_typename_match(params, m_type_name, m_ti, t_conversions))
105 -
            {
106 -
              return (*m_func)(params, t_conversions);
107 -
            } else {
108 -
              throw exception::guard_error();
109 -
            } 
110 -
          }
73 +
        bool is_attribute_function() const noexcept override { return m_is_attribute; }
111 74
112 -
          bool compare_first_type(const Boxed_Value &bv, const Type_Conversions_State &t_conversions) const noexcept override
113 -
          {
114 -
            return dynamic_object_typename_match(bv, m_type_name, m_ti, t_conversions);
75 +
        bool call_match(const chaiscript::Function_Params &vals, const Type_Conversions_State &t_conversions) const noexcept override {
76 +
          if (dynamic_object_typename_match(vals, m_type_name, m_ti, t_conversions)) {
77 +
            return m_func->call_match(vals, t_conversions);
78 +
          } else {
79 +
            return false;
115 80
          }
81 +
        }
116 82
117 -
        private:
118 -
          static std::vector<Type_Info> build_param_types(
119 -
              const std::vector<Type_Info> &t_inner_types, const Type_Info& t_objectti)
120 -
          {
121 -
            std::vector<Type_Info> types(t_inner_types);
83 +
        std::vector<Const_Proxy_Function> get_contained_functions() const override { return {m_func}; }
122 84
123 -
            assert(types.size() > 1);
124 -
            //assert(types[1].bare_equal(user_type<Boxed_Value>()));
125 -
            types[1] = t_objectti;
126 -
            return types;
85 +
      protected:
86 +
        Boxed_Value do_call(const chaiscript::Function_Params &params, const Type_Conversions_State &t_conversions) const override {
87 +
          if (dynamic_object_typename_match(params, m_type_name, m_ti, t_conversions)) {
88 +
            return (*m_func)(params, t_conversions);
89 +
          } else {
90 +
            throw exception::guard_error();
127 91
          }
128 -
129 -
          bool dynamic_object_typename_match(const Boxed_Value &bv, const std::string &name,
130 -
              const std::unique_ptr<Type_Info> &ti, const Type_Conversions_State &t_conversions) const noexcept
131 -
          {
132 -
            if (bv.get_type_info().bare_equal(m_doti))
133 -
            {
134 -
              try {
135 -
                const Dynamic_Object &d = boxed_cast<const Dynamic_Object &>(bv, &t_conversions);
136 -
                return name == "Dynamic_Object" || d.get_type_name() == name;
137 -
              } catch (const std::bad_cast &) {
138 -
                return false;
139 -
              } 
140 -
            } else {
141 -
              if (ti)
142 -
              {
143 -
                return bv.get_type_info().bare_equal(*ti);
144 -
              } else {
145 -
                return false;
146 -
              }
92 +
        }
93 +
94 +
        bool compare_first_type(const Boxed_Value &bv, const Type_Conversions_State &t_conversions) const noexcept override {
95 +
          return dynamic_object_typename_match(bv, m_type_name, m_ti, t_conversions);
96 +
        }
97 +
98 +
      private:
99 +
        static std::vector<Type_Info> build_param_types(const std::vector<Type_Info> &t_inner_types, const Type_Info &t_objectti) {
100 +
          std::vector<Type_Info> types(t_inner_types);
101 +
102 +
          assert(types.size() > 1);
103 +
          // assert(types[1].bare_equal(user_type<Boxed_Value>()));
104 +
          types[1] = t_objectti;
105 +
          return types;
106 +
        }
107 +
108 +
        bool dynamic_object_typename_match(const Boxed_Value &bv,
109 +
                                           const std::string &name,
110 +
                                           const std::unique_ptr<Type_Info> &ti,
111 +
                                           const Type_Conversions_State &t_conversions) const noexcept {
112 +
          if (bv.get_type_info().bare_equal(m_doti)) {
113 +
            try {
114 +
              const Dynamic_Object &d = boxed_cast<const Dynamic_Object &>(bv, &t_conversions);
115 +
              return name == "Dynamic_Object" || d.get_type_name() == name;
116 +
            } catch (const std::bad_cast &) {
117 +
              return false;
147 118
            }
148 -
149 -
          }
150 -
151 -
          bool dynamic_object_typename_match(const chaiscript::Function_Params &bvs, const std::string &name,
152 -
              const std::unique_ptr<Type_Info> &ti, const Type_Conversions_State &t_conversions) const noexcept
153 -
          {
154 -
            if (!bvs.empty())
155 -
            {
156 -
              return dynamic_object_typename_match(bvs[0], name, ti, t_conversions);
119 +
          } else {
120 +
            if (ti) {
121 +
              return bv.get_type_info().bare_equal(*ti);
157 122
            } else {
158 123
              return false;
159 124
            }
160 125
          }
126 +
        }
127 +
128 +
        bool dynamic_object_typename_match(const chaiscript::Function_Params &bvs,
129 +
                                           const std::string &name,
130 +
                                           const std::unique_ptr<Type_Info> &ti,
131 +
                                           const Type_Conversions_State &t_conversions) const noexcept {
132 +
          if (!bvs.empty()) {
133 +
            return dynamic_object_typename_match(bvs[0], name, ti, t_conversions);
134 +
          } else {
135 +
            return false;
136 +
          }
137 +
        }
161 138
162 -
          std::string m_type_name;
163 -
          Proxy_Function m_func;
164 -
          std::unique_ptr<Type_Info> m_ti;
165 -
          const Type_Info m_doti;
166 -
          const bool m_is_attribute;
139 +
        std::string m_type_name;
140 +
        Proxy_Function m_func;
141 +
        std::unique_ptr<Type_Info> m_ti;
142 +
        const Type_Info m_doti;
143 +
        const bool m_is_attribute;
167 144
      };
168 145
169 -
170 146
      /**
171 -
       * A Proxy_Function implementation designed for creating a new
172 -
       * Dynamic_Object
173 -
       * that is automatically guarded based on the first param based on the
174 -
       * param's type name
175 -
       */
176 -
      class Dynamic_Object_Constructor final : public Proxy_Function_Base
177 -
      {
178 -
        public:
179 -
          Dynamic_Object_Constructor(
180 -
              std::string t_type_name,
181 -
              const Proxy_Function &t_func)
182 -
            : Proxy_Function_Base(build_type_list(t_func->get_param_types()), t_func->get_arity() - 1),
183 -
              m_type_name(std::move(t_type_name)), m_func(t_func)
184 -
          {
185 -
            assert( (t_func->get_arity() > 0 || t_func->get_arity() < 0)
186 -
                && "Programming error, Dynamic_Object_Function must have at least one parameter (this)");
187 -
          }
188 -
189 -
          static std::vector<Type_Info> build_type_list(const std::vector<Type_Info> &tl)
190 -
          {
191 -
            auto begin = tl.begin();
192 -
            auto end = tl.end();
193 -
194 -
            if (begin != end)
195 -
            {
196 -
              ++begin;
197 -
            }
198 -
199 -
            return std::vector<Type_Info>(begin, end);
147 +
 * A Proxy_Function implementation designed for creating a new
148 +
 * Dynamic_Object
149 +
 * that is automatically guarded based on the first param based on the
150 +
 * param's type name
151 +
 */
152 +
      class Dynamic_Object_Constructor final : public Proxy_Function_Base {
153 +
      public:
154 +
        Dynamic_Object_Constructor(std::string t_type_name, const Proxy_Function &t_func)
155 +
            : Proxy_Function_Base(build_type_list(t_func->get_param_types()), t_func->get_arity() - 1)
156 +
            , m_type_name(std::move(t_type_name))
157 +
            , m_func(t_func) {
158 +
          assert((t_func->get_arity() > 0 || t_func->get_arity() < 0)
159 +
                 && "Programming error, Dynamic_Object_Function must have at least one parameter (this)");
160 +
        }
161 +
162 +
        static std::vector<Type_Info> build_type_list(const std::vector<Type_Info> &tl) {
163 +
          auto begin = tl.begin();
164 +
          auto end = tl.end();
165 +
166 +
          if (begin != end) {
167 +
            ++begin;
200 168
          }
201 169
202 -
          bool operator==(const Proxy_Function_Base &f) const noexcept override
203 -
          {
204 -
            const Dynamic_Object_Constructor *dc = dynamic_cast<const Dynamic_Object_Constructor*>(&f);
205 -
            return (dc != nullptr) && dc->m_type_name == m_type_name && (*dc->m_func) == (*m_func);
206 -
          }
170 +
          return std::vector<Type_Info>(begin, end);
171 +
        }
207 172
208 -
          bool call_match(const chaiscript::Function_Params &vals, const Type_Conversions_State &t_conversions) const override
209 -
          {
210 -
            std::vector<Boxed_Value> new_vals{Boxed_Value(Dynamic_Object(m_type_name))};
211 -
            new_vals.insert(new_vals.end(), vals.begin(), vals.end());
173 +
        bool operator==(const Proxy_Function_Base &f) const noexcept override {
174 +
          const Dynamic_Object_Constructor *dc = dynamic_cast<const Dynamic_Object_Constructor *>(&f);
175 +
          return (dc != nullptr) && dc->m_type_name == m_type_name && (*dc->m_func) == (*m_func);
176 +
        }
212 177
213 -
            return m_func->call_match(chaiscript::Function_Params{new_vals}, t_conversions);
214 -
          }
178 +
        bool call_match(const chaiscript::Function_Params &vals, const Type_Conversions_State &t_conversions) const override {
179 +
          std::vector<Boxed_Value> new_vals{Boxed_Value(Dynamic_Object(m_type_name))};
180 +
          new_vals.insert(new_vals.end(), vals.begin(), vals.end());
215 181
216 -
        protected:
217 -
          Boxed_Value do_call(const chaiscript::Function_Params &params, const Type_Conversions_State &t_conversions) const override
218 -
          {
219 -
            auto bv = Boxed_Value(Dynamic_Object(m_type_name), true);
220 -
            std::vector<Boxed_Value> new_params{bv};
221 -
            new_params.insert(new_params.end(), params.begin(), params.end());
182 +
          return m_func->call_match(chaiscript::Function_Params{new_vals}, t_conversions);
183 +
        }
222 184
223 -
            (*m_func)(chaiscript::Function_Params{new_params}, t_conversions);
185 +
      protected:
186 +
        Boxed_Value do_call(const chaiscript::Function_Params &params, const Type_Conversions_State &t_conversions) const override {
187 +
          auto bv = Boxed_Value(Dynamic_Object(m_type_name), true);
188 +
          std::vector<Boxed_Value> new_params{bv};
189 +
          new_params.insert(new_params.end(), params.begin(), params.end());
224 190
225 -
            return bv;
226 -
          }
191 +
          (*m_func)(chaiscript::Function_Params{new_params}, t_conversions);
227 192
228 -
        private:
229 -
          const std::string m_type_name;
230 -
          const Proxy_Function m_func;
193 +
          return bv;
194 +
        }
231 195
196 +
      private:
197 +
        const std::string m_type_name;
198 +
        const Proxy_Function m_func;
232 199
      };
233 -
    }
234 -
  }
235 -
}
200 +
    } // namespace detail
201 +
  } // namespace dispatch
202 +
} // namespace chaiscript
236 203
#endif
237 -

@@ -7,7 +7,6 @@
Loading
7 7
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
8 8
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
9 9
10 -
11 10
#include <iostream>
12 11
#include <list>
13 12
#include <regex>
@@ -16,48 +15,43 @@
Loading
16 15
#define _CRT_SECURE_NO_WARNINGS
17 16
#endif
18 17
19 -
#include <chaiscript/chaiscript_basic.hpp>
20 18
#include "../static_libs/chaiscript_parser.hpp"
21 19
#include "../static_libs/chaiscript_stdlib.hpp"
22 -
20 +
#include <chaiscript/chaiscript_basic.hpp>
23 21
24 22
#ifdef READLINE_AVAILABLE
25 -
#include <readline/readline.h>
26 23
#include <readline/history.h>
24 +
#include <readline/readline.h>
27 25
#else
28 26
29 -
char *mystrdup (const char *s) {
27 +
char *mystrdup(const char *s) {
30 28
  size_t len = strlen(s); // Space for length plus nul
31 -
  char *d = static_cast<char*>(malloc (len+1));
32 -
  if (d == nullptr) { return nullptr; }         // No memory
29 +
  char *d = static_cast<char *>(malloc(len + 1));
30 +
  if (d == nullptr) {
31 +
    return nullptr;
32 +
  } // No memory
33 33
#ifdef CHAISCRIPT_MSVC
34 -
  strcpy_s(d, len+1, s);                        // Copy the characters
34 +
  strcpy_s(d, len + 1, s); // Copy the characters
35 35
#else
36 -
  strncpy(d,s,len);                        // Copy the characters
36 +
  strncpy(d, s, len); // Copy the characters
37 37
#endif
38 38
  d[len] = '\0';
39 -
  return d;                            // Return the new string
39 +
  return d; // Return the new string
40 40
}
41 41
42 -
char* readline(const char* p)
43 -
{
42 +
char *readline(const char *p) {
44 43
  std::string retval;
45 -
  std::cout << p ;
44 +
  std::cout << p;
46 45
  std::getline(std::cin, retval);
47 46
  return std::cin.eof() ? nullptr : mystrdup(retval.c_str());
48 47
}
49 48
50 -
51 -
void add_history(const char* /*unused*/){}
52 -
void using_history(){}
49 +
void add_history(const char * /*unused*/) {}
50 +
void using_history() {}
53 51
#endif
54 52
55 -
56 -
57 -
void *cast_module_symbol(std::vector<std::string> (*t_path)())
58 -
{
59 -
  union cast_union
60 -
  {
53 +
void *cast_module_symbol(std::vector<std::string> (*t_path)()) {
54 +
  union cast_union {
61 55
    std::vector<std::string> (*in_ptr)();
62 56
    void *out_ptr;
63 57
  };
@@ -67,26 +61,23 @@
Loading
67 61
  return c.out_ptr;
68 62
}
69 63
70 -
std::vector<std::string> default_search_paths()
71 -
{
64 +
std::vector<std::string> default_search_paths() {
72 65
  std::vector<std::string> paths;
73 66
74 67
#ifndef CHAISCRIPT_NO_DYNLOAD
75 -
#ifdef CHAISCRIPT_WINDOWS  // force no unicode
68 +
#ifdef CHAISCRIPT_WINDOWS // force no unicode
76 69
  CHAR path[4096];
77 -
  int size = GetModuleFileNameA(nullptr, path, sizeof(path)-1);
70 +
  int size = GetModuleFileNameA(nullptr, path, sizeof(path) - 1);
78 71
79 72
  std::string exepath(path, size);
80 73
81 74
  size_t lastslash = exepath.rfind('\\');
82 75
  size_t secondtolastslash = exepath.rfind('\\', lastslash - 1);
83 -
  if (lastslash != std::string::npos)
84 -
  {
76 +
  if (lastslash != std::string::npos) {
85 77
    paths.push_back(exepath.substr(0, lastslash));
86 78
  }
87 79
88 -
  if (secondtolastslash != std::string::npos)
89 -
  {
80 +
  if (secondtolastslash != std::string::npos) {
90 81
    return {exepath.substr(0, secondtolastslash) + "\\lib\\chaiscript\\"};
91 82
  }
92 83
#else
@@ -96,32 +87,26 @@
Loading
96 87
  std::vector<char> buf(2048);
97 88
  ssize_t size = -1;
98 89
99 -
  if ((size = readlink("/proc/self/exe", &buf.front(), buf.size())) >= 0)
100 -
  {
90 +
  if ((size = readlink("/proc/self/exe", &buf.front(), buf.size())) >= 0) {
101 91
    exepath = std::string(&buf.front(), static_cast<size_t>(size));
102 92
  }
103 93
104 -
  if (exepath.empty())
105 -
  {
106 -
    if ((size = readlink("/proc/curproc/file", &buf.front(), buf.size())) >= 0)
107 -
    {
94 +
  if (exepath.empty()) {
95 +
    if ((size = readlink("/proc/curproc/file", &buf.front(), buf.size())) >= 0) {
108 96
      exepath = std::string(&buf.front(), static_cast<size_t>(size));
109 97
    }
110 98
  }
111 99
112 -
  if (exepath.empty())
113 -
  {
114 -
    if ((size = readlink("/proc/self/path/a.out", &buf.front(), buf.size())) >= 0)
115 -
    {
100 +
  if (exepath.empty()) {
101 +
    if ((size = readlink("/proc/self/path/a.out", &buf.front(), buf.size())) >= 0) {
116 102
      exepath = std::string(&buf.front(), static_cast<size_t>(size));
117 103
    }
118 104
  }
119 105
120 -
  if (exepath.empty())
121 -
  {
106 +
  if (exepath.empty()) {
122 107
    Dl_info rInfo;
123 -
    memset( &rInfo, 0, sizeof(rInfo) ); 
124 -
    if ( dladdr(cast_module_symbol(&default_search_paths), &rInfo) == 0 || rInfo.dli_fname == nullptr ) { 
108 +
    memset(&rInfo, 0, sizeof(rInfo));
109 +
    if (dladdr(cast_module_symbol(&default_search_paths), &rInfo) == 0 || rInfo.dli_fname == nullptr) {
125 110
      return paths;
126 111
    }
127 112
@@ -131,13 +116,11 @@
Loading
131 116
  size_t lastslash = exepath.rfind('/');
132 117
133 118
  size_t secondtolastslash = exepath.rfind('/', lastslash - 1);
134 -
  if (lastslash != std::string::npos)
135 -
  {
136 -
    paths.push_back(exepath.substr(0, lastslash+1));
119 +
  if (lastslash != std::string::npos) {
120 +
    paths.push_back(exepath.substr(0, lastslash + 1));
137 121
  }
138 122
139 -
  if (secondtolastslash != std::string::npos)
140 -
  {
123 +
  if (secondtolastslash != std::string::npos) {
141 124
    paths.push_back(exepath.substr(0, secondtolastslash) + "/lib/chaiscript/");
142 125
  }
143 126
#endif
@@ -147,25 +130,24 @@
Loading
147 130
}
148 131
149 132
void help(int n) {
150 -
  if ( n >= 0 ) {
133 +
  if (n >= 0) {
151 134
    std::cout << "ChaiScript evaluator.  To evaluate an expression, type it and press <enter>.\n";
152 135
    std::cout << "Additionally, you can inspect the runtime system using:\n";
153 136
    std::cout << "  dump_system() - outputs all functions registered to the system\n";
154 137
    std::cout << "  dump_object(x) - dumps information about the given symbol\n";
155 138
  } else {
156 139
    std::cout << "usage : chai [option]+\n";
157 -
    std::cout << "option:"                << '\n';
158 -
    std::cout << "   -h | --help"         << '\n';
159 -
    std::cout << "   -i | --interactive"  << '\n';
160 -
    std::cout << "   -c | --command cmd"  << '\n';
161 -
    std::cout << "   -v | --version"      << '\n';
162 -
    std::cout << "   -    --stdin"        << '\n';
163 -
    std::cout << "   filepath"            << '\n';
140 +
    std::cout << "option:" << '\n';
141 +
    std::cout << "   -h | --help" << '\n';
142 +
    std::cout << "   -i | --interactive" << '\n';
143 +
    std::cout << "   -c | --command cmd" << '\n';
144 +
    std::cout << "   -v | --version" << '\n';
145 +
    std::cout << "   -    --stdin" << '\n';
146 +
    std::cout << "   filepath" << '\n';
164 147
  }
165 148
}
166 149
167 -
std::string throws_exception(const std::function<void ()> &f)
168 -
{
150 +
std::string throws_exception(const std::function<void()> &f) {
169 151
  try {
170 152
    f();
171 153
  } catch (const std::exception &e) {
@@ -175,8 +157,7 @@
Loading
175 157
  return "";
176 158
}
177 159
178 -
chaiscript::exception::eval_error get_eval_error(const std::function<void ()> &f)
179 -
{
160 +
chaiscript::exception::eval_error get_eval_error(const std::function<void()> &f) {
180 161
  try {
181 162
    f();
182 163
  } catch (const chaiscript::exception::eval_error &e) {
@@ -188,21 +169,19 @@
Loading
188 169
189 170
std::string get_next_command() {
190 171
  std::string retval("quit");
191 -
  if ( ! std::cin.eof() ) {
172 +
  if (!std::cin.eof()) {
192 173
    char *input_raw = readline("eval> ");
193 -
    if ( input_raw != nullptr ) {
174 +
    if (input_raw != nullptr) {
194 175
      add_history(input_raw);
195 176
196 177
      std::string val(input_raw);
197 178
      size_t pos = val.find_first_not_of("\t \n");
198 -
      if (pos != std::string::npos)
199 -
      {
179 +
      if (pos != std::string::npos) {
200 180
        val.erase(0, pos);
201 181
      }
202 182
      pos = val.find_last_not_of("\t \n");
203 -
      if (pos != std::string::npos)
204 -
      {
205 -
        val.erase(pos+1, std::string::npos);
183 +
      if (pos != std::string::npos) {
184 +
        val.erase(pos + 1, std::string::npos);
206 185
      }
207 186
208 187
      retval = val;
@@ -210,11 +189,7 @@
Loading
210 189
      ::free(input_raw);
211 190
    }
212 191
  }
213 -
  if(   retval == "quit"
214 -
     || retval == "exit"
215 -
     || retval == "help"
216 -
     || retval == "version") 
217 -
  {
192 +
  if (retval == "quit" || retval == "exit" || retval == "help" || retval == "version") {
218 193
    retval += "(0)";
219 194
  }
220 195
  return retval;
@@ -226,8 +201,7 @@
Loading
226 201
  exit(return_val);
227 202
}
228 203
229 -
void interactive(chaiscript::ChaiScript_Basic& chai)
230 -
{
204 +
void interactive(chaiscript::ChaiScript_Basic &chai) {
231 205
  using_history();
232 206
233 207
  for (;;) {
@@ -236,39 +210,34 @@
Loading
236 210
      // evaluate input
237 211
      chaiscript::Boxed_Value val = chai.eval(input);
238 212
239 -
      //Then, we try to print the result of the evaluation to the user
213 +
      // Then, we try to print the result of the evaluation to the user
240 214
      if (!val.get_type_info().bare_equal(chaiscript::user_type<void>())) {
241 215
        try {
242 -
          std::cout << chai.eval<std::function<std::string (const chaiscript::Boxed_Value &bv)> >("to_string")(val) << '\n';
243 -
        }
244 -
        catch (...) {} //If we can't, do nothing
216 +
          std::cout << chai.eval<std::function<std::string(const chaiscript::Boxed_Value &bv)>>("to_string")(val) << '\n';
217 +
        } catch (...) {
218 +
        } // If we can't, do nothing
245 219
      }
246 -
    }
247 -
    catch (const chaiscript::exception::eval_error &ee) {
220 +
    } catch (const chaiscript::exception::eval_error &ee) {
248 221
      std::cout << ee.what();
249 -
      if ( !ee.call_stack.empty() ) {
222 +
      if (!ee.call_stack.empty()) {
250 223
        std::cout << "during evaluation at (" << ee.call_stack[0].start().line << ", " << ee.call_stack[0].start().column << ")";
251 224
      }
252 225
      std::cout << '\n';
253 -
    }
254 -
    catch (const std::exception &e) {
226 +
    } catch (const std::exception &e) {
255 227
      std::cout << e.what();
256 228
      std::cout << '\n';
257 229
    }
258 230
  }
259 231
}
260 232
261 -
double now()
262 -
{
233 +
double now() {
263 234
  using namespace std::chrono;
264 235
  auto now = high_resolution_clock::now();
265 236
  return duration_cast<duration<double>>(now.time_since_epoch()).count();
266 237
}
267 238
268 -
int main(int argc, char *argv[])
269 -
{
270 -
271 -
  // Disable deprecation warning for getenv call.
239 +
int main(int argc, char *argv[]) {
240 +
// Disable deprecation warning for getenv call.
272 241
#ifdef CHAISCRIPT_MSVC
273 242
#pragma warning(push)
274 243
#pragma warning(disable : 4996)
@@ -283,8 +252,7 @@
Loading
283 252
284 253
  std::vector<std::string> usepaths;
285 254
  usepaths.emplace_back("");
286 -
  if (usepath != nullptr)
287 -
  {
255 +
  if (usepath != nullptr) {
288 256
    usepaths.emplace_back(usepath);
289 257
  }
290 258
@@ -292,12 +260,11 @@
Loading
292 260
  std::vector<std::string> searchpaths = default_search_paths();
293 261
  modulepaths.insert(modulepaths.end(), searchpaths.begin(), searchpaths.end());
294 262
  modulepaths.emplace_back("");
295 -
  if (modulepath != nullptr)
296 -
  {
263 +
  if (modulepath != nullptr) {
297 264
    modulepaths.emplace_back(modulepath);
298 265
  }
299 266
300 -
  chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(),create_chaiscript_parser(),modulepaths,usepaths);
267 +
  chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(), create_chaiscript_parser(), modulepaths, usepaths);
301 268
302 269
  chai.add(chaiscript::fun(&myexit), "exit");
303 270
  chai.add(chaiscript::fun(&myexit), "quit");
@@ -311,46 +278,48 @@
Loading
311 278
  bool any_exception_ok = false;
312 279
313 280
  for (int i = 0; i < argc; ++i) {
314 -
    if ( i == 0 && argc > 1 ) {
281 +
    if (i == 0 && argc > 1) {
315 282
      ++i;
316 283
    }
317 284
318 -
    std::string arg( i != 0 ? argv[i] : "--interactive" );
285 +
    std::string arg(i != 0 ? argv[i] : "--interactive");
319 286
320 -
    enum { eInteractive
321 -
         , eCommand
322 -
         , eFile
323 -
    } mode = eCommand ;
287 +
    enum {
288 +
      eInteractive,
289 +
      eCommand,
290 +
      eFile
291 +
    } mode
292 +
        = eCommand;
324 293
325 -
    if  ( arg == "-c" || arg == "--command" ) {
326 -
      if ( (i+1) >= argc ) {
294 +
    if (arg == "-c" || arg == "--command") {
295 +
      if ((i + 1) >= argc) {
327 296
        std::cout << "insufficient input following " << arg << '\n';
328 297
        return EXIT_FAILURE;
329 -
      } 
330 -
        arg = argv[++i];
331 -
      
332 -
    } else if ( arg == "-" || arg == "--stdin" ) {
333 -
      arg = "" ;
298 +
      }
299 +
      arg = argv[++i];
300 +
301 +
    } else if (arg == "-" || arg == "--stdin") {
302 +
      arg = "";
334 303
      std::string line;
335 -
      while ( std::getline(std::cin, line) ) {
336 -
        arg += line + '\n' ;
304 +
      while (std::getline(std::cin, line)) {
305 +
        arg += line + '\n';
337 306
      }
338 -
    } else if ( arg == "-v" || arg == "--version" ) {
339 -
      arg = "print(version())" ;
340 -
    } else if ( arg == "-h" || arg == "--help" ) {
307 +
    } else if (arg == "-v" || arg == "--version") {
308 +
      arg = "print(version())";
309 +
    } else if (arg == "-h" || arg == "--help") {
341 310
      arg = "help(-1)";
342 -
    } else if ( arg == "-e" || arg == "--evalerrorok" ) {
311 +
    } else if (arg == "-e" || arg == "--evalerrorok") {
343 312
      eval_error_ok = true;
344 313
      continue;
345 -
    } else if ( arg == "--exception" ) {
314 +
    } else if (arg == "--exception") {
346 315
      boxed_exception_ok = true;
347 316
      continue;
348 -
    } else if ( arg == "--any-exception" ) {
317 +
    } else if (arg == "--any-exception") {
349 318
      any_exception_ok = true;
350 319
      continue;
351 -
    } else if ( arg == "-i" || arg == "--interactive" ) {
352 -
      mode = eInteractive ;
353 -
    } else if ( arg.find('-') == 0 ) {
320 +
    } else if (arg == "-i" || arg == "--interactive") {
321 +
      mode = eInteractive;
322 +
    } else if (arg.find('-') == 0) {
354 323
      std::cout << "unrecognised argument " << arg << '\n';
355 324
      return EXIT_FAILURE;
356 325
    } else {
@@ -358,7 +327,7 @@
Loading
358 327
    }
359 328
360 329
    try {
361 -
      switch ( mode ) {
330 +
      switch (mode) {
362 331
        case eInteractive:
363 332
          interactive(chai);
364 333
          break;
@@ -368,32 +337,28 @@
Loading
368 337
        case eFile:
369 338
          chai.eval_file(arg);
370 339
      }
371 -
    }
372 -
    catch (const chaiscript::exception::eval_error &ee) {
340 +
    } catch (const chaiscript::exception::eval_error &ee) {
373 341
      std::cout << ee.pretty_print();
374 342
      std::cout << '\n';
375 343
376 344
      if (!eval_error_ok) {
377 345
        return EXIT_FAILURE;
378 346
      }
379 -
    }
380 -
    catch (const chaiscript::Boxed_Value &e) {
347 +
    } catch (const chaiscript::Boxed_Value &e) {
381 348
      std::cout << "Unhandled exception thrown of type " << e.get_type_info().name() << '\n';
382 349
383 350
      if (!boxed_exception_ok) {
384 351
        return EXIT_FAILURE;
385 352
      }
386 -
    }
387 -
    catch (const chaiscript::exception::load_module_error &e) {
388 -
      std::cout << "Unhandled module load error\n" << e.what() << '\n';
389 -
    }
390 -
    catch (std::exception &e) {
353 +
    } catch (const chaiscript::exception::load_module_error &e) {
354 +
      std::cout << "Unhandled module load error\n"
355 +
                << e.what() << '\n';
356 +
    } catch (std::exception &e) {
391 357
      std::cout << "Unhandled standard exception: " << e.what() << '\n';
392 358
      if (!any_exception_ok) {
393 359
        throw;
394 360
      }
395 -
    }
396 -
    catch (...) {
361 +
    } catch (...) {
397 362
      std::cout << "Unhandled unknown exception" << '\n';
398 363
      if (!any_exception_ok) {
399 364
        throw;

@@ -7,7 +7,6 @@
Loading
7 7
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
8 8
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
9 9
10 -
11 10
#ifndef CHAISCRIPT_BOXED_CAST_HPP_
12 11
#define CHAISCRIPT_BOXED_CAST_HPP_
13 12
@@ -19,23 +18,19 @@
Loading
19 18
#include "type_info.hpp"
20 19
21 20
namespace chaiscript {
22 -
class Type_Conversions;
23 -
namespace detail {
24 -
namespace exception {
25 -
class bad_any_cast;
26 -
}  // namespace exception
27 -
}  // namespace detail
28 -
}  // namespace chaiscript
21 +
  class Type_Conversions;
22 +
}
23 +
namespace chaiscript::detail::exception {
24 +
  class bad_any_cast;
25 +
} // namespace chaiscript::detail::exception
29 26
30 -
namespace chaiscript 
31 -
{
32 -
 
27 +
namespace chaiscript {
33 28
  /// \brief Function for extracting a value stored in a Boxed_Value object
34 29
  /// \tparam Type The type to extract from the Boxed_Value
35 30
  /// \param[in] bv The Boxed_Value to extract a typed value from
36 -
  /// \returns Type equivalent to the requested type 
31 +
  /// \returns Type equivalent to the requested type
37 32
  /// \throws exception::bad_boxed_cast If the requested conversion is not possible
38 -
  /// 
33 +
  ///
39 34
  /// boxed_cast will attempt to make conversions between value, &, *, std::shared_ptr, std::reference_wrapper,
40 35
  /// and std::function (const and non-const) where possible. boxed_cast is used internally during function
41 36
  /// dispatch. This means that all of these conversions will be attempted automatically for you during
@@ -67,47 +62,41 @@
Loading
67 62
  /// std::function conversion example
68 63
  /// \code
69 64
  /// chaiscript::ChaiScript chai;
70 -
  /// Boxed_Value bv = chai.eval("`+`"); // Get the functor for the + operator which is built in 
65 +
  /// Boxed_Value bv = chai.eval("`+`"); // Get the functor for the + operator which is built in
71 66
  /// std::function<int (int, int)> f = chaiscript::boxed_cast<std::function<int (int, int)> >(bv);
72 67
  /// int i = f(2,3);
73 68
  /// assert(i == 5);
74 69
  /// \endcode
75 70
  template<typename Type>
76 -
  decltype(auto) boxed_cast(const Boxed_Value &bv, const Type_Conversions_State *t_conversions = nullptr)
77 -
  {
71 +
  decltype(auto) boxed_cast(const Boxed_Value &bv, const Type_Conversions_State *t_conversions = nullptr) {
78 72
    if (!t_conversions || bv.get_type_info().bare_equal(user_type<Type>()) || (t_conversions && !(*t_conversions)->convertable_type<Type>())) {
79 73
      try {
80 -
        return(detail::Cast_Helper<Type>::cast(bv, t_conversions));
74 +
        return detail::Cast_Helper<Type>::cast(bv, t_conversions);
81 75
      } catch (const chaiscript::detail::exception::bad_any_cast &) {
82 76
      }
83 77
    }
84 78
85 -
86 -
    if (t_conversions && (*t_conversions)->convertable_type<Type>())
87 -
    {
79 +
    if (t_conversions && (*t_conversions)->convertable_type<Type>()) {
88 80
      try {
89 81
        // We will not catch any bad_boxed_dynamic_cast that is thrown, let the user get it
90 82
        // either way, we are not responsible if it doesn't work
91 -
        return(detail::Cast_Helper<Type>::cast((*t_conversions)->boxed_type_conversion<Type>(t_conversions->saves(), bv), t_conversions));
83 +
        return (detail::Cast_Helper<Type>::cast((*t_conversions)->boxed_type_conversion<Type>(t_conversions->saves(), bv), t_conversions));
92 84
      } catch (...) {
93 85
        try {
94 86
          // try going the other way
95 -
          return(detail::Cast_Helper<Type>::cast((*t_conversions)->boxed_type_down_conversion<Type>(t_conversions->saves(), bv), t_conversions));
87 +
          return (detail::Cast_Helper<Type>::cast((*t_conversions)->boxed_type_down_conversion<Type>(t_conversions->saves(), bv),
88 +
                                                  t_conversions));
96 89
        } catch (const chaiscript::detail::exception::bad_any_cast &) {
97 90
          throw exception::bad_boxed_cast(bv.get_type_info(), typeid(Type));
98 91
        }
99 92
      }
100 93
    } else {
101 -
      // If it's not convertable, just throw the error, don't waste the time on the 
94 +
      // If it's not convertable, just throw the error, don't waste the time on the
102 95
      // attempted dynamic_cast
103 96
      throw exception::bad_boxed_cast(bv.get_type_info(), typeid(Type));
104 97
    }
105 -
106 98
  }
107 99
108 -
}
109 -
110 -
100 +
} // namespace chaiscript
111 101
112 102
#endif
113 -

@@ -1,7 +1,6 @@
Loading
1 1
2 2
#include <chaiscript/chaiscript_stdlib.hpp>
3 3
4 -
5 4
// MSVC doesn't like that we are using C++ return types from our C declared module
6 5
// but this is the best way to do it for cross platform compatibility
7 6
#ifdef CHAISCRIPT_MSVC
@@ -14,13 +13,10 @@
Loading
14 13
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
15 14
#endif
16 15
17 -
18 -
CHAISCRIPT_MODULE_EXPORT  chaiscript::ModulePtr create_chaiscript_module_chaiscript_stdlib()
19 -
{
16 +
CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_chaiscript_stdlib() {
20 17
  return chaiscript::Std_Lib::library();
21 18
}
22 19
23 -
24 20
#ifdef __llvm__
25 21
#pragma clang diagnostic pop
26 22
#endif

@@ -8,20 +8,17 @@
Loading
8 8
#include <chaiscript/chaiscript_basic.hpp>
9 9
#include <chaiscript/language/chaiscript_parser.hpp>
10 10
11 -
int expected_value(int num_iters)
12 -
{
11 +
int expected_value(int num_iters) {
13 12
  int i = 0;
14 -
  for (int k = 0; k<num_iters * 10; ++k)
15 -
  {
13 +
  for (int k = 0; k < num_iters * 10; ++k) {
16 14
    i += k;
17 15
  }
18 16
19 17
  return i;
20 18
}
21 19
22 -
void do_work(chaiscript::ChaiScript_Basic &c, const size_t id)
23 -
{
24 -
  try{
20 +
void do_work(chaiscript::ChaiScript_Basic &c, const size_t id) {
21 +
  try {
25 22
    std::stringstream ss;
26 23
    ss << "MyVar" << rand();
27 24
    c.add(chaiscript::var(5), ss.str());
@@ -34,9 +31,8 @@
Loading
34 31
  }
35 32
}
36 33
37 -
int main()
38 -
{
39 -
  // Disable deprecation warning for getenv call.
34 +
int main() {
35 +
// Disable deprecation warning for getenv call.
40 36
#ifdef CHAISCRIPT_MSVC
41 37
#ifdef max // Why Microsoft? why?
42 38
#undef max
@@ -54,63 +50,54 @@
Loading
54 50
55 51
  std::vector<std::string> usepaths;
56 52
  usepaths.emplace_back("");
57 -
  if (usepath)
58 -
  {
53 +
  if (usepath) {
59 54
    usepaths.emplace_back(usepath);
60 55
  }
61 56
62 57
  std::vector<std::string> modulepaths;
63 58
64 59
#ifdef CHAISCRIPT_NO_DYNLOAD
65 -
  chaiscript::ChaiScript chai(/* unused */modulepaths, usepaths);
60 +
  chaiscript::ChaiScript chai(/* unused */ modulepaths, usepaths);
66 61
#else
67 62
  modulepaths.emplace_back("");
68 -
  if (modulepath)
69 -
  {
63 +
  if (modulepath) {
70 64
    modulepaths.emplace_back(modulepath);
71 65
  }
72 -
  
66 +
73 67
  // For this test we are going to load the dynamic stdlib
74 68
  // to make sure it continues to work
75 69
  chaiscript::ChaiScript_Basic chai(
76 70
      std::make_unique<chaiscript::parser::ChaiScript_Parser<chaiscript::eval::Noop_Tracer, chaiscript::optimizer::Optimizer_Default>>(),
77 -
      modulepaths,usepaths);
71 +
      modulepaths,
72 +
      usepaths);
78 73
#endif
79 74
80 -
  std::vector<std::shared_ptr<std::thread> > threads;
75 +
  std::vector<std::shared_ptr<std::thread>> threads;
81 76
82 77
  // Ensure at least two, but say only 7 on an 8 core processor
83 78
  size_t num_threads = static_cast<size_t>(std::max(static_cast<int>(std::thread::hardware_concurrency()) - 1, 2));
84 79
85 80
  std::cout << "Num threads: " << num_threads << '\n';
86 81
87 -
  for (size_t i = 0; i < num_threads; ++i)
88 -
  {
82 +
  for (size_t i = 0; i < num_threads; ++i) {
89 83
    threads.push_back(std::make_shared<std::thread>(do_work, std::ref(chai), i));
90 84
  }
91 85
92 -
  for (size_t i = 0; i < num_threads; ++i)
93 -
  {
86 +
  for (size_t i = 0; i < num_threads; ++i) {
94 87
    threads[i]->join();
95 88
  }
96 89
97 -
98 -
99 -
  for (size_t i = 0; i < num_threads; ++i)
100 -
  {
90 +
  for (size_t i = 0; i < num_threads; ++i) {
101 91
    std::stringstream ss;
102 92
    ss << i;
103 -
    if (chai.eval<int>("getvalue(" + ss.str() + ")") != expected_value(4000))
104 -
    {
93 +
    if (chai.eval<int>("getvalue(" + ss.str() + ")") != expected_value(4000)) {
105 94
      return EXIT_FAILURE;
106 95
    }
107 96
108 -
    if (chai.eval<int>("getid(" + ss.str() + ")") != static_cast<int>(i))
109 -
    {
97 +
    if (chai.eval<int>("getid(" + ss.str() + ")") != static_cast<int>(i)) {
110 98
      return EXIT_FAILURE;
111 99
    }
112 100
  }
113 101
114 102
  return EXIT_SUCCESS;
115 103
}
116 -

@@ -7,40 +7,31 @@
Loading
7 7
#ifndef CHAISCRIPT_TRACER_HPP_
8 8
#define CHAISCRIPT_TRACER_HPP_
9 9
10 -
namespace chaiscript {
11 -
  namespace eval {
10 +
namespace chaiscript::eval {
11 +
  struct Noop_Tracer_Detail {
12 +
    template<typename T>
13 +
    constexpr void trace(const chaiscript::detail::Dispatch_State &, const AST_Node_Impl<T> *) noexcept {
14 +
    }
15 +
  };
12 16
17 +
  template<typename... T>
18 +
  struct Tracer : T... {
19 +
    Tracer() = default;
20 +
    constexpr explicit Tracer(T... t)
21 +
        : T(std::move(t))... {
22 +
    }
13 23
14 -
    struct Noop_Tracer_Detail
15 -
    {
16 -
      template<typename T>
17 -
        constexpr void trace(const chaiscript::detail::Dispatch_State &, const AST_Node_Impl<T> *) noexcept
18 -
        {
19 -
        }
20 -
    };
24 +
    void do_trace(const chaiscript::detail::Dispatch_State &ds, const AST_Node_Impl<Tracer<T...>> *node) {
25 +
      (static_cast<T &>(*this).trace(ds, node), ...);
26 +
    }
21 27
22 -
    template<typename ... T>
23 -
      struct Tracer : T...
24 -
    {
25 -
      Tracer() = default;
26 -
      constexpr explicit Tracer(T ... t)
27 -
        : T(std::move(t))...
28 -
      {
29 -
      }
28 +
    static void trace(const chaiscript::detail::Dispatch_State &ds, const AST_Node_Impl<Tracer<T...>> *node) {
29 +
      ds->get_parser().get_tracer<Tracer<T...>>().do_trace(ds, node);
30 +
    }
31 +
  };
30 32
31 -
      void do_trace(const chaiscript::detail::Dispatch_State &ds, const AST_Node_Impl<Tracer<T...>> *node) {
32 -
        (static_cast<T&>(*this).trace(ds, node), ... );
33 -
      }
33 +
  using Noop_Tracer = Tracer<Noop_Tracer_Detail>;
34 34
35 -
      static void trace(const chaiscript::detail::Dispatch_State &ds, const AST_Node_Impl<Tracer<T...>> *node) {
36 -
        ds->get_parser().get_tracer<Tracer<T...>>().do_trace(ds, node);
37 -
      }
38 -
    };
39 -
40 -
    using Noop_Tracer = Tracer<Noop_Tracer_Detail>;
41 -
42 -
  }
43 -
}
35 +
} // namespace chaiscript::eval
44 36
45 37
#endif
46 -

@@ -7,7 +7,6 @@
Loading
7 7
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
8 8
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
9 9
10 -
11 10
#include <chaiscript/chaiscript_basic.hpp>
12 11
#include <chaiscript/dispatchkit/bootstrap_stl.hpp>
13 12
#include <list>
@@ -25,11 +24,10 @@
Loading
25 24
#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
26 25
#endif
27 26
28 -
CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_stl_extra()
29 -
{
27 +
CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_stl_extra() {
30 28
  auto module = std::make_shared<chaiscript::Module>();
31 -
  chaiscript::bootstrap::standard_library::list_type<std::list<chaiscript::Boxed_Value> >("List", *module);
32 -
  chaiscript::bootstrap::standard_library::vector_type<std::vector<uint16_t> >("u16vector", *module);
29 +
  chaiscript::bootstrap::standard_library::list_type<std::list<chaiscript::Boxed_Value>>("List", *module);
30 +
  chaiscript::bootstrap::standard_library::vector_type<std::vector<uint16_t>>("u16vector", *module);
33 31
  module->add(chaiscript::vector_conversion<std::vector<uint16_t>>());
34 32
  return module;
35 33
}

@@ -12,55 +12,54 @@
Loading
12 12
#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
13 13
// start catch.hpp
14 14
15 -
16 15
#define CATCH_VERSION_MAJOR 2
17 16
#define CATCH_VERSION_MINOR 13
18 17
#define CATCH_VERSION_PATCH 6
19 18
20 19
#ifdef __clang__
21 -
#    pragma clang system_header
20 +
#pragma clang system_header
22 21
#elif defined __GNUC__
23 -
#    pragma GCC system_header
22 +
#pragma GCC system_header
24 23
#endif
25 24
26 25
// start catch_suppress_warnings.h
27 26
28 27
#ifdef __clang__
29 -
#   ifdef __ICC // icpc defines the __clang__ macro
30 -
#       pragma warning(push)
31 -
#       pragma warning(disable: 161 1682)
32 -
#   else // __ICC
33 -
#       pragma clang diagnostic push
34 -
#       pragma clang diagnostic ignored "-Wpadded"
35 -
#       pragma clang diagnostic ignored "-Wswitch-enum"
36 -
#       pragma clang diagnostic ignored "-Wcovered-switch-default"
37 -
#    endif
28 +
#ifdef __ICC // icpc defines the __clang__ macro
29 +
#pragma warning(push)
30 +
#pragma warning(disable : 161 1682)
31 +
#else // __ICC
32 +
#pragma clang diagnostic push
33 +
#pragma clang diagnostic ignored "-Wpadded"
34 +
#pragma clang diagnostic ignored "-Wswitch-enum"
35 +
#pragma clang diagnostic ignored "-Wcovered-switch-default"
36 +
#endif
38 37
#elif defined __GNUC__
39 -
     // Because REQUIREs trigger GCC's -Wparentheses, and because still
40 -
     // supported version of g++ have only buggy support for _Pragmas,
41 -
     // Wparentheses have to be suppressed globally.
42 -
#    pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details
43 -
44 -
#    pragma GCC diagnostic push
45 -
#    pragma GCC diagnostic ignored "-Wunused-variable"
46 -
#    pragma GCC diagnostic ignored "-Wpadded"
38 +
// Because REQUIREs trigger GCC's -Wparentheses, and because still
39 +
// supported version of g++ have only buggy support for _Pragmas,
40 +
// Wparentheses have to be suppressed globally.
41 +
#pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details
42 +
43 +
#pragma GCC diagnostic push
44 +
#pragma GCC diagnostic ignored "-Wunused-variable"
45 +
#pragma GCC diagnostic ignored "-Wpadded"
47 46
#endif
48 47
// end catch_suppress_warnings.h
49 48
#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER)
50 -
#  define CATCH_IMPL
51 -
#  define CATCH_CONFIG_ALL_PARTS
49 +
#define CATCH_IMPL
50 +
#define CATCH_CONFIG_ALL_PARTS
52 51
#endif
53 52
54 53
// In the impl file, we want to have access to all parts of the headers
55 54
// Can also be used to sanely support PCHs
56 55
#if defined(CATCH_CONFIG_ALL_PARTS)
57 -
#  define CATCH_CONFIG_EXTERNAL_INTERFACES
58 -
#  if defined(CATCH_CONFIG_DISABLE_MATCHERS)
59 -
#    undef CATCH_CONFIG_DISABLE_MATCHERS
60 -
#  endif
61 -
#  if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER)
62 -
#    define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
63 -
#  endif
56 +
#define CATCH_CONFIG_EXTERNAL_INTERFACES
57 +
#if defined(CATCH_CONFIG_DISABLE_MATCHERS)
58 +
#undef CATCH_CONFIG_DISABLE_MATCHERS
59 +
#endif
60 +
#if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER)
61 +
#define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
62 +
#endif
64 63
#endif
65 64
66 65
#if !defined(CATCH_CONFIG_IMPL_ONLY)
@@ -69,34 +68,33 @@
Loading
69 68
// See e.g.:
70 69
// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html
71 70
#ifdef __APPLE__
72 -
#  include <TargetConditionals.h>
73 -
#  if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \
74 -
      (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1)
75 -
#    define CATCH_PLATFORM_MAC
76 -
#  elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1)
77 -
#    define CATCH_PLATFORM_IPHONE
78 -
#  endif
71 +
#include <TargetConditionals.h>
72 +
#if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1)
73 +
#define CATCH_PLATFORM_MAC
74 +
#elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1)
75 +
#define CATCH_PLATFORM_IPHONE
76 +
#endif
79 77
80 78
#elif defined(linux) || defined(__linux) || defined(__linux__)
81 -
#  define CATCH_PLATFORM_LINUX
79 +
#define CATCH_PLATFORM_LINUX
82 80
83 81
#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__)
84 -
#  define CATCH_PLATFORM_WINDOWS
82 +
#define CATCH_PLATFORM_WINDOWS
85 83
#endif
86 84
87 85
// end catch_platform.h
88 86
89 87
#ifdef CATCH_IMPL
90 -
#  ifndef CLARA_CONFIG_MAIN
91 -
#    define CLARA_CONFIG_MAIN_NOT_DEFINED
92 -
#    define CLARA_CONFIG_MAIN
93 -
#  endif
88 +
#ifndef CLARA_CONFIG_MAIN
89 +
#define CLARA_CONFIG_MAIN_NOT_DEFINED
90 +
#define CLARA_CONFIG_MAIN
91 +
#endif
94 92
#endif
95 93
96 94
// start catch_user_interfaces.h
97 95
98 96
namespace Catch {
99 -
    unsigned int rngSeed();
97 +
  unsigned int rngSeed();
100 98
}
101 99
102 100
// end catch_user_interfaces.h
@@ -125,30 +123,30 @@
Loading
125 123
126 124
#ifdef __cplusplus
127 125
128 -
#  if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
129 -
#    define CATCH_CPP14_OR_GREATER
130 -
#  endif
126 +
#if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
127 +
#define CATCH_CPP14_OR_GREATER
128 +
#endif
131 129
132 -
#  if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
133 -
#    define CATCH_CPP17_OR_GREATER
134 -
#  endif
130 +
#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
131 +
#define CATCH_CPP17_OR_GREATER
132 +
#endif
135 133
136 134
#endif
137 135
138 136
// Only GCC compiler should be used in this block, so other compilers trying to
139 137
// mask themselves as GCC should be ignored.
140 138
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__)
141 -
#    define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" )
142 -
#    define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION  _Pragma( "GCC diagnostic pop" )
139 +
#define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma("GCC diagnostic push")
140 +
#define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma("GCC diagnostic pop")
143 141
144 -
#    define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__)
142 +
#define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__)
145 143
146 144
#endif
147 145
148 146
#if defined(__clang__)
149 147
150 -
#    define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" )
151 -
#    define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION  _Pragma( "clang diagnostic pop" )
148 +
#define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma("clang diagnostic push")
149 +
#define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma("clang diagnostic pop")
152 150
153 151
// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug
154 152
// which results in calls to destructors being emitted for each temporary,
@@ -161,62 +159,58 @@
Loading
161 159
// ```
162 160
//
163 161
// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented.
164 -
#  if !defined(__ibmxl__) && !defined(__CUDACC__)
165 -
#    define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */
166 -
#  endif
162 +
#if !defined(__ibmxl__) && !defined(__CUDACC__)
163 +
#define CATCH_INTERNAL_IGNORE_BUT_WARN(...) \
164 +
  (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */
165 +
#endif
167 166
168 -
#    define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
169 -
         _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \
170 -
         _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"")
167 +
#define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
168 +
  _Pragma("clang diagnostic ignored \"-Wexit-time-destructors\"") _Pragma("clang diagnostic ignored \"-Wglobal-constructors\"")
171 169
172 -
#    define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
173 -
         _Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
170 +
#define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma("clang diagnostic ignored \"-Wparentheses\"")
174 171
175 -
#    define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \
176 -
         _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" )
172 +
#define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS _Pragma("clang diagnostic ignored \"-Wunused-variable\"")
177 173
178 -
#    define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \
179 -
         _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" )
174 +
#define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS _Pragma("clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"")
180 175
181 -
#    define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \
182 -
         _Pragma( "clang diagnostic ignored \"-Wunused-template\"" )
176 +
#define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS _Pragma("clang diagnostic ignored \"-Wunused-template\"")
183 177
184 178
#endif // __clang__
185 179
186 180
////////////////////////////////////////////////////////////////////////////////
187 181
// Assume that non-Windows platforms support posix signals by default
188 182
#if !defined(CATCH_PLATFORM_WINDOWS)
189 -
    #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS
183 +
#define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS
190 184
#endif
191 185
192 186
////////////////////////////////////////////////////////////////////////////////
193 187
// We know some environments not to support full POSIX signals
194 188
#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__)
195 -
    #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
189 +
#define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
196 190
#endif
197 191
198 192
#ifdef __OS400__
199 -
#       define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
200 -
#       define CATCH_CONFIG_COLOUR_NONE
193 +
#define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
194 +
#define CATCH_CONFIG_COLOUR_NONE
201 195
#endif
202 196
203 197
////////////////////////////////////////////////////////////////////////////////
204 198
// Android somehow still does not support std::to_string
205 199
#if defined(__ANDROID__)
206 -
#    define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
207 -
#    define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE
200 +
#define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
201 +
#define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE
208 202
#endif
209 203
210 204
////////////////////////////////////////////////////////////////////////////////
211 205
// Not all Windows environments support SEH properly
212 206
#if defined(__MINGW32__)
213 -
#    define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH
207 +
#define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH
214 208
#endif
215 209
216 210
////////////////////////////////////////////////////////////////////////////////
217 211
// PS4
218 212
#if defined(__ORBIS__)
219 -
#    define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE
213 +
#define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE
220 214
#endif
221 215
222 216
////////////////////////////////////////////////////////////////////////////////
@@ -225,64 +219,63 @@
Loading
225 219
226 220
// Required for some versions of Cygwin to declare gettimeofday
227 221
// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin
228 -
#   define _BSD_SOURCE
222 +
#define _BSD_SOURCE
229 223
// some versions of cygwin (most) do not support std::to_string. Use the libstd check.
230 224
// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813
231 -
# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
232 -
           && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
225 +
#if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
233 226
234 -
#    define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
227 +
#define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
235 228
236 -
# endif
229 +
#endif
237 230
#endif // __CYGWIN__
238 231
239 232
////////////////////////////////////////////////////////////////////////////////
240 233
// Visual C++
241 234
#if defined(_MSC_VER)
242 235
243 -
#  define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) )
244 -
#  define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION  __pragma( warning(pop) )
236 +
#define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma(warning(push))
237 +
#define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma(warning(pop))
245 238
246 239
// Universal Windows platform does not support SEH
247 240
// Or console colours (or console at all...)
248 -
#  if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
249 -
#    define CATCH_CONFIG_COLOUR_NONE
250 -
#  else
251 -
#    define CATCH_INTERNAL_CONFIG_WINDOWS_SEH
252 -
#  endif
241 +
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
242 +
#define CATCH_CONFIG_COLOUR_NONE
243 +
#else
244 +
#define CATCH_INTERNAL_CONFIG_WINDOWS_SEH
245 +
#endif
253 246
254 247
// MSVC traditional preprocessor needs some workaround for __VA_ARGS__
255 248
// _MSVC_TRADITIONAL == 0 means new conformant preprocessor
256 249
// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor
257 -
#  if !defined(__clang__) // Handle Clang masquerading for msvc
258 -
#    if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL)
259 -
#      define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
260 -
#    endif // MSVC_TRADITIONAL
261 -
#  endif // __clang__
250 +
#if !defined(__clang__) // Handle Clang masquerading for msvc
251 +
#if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL)
252 +
#define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
253 +
#endif // MSVC_TRADITIONAL
254 +
#endif // __clang__
262 255
263 256
#endif // _MSC_VER
264 257
265 258
#if defined(_REENTRANT) || defined(_MSC_VER)
266 259
// Enable async processing, as -pthread is specified or no additional linking is required
267 -
# define CATCH_INTERNAL_CONFIG_USE_ASYNC
260 +
#define CATCH_INTERNAL_CONFIG_USE_ASYNC
268 261
#endif // _MSC_VER
269 262
270 263
////////////////////////////////////////////////////////////////////////////////
271 264
// Check if we are compiled with -fno-exceptions or equivalent
272 265
#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND)
273 -
#  define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED
266 +
#define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED
274 267
#endif
275 268
276 269
////////////////////////////////////////////////////////////////////////////////
277 270
// DJGPP
278 271
#ifdef __DJGPP__
279 -
#  define CATCH_INTERNAL_CONFIG_NO_WCHAR
272 +
#define CATCH_INTERNAL_CONFIG_NO_WCHAR
280 273
#endif // __DJGPP__
281 274
282 275
////////////////////////////////////////////////////////////////////////////////
283 276
// Embarcadero C++Build
284 277
#if defined(__BORLANDC__)
285 -
    #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN
278 +
#define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN
286 279
#endif
287 280
288 281
////////////////////////////////////////////////////////////////////////////////
@@ -292,8 +285,8 @@
Loading
292 285
// handled by it.
293 286
// Otherwise all supported compilers support COUNTER macro,
294 287
// but user still might want to turn it off
295 -
#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L )
296 -
    #define CATCH_INTERNAL_CONFIG_COUNTER
288 +
#if (!defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L)
289 +
#define CATCH_INTERNAL_CONFIG_COUNTER
297 290
#endif
298 291
299 292
////////////////////////////////////////////////////////////////////////////////
@@ -302,9 +295,9 @@
Loading
302 295
// This means that it is detected as Windows, but does not provide
303 296
// the same set of capabilities as real Windows does.
304 297
#if defined(UNDER_RTSS) || defined(RTX64_BUILD)
305 -
    #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH
306 -
    #define CATCH_INTERNAL_CONFIG_NO_ASYNC
307 -
    #define CATCH_CONFIG_COLOUR_NONE
298 +
#define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH
299 +
#define CATCH_INTERNAL_CONFIG_NO_ASYNC
300 +
#define CATCH_CONFIG_COLOUR_NONE
308 301
#endif
309 302
310 303
#if !defined(_GLIBCXX_USE_C99_MATH_TR1)
@@ -313,139 +306,147 @@
Loading
313 306
314 307
// Various stdlib support checks that require __has_include
315 308
#if defined(__has_include)
316 -
  // Check if string_view is available and usable
317 -
  #if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER)
318 -
  #    define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW
319 -
  #endif
320 -
321 -
  // Check if optional is available and usable
322 -
  #  if __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER)
323 -
  #    define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL
324 -
  #  endif // __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER)
325 -
326 -
  // Check if byte is available and usable
327 -
  #  if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
328 -
  #    include <cstddef>
329 -
  #    if __cpp_lib_byte > 0
330 -
  #      define CATCH_INTERNAL_CONFIG_CPP17_BYTE
331 -
  #    endif
332 -
  #  endif // __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
333 -
334 -
  // Check if variant is available and usable
335 -
  #  if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
336 -
  #    if defined(__clang__) && (__clang_major__ < 8)
337 -
         // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852
338 -
         // fix should be in clang 8, workaround in libstdc++ 8.2
339 -
  #      include <ciso646>
340 -
  #      if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
341 -
  #        define CATCH_CONFIG_NO_CPP17_VARIANT
342 -
  #      else
343 -
  #        define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
344 -
  #      endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
345 -
  #    else
346 -
  #      define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
347 -
  #    endif // defined(__clang__) && (__clang_major__ < 8)
348 -
  #  endif // __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
309 +
// Check if string_view is available and usable
310 +
#if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER)
311 +
#define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW
312 +
#endif
313 +
314 +
// Check if optional is available and usable
315 +
#if __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER)
316 +
#define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL
317 +
#endif // __has_include(<optional>) && defined(CATCH_CPP17_OR_GREATER)
318 +
319 +
// Check if byte is available and usable
320 +
#if __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
321 +
#include <cstddef>
322 +
#if __cpp_lib_byte > 0
323 +
#define CATCH_INTERNAL_CONFIG_CPP17_BYTE
324 +
#endif
325 +
#endif // __has_include(<cstddef>) && defined(CATCH_CPP17_OR_GREATER)
326 +
327 +
// Check if variant is available and usable
328 +
#if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
329 +
#if defined(__clang__) && (__clang_major__ < 8)
330 +
// work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852
331 +
// fix should be in clang 8, workaround in libstdc++ 8.2
332 +
#include <ciso646>
333 +
#if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
334 +
#define CATCH_CONFIG_NO_CPP17_VARIANT
335 +
#else
336 +
#define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
337 +
#endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
338 +
#else
339 +
#define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
340 +
#endif // defined(__clang__) && (__clang_major__ < 8)
341 +
#endif // __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
349 342
#endif // defined(__has_include)
350 343
351 344
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
352 -
#   define CATCH_CONFIG_COUNTER
345 +
#define CATCH_CONFIG_COUNTER
353 346
#endif
354 -
#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH)
355 -
#   define CATCH_CONFIG_WINDOWS_SEH
347 +
#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) \
348 +
    && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH)
349 +
#define CATCH_CONFIG_WINDOWS_SEH
356 350
#endif
357 351
// This is set by default, because we assume that unix compilers are posix-signal-compatible by default.
358 -
#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS)
359 -
#   define CATCH_CONFIG_POSIX_SIGNALS
352 +
#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) \
353 +
    && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS)
354 +
#define CATCH_CONFIG_POSIX_SIGNALS
360 355
#endif
361 356
// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions.
362 357
#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR)
363 -
#   define CATCH_CONFIG_WCHAR
358 +
#define CATCH_CONFIG_WCHAR
364 359
#endif
365 360
366 -
#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING)
367 -
#    define CATCH_CONFIG_CPP11_TO_STRING
361 +
#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) \
362 +
    && !defined(CATCH_CONFIG_CPP11_TO_STRING)
363 +
#define CATCH_CONFIG_CPP11_TO_STRING
368 364
#endif
369 365
370 366
#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL)
371 -
#  define CATCH_CONFIG_CPP17_OPTIONAL
367 +
#define CATCH_CONFIG_CPP17_OPTIONAL
372 368
#endif
373 369
374 -
#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW)
375 -
#  define CATCH_CONFIG_CPP17_STRING_VIEW
370 +
#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) \
371 +
    && !defined(CATCH_CONFIG_CPP17_STRING_VIEW)
372 +
#define CATCH_CONFIG_CPP17_STRING_VIEW
376 373
#endif
377 374
378 375
#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT)
379 -
#  define CATCH_CONFIG_CPP17_VARIANT
376 +
#define CATCH_CONFIG_CPP17_VARIANT
380 377
#endif
381 378
382 379
#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE)
383 -
#  define CATCH_CONFIG_CPP17_BYTE
380 +
#define CATCH_CONFIG_CPP17_BYTE
384 381
#endif
385 382
386 383
#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)
387 -
#  define CATCH_INTERNAL_CONFIG_NEW_CAPTURE
384 +
#define CATCH_INTERNAL_CONFIG_NEW_CAPTURE
388 385
#endif
389 386
390 -
#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE)
391 -
#  define CATCH_CONFIG_NEW_CAPTURE
387 +
#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) \
388 +
    && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE)
389 +
#define CATCH_CONFIG_NEW_CAPTURE
392 390
#endif
393 391
394 392
#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
395 -
#  define CATCH_CONFIG_DISABLE_EXCEPTIONS
393 +
#define CATCH_CONFIG_DISABLE_EXCEPTIONS
396 394
#endif
397 395
398 396
#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN)
399 -
#  define CATCH_CONFIG_POLYFILL_ISNAN
397 +
#define CATCH_CONFIG_POLYFILL_ISNAN
400 398
#endif
401 399
402 -
#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC)  && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC)
403 -
#  define CATCH_CONFIG_USE_ASYNC
400 +
#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) \
401 +
    && !defined(CATCH_CONFIG_USE_ASYNC)
402 +
#define CATCH_CONFIG_USE_ASYNC
404 403
#endif
405 404
406 -
#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE)
407 -
#  define CATCH_CONFIG_ANDROID_LOGWRITE
405 +
#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) \
406 +
    && !defined(CATCH_CONFIG_ANDROID_LOGWRITE)
407 +
#define CATCH_CONFIG_ANDROID_LOGWRITE
408 408
#endif
409 409
410 -
#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
411 -
#  define CATCH_CONFIG_GLOBAL_NEXTAFTER
410 +
#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) \
411 +
    && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER)
412 +
#define CATCH_CONFIG_GLOBAL_NEXTAFTER
412 413
#endif
413 414
414 415
// Even if we do not think the compiler has that warning, we still have
415 416
// to provide a macro that can be used by the code.
416 417
#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION)
417 -
#   define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION
418 +
#define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION
418 419
#endif
419 420
#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION)
420 -
#   define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
421 +
#define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
421 422
#endif
422 423
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
423 -
#   define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
424 +
#define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
424 425
#endif
425 426
#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS)
426 -
#   define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
427 +
#define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS
427 428
#endif
428 429
#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS)
429 -
#   define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS
430 +
#define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS
430 431
#endif
431 432
#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS)
432 -
#   define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS
433 +
#define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS
433 434
#endif
434 435
435 436
// The goal of this macro is to avoid evaluation of the arguments, but
436 437
// still have the compiler warn on problems inside...
437 438
#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN)
438 -
#   define CATCH_INTERNAL_IGNORE_BUT_WARN(...)
439 +
#define CATCH_INTERNAL_IGNORE_BUT_WARN(...)
439 440
#endif
440 441
441 442
#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10)
442 -
#   undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
443 +
#undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
443 444
#elif defined(__clang__) && (__clang_major__ < 5)
444 -
#   undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
445 +
#undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
445 446
#endif
446 447
447 448
#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS)
448 -
#   define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
449 +
#define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS
449 450
#endif
450 451
451 452
#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
@@ -458,103 +459,105 @@
Loading
458 459
#define CATCH_CATCH_ANON(type) catch (type)
459 460
#endif
460 461
461 -
#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR)
462 +
#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) \
463 +
    && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR)
462 464
#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR
463 465
#endif
464 466
465 467
// end catch_compiler_capabilities.h
466 -
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
467 -
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
468 +
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2(name, line) name##line
469 +
#define INTERNAL_CATCH_UNIQUE_NAME_LINE(name, line) INTERNAL_CATCH_UNIQUE_NAME_LINE2(name, line)
468 470
#ifdef CATCH_CONFIG_COUNTER
469 -
#  define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
471 +
#define INTERNAL_CATCH_UNIQUE_NAME(name) INTERNAL_CATCH_UNIQUE_NAME_LINE(name, __COUNTER__)
470 472
#else
471 -
#  define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
473 +
#define INTERNAL_CATCH_UNIQUE_NAME(name) INTERNAL_CATCH_UNIQUE_NAME_LINE(name, __LINE__)
472 474
#endif
473 475
476 +
#include <cstdint>
474 477
#include <iosfwd>
475 478
#include <string>
476 -
#include <cstdint>
477 479
478 480
// We need a dummy global operator<< so we can bring it into Catch namespace later
479 -
struct Catch_global_namespace_dummy {};
480 -
std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy);
481 +
struct Catch_global_namespace_dummy {
482 +
};
483 +
std::ostream &operator<<(std::ostream &, Catch_global_namespace_dummy);
481 484
482 485
namespace Catch {
483 -
484 -
    struct CaseSensitive { enum Choice {
485 -
        Yes,
486 -
        No
487 -
    }; };
488 -
489 -
    class NonCopyable {
490 -
        NonCopyable( NonCopyable const& )              = delete;
491 -
        NonCopyable( NonCopyable && )                  = delete;
492 -
        NonCopyable& operator = ( NonCopyable const& ) = delete;
493 -
        NonCopyable& operator = ( NonCopyable && )     = delete;
494 -
495 -
    protected:
496 -
        NonCopyable();
497 -
        virtual ~NonCopyable();
498 -
    };
499 -
500 -
    struct SourceLineInfo {
501 -
502 -
        SourceLineInfo() = delete;
503 -
        SourceLineInfo( char const* _file, std::size_t _line ) noexcept
504 -
        :   file( _file ),
505 -
            line( _line )
506 -
        {}
507 -
508 -
        SourceLineInfo( SourceLineInfo const& other )            = default;
509 -
        SourceLineInfo& operator = ( SourceLineInfo const& )     = default;
510 -
        SourceLineInfo( SourceLineInfo&& )              noexcept = default;
511 -
        SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default;
512 -
513 -
        bool empty() const noexcept { return file[0] == '\0'; }
514 -
        bool operator == ( SourceLineInfo const& other ) const noexcept;
515 -
        bool operator < ( SourceLineInfo const& other ) const noexcept;
516 -
517 -
        char const* file;
518 -
        std::size_t line;
519 -
    };
520 -
521 -
    std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info );
522 -
523 -
    // Bring in operator<< from global namespace into Catch namespace
524 -
    // This is necessary because the overload of operator<< above makes
525 -
    // lookup stop at namespace Catch
526 -
    using ::operator<<;
527 -
528 -
    // Use this in variadic streaming macros to allow
529 -
    //    >> +StreamEndStop
530 -
    // as well as
531 -
    //    >> stuff +StreamEndStop
532 -
    struct StreamEndStop {
533 -
        std::string operator+() const;
486 +
  struct CaseSensitive {
487 +
    enum Choice {
488 +
      Yes,
489 +
      No
534 490
    };
535 -
    template<typename T>
536 -
    T const& operator + ( T const& value, StreamEndStop ) {
537 -
        return value;
538 -
    }
539 -
}
491 +
  };
492 +
493 +
  class NonCopyable {
494 +
    NonCopyable(NonCopyable const &) = delete;
495 +
    NonCopyable(NonCopyable &&) = delete;
496 +
    NonCopyable &operator=(NonCopyable const &) = delete;
497 +
    NonCopyable &operator=(NonCopyable &&) = delete;
498 +
499 +
  protected:
500 +
    NonCopyable();
501 +
    virtual ~NonCopyable();
502 +
  };
503 +
504 +
  struct SourceLineInfo {
505 +
    SourceLineInfo() = delete;
506 +
    SourceLineInfo(char const *_file, std::size_t _line) noexcept
507 +
        : file(_file)
508 +
        , line(_line) {
509 +
    }
510 +
511 +
    SourceLineInfo(SourceLineInfo const &other) = default;
512 +
    SourceLineInfo &operator=(SourceLineInfo const &) = default;
513 +
    SourceLineInfo(SourceLineInfo &&) noexcept = default;
514 +
    SourceLineInfo &operator=(SourceLineInfo &&) noexcept = default;
515 +
516 +
    bool empty() const noexcept { return file[0] == '\0'; }
517 +
    bool operator==(SourceLineInfo const &other) const noexcept;
518 +
    bool operator<(SourceLineInfo const &other) const noexcept;
519 +
520 +
    char const *file;
521 +
    std::size_t line;
522 +
  };
523 +
524 +
  std::ostream &operator<<(std::ostream &os, SourceLineInfo const &info);
525 +
526 +
  // Bring in operator<< from global namespace into Catch namespace
527 +
  // This is necessary because the overload of operator<< above makes
528 +
  // lookup stop at namespace Catch
529 +
  using ::operator<<;
530 +
531 +
  // Use this in variadic streaming macros to allow
532 +
  //    >> +StreamEndStop
533 +
  // as well as
534 +
  //    >> stuff +StreamEndStop
535 +
  struct StreamEndStop {
536 +
    std::string operator+() const;
537 +
  };
538 +
  template<typename T>
539 +
  T const &operator+(T const &value, StreamEndStop) {
540 +
    return value;
541 +
  }
542 +
} // namespace Catch
540 543
541 -
#define CATCH_INTERNAL_LINEINFO \
542 -
    ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )
544 +
#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo(__FILE__, static_cast<std::size_t>(__LINE__))
543 545
544 546
// end catch_common.h
545 547
namespace Catch {
546 -
547 -
    struct RegistrarForTagAliases {
548 -
        RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo );
549 -
    };
548 +
  struct RegistrarForTagAliases {
549 +
    RegistrarForTagAliases(char const *alias, char const *tag, SourceLineInfo const &lineInfo);
550 +
  };
550 551
551 552
} // end namespace Catch
552 553
553 -
#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \
554 -
    CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \
555 -
    CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \
556 -
    namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \
557 -
    CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
554 +
#define CATCH_REGISTER_TAG_ALIAS(alias, spec)                                                                             \
555 +
  CATCH_INTERNAL_START_WARNINGS_SUPPRESSION                                                                               \
556 +
  CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS                                                                                \
557 +
  namespace {                                                                                                             \
558 +
    Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME(AutoRegisterTagAlias)(alias, spec, CATCH_INTERNAL_LINEINFO); \
559 +
  }                                                                                                                       \
560 +
  CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION
558 561
559 562
// end catch_tag_alias_autoregistrar.h
560 563
// start catch_test_registry.h
@@ -564,130 +567,117 @@
Loading
564 567
#include <vector>
565 568
566 569
namespace Catch {
570 +
  class TestSpec;
567 571
568 -
    class TestSpec;
569 -
570 -
    struct ITestInvoker {
571 -
        virtual void invoke () const = 0;
572 -
        virtual ~ITestInvoker();
573 -
    };
572 +
  struct ITestInvoker {
573 +
    virtual void invoke() const = 0;
574 +
    virtual ~ITestInvoker();
575 +
  };
574 576
575 -
    class TestCase;
576 -
    struct IConfig;
577 +
  class TestCase;
578 +
  struct IConfig;
577 579
578 -
    struct ITestCaseRegistry {
579 -
        virtual ~ITestCaseRegistry();
580 -
        virtual std::vector<TestCase> const& getAllTests() const = 0;
581 -
        virtual std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const = 0;
582 -
    };
580 +
  struct ITestCaseRegistry {
581 +
    virtual ~ITestCaseRegistry();
582 +
    virtual std::vector<TestCase> const &getAllTests() const = 0;
583 +
    virtual std::vector<TestCase> const &getAllTestsSorted(IConfig const &config) const = 0;
584 +
  };
583 585
584 -
    bool isThrowSafe( TestCase const& testCase, IConfig const& config );
585 -
    bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );
586 -
    std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );
587 -
    std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );
586 +
  bool isThrowSafe(TestCase const &testCase, IConfig const &config);
587 +
  bool matchTest(TestCase const &testCase, TestSpec const &testSpec, IConfig const &config);
588 +
  std::vector<TestCase> filterTests(std::vector<TestCase> const &testCases, TestSpec const &testSpec, IConfig const &config);
589 +
  std::vector<TestCase> const &getAllTestCasesSorted(IConfig const &config);
588 590
589 -
}
591 +
} // namespace Catch
590 592
591 593
// end catch_interfaces_testcase.h
592 594
// start catch_stringref.h
593 595
596 +
#include <cassert>
594 597
#include <cstddef>
595 -
#include <string>
596 598
#include <iosfwd>
597 -
#include <cassert>
599 +
#include <string>
598 600
599 601
namespace Catch {
602 +
  /// A non-owning string class (similar to the forthcoming std::string_view)
603 +
  /// Note that, because a StringRef may be a substring of another string,
604 +
  /// it may not be null terminated.
605 +
  class StringRef {
606 +
  public:
607 +
    using size_type = std::size_t;
608 +
    using const_iterator = const char *;
600 609
601 -
    /// A non-owning string class (similar to the forthcoming std::string_view)
602 -
    /// Note that, because a StringRef may be a substring of another string,
603 -
    /// it may not be null terminated.
604 -
    class StringRef {
605 -
    public:
606 -
        using size_type = std::size_t;
607 -
        using const_iterator = const char*;
608 -
609 -
    private:
610 -
        static constexpr char const* const s_empty = "";
610 +
  private:
611 +
    static constexpr char const *const s_empty = "";
611 612
612 -
        char const* m_start = s_empty;
613 -
        size_type m_size = 0;
613 +
    char const *m_start = s_empty;
614 +
    size_type m_size = 0;
614 615
615 -
    public: // construction
616 -
        constexpr StringRef() noexcept = default;
616 +
  public: // construction
617 +
    constexpr StringRef() noexcept = default;
617 618
618 -
        StringRef( char const* rawChars ) noexcept;
619 +
    StringRef(char const *rawChars) noexcept;
619 620
620 -
        constexpr StringRef( char const* rawChars, size_type size ) noexcept
621 -
        :   m_start( rawChars ),
622 -
            m_size( size )
623 -
        {}
621 +
    constexpr StringRef(char const *rawChars, size_type size) noexcept
622 +
        : m_start(rawChars)
623 +
        , m_size(size) {
624 +
    }
624 625
625 -
        StringRef( std::string const& stdString ) noexcept
626 -
        :   m_start( stdString.c_str() ),
627 -
            m_size( stdString.size() )
628 -
        {}
626 +
    StringRef(std::string const &stdString) noexcept
627 +
        : m_start(stdString.c_str())
628 +
        , m_size(stdString.size()) {
629 +
    }
629 630
630 -
        explicit operator std::string() const {
631 -
            return std::string(m_start, m_size);
632 -
        }
631 +
    explicit operator std::string() const { return std::string(m_start, m_size); }
633 632
634 -
    public: // operators
635 -
        auto operator == ( StringRef const& other ) const noexcept -> bool;
636 -
        auto operator != (StringRef const& other) const noexcept -> bool {
637 -
            return !(*this == other);
638 -
        }
633 +
  public: // operators
634 +
    auto operator==(StringRef const &other) const noexcept -> bool;
635 +
    auto operator!=(StringRef const &other) const noexcept -> bool { return !(*this == other); }
639 636
640 -
        auto operator[] ( size_type index ) const noexcept -> char {
641 -
            assert(index < m_size);
642 -
            return m_start[index];
643 -
        }
637 +
    auto operator[](size_type index) const noexcept -> char {
638 +
      assert(index < m_size);
639 +
      return m_start[index];
640 +
    }
644 641
645 -
    public: // named queries
646 -
        constexpr auto empty() const noexcept -> bool {
647 -
            return m_size == 0;
648 -
        }
649 -
        constexpr auto size() const noexcept -> size_type {
650 -
            return m_size;
651 -
        }
642 +
  public: // named queries
643 +
    constexpr auto empty() const noexcept -> bool { return m_size == 0; }
644 +
    constexpr auto size() const noexcept -> size_type { return m_size; }
652 645
653 -
        // Returns the current start pointer. If the StringRef is not
654 -
        // null-terminated, throws std::domain_exception
655 -
        auto c_str() const -> char const*;
646 +
    // Returns the current start pointer. If the StringRef is not
647 +
    // null-terminated, throws std::domain_exception
648 +
    auto c_str() const -> char const *;
656 649
657 -
    public: // substrings and searches
658 -
        // Returns a substring of [start, start + length).
659 -
        // If start + length > size(), then the substring is [start, size()).
660 -
        // If start > size(), then the substring is empty.
661 -
        auto substr( size_type start, size_type length ) const noexcept -> StringRef;
650 +
  public: // substrings and searches
651 +
    // Returns a substring of [start, start + length).
652 +
    // If start + length > size(), then the substring is [start, size()).
653 +
    // If start > size(), then the substring is empty.
654 +
    auto substr(size_type start, size_type length) const noexcept -> StringRef;
662 655
663 -
        // Returns the current start pointer. May not be null-terminated.
664 -
        auto data() const noexcept -> char const*;
656 +
    // Returns the current start pointer. May not be null-terminated.
657 +
    auto data() const noexcept -> char const *;
665 658
666 -
        constexpr auto isNullTerminated() const noexcept -> bool {
667 -
            return m_start[m_size] == '\0';
668 -
        }
659 +
    constexpr auto isNullTerminated() const noexcept -> bool { return m_start[m_size] == '\0'; }
669 660
670 -
    public: // iterators
671 -
        constexpr const_iterator begin() const { return m_start; }
672 -
        constexpr const_iterator end() const { return m_start + m_size; }
673 -
    };
661 +
  public: // iterators
662 +
    constexpr const_iterator begin() const { return m_start; }
663 +
    constexpr const_iterator end() const { return m_start + m_size; }
664 +
  };
674 665
675 -
    auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&;
676 -
    auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&;
666 +
  auto operator+=(std::string &lhs, StringRef const &sr) -> std::string &;
667 +
  auto operator<<(std::ostream &os, StringRef const &sr) -> std::ostream &;
677 668
678 -
    constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
679 -
        return StringRef( rawChars, size );
680 -
    }
669 +
  constexpr auto operator"" _sr(char const *rawChars, std::size_t size) noexcept -> StringRef {
670 +
    return StringRef(rawChars, size);
671 +
  }
681 672
} // namespace Catch
682 673
683 -
constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef {
684 -
    return Catch::StringRef( rawChars, size );
674 +
constexpr auto operator"" _catch_sr(char const *rawChars, std::size_t size) noexcept -> Catch::StringRef {
675 +
  return Catch::StringRef(rawChars, size);
685 676
}
686 677
687 678
// end catch_stringref.h
688 679
// start catch_preprocessor.hpp
689 680
690 -
691 681
#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__
692 682
#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__)))
693 683
#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__)))
@@ -699,9 +689,9 @@
Loading
699 689
#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__
700 690
// MSVC needs more evaluations
701 691
#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__)))
702 -
#define CATCH_RECURSE(...)  CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__))
692 +
#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__))
703 693
#else
704 -
#define CATCH_RECURSE(...)  CATCH_RECURSION_LEVEL5(__VA_ARGS__)
694 +
#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__)
705 695
#endif
706 696
707 697
#define CATCH_REC_END(...)
@@ -714,16 +704,21 @@
Loading
714 704
#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2
715 705
#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1
716 706
#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT
717 -
#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0)
718 -
#define CATCH_REC_NEXT(test, next)  CATCH_REC_NEXT1(CATCH_REC_GET_END test, next)
719 -
720 -
#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ )
721 -
#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ )
722 -
#define CATCH_REC_LIST2(f, x, peek, ...)   f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ )
723 -
724 -
#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ )
725 -
#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ )
726 -
#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...)   f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ )
707 +
#define CATCH_REC_NEXT1(test, next) \
708 +
  CATCH_DEFER(CATCH_REC_NEXT0)      \
709 +
  (test, next, 0)
710 +
#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next)
711 +
712 +
#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST1))(f, peek, __VA_ARGS__)
713 +
#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST0))(f, peek, __VA_ARGS__)
714 +
#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST1))(f, peek, __VA_ARGS__)
715 +
716 +
#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) \
717 +
  , f(userdata, x) CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD))(f, userdata, peek, __VA_ARGS__)
718 +
#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) \
719 +
  , f(userdata, x) CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD))(f, userdata, peek, __VA_ARGS__)
720 +
#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) \
721 +
  f(userdata, x) CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD))(f, userdata, peek, __VA_ARGS__)
727 722
728 723
// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results,
729 724
// and passes userdata as the first parameter to each invocation,
@@ -733,7 +728,7 @@
Loading
733 728
#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0))
734 729
735 730
#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param)
736 -
#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__
731 +
#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO##__VA_ARGS__
737 732
#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__
738 733
#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF
739 734
#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__)
@@ -756,585 +751,1066 @@
Loading
756 751
#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS_GEN(__VA_ARGS__)>())
757 752
#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))
758 753
#else
759 -
#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS_GEN(__VA_ARGS__)>()))
760 -
#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)))
754 +
#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) \
755 +
  INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper<INTERNAL_CATCH_REMOVE_PARENS_GEN(__VA_ARGS__)>()))
756 +
#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) \
757 +
  INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)))
761 758
#endif
762 759
763 -
#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\
764 -
    CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__)
760 +
#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...) CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST, __VA_ARGS__)
765 761
766 762
#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0)
767 763
#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1)
768 764
#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2)
769 -
#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3)
770 -
#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4)
771 -
#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5)
772 -
#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6)
773 -
#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7)
774 -
#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8)
775 -
#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9)
776 -
#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10)
765 +
#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) \
766 +
  INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3)
767 +
#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) \
768 +
  INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4)
769 +
#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) \
770 +
  INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5)
771 +
#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) \
772 +
  INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6)
773 +
#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) \
774 +
  INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7)
775 +
#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) \
776 +
  INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8)
777 +
#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \
778 +
  INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9)
779 +
#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \
780 +
  INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10)
777 781
778 782
#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
779 783
780 -
#define INTERNAL_CATCH_TYPE_GEN\
781 -
    template<typename...> struct TypeList {};\
782 -
    template<typename...Ts>\
783 -
    constexpr auto get_wrapper() noexcept -> TypeList<Ts...> { return {}; }\
784 -
    template<template<typename...> class...> struct TemplateTypeList{};\
785 -
    template<template<typename...> class...Cs>\
786 -
    constexpr auto get_wrapper() noexcept -> TemplateTypeList<Cs...> { return {}; }\
787 -
    template<typename...>\
788 -
    struct append;\
789 -
    template<typename...>\
790 -
    struct rewrap;\
791 -
    template<template<typename...> class, typename...>\
792 -
    struct create;\
793 -
    template<template<typename...> class, typename>\
794 -
    struct convert;\
795 -
    \
796 -
    template<typename T> \
797 -
    struct append<T> { using type = T; };\
798 -
    template< template<typename...> class L1, typename...E1, template<typename...> class L2, typename...E2, typename...Rest>\
799 -
    struct append<L1<E1...>, L2<E2...>, Rest...> { using type = typename append<L1<E1...,E2...>, Rest...>::type; };\
800 -
    template< template<typename...> class L1, typename...E1, typename...Rest>\
801 -
    struct append<L1<E1...>, TypeList<mpl_::na>, Rest...> { using type = L1<E1...>; };\
802 -
    \
803 -
    template< template<typename...> class Container, template<typename...> class List, typename...elems>\
804 -
    struct rewrap<TemplateTypeList<Container>, List<elems...>> { using type = TypeList<Container<elems...>>; };\
805 -
    template< template<typename...> class Container, template<typename...> class List, class...Elems, typename...Elements>\
806 -
    struct rewrap<TemplateTypeList<Container>, List<Elems...>, Elements...> { using type = typename append<TypeList<Container<Elems...>>, typename rewrap<TemplateTypeList<Container>, Elements...>::type>::type; };\
807 -
    \
808 -
    template<template <typename...> class Final, template< typename...> class...Containers, typename...Types>\
809 -
    struct create<Final, TemplateTypeList<Containers...>, TypeList<Types...>> { using type = typename append<Final<>, typename rewrap<TemplateTypeList<Containers>, Types...>::type...>::type; };\
810 -
    template<template <typename...> class Final, template <typename...> class List, typename...Ts>\
811 -
    struct convert<Final, List<Ts...>> { using type = typename append<Final<>,TypeList<Ts>...>::type; };
812 -
813 -
#define INTERNAL_CATCH_NTTP_1(signature, ...)\
814 -
    template<INTERNAL_CATCH_REMOVE_PARENS(signature)> struct Nttp{};\
815 -
    template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
816 -
    constexpr auto get_wrapper() noexcept -> Nttp<__VA_ARGS__> { return {}; } \
817 -
    template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...> struct NttpTemplateTypeList{};\
818 -
    template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...Cs>\
819 -
    constexpr auto get_wrapper() noexcept -> NttpTemplateTypeList<Cs...> { return {}; } \
820 -
    \
821 -
    template< template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature)>\
822 -
    struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>> { using type = TypeList<Container<__VA_ARGS__>>; };\
823 -
    template< template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class List, INTERNAL_CATCH_REMOVE_PARENS(signature), typename...Elements>\
824 -
    struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>, Elements...> { using type = typename append<TypeList<Container<__VA_ARGS__>>, typename rewrap<NttpTemplateTypeList<Container>, Elements...>::type>::type; };\
825 -
    template<template <typename...> class Final, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...Containers, typename...Types>\
826 -
    struct create<Final, NttpTemplateTypeList<Containers...>, TypeList<Types...>> { using type = typename append<Final<>, typename rewrap<NttpTemplateTypeList<Containers>, Types...>::type...>::type; };
784 +
#define INTERNAL_CATCH_TYPE_GEN                                                                                                         \
785 +
  template<typename...>                                                                                                                 \
786 +
  struct TypeList {                                                                                                                     \
787 +
  };                                                                                                                                    \
788 +
  template<typename... Ts>                                                                                                              \
789 +
  constexpr auto get_wrapper() noexcept->TypeList<Ts...> {                                                                              \
790 +
    return {};                                                                                                                          \
791 +
  }                                                                                                                                     \
792 +
  template<template<typename...> class...>                                                                                              \
793 +
  struct TemplateTypeList {                                                                                                             \
794 +
  };                                                                                                                                    \
795 +
  template<template<typename...> class... Cs>                                                                                           \
796 +
  constexpr auto get_wrapper() noexcept->TemplateTypeList<Cs...> {                                                                      \
797 +
    return {};                                                                                                                          \
798 +
  }                                                                                                                                     \
799 +
  template<typename...>                                                                                                                 \
800 +
  struct append;                                                                                                                        \
801 +
  template<typename...>                                                                                                                 \
802 +
  struct rewrap;                                                                                                                        \
803 +
  template<template<typename...> class, typename...>                                                                                    \
804 +
  struct create;                                                                                                                        \
805 +
  template<template<typename...> class, typename>                                                                                       \
806 +
  struct convert;                                                                                                                       \
807 +
                                                                                                                                        \
808 +
  template<typename T>                                                                                                                  \
809 +
  struct append<T> {                                                                                                                    \
810 +
    using type = T;                                                                                                                     \
811 +
  };                                                                                                                                    \
812 +
  template<template<typename...> class L1, typename... E1, template<typename...> class L2, typename... E2, typename... Rest>            \
813 +
  struct append<L1<E1...>, L2<E2...>, Rest...> {                                                                                        \
814 +
    using type = typename append<L1<E1..., E2...>, Rest...>::type;                                                                      \
815 +
  };                                                                                                                                    \
816 +
  template<template<typename...> class L1, typename... E1, typename... Rest>                                                            \
817 +
  struct append<L1<E1...>, TypeList<mpl_::na>, Rest...> {                                                                               \
818 +
    using type = L1<E1...>;                                                                                                             \
819 +
  };                                                                                                                                    \
820 +
                                                                                                                                        \
821 +
  template<template<typename...> class Container, template<typename...> class List, typename... elems>                                  \
822 +
  struct rewrap<TemplateTypeList<Container>, List<elems...>> {                                                                          \
823 +
    using type = TypeList<Container<elems...>>;                                                                                         \
824 +
  };                                                                                                                                    \
825 +
  template<template<typename...> class Container, template<typename...> class List, class... Elems, typename... Elements>               \
826 +
  struct rewrap<TemplateTypeList<Container>, List<Elems...>, Elements...> {                                                             \
827 +
    using type = typename append<TypeList<Container<Elems...>>, typename rewrap<TemplateTypeList<Container>, Elements...>::type>::type; \
828 +
  };                                                                                                                                    \
829 +
                                                                                                                                        \
830 +
  template<template<typename...> class Final, template<typename...> class... Containers, typename... Types>                             \
831 +
  struct create<Final, TemplateTypeList<Containers...>, TypeList<Types...>> {                                                           \
832 +
    using type = typename append<Final<>, typename rewrap<TemplateTypeList<Containers>, Types...>::type...>::type;                      \
833 +
  };                                                                                                                                    \
834 +
  template<template<typename...> class Final, template<typename...> class List, typename... Ts>                                         \
835 +
  struct convert<Final, List<Ts...>> {                                                                                                  \
836 +
    using type = typename append<Final<>, TypeList<Ts>...>::type;                                                                       \
837 +
  };
838 +
839 +
#define INTERNAL_CATCH_NTTP_1(signature, ...)                                                                                           \
840 +
  template<INTERNAL_CATCH_REMOVE_PARENS(signature)>                                                                                     \
841 +
  struct Nttp {                                                                                                                         \
842 +
  };                                                                                                                                    \
843 +
  template<INTERNAL_CATCH_REMOVE_PARENS(signature)>                                                                                     \
844 +
  constexpr auto get_wrapper() noexcept->Nttp<__VA_ARGS__> {                                                                            \
845 +
    return {};                                                                                                                          \
846 +
  }                                                                                                                                     \
847 +
  template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class...>                                                                  \
848 +
  struct NttpTemplateTypeList {                                                                                                         \
849 +
  };                                                                                                                                    \
850 +
  template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class... Cs>                                                               \
851 +
  constexpr auto get_wrapper() noexcept->NttpTemplateTypeList<Cs...> {                                                                  \
852 +
    return {};                                                                                                                          \
853 +
  }                                                                                                                                     \
854 +
                                                                                                                                        \
855 +
  template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container,                                                           \
856 +
           template<INTERNAL_CATCH_REMOVE_PARENS(signature)>                                                                            \
857 +
           class List,                                                                                                                  \
858 +
           INTERNAL_CATCH_REMOVE_PARENS(signature)>                                                                                     \
859 +
  struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>> {                                                                   \
860 +
    using type = TypeList<Container<__VA_ARGS__>>;                                                                                      \
861 +
  };                                                                                                                                    \
862 +
  template<template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class Container,                                                           \
863 +
           template<INTERNAL_CATCH_REMOVE_PARENS(signature)>                                                                            \
864 +
           class List,                                                                                                                  \
865 +
           INTERNAL_CATCH_REMOVE_PARENS(signature),                                                                                     \
866 +
           typename... Elements>                                                                                                        \
867 +
  struct rewrap<NttpTemplateTypeList<Container>, List<__VA_ARGS__>, Elements...> {                                                      \
868 +
    using type =                                                                                                                        \
869 +
        typename append<TypeList<Container<__VA_ARGS__>>, typename rewrap<NttpTemplateTypeList<Container>, Elements...>::type>::type;   \
870 +
  };                                                                                                                                    \
871 +
  template<template<typename...> class Final, template<INTERNAL_CATCH_REMOVE_PARENS(signature)> class... Containers, typename... Types> \
872 +
  struct create<Final, NttpTemplateTypeList<Containers...>, TypeList<Types...>> {                                                       \
873 +
    using type = typename append<Final<>, typename rewrap<NttpTemplateTypeList<Containers>, Types...>::type...>::type;                  \
874 +
  };
827 875
828 876
#define INTERNAL_CATCH_DECLARE_SIG_TEST0(TestName)
829 -
#define INTERNAL_CATCH_DECLARE_SIG_TEST1(TestName, signature)\
830 -
    template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
831 -
    static void TestName()
832 -
#define INTERNAL_CATCH_DECLARE_SIG_TEST_X(TestName, signature, ...)\
833 -
    template<INTERNAL_CATCH_REMOVE_PARENS(signature)>\
834 -
    static void TestName()
877 +
#define INTERNAL_CATCH_DECLARE_SIG_TEST1(TestName, signature) \
878 +
  template<INTERNAL_CATCH_REMOVE_PARENS(signature)>           \
879 +
  static void TestName()
880 +
#define INTERNAL_CATCH_DECLARE_SIG_TEST_X(TestName, signature, ...) \
881 +
  template<INTERNAL_CATCH_REMOVE_PARENS(signature)>                 \
882 +
  static void TestName()
835