Index: tools/json_schema_compiler/schema_bundle_generator.py |
diff --git a/tools/json_schema_compiler/schema_bundle_generator.py b/tools/json_schema_compiler/schema_bundle_generator.py |
index 08cc4a8887f69499ff5deade4f8297f9e17ad1c0..329aa748b63372ea53c765fb7c995420bcd74703 100644 |
--- a/tools/json_schema_compiler/schema_bundle_generator.py |
+++ b/tools/json_schema_compiler/schema_bundle_generator.py |
@@ -12,6 +12,10 @@ import re |
# TODO(miket/asargent) - parameterize this. |
SOURCE_BASE_PATH = 'chrome/common/extensions/api' |
+ |
+def CapitalizeFirstLetter(value): |
not at google - send to devlin
2012/07/18 04:27:37
nit: start with _
asargent_no_longer_on_chrome
2012/07/20 00:11:47
this function moved to schema_util.py
|
+ return value[0].capitalize() + value[1:] |
+ |
class SchemaBundleGenerator(object): |
"""This class contains methods to generate code based on multiple schemas. |
""" |
@@ -68,9 +72,6 @@ class SchemaBundleGenerator(object): |
c.Append() |
return self.GenerateHeader('generated_api', c) |
- def CapitalizeFirstLetter(self, value): |
- return value[0].capitalize() + value[1:] |
- |
def GenerateFunctionRegistry(self): |
c = code.Code() |
c.Sblock("class GeneratedFunctionRegistry {") |
@@ -80,10 +81,17 @@ class SchemaBundleGenerator(object): |
for function in namespace.functions.values(): |
if function.nocompile: |
continue |
- namespace_name = self.CapitalizeFirstLetter(namespace.name.replace( |
- "experimental.", "")) |
- function_name = namespace_name + self.CapitalizeFirstLetter( |
- function.name) |
+ |
+ # Transform a fully qualified function name like foo.bar.baz into |
+ # FooBarBaz, stripping any leading 'Experimental' prefix. |
+ parts = [] |
+ function_name = namespace.name + "." + function.name |
+ for part in function_name.split("."): |
+ parts.append(CapitalizeFirstLetter(part)) |
+ if parts[0] == "Experimental": |
+ del parts[0] |
+ function_name = "".join(parts) |
+ |
c.Append("registry->RegisterFunction<%sFunction>();" % ( |
function_name)) |
c.Eblock("}") |