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

Unified Diff: tools/json_schema_compiler/cpp_bundle_generator.py

Issue 12330089: JSON compiler to include "customBindings" in the function name. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/api/storage.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/cpp_bundle_generator.py
===================================================================
--- tools/json_schema_compiler/cpp_bundle_generator.py (revision 182503)
+++ tools/json_schema_compiler/cpp_bundle_generator.py (working copy)
@@ -82,13 +82,20 @@
raise ValueError("Unsupported platform ifdef: %s" % platform.name)
return ' and '.join(ifdefs)
- def _GetNamespaceFunctions(self, namespace):
- functions = list(namespace.functions.values())
- if namespace.compiler_options.get("generate_type_functions", False):
- for type_ in namespace.types.values():
- functions += list(type_.functions.values())
- return functions
+ def _GenerateRegisterFunctions(self, namespace_name, function):
+ c = code.Code()
+ function_ifdefs = self._GetPlatformIfdefs(function)
+ if function_ifdefs is not None:
+ c.Append("#if %s" % function_ifdefs, indent_level=0)
+ function_name = JsFunctionNameToClassName(namespace_name, function.name)
+ c.Append("registry->RegisterFunction<%sFunction>();" % (
+ function_name))
+
+ if function_ifdefs is not None:
+ c.Append("#endif // %s" % function_ifdefs, indent_level=0)
+ return c
+
def _GenerateFunctionRegistryRegisterAll(self):
c = code.Code()
c.Append('// static')
@@ -101,20 +108,20 @@
namespace_name = CapitalizeFirstLetter(namespace.name.replace(
"experimental.", ""))
- for function in self._GetNamespaceFunctions(namespace):
+ for function in namespace.functions.values():
if function.nocompile:
continue
- function_ifdefs = self._GetPlatformIfdefs(function)
- if function_ifdefs is not None:
- c.Append("#if %s" % function_ifdefs, indent_level=0)
+ c.Concat(self._GenerateRegisterFunctions(namespace.name, function))
- function_name = JsFunctionNameToClassName(namespace.name, function.name)
- c.Append("registry->RegisterFunction<%sFunction>();" % (
- function_name))
+ for type_ in namespace.types.values():
+ for function in type_.functions.values():
+ if function.nocompile:
+ continue
+ namespace_types_name = JsFunctionNameToClassName(
+ namespace.name, type_.name)
+ c.Concat(self._GenerateRegisterFunctions(namespace_types_name,
+ function))
- if function_ifdefs is not None:
- c.Append("#endif // %s" % function_ifdefs, indent_level=0)
-
if namespace_ifdefs is not None:
c.Append("#endif // %s" % namespace_ifdefs, indent_level=0)
c.Eblock("}")
« no previous file with comments | « chrome/common/extensions/api/storage.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698