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

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: Synced. 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 70
71 def CapitalizeFirstLetter(self, value): 71 def CapitalizeFirstLetter(self, value):
72 return value[0].capitalize() + value[1:] 72 return value[0].capitalize() + value[1:]
73 73
74 def GenerateFunctionRegistry(self): 74 def GenerateFunctionRegistry(self):
75 c = code.Code() 75 c = code.Code()
76 c.Sblock("class GeneratedFunctionRegistry {") 76 c.Sblock("class GeneratedFunctionRegistry {")
77 c.Append("public:") 77 c.Append("public:")
78 c.Sblock("static void RegisterAll(ExtensionFunctionRegistry* registry) {") 78 c.Sblock("static void RegisterAll(ExtensionFunctionRegistry* registry) {")
79 for namespace in self._model.namespaces.values(): 79 for namespace in self._model.namespaces.values():
80 namespace_name = self.CapitalizeFirstLetter(namespace.name.replace(
81 "experimental.", ""))
80 for function in namespace.functions.values(): 82 for function in namespace.functions.values():
81 if function.nocompile: 83 if function.nocompile:
82 continue 84 continue
83 namespace_name = self.CapitalizeFirstLetter(namespace.name.replace(
84 "experimental.", ""))
85 function_name = namespace_name + self.CapitalizeFirstLetter( 85 function_name = namespace_name + self.CapitalizeFirstLetter(
86 function.name) 86 function.name)
87 c.Append("registry->RegisterFunction<%sFunction>();" % ( 87 c.Append("registry->RegisterFunction<%sFunction>();" % function_name)
88 function_name))
89 c.Eblock("}") 88 c.Eblock("}")
90 c.Eblock("};") 89 c.Eblock("};")
91 c.Append() 90 c.Append()
92 return c 91 return c
93 92
94 def GenerateSchemasHeader(self): 93 def GenerateSchemasHeader(self):
95 """Generates a code.Code object for the generated schemas .h file""" 94 """Generates a code.Code object for the generated schemas .h file"""
96 c = code.Code() 95 c = code.Code()
97 c.Append('#include <map>') 96 c.Append('#include <map>')
98 c.Append('#include <string>') 97 c.Append('#include <string>')
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 for index, line in enumerate(lines): 135 for index, line in enumerate(lines):
137 line = ' "%s"' % line 136 line = ' "%s"' % line
138 if index == len(lines) - 1: 137 if index == len(lines) - 1:
139 line += ';' 138 line += ';'
140 c.Append(line) 139 c.Append(line)
141 c.Eblock('}') 140 c.Eblock('}')
142 c.Append() 141 c.Append()
143 c.Concat(self._cpp_type_generator.GetRootNamespaceEnd()) 142 c.Concat(self._cpp_type_generator.GetRootNamespaceEnd())
144 c.Append() 143 c.Append()
145 return c 144 return c
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/model_test.py ('k') | tools/json_schema_compiler/test/additional_properties_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698