Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 Create(self, any_prop, src): | |
| 13 """Create a new Any instance, populated with |src|. | |
| 14 | |
| 15 src: Value* | |
| 16 dst: Type* | |
|
not at google - send to devlin
2012/02/28 22:41:17
The parameters and documentation seem wrong. Where
not at google - send to devlin
2012/03/01 07:09:37
Ping. I can't see this function being called anywh
| |
| 17 """ | |
| 18 return 'new %s' % ANY_CLASS | |
| 19 | |
| 20 def CopyInto(self, any_prop, src, dst): | |
| 21 """Copy |src| into |dst|.|any_prop|. | |
| 22 | |
| 23 src: Value* | |
| 24 dst: Type* | |
| 25 """ | |
| 26 if any_prop.optional: | |
| 27 return '%s->%s->CopyFrom(*%s)' % (dst, any_prop.name, src) | |
| 28 else: | |
| 29 return '%s->%s.CopyFrom(*%s)' % (dst, any_prop.name, src) | |
| 30 | |
| 31 def GetValue(self, any_prop, var): | |
| 32 """Get |var| as a const Value&. | |
| 33 | |
| 34 var: Any* or Any | |
| 35 """ | |
| 36 if any_prop.optional: | |
| 37 return '%s->value()' % var | |
| 38 else: | |
| 39 return '%s.value()' % var | |
| 40 | |
| OLD | NEW |