tools/json_to_struct/element_generator.py
def _GenerateArray(element_name, field_info, content, lines, indent,
                   field_name_count):
  """Generates an array to be included in a static structure initializer. If
  content is not specified, uses NULL. The array is assigned to a temporary
  variable which is initialized before the structure.
  """
  if content is None:
    lines.append(indent + 'NULL,')
    lines.append(indent + '0,')  # Size of the array.
    return

  # Create a new array variable and use it in the structure initializer.
  # This prohibits nested arrays. Add a clash detection and renaming mechanism
  # to solve the problem.
  var = _GenerateArrayVariableName(element_name, field_info['field'],
                                   field_name_count)
  lines.append(indent + '%s,' % var)
  lines.append(indent + '%s,' % len(content))  # Size of the array.
  # Generate the array content.
  array_lines = []
  field_info['contents']['field'] = var;
  array_lines.append(struct_generator.GenerateField(
                     field_info['contents']) + '[] = {')
  for subcontent in content:
    GenerateFieldContent(element_name, field_info['contents'], subcontent,
                         array_lines, indent, field_name_count)
  array_lines.append('};')
  # Prepend the generated array so it is initialized before the structure.
  lines.reverse()
  array_lines.reverse()
  lines.extend(array_lines)
  lines.reverse()
Generates an array to be included in a static structure initializer. If
  content is not specified, uses NULL. The array is assigned to a temporary
  variable which is initialized before the structure.
  
Generates an array to be included in a static structure initializer. If
content is not specified, uses NULL. The array is assigned to a temporary
variable which is initialized before the structure.
Generates an array to be included in a static structure initializer . If content is not specified uses NULL . The array is assigned to a temporary variable which is initialized before the structure .
def _GenerateArray(element_name, field_info, content, lines, indent,
                   field_name_count):
  if content is None:
    lines.append(indent + 'NULL,')
    lines.append(indent + '0,')  
    return
  var = _GenerateArrayVariableName(element_name, field_info['field'],
                                   field_name_count)
  lines.append(indent + '%s,' % var)
  lines.append(indent + '%s,' % len(content))  
  array_lines = []
  field_info['contents']['field'] = var;
  array_lines.append(struct_generator.GenerateField(
                     field_info['contents']) + '[] = {')
  for subcontent in content:
    GenerateFieldContent(element_name, field_info['contents'], subcontent,
                         array_lines, indent, field_name_count)
  array_lines.append('};')
  lines.reverse()
  array_lines.reverse()
  lines.extend(array_lines)
  lines.reverse()
def _GenerateArray ( element_name , field_info , content , lines , indent , field_name_count ) : if content is None : lines . append ( indent + 'NULL,' ) lines . append ( indent + '0,' ) return var = _GenerateArrayVariableName ( element_name , field_info [ 'field' ] , field_name_count ) lines . append ( indent + '%s,' % var ) lines . append ( indent + '%s,' % len ( content ) ) array_lines = [ ] field_info [ 'contents' ] [ 'field' ] = var ; array_lines . append ( struct_generator . GenerateField ( field_info [ 'contents' ] ) + '[] = {' ) for subcontent in content : GenerateFieldContent ( element_name , field_info [ 'contents' ] , subcontent , array_lines , indent , field_name_count ) array_lines . append ( '};' ) lines . reverse ( ) array_lines . reverse ( ) lines . extend ( array_lines ) lines . reverse ( )
Generates an array to be included in a static structure initializer.
Generates an array to be included in a static structure initializer .
"""Generates an array to be included in a static structure initializer. If
  content is not specified, uses NULL. The array is assigned to a temporary
  variable which is initialized before the structure.
  """ # Size of the array. # Create a new array variable and use it in the structure initializer. # This prohibits nested arrays. Add a clash detection and renaming mechanism # to solve the problem. # Size of the array. # Generate the array content. # Prepend the generated array so it is initialized before the structure.
element_name
field_info
content
lines
indent
field_name_count