From 46497e4f9ad2f8193dc12cad02d525f93c8f4fd0 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Mon, 17 Apr 2017 17:40:02 -0700 Subject: [PATCH] Fixed hashed values in JSON for signed ints. Change-Id: Iae389c6dc9776058b39f4017d30efbf9580aced1 Tested: on Linux. --- src/idl_parser.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp index ce9df4c80..8e618fe80 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -1098,14 +1098,24 @@ CheckedError Parser::ParseHash(Value &e, FieldDef* field) { assert(field); Value *hash_name = field->attributes.Lookup("hash"); switch (e.type.base_type) { - case BASE_TYPE_INT: + case BASE_TYPE_INT: { + auto hash = FindHashFunction32(hash_name->constant.c_str()); + int32_t hashed_value = static_cast(hash(attribute_.c_str())); + e.constant = NumToString(hashed_value); + break; + } case BASE_TYPE_UINT: { auto hash = FindHashFunction32(hash_name->constant.c_str()); uint32_t hashed_value = hash(attribute_.c_str()); e.constant = NumToString(hashed_value); break; } - case BASE_TYPE_LONG: + case BASE_TYPE_LONG: { + auto hash = FindHashFunction64(hash_name->constant.c_str()); + int64_t hashed_value = static_cast(hash(attribute_.c_str())); + e.constant = NumToString(hashed_value); + break; + } case BASE_TYPE_ULONG: { auto hash = FindHashFunction64(hash_name->constant.c_str()); uint64_t hashed_value = hash(attribute_.c_str());