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

Unified Diff: tools/json_schema_compiler/model.py

Issue 9309044: Supporting more APIs with json_schema_compiler (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rework, add a couple of tests Created 8 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 | « tools/json_schema_compiler/h_generator.py ('k') | tools/json_schema_compiler/test/array.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/model.py
diff --git a/tools/json_schema_compiler/model.py b/tools/json_schema_compiler/model.py
index 9ac7dfd01828c6c56a17128d350eb9a4358dd725..ad6cebec8d94759c4ab1f9332e72e1019ec78c57 100644
--- a/tools/json_schema_compiler/model.py
+++ b/tools/json_schema_compiler/model.py
@@ -4,6 +4,7 @@
import os.path
import re
+import copy
class Model(object):
"""Model of all namespaces that comprise an API.
@@ -30,15 +31,16 @@ class Namespace(object):
Properties:
- |name| the name of the namespace
- - |source_file_dir| the directory component of the file that contained the
- namespace definition
- - |source_file_filename| the filename component of the file that contained
- the namespace definition
+ - |unix_name| the unix_name of the namespace
+ - |source_file| the file that contained the namespace definition
+ - |source_file_dir| the directory component of |source_file|
+ - |source_file_filename| the filename component of |source_file|
- |types| a map of type names to their model.Type
- |functions| a map of function names to their model.Function
"""
def __init__(self, json, source_file):
self.name = json['namespace']
+ self.unix_name = _UnixName(self.name)
self.source_file = source_file
self.source_file_dir, self.source_file_filename = os.path.split(source_file)
self.types = {}
@@ -193,6 +195,14 @@ class Property(object):
(self.name, self._unix_name))
self._unix_name = unix_name
+ def Copy(self):
+ """Makes a copy of this model.Property object and allow the unix_name to be
+ set again.
+ """
+ property_copy = copy.copy(self)
+ property_copy._unix_name_used = False
+ return property_copy
+
unix_name = property(GetUnixName, SetUnixName)
class PropertyType(object):
@@ -217,7 +227,7 @@ class PropertyType(object):
ANY = _Info(False, "ANY")
def _UnixName(name):
- """Returns the unix_style name for a given string in lowerCamelCase format.
+ """Returns the unix_style name for a given lowerCamelCase string.
"""
return '_'.join([x.lower()
for x in re.findall('[A-Z][a-z_]*', name[0].upper() + name[1:])])
« no previous file with comments | « tools/json_schema_compiler/h_generator.py ('k') | tools/json_schema_compiler/test/array.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698