Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: tools/json_schema_compiler/any_helper.py

Issue 11827026: Overhaul JSON Schema Compiler to support a number of features required to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/json_schema_compiler/any.cc ('k') | tools/json_schema_compiler/api_gen_util.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 ANY_NAMESPACE = 'json_schema_compiler::any'
6 ANY_CLASS = ANY_NAMESPACE + '::Any'
7
8 class AnyHelper(object):
9 """A util class that generates code that uses
10 tools/json_schema_compiler/any.cc.
11 """
12 def Init(self, any_prop, src, dst):
13 """Initialize |dst|.|any_prop| to |src|.
14
15 src: Value*
16 dst: Type*
17 """
18 if any_prop.optional:
19 return '%s->%s->Init(*%s)' % (dst, any_prop.unix_name, src)
20 else:
21 return '%s->%s.Init(*%s)' % (dst, any_prop.unix_name, src)
22
23 def GetValue(self, any_prop, var):
24 """Get |var| as a const Value&.
25
26 var: Any* or Any
27 """
28 if any_prop.optional:
29 return '%s->value()' % var
30 else:
31 return '%s.value()' % var
32
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/any.cc ('k') | tools/json_schema_compiler/api_gen_util.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698