Skip to content

Commit

Permalink
Fixed hashed values in JSON for signed ints.
Browse files Browse the repository at this point in the history
Change-Id: Iae389c6dc9776058b39f4017d30efbf9580aced1
Tested: on Linux.
  • Loading branch information
aardappel committed Apr 18, 2017
1 parent b627b7c commit 46497e4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/idl_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int32_t>(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<int64_t>(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());
Expand Down

0 comments on commit 46497e4

Please sign in to comment.