buffet: Clean up property system in preparation for Array support

- Made ObjectSchema::PropFromJson a public method to allow parsing
  type definitions for other elements, not only object properties
  (it will be used to parse "items" definition for arrays). Made this
  method to return std::unique_ptr<PropType> instead of putting the
  type directly into property map.

- Cleaned up error reporting when parsing type definitions from JSON.
  Now PropFromJson does not refer to any particular property name
  in error messages. The property name is added on the level higher
  (at ObjectSchema::FromJson).

- Moved GetObjectSchema() method from base PropType class to the
  only place where it is being used right now - ObjectPropType.

- Switched value constraints to use generic PropType instead of
  ObjectSchema which will allow to add support for constraints
  on more complex types (such as arrays). Also added
  CloneWithNoConstraints() method to base class to help implement
  OneOf() constraint of polymorphic type (will be used more in the
  following CLs to support arrays of values).

- Fixed some formatting of function definitions.

- Moved static methods in object_schema.cc into an anonymous namespace
  at the beginning of the source file.

BUG=brillo:107
TEST=`FEATURES=test emerge-link buffet`

Change-Id: I86dd6c0780a46f4996ffe698dffb5d409699ff31
Reviewed-on: https://chromium-review.googlesource.com/260852
Reviewed-by: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Alex Vakulenko <avakulenko@chromium.org>
Trybot-Ready: Alex Vakulenko <avakulenko@chromium.org>
11 files changed
tree: cec5a67240bf2206d50cdbb30d2ab8c874c06475
  1. buffet/