@@ -163,7 +163,7 @@ class any {
163 mutable cstring r;
163 mutable cstring r;
164 mutable fn f;
164 mutable fn f;
165 mutable eff_fn e;
165 mutable eff_fn e;
166− mutable void * u;
166+ mutable void * v;
167 mutable managed<string> s;
167 mutable managed<string> s;
168 mutable managed<array> a;
168 mutable managed<array> a;
169 mutable managed<Closure> l;
169 mutable managed<Closure> l;
@@ -181,15 +181,12 @@ class any {
182 any(const double val) noexcept : tag(Tag::Double), d(val) {}
182 any(const double val) noexcept : tag(Tag::Double), d(val) {}
183 any(const char val) noexcept : tag(Tag::Character), c(val) {}
183 any(const char val) noexcept : tag(Tag::Character), c(val) {}
184+ any(const char32_t val) noexcept : tag(Tag::Integer), i(val) {}
185 template <typename T, typename = typename std::enable_if<std::is_same<bool,T>::value>::type>
186 template <typename T, typename = typename std::enable_if<std::is_same<bool,T>::value>::type>
186 any(const T val) noexcept : tag(Tag::Boolean), b(val) {}
187 any(const T val) noexcept : tag(Tag::Boolean), b(val) {}
189− any(const char (&val)[N]) noexcept : tag(Tag::StringLiteral), r(val) {}
190 any(const char * val) : tag(Tag::String), s(make_managed<string>(val)) {}
189 any(const char * val) : tag(Tag::String), s(make_managed<string>(val)) {}
191− any(char * val) : tag(Tag::String), s(make_managed<string>(val)) {}
193 any(const string& val) : tag(Tag::String), s(make_managed<string>(val)) {}
190 any(const string& val) : tag(Tag::String), s(make_managed<string>(val)) {}
194 any(string&& val) noexcept : tag(Tag::String), s(make_managed<string>(std::move(val))) {}
191 any(string&& val) noexcept : tag(Tag::String), s(make_managed<string>(std::move(val))) {}
@@ -240,9 +237,9 @@ class any {
240 // Explicit void* to raw pointer value
237 // Explicit void* to raw pointer value
241 template <typename T>
238 template <typename T>
242 any(const T& val, typename std::enable_if<std::is_same<T,void*>::value>::type* = 0) noexcept
239 any(const T& val, typename std::enable_if<std::is_same<T,void*>::value>::type* = 0) noexcept
243− : tag(Tag::RawPointer), u(val) {}
240+ : tag(Tag::RawPointer), v(val) {}
245− any(nullptr_t) noexcept : tag(Tag::RawPointer), u(nullptr) {}
242+ any(nullptr_t) noexcept : tag(Tag::RawPointer), v(nullptr) {}
248#if !defined(USE_GC)
245#if !defined(USE_GC)
@@ -272,7 +269,7 @@ class any {
272 case Tag::StringLiteral: r = other.r; break;
269 case Tag::StringLiteral: r = other.r; break;
273 case Tag::Function: f = other.f; break;
270 case Tag::Function: f = other.f; break;
274 case Tag::EffFunction: e = other.e; break;
271 case Tag::EffFunction: e = other.e; break;
275− case Tag::RawPointer: u = other.u; break;
272+ case Tag::RawPointer: v = other.v; break;
277 case Tag::String: new (&s) managed<string>(move_if_rvalue<T>(other.s)); break;
274 case Tag::String: new (&s) managed<string>(move_if_rvalue<T>(other.s)); break;
278 case Tag::Array: new (&a) managed<array>(move_if_rvalue<T>(other.a)); break;
275 case Tag::Array: new (&a) managed<array>(move_if_rvalue<T>(other.a)); break;
@@ -340,7 +337,7 @@ class any {
340 operator bool() const;
337 operator bool() const;
341 operator char() const;
338 operator char() const;
342 operator size_t() const;
339 operator size_t() const;
343− operator cstring() const;
340+ operator const char *() const;
344 operator const array&() const;
341 operator const array&() const;
346 auto operator[](const size_t) const -> const any&;
343 auto operator[](const size_t) const -> const any&;
@@ -354,66 +351,51 @@ class any {
354 auto rawPointer() const -> void* {
351 auto rawPointer() const -> void* {
355 const any& variant = unthunkVariant(*this);
352 const any& variant = unthunkVariant(*this);
356 assert(tag == Tag::RawPointer);
353 assert(tag == Tag::RawPointer);
357− return variant.u;
354+ return variant.v;
360 static auto unthunkVariant(const any&) -> const any&;
357 static auto unthunkVariant(const any&) -> const any&;
362− #define DEFINE_OPERATOR(op, ty, rty) \
359+ #define DEFINE_OPERATOR(op) \
360+ template <typename T> \
363− inline friend auto operator op (const any& lhs, ty rhs) -> rty { \
361+ inline friend auto operator op (const any& lhs, T rhs) -> T { \
364− return (ty)lhs op rhs; \
362+ return static_cast<T>(lhs) op rhs; \
364+ template <typename T> \
366− inline friend auto operator op (ty lhs, const any& rhs) -> rty { \
365+ inline friend auto operator op (T lhs, const any& rhs) -> T { \
367− return lhs op (ty)rhs; \
366+ return lhs op static_cast<T>(rhs); \
368+ friend auto operator op (const any&, const any&) -> any;
370− #define DECLARE_COMPARISON_OPERATOR(op) \
370+ #define DEFINE_COMPARISON_OPERATOR(op) \
371+ template <typename T> \
372+ inline friend auto operator op (const any& lhs, T rhs) -> bool { \
373+ return static_cast<T>(lhs) op rhs; \
375+ template <typename T> \
376+ inline friend auto operator op (T lhs, const any& rhs) -> bool { \
377+ return lhs op static_cast<T>(rhs); \
371 friend auto operator op (const any&, const any&) -> bool; \
379 friend auto operator op (const any&, const any&) -> bool; \
372− DEFINE_OPERATOR(op, int, bool) \
373− DEFINE_OPERATOR(op, double, bool) \
374− DEFINE_OPERATOR(op, char, bool) \
375− DEFINE_OPERATOR(op, bool, bool) \
376 friend auto operator op (const any&, const char * const) -> bool; \
380 friend auto operator op (const any&, const char * const) -> bool; \
377 friend auto operator op (const char * const, const any&) -> bool;
381 friend auto operator op (const char * const, const any&) -> bool;
379− DECLARE_COMPARISON_OPERATOR(==)
383+ DEFINE_COMPARISON_OPERATOR(==)
380− DECLARE_COMPARISON_OPERATOR(!=)
384+ DEFINE_COMPARISON_OPERATOR(!=)
381− DECLARE_COMPARISON_OPERATOR(<)
385+ DEFINE_COMPARISON_OPERATOR(<)
382− DECLARE_COMPARISON_OPERATOR(<=)
386+ DEFINE_COMPARISON_OPERATOR(<=)
383− DECLARE_COMPARISON_OPERATOR(>)
387+ DEFINE_COMPARISON_OPERATOR(>)
384− DECLARE_COMPARISON_OPERATOR(>=)
388+ DEFINE_COMPARISON_OPERATOR(>=)
386− friend auto operator+(const any&, const any&) -> any;
390+ DEFINE_OPERATOR(+)
388− DEFINE_OPERATOR(+, int, int)
389− DEFINE_OPERATOR(+, double, double)
390− DEFINE_OPERATOR(+, char, char)
391 friend auto operator+(const any& lhs, const char * const rhs) -> string;
396 friend auto operator+(const any& lhs, const char * const rhs) -> string;
392 friend auto operator+(const char * const lhs, const any& rhs) -> string;
397 friend auto operator+(const char * const lhs, const any& rhs) -> string;
394− friend auto operator-(const any&, const any&) -> any;
396− DEFINE_OPERATOR(-, int, int)
397− DEFINE_OPERATOR(-, double, double)
398− DEFINE_OPERATOR(-, char, char)
400− friend auto operator*(const any&, const any&) -> any;
402− DEFINE_OPERATOR(*, int, int)
403− DEFINE_OPERATOR(*, double, double)
404− DEFINE_OPERATOR(*, char, char)
406− friend auto operator/(const any&, const any&) -> any;
408− DEFINE_OPERATOR(/, int, int)
409− DEFINE_OPERATOR(/, double, double)
410− DEFINE_OPERATOR(/, char, char)
412− friend auto operator%(const any&, const any&) -> any;
414− DEFINE_OPERATOR(%, int, int)
415− DEFINE_OPERATOR(%, char, char)
417 friend auto operator-(const any&) -> any; // unary negate
399 friend auto operator-(const any&) -> any; // unary negate
419}; // class any
401}; // class any
@@ -447,7 +429,7 @@ constexpr auto cast(const T& a) -> const T& {
447template <typename T>
429template <typename T>
448inline auto cast(const any& a) ->
430inline auto cast(const any& a) ->
449 typename std::enable_if<std::is_arithmetic<T>::value ||
431 typename std::enable_if<std::is_arithmetic<T>::value ||
450− std::is_same<T,cstring>::value, T>::type {
432+ std::is_same<T,const char *>::value, T>::type {
451 return a;
433 return a;
@@ -466,7 +448,7 @@ inline auto cast(const any& a) ->
466template <typename T,
448template <typename T,
467 typename = typename std::enable_if<std::is_pointer<T>::value &&
449 typename = typename std::enable_if<std::is_pointer<T>::value &&
468 !std::is_same<T,void*>::value &&
450 !std::is_same<T,void*>::value &&
469− !std::is_same<T,cstring>::value>::type>
451+ !std::is_same<T,const char *>::value>::type>
470inline auto cast(const any& a) -> T {
452inline auto cast(const any& a) -> T {
471 return static_cast<T>(a.extractPointer(IF_DEBUG(Private::TagHelper<T>::tag)));
453 return static_cast<T>(a.extractPointer(IF_DEBUG(Private::TagHelper<T>::tag)));
@@ -568,6 +550,6 @@ namespace data {
568#undef WITH_ALLOCATOR
550#undef WITH_ALLOCATOR
569#undef IS_POINTER_TYPE
551#undef IS_POINTER_TYPE
570#undef DEFINE_OPERATOR
552#undef DEFINE_OPERATOR
571−#undef DECLARE_COMPARISON_OPERATOR
553+#undef DEFINE_COMPARISON_OPERATOR
573#endif // PureScript_HH
555#endif // PureScript_HH