summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler/schema_util.py
diff options
context:
space:
mode:
authorkalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-29 00:56:27 +0000
committerkalman@chromium.org <kalman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-29 00:56:27 +0000
commitc1411679a85859a85d6ebc0b8118f1991da6203a (patch)
treec670a712d494f4cb20f6e35e6782bf7ce2ed1c5e /tools/json_schema_compiler/schema_util.py
parent98ca8224b564679f9c14fcce4a697e71e927d65d (diff)
downloadchromium_src-c1411679a85859a85d6ebc0b8118f1991da6203a.zip
chromium_src-c1411679a85859a85d6ebc0b8118f1991da6203a.tar.gz
chromium_src-c1411679a85859a85d6ebc0b8118f1991da6203a.tar.bz2
Fix up how the JSON Schema compiler decides whether to include or forward
declare references to C++ types in other files. This fixed up a problem where references as part of required properties would cause compilation errors, specifically for the use of tabs.InjectDetails from the webview API. BUG=171726 Review URL: https://chromiumcodereview.appspot.com/11953121 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179232 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/json_schema_compiler/schema_util.py')
-rw-r--r--tools/json_schema_compiler/schema_util.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/tools/json_schema_compiler/schema_util.py b/tools/json_schema_compiler/schema_util.py
index e71be8b..7ce399e 100644
--- a/tools/json_schema_compiler/schema_util.py
+++ b/tools/json_schema_compiler/schema_util.py
@@ -9,15 +9,19 @@ import json_parse
def CapitalizeFirstLetter(value):
return value[0].capitalize() + value[1:]
-def GetNamespace(ref_type):
- if '.' in ref_type:
- return ref_type[:ref_type.rindex('.')]
+def GetNamespace(ref):
+ return SplitNamespace(ref)[0]
-def StripSchemaNamespace(s):
- last_dot = s.rfind('.')
- if not last_dot == -1:
- return s[last_dot + 1:]
- return s
+def StripNamespace(ref):
+ return SplitNamespace(ref)[1]
+
+def SplitNamespace(ref):
+ """Returns (namespace, entity) from |ref|, e.g. app.window.AppWindow ->
+ (app.window, AppWindow). If |ref| isn't qualified then returns (None, ref).
+ """
+ if '.' in ref:
+ return tuple(ref.rsplit('.', 1))
+ return (None, ref)
def JsFunctionNameToClassName(namespace_name, function_name):
"""Transform a fully qualified function name like foo.bar.baz into FooBarBaz