Browse Source

Fixing compiler warnings for implicit casts and unused parameters.

Samuel Jaffe 8 years ago
parent
commit
4b6d76372d

+ 2 - 2
json.cpp

@@ -98,9 +98,9 @@ json::value::int_jt json::value::as_int() const {
 
 json::value::uint_jt json::value::as_uint() const {
   if (data.is<double_jt>()) {
-    return static_cast<int_jt>(data.get<double_jt>());
+    return static_cast<uint_jt>(data.get<double_jt>());
   } else if (data.is<int_jt>() && data.get<int_jt>() >= 0) {
-    return data.get<int_jt>();
+    return static_cast<uint_jt>(data.get<int_jt>());
   } else if (data.is<uint_jt>()) {
     return data.get<uint_jt>();
   } else if (data.is<bool_jt>()) {

+ 2 - 2
json.xcodeproj/xcuserdata/samjaffe.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -16,7 +16,7 @@
 			<key>isShown</key>
 			<false/>
 			<key>orderHint</key>
-			<integer>31</integer>
+			<integer>28</integer>
 		</dict>
 		<key>json.xcscheme</key>
 		<dict>
@@ -30,7 +30,7 @@
 			<key>isShown</key>
 			<false/>
 			<key>orderHint</key>
-			<integer>32</integer>
+			<integer>29</integer>
 		</dict>
 		<key>json_tc.xcscheme</key>
 		<dict>

+ 1 - 1
json/json_binder_parser.hpp

@@ -30,7 +30,7 @@ namespace json {
     void parse(binder::visitor<T, S>&& v, std::istream & in, options opts = allow_all) {
       if (!in) return;
       in.seekg(0, std::ios_base::end);
-      size_t end = in.tellg();
+      std::istream::pos_type end = in.tellg();
       std::unique_ptr<char[]> data{new char[end]};
       in.seekg(0);
       in.read(data.get(), end);

+ 1 - 1
json/json_direct_get_binder.hpp

@@ -106,7 +106,7 @@ namespace json { namespace binder {
     template <>
     struct array_binder_helper<1> {
       template <typename BindOut, typename BindIn>
-      tuple_binder<BindOut> & operator()(tuple_binder<BindOut> & bind, BindIn && ith) const { return bind; }
+      tuple_binder<BindOut> & operator()(tuple_binder<BindOut> & bind, BindIn &&) const { return bind; }
     };
     
     template <std::size_t N>

+ 3 - 3
json_common.cpp

@@ -31,7 +31,7 @@ namespace json {
         { numeric_token_info::octal,       "01234567" },
         { numeric_token_info::hexadecimal, "0123456789aAbBcCdDeEfF" }
       };
-      std::map<char, int_jt> values{
+      std::map<char, uint_jt> values{
         { '0',  0 }, { '1',  1 }, { '2',  2 }, { '3',  3 },
         { '4',  4 }, { '5',  5 }, { '6',  6 }, { '7',  7 },
         { '8',  8 }, { '9',  9 }, { 'a', 10 }, { 'A', 10 },
@@ -44,7 +44,7 @@ namespace json {
         { numeric_token_info::octal,       UINT_JT_MAX /  8 },
         { numeric_token_info::hexadecimal, UINT_JT_MAX / 16 }
       };
-      std::map<numeric_token_info::parse_state, int_jt> last_digits{
+      std::map<numeric_token_info::parse_state, uint_jt> last_digits{
         { numeric_token_info::decimal,     INT_JT_MAX % 10 },
         { numeric_token_info::octal,       INT_JT_MAX %  8 },
         { numeric_token_info::hexadecimal, INT_JT_MAX % 16 }
@@ -88,7 +88,7 @@ namespace json {
       uint_jt const last_digit = last_digits[base];
       val = 0;
       for (char c = *it; it != end; c = *++it) {
-        int_jt digit = values[c];
+        uint_jt digit = values[c];
         if (val > threshold ||
             ( val == threshold && ((it + 1) < end ||
               digit > last_digit))) {

+ 4 - 4
json_common.hpp

@@ -145,22 +145,22 @@ namespace json { namespace helper {
     } else if ( info.is_double || info.parse_numeric() == DOUBLE ) {
       throw json_numeric_exception{"Expected integer, got double"};
     } else if (info.base == numeric_token_info::decimal &&
-               (fls(info.val) > std::numeric_limits<J>::digits + info.is_negative
+               (fls(static_cast<int_jt>(info.val)) > std::numeric_limits<J>::digits + info.is_negative
                || info.val > json::numeric_limits<J>::over)) {
       throw json_numeric_width_exception{"Integer width too small for parsed value"};
     } else if (info.is_negative) {
       if (info.val == json::numeric_limits<J>::over) {
         json = json::numeric_limits<J>::min;
       } else {
-        json = -int_jt(info.val);
+        json = static_cast<J>(-int_jt(info.val));
       }
     } else if (info.val <= uint_jt(INT_JT_MAX)) {
-      json = int_jt(info.val);
+      json = static_cast<J>(int_jt(info.val));
     } else if (std::is_signed<J>::value &&
                info.base == numeric_token_info::decimal) {
       throw json_numeric_exception{"Expected unsigned integer"};
     } else {
-      json = info.val;
+      json = static_cast<J>(info.val);
     }
     data = info.it;
   }

+ 1 - 1
json_parser.cpp

@@ -67,7 +67,7 @@ namespace json {
     
     void parse(json::value& json, std::istream & in) {
       in.seekg(0, std::ios_base::end);
-      size_t end = in.tellg();
+      std::istream::pos_type end = in.tellg();
       std::unique_ptr<char[]> data{new char[end]};
       in.seekg(0);
       in.read(data.get(), end);