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

Unified Diff: tools/json_to_struct/json_to_struct.py

Issue 1209733002: Add the ability to code generated prepopulated static nested structs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test Created 5 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
« no previous file with comments | « tools/json_to_struct/element_generator_test.py ('k') | tools/json_to_struct/struct_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_to_struct/json_to_struct.py
diff --git a/tools/json_to_struct/json_to_struct.py b/tools/json_to_struct/json_to_struct.py
index 2e9c83c726fb23a28a232cfd24312efdac4b841f..726cec93d1cd11d307ef3756bc8270120fc80379 100755
--- a/tools/json_to_struct/json_to_struct.py
+++ b/tools/json_to_struct/json_to_struct.py
@@ -12,7 +12,7 @@
# "schema": [ // Fields of the generated structure.
# {
# "field": "my_enum_field",
-# "type": "enum", // Either: int, string, string16, enum, array.
+# "type": "enum", // Either: int, string, string16, enum, array, struct.
# "default": "RED", // Optional. Cannot be used for array.
# "ctype": "Color" // Only for enum, specify the C type.
# },
@@ -23,6 +23,15 @@
# "type": "int" // Either: int, string, string16, enum, array.
# }
# },
+# {
+# "field": "my_struct_field",
+# "type_name": "PointStuct",
+# "type": "struct",
+# "fields": [
+# {"field": "x", "type": "int"},
+# {"field": "y", "type": "int"}
+# ]
+# },
# ...
# ]
# }
@@ -39,6 +48,7 @@
# "my_string_field": "foo bar",
# "my_enum_field": "BLACK",
# "my_int_array_field": [ 1, 2, 3, 5, 7 ],
+# "my_struct_field": {"x": 1, "y": 2}
# },
# "my_other_const_variable": {
# ...
@@ -119,7 +129,7 @@ def _GenerateH(basepath, fileroot, head, namespace, schema, description):
schema['type_name'], schema['schema']))
f.write('\n')
- for var_name, value in description.get('int_variables', []).items():
+ for var_name, value in description.get('int_variables', {}).items():
f.write('extern const int %s;\n' % var_name)
f.write('\n')
« no previous file with comments | « tools/json_to_struct/element_generator_test.py ('k') | tools/json_to_struct/struct_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698