| Index: tools/json_to_struct/struct_generator.py
|
| diff --git a/tools/json_to_struct/struct_generator.py b/tools/json_to_struct/struct_generator.py
|
| index 501cb577e52d38eb6c01febb1ecc23b54c636e40..5849d82b4511d3124c669098c3713ac2aaf532bd 100644
|
| --- a/tools/json_to_struct/struct_generator.py
|
| +++ b/tools/json_to_struct/struct_generator.py
|
| @@ -28,6 +28,8 @@ def GenerateField(field_info):
|
| return 'const %s %s' % (field_info['ctype'], field)
|
| elif type == 'array':
|
| return _GenerateArrayField(field_info)
|
| + elif type == 'struct':
|
| + return 'const %s %s' % (field_info['type_name'], field)
|
| else:
|
| raise RuntimeError('Unknown field type "%s"' % type)
|
|
|
| @@ -38,6 +40,14 @@ def GenerateStruct(type_name, schema):
|
| lines = [];
|
| lines.append('struct %s {' % type_name)
|
| for field_info in schema:
|
| + if field_info['type'] == 'struct':
|
| + lines.insert(0, GenerateStruct(field_info['type_name'],
|
| + field_info['fields']))
|
| + elif (field_info['type'] == 'array'
|
| + and field_info['contents']['type'] == 'struct'):
|
| + contents = field_info['contents']
|
| + lines.insert(0, GenerateStruct(contents['type_name'],
|
| + contents['fields']))
|
| lines.append(' ' + GenerateField(field_info) + ';')
|
| lines.append('};');
|
| return '\n'.join(lines) + '\n';
|
|
|