From 0bf053197c6c947bdace789ba150bfea79053171 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 9 Feb 2018 20:09:37 -0800 Subject: [PATCH] ircd::json: Massage away json::value template ctor. --- include/ircd/json/value.h | 69 ++++----------------------------------- ircd/m/m.cc | 2 +- ircd/m/room.cc | 2 +- modules/key/server.cc | 2 +- 4 files changed, 9 insertions(+), 66 deletions(-) diff --git a/include/ircd/json/value.h b/include/ircd/json/value.h index f1a4e1d4d..ad7329506 100644 --- a/include/ircd/json/value.h +++ b/include/ircd/json/value.h @@ -85,9 +85,11 @@ struct ircd::json::value explicit operator int64_t() const; explicit operator std::string() const; ///< NOTE full stringify() of value - template explicit value(const T &specialized); value(const string_view &sv, const enum type &); template value(const char (&)[N]); + explicit value(const int64_t &); + explicit value(const double &); + explicit value(const bool &); value(const char *const &s); value(const string_view &sv); value(const struct member *const &, const size_t &len); @@ -117,20 +119,6 @@ struct ircd::json::value friend std::ostream &operator<<(std::ostream &, const value &); }; -namespace ircd::json -{ - template<> value::value(const double &floating); - template<> value::value(const uint64_t &integer); - template<> value::value(const int64_t &integer); - template<> value::value(const float &floating); - template<> value::value(const uint32_t &integer); - template<> value::value(const int32_t &integer); - template<> value::value(const uint16_t &integer); - template<> value::value(const int16_t &integer); - template<> value::value(const bool &boolean); - template<> value::value(const std::string &str); -} - static_assert(sizeof(ircd::json::value) == 16, ""); inline @@ -174,24 +162,11 @@ ircd::json::value::value(const char (&str)[N]) ,floats{false} {} -template<> inline -ircd::json::value::value(const std::string &str) -:value{string_view{str}} -{} - inline ircd::json::value::value(const string_view &sv) :value{sv, json::type(sv, std::nothrow)} {} -template -ircd::json::value::value(const T &t) -:value{static_cast(t)} -{ - static_assert(std::is_base_of() || - std::is_convertible(), ""); -} - inline ircd::json::value::value(const nullptr_t &) :value @@ -199,7 +174,7 @@ ircd::json::value::value(const nullptr_t &) literal_null, type::LITERAL }{} -template<> inline +inline ircd::json::value::value(const bool &boolean) :value { @@ -255,7 +230,7 @@ ircd::json::value::value(std::unique_ptr object, object.release(); } -template<> inline +inline ircd::json::value::value(const int64_t &integer) :integer{integer} ,len{0} @@ -265,7 +240,7 @@ ircd::json::value::value(const int64_t &integer) ,floats{false} {} -template<> inline +inline ircd::json::value::value(const double &floating) :floating{floating} ,len{0} @@ -275,38 +250,6 @@ ircd::json::value::value(const double &floating) ,floats{true} {} -template<> -__attribute__((warning("uint64_t narrows to int64_t when used in json::value"))) -inline -ircd::json::value::value(const uint64_t &integer) -:value{int64_t(integer)} -{} - -template<> inline -ircd::json::value::value(const float &floating) -:value{double(floating)} -{} - -template<> inline -ircd::json::value::value(const int32_t &integer) -:value{int64_t(integer)} -{} - -template<> inline -ircd::json::value::value(const uint32_t &integer) -:value{int64_t(integer)} -{} - -template<> inline -ircd::json::value::value(const int16_t &integer) -:value{int64_t(integer)} -{} - -template<> inline -ircd::json::value::value(const uint16_t &integer) -:value{int64_t(integer)} -{} - inline ircd::json::value::value(value &&other) noexcept diff --git a/ircd/m/m.cc b/ircd/m/m.cc index ab7cb8647..bbc64424b 100644 --- a/ircd/m/m.cc +++ b/ircd/m/m.cc @@ -178,7 +178,7 @@ ircd::m::init_listener(const json::object &conf, { { "name", name }, { "host", host }, - { "port", opts.get("port", 8448) }, + { "port", opts.get("port", 8448L) }, { "ssl_certificate_file_pem", conf["tls_certificate_path"] }, { "ssl_private_key_file_pem", conf["tls_private_key_path"] }, { "ssl_tmp_dh_file", conf["tls_dh_params_path"] }, diff --git a/ircd/m/room.cc b/ircd/m/room.cc index af80f42e0..20469bab7 100644 --- a/ircd/m/room.cc +++ b/ircd/m/room.cc @@ -56,7 +56,7 @@ ircd::m::create(const id::room &room_id, json::iov::set _set[] { - { event, { "depth", 1 }}, + { event, { "depth", 0L }}, { event, { "type", "m.room.create" }}, { event, { "state_key", "" }}, }; diff --git a/modules/key/server.cc b/modules/key/server.cc index e16386432..67cca6da7 100644 --- a/modules/key/server.cc +++ b/modules/key/server.cc @@ -107,7 +107,7 @@ void foop() std::cout << test(json::strung(json::members { - { "one", 1 }, + { "one", 1L }, { "two", "Two" } })) << std::endl;