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

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

Issue 10701012: JSON Schema Compiler: Added event compilation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reworked Create functions and lots of tests. Created 8 years, 5 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
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 import code 5 import code
6 import cpp_util 6 import cpp_util
7 7
8 import json 8 import json
9 import os 9 import os
10 import re 10 import re
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 def CapitalizeFirstLetter(self, value): 72 def CapitalizeFirstLetter(self, value):
73 return value[0].capitalize() + value[1:] 73 return value[0].capitalize() + value[1:]
74 74
75 def GenerateFunctionRegistry(self): 75 def GenerateFunctionRegistry(self):
76 c = code.Code() 76 c = code.Code()
77 c.Sblock("class GeneratedFunctionRegistry {") 77 c.Sblock("class GeneratedFunctionRegistry {")
78 c.Append("public:") 78 c.Append("public:")
79 c.Sblock("static void RegisterAll(ExtensionFunctionRegistry* registry) {") 79 c.Sblock("static void RegisterAll(ExtensionFunctionRegistry* registry) {")
80 for namespace in self._model.namespaces.values(): 80 for namespace in self._model.namespaces.values():
81 namespace_name = self.CapitalizeFirstLetter(namespace.name.replace(
82 "experimental.", ""))
81 for function in namespace.functions.values(): 83 for function in namespace.functions.values():
82 if function.nocompile: 84 if function.nocompile:
83 continue 85 continue
84 namespace_name = self.CapitalizeFirstLetter(namespace.name.replace(
85 "experimental.", ""))
86 function_name = namespace_name + self.CapitalizeFirstLetter( 86 function_name = namespace_name + self.CapitalizeFirstLetter(
87 function.name) 87 function.name)
88 c.Append("registry->RegisterFunction<%sFunction>();" % ( 88 c.Append("registry->RegisterFunction<%sFunction>();" % function_name)
89 function_name))
90 c.Eblock("}") 89 c.Eblock("}")
91 c.Eblock("};") 90 c.Eblock("};")
92 c.Append() 91 c.Append()
93 return c 92 return c
94 93
95 def GenerateSchemasHeader(self): 94 def GenerateSchemasHeader(self):
96 """Generates a code.Code object for the generated schemas .h file""" 95 """Generates a code.Code object for the generated schemas .h file"""
97 c = code.Code() 96 c = code.Code()
98 c.Append('#include <map>') 97 c.Append('#include <map>')
99 c.Append('#include <string>') 98 c.Append('#include <string>')
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 for index, line in enumerate(lines): 136 for index, line in enumerate(lines):
138 line = ' "%s"' % line 137 line = ' "%s"' % line
139 if index == len(lines) - 1: 138 if index == len(lines) - 1:
140 line += ';' 139 line += ';'
141 c.Append(line) 140 c.Append(line)
142 c.Eblock('}') 141 c.Eblock('}')
143 c.Append() 142 c.Append()
144 c.Concat(self._cpp_type_generator.GetRootNamespaceEnd()) 143 c.Concat(self._cpp_type_generator.GetRootNamespaceEnd())
145 c.Append() 144 c.Append()
146 return c 145 return c
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698