From 89a17f7839bfedeee84ae1dbc178fb13dfe03eba Mon Sep 17 00:00:00 2001 From: reillyg <reillyg@chromium.org> Date: Tue, 5 May 2015 19:34:27 -0700 Subject: Add support for passing errors through PopulateArrayFromList. When a JSON schema includes an array of objects PopulateArrayFromList calls a specialized PopulateItem instance for the generated object type. When compiled with generate_error_messages=True the generated type's Populate method expects to receive an error parameter. This patch adds versions of the PopulateArrayFromList and PopulateItem functions that pass through and provide that parameter. This capability is required for a new manifest key that will include an array of objects being added as part of issue 468955. Review URL: https://codereview.chromium.org/1128523003 Cr-Commit-Position: refs/heads/master@{#328471} --- tools/json_schema_compiler/cc_generator.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tools/json_schema_compiler/cc_generator.py') diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py index 6faac39..4fa55be 100644 --- a/tools/json_schema_compiler/cc_generator.py +++ b/tools/json_schema_compiler/cc_generator.py @@ -778,10 +778,9 @@ class _Generator(object): failure_value, is_ptr=is_ptr)) else: - c.Sblock('if (!%s) {' % self._util_cc_helper.PopulateArrayFromList( - 'list', - dst_var, - is_ptr)) + c.Sblock('if (!%s(%s)) {' % ( + self._util_cc_helper.PopulateArrayFromListFunction(is_ptr), + self._GenerateArgs(('*list', '&%(dst_var)s')))) c.Concat(self._GenerateError( '"unable to populate array \'%%(parent_key)s\'"')) if is_ptr and self._generate_error_messages: -- cgit v1.1