External references for the object API thru a resolver function.

This allows hashed string fields to be used for lookup of any
C++ objects, a pointer to which are then stored in the object
besides the original hash for easy access.

Change-Id: I2247a13c349b905f1c54660becde2c818ad23e97
Tested: on Linux.
Bug: 30204449
This commit is contained in:
Wouter van Oortmerssen
2016-10-05 16:59:15 -07:00
parent b2e55c556e
commit dc2fa215b8
10 changed files with 161 additions and 76 deletions

View File

@@ -657,6 +657,11 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
"only int, uint, long and ulong data types support hashing.");
}
}
auto cpp_type = field->attributes.Lookup("cpp_type");
if (cpp_type) {
if (!hash_name)
return Error("cpp_type can only be used with a hashed field");
}
if (field->deprecated && struct_def.fixed)
return Error("can't deprecate fields in a struct");
field->required = field->attributes.Lookup("required") != nullptr;