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

Unified Diff: tools/json_schema_compiler/cpp_type_generator.py

Issue 10701012: JSON Schema Compiler: Added event compilation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reworked Create functions and lots of tests. 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 side-by-side diff with in-line comments
Download patch
Index: tools/json_schema_compiler/cpp_type_generator.py
diff --git a/tools/json_schema_compiler/cpp_type_generator.py b/tools/json_schema_compiler/cpp_type_generator.py
index 55cb36e497059b6e8ec3fdcdd8aee353d46bc19e..5cd924ee8efa54b58ea0249e1bd6c75e4c721ef4 100644
--- a/tools/json_schema_compiler/cpp_type_generator.py
+++ b/tools/json_schema_compiler/cpp_type_generator.py
@@ -36,22 +36,31 @@ class CppTypeGenerator(object):
self._type_namespaces[type_] = namespace
self._cpp_namespaces[namespace] = cpp_namespace
- def GetExpandedChoicesInParams(self, params):
+ def GetAllPossibleParameters(self, params):
not at google - send to devlin 2012/07/11 07:22:06 I was confused in the other class what the differe
Matt Tytel 2012/07/12 03:07:56 Done.
"""Returns the given parameters with PropertyType.CHOICES parameters
- expanded so that each choice is a separate parameter and sets a unix_name
- for each choice.
+ expanded so that each choice is a separate parameter.
"""
expanded = []
for param in params:
if param.type_ == PropertyType.CHOICES:
for choice in param.choices.values():
- choice.unix_name = (
- param.unix_name + '_' + choice.type_.name.lower())
expanded.append(choice)
else:
expanded.append(param)
return expanded
+ def GetAllPossibleParameterLists(self, params):
+ """Returns all possible parameter lists for the given set of parameters.
+ Every combination of arguments passed to any of the PropertyType.CHOICES
+ parameters will have a corresponding parameter list returned here.
+ """
+ if not params:
+ return [[]]
not at google - send to devlin 2012/07/11 07:22:06 Why this check here? Can it be handled outside thi
Matt Tytel 2012/07/12 03:07:56 This function is recursive, this is the base case.
+ partial_parameter_lists = self.GetAllPossibleParameterLists(params[1:])
+ return [[param] + partial_list
+ for param in self.GetAllPossibleParameters(params[:1])
+ for partial_list in partial_parameter_lists]
not at google - send to devlin 2012/07/11 07:22:06 took me a little while to parse that, but nice.
Matt Tytel 2012/07/12 03:07:56 I was nervous putting this in, some people don't l
+
def GetCppNamespaceName(self, namespace):
"""Gets the mapped C++ namespace name for the given namespace relative to
the root namespace.

Powered by Google App Engine
This is Rietveld 408576698