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

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

Issue 143473003: Generate ax enums from idl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Caught Blink enum conversion bug! Created 6 years, 10 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
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 cpp_util 7 import cpp_util
8 import schema_util 8 import schema_util
9 import util_cc_helper 9 import util_cc_helper
10 10
(...skipping 28 matching lines...) Expand all
39 c = Code() 39 c = Code()
40 (c.Append(cpp_util.CHROMIUM_LICENSE) 40 (c.Append(cpp_util.CHROMIUM_LICENSE)
41 .Append() 41 .Append()
42 .Append(cpp_util.GENERATED_FILE_MESSAGE % self._namespace.source_file) 42 .Append(cpp_util.GENERATED_FILE_MESSAGE % self._namespace.source_file)
43 .Append() 43 .Append()
44 .Append(self._util_cc_helper.GetIncludePath()) 44 .Append(self._util_cc_helper.GetIncludePath())
45 .Append('#include "base/logging.h"') 45 .Append('#include "base/logging.h"')
46 .Append('#include "base/strings/string_number_conversions.h"') 46 .Append('#include "base/strings/string_number_conversions.h"')
47 .Append('#include "base/strings/utf_string_conversions.h"') 47 .Append('#include "base/strings/utf_string_conversions.h"')
48 .Append('#include "%s/%s.h"' % 48 .Append('#include "%s/%s.h"' %
49 (self._namespace.source_file_dir, self._namespace.unix_name)) 49 (self._namespace.source_file_dir, self._namespace.short_filename))
50 .Cblock(self._type_helper.GenerateIncludes(include_soft=True)) 50 .Cblock(self._type_helper.GenerateIncludes(include_soft=True))
51 .Append() 51 .Append()
52 .Concat(cpp_util.OpenNamespace(self._cpp_namespace)) 52 .Concat(cpp_util.OpenNamespace(self._cpp_namespace))
53 .Cblock(self._type_helper.GetNamespaceStart()) 53 .Cblock(self._type_helper.GetNamespaceStart())
54 ) 54 )
55 if self._namespace.properties: 55 if self._namespace.properties:
56 (c.Append('//') 56 (c.Append('//')
57 .Append('// Properties') 57 .Append('// Properties')
58 .Append('//') 58 .Append('//')
59 .Append() 59 .Append()
(...skipping 24 matching lines...) Expand all
84 (c.Append('//') 84 (c.Append('//')
85 .Append('// Events') 85 .Append('// Events')
86 .Append('//') 86 .Append('//')
87 .Append() 87 .Append()
88 ) 88 )
89 for event in self._namespace.events.values(): 89 for event in self._namespace.events.values():
90 c.Cblock(self._GenerateEvent(event)) 90 c.Cblock(self._GenerateEvent(event))
91 (c.Concat(self._type_helper.GetNamespaceEnd()) 91 (c.Concat(self._type_helper.GetNamespaceEnd())
92 .Cblock(cpp_util.CloseNamespace(self._cpp_namespace)) 92 .Cblock(cpp_util.CloseNamespace(self._cpp_namespace))
93 ) 93 )
94 c.Append()
94 return c 95 return c
95 96
96 def _GenerateType(self, cpp_namespace, type_): 97 def _GenerateType(self, cpp_namespace, type_):
97 """Generates the function definitions for a type. 98 """Generates the function definitions for a type.
98 """ 99 """
99 classname = cpp_util.Classname(schema_util.StripNamespace(type_.name)) 100 classname = cpp_util.Classname(schema_util.StripNamespace(type_.name))
100 c = Code() 101 c = Code()
101 102
102 if type_.functions: 103 if type_.functions:
103 # Wrap functions within types in the type's namespace. 104 # Wrap functions within types in the type's namespace.
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 if self._generate_error_messages: 937 if self._generate_error_messages:
937 params = list(params) + ['base::string16* error'] 938 params = list(params) + ['base::string16* error']
938 return ', '.join(str(p) for p in params) 939 return ', '.join(str(p) for p in params)
939 940
940 def _GenerateArgs(self, args): 941 def _GenerateArgs(self, args):
941 """Builds the argument list for a function, given an array of arguments. 942 """Builds the argument list for a function, given an array of arguments.
942 """ 943 """
943 if self._generate_error_messages: 944 if self._generate_error_messages:
944 args = list(args) + ['error'] 945 args = list(args) + ['error']
945 return ', '.join(str(a) for a in args) 946 return ', '.join(str(a) for a in args)
OLDNEW
« no previous file with comments | « content/renderer/accessibility/renderer_accessibility_focus_only.cc ('k') | tools/json_schema_compiler/compiler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698