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

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

Issue 10907151: Extensions Docs Server: Enum values do not show up if enum is a type (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: schema compiler enum fix Created 8 years, 3 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 | « no previous file | tools/json_schema_compiler/cpp_type_generator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from code import Code 5 from code import Code
6 from model import PropertyType 6 from model import PropertyType
7 import any_helper 7 import any_helper
8 import cpp_util 8 import cpp_util
9 import model 9 import model
10 import schema_util 10 import schema_util
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 c.Sblock('scoped_ptr<base::Value> CreateEnumValue(%s %s) {' % ( 742 c.Sblock('scoped_ptr<base::Value> CreateEnumValue(%s %s) {' % (
743 classname, classname.lower())) 743 classname, classname.lower()))
744 c.Sblock('switch (%s) {' % classname.lower()) 744 c.Sblock('switch (%s) {' % classname.lower())
745 745
746 enum_prop = self._cpp_type_generator.GetReferencedProperty(prop) 746 enum_prop = self._cpp_type_generator.GetReferencedProperty(prop)
747 for enum_value in enum_prop.enum_values: 747 for enum_value in enum_prop.enum_values:
748 c.Concat(self._GenerateReturnCase( 748 c.Concat(self._GenerateReturnCase(
749 '%s_%s' % (classname.upper(), enum_value.upper()), 749 '%s_%s' % (classname.upper(), enum_value.upper()),
750 'scoped_ptr<base::Value>(base::Value::CreateStringValue("%s"))' % 750 'scoped_ptr<base::Value>(base::Value::CreateStringValue("%s"))' %
751 enum_value)) 751 enum_value))
752 (c.Eblock('}') 752 (c.Append('default:')
753 .Append('NOTREACHED();') 753 .Append(' NOTREACHED();')
not at google - send to devlin 2012/09/11 23:07:43 is this necessary?
cduvall 2012/09/11 23:10:38 I just had it because that's what used to be there
not at google - send to devlin 2012/09/11 23:14:09 Used to be there when?
cduvall 2012/09/11 23:18:28 Were you talking about the NOTREACHED or the defau
not at google - send to devlin 2012/09/11 23:19:52 Yeah, the thing abou the default case vs the fall-
754 .Append('return scoped_ptr<base::Value>();') 754 .Eblock('}')
755 .Eblock('}') 755 .Append('return scoped_ptr<base::Value>();')
756 ) 756 .Eblock('}'))
757 return c 757 return c
758 758
759 # TODO(chebert): This is basically the same as GenerateCreateEnumTypeValue(). 759 # TODO(chebert): This is basically the same as GenerateCreateEnumTypeValue().
760 # The plan is to phase out the old-style enums, and make all enums into REF 760 # The plan is to phase out the old-style enums, and make all enums into REF
761 # types. 761 # types.
762 def _GenerateCreateEnumValue(self, cpp_namespace, prop): 762 def _GenerateCreateEnumValue(self, cpp_namespace, prop):
763 """Generates CreateEnumValue() that returns the base::StringValue 763 """Generates CreateEnumValue() that returns the base::StringValue
764 representation of an enum. 764 representation of an enum.
765 """ 765 """
766 c = Code() 766 c = Code()
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 """ 898 """
899 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ == 899 return (self._cpp_type_generator.GetReferencedProperty(prop).type_ ==
900 PropertyType.ARRAY) 900 PropertyType.ARRAY)
901 901
902 def _IsFundamentalOrFundamentalRef(self, prop): 902 def _IsFundamentalOrFundamentalRef(self, prop):
903 """Determines if this property is a Fundamental type or is a ref to a 903 """Determines if this property is a Fundamental type or is a ref to a
904 Fundamental type. 904 Fundamental type.
905 """ 905 """
906 return (self._cpp_type_generator.GetReferencedProperty(prop).type_. 906 return (self._cpp_type_generator.GetReferencedProperty(prop).type_.
907 is_fundamental) 907 is_fundamental)
OLDNEW
« no previous file with comments | « no previous file | tools/json_schema_compiler/cpp_type_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698