third_party/android_crazy_linker/src/tests/pylib/source_utils.py
def CSourceForArrayData(values, formatter, margin=4, width=80):
  """Turn an array of values into a C source array data definition.

  Args:
    values: Array of input values.
    formatter: Formatting function, applied to each input value to get a
      C-source description of the value.
    margin: Left-side margin / indentation level.
    width: Maximum line width.
  Returns:
    A string containing the data definition as a C source fragment.
  """
  read_pos = 0
  read_len = len(values)
  write_pos = margin
  line_start = ' ' * margin
  # Account for the margin + one final comma.
  max_width = width - margin - 1
  out = ''
  while read_pos < read_len:
    out += line_start
    write_pos = 0
    comma = ''
    while read_pos < read_len:
      item = comma + formatter(values[read_pos])
      if write_pos + len(item) > max_width:
        break  # Too long, break line before this item.
      out += item
      read_pos += 1
      write_pos += len(item)
      comma = ','
    if read_pos == read_len:
      break
    out += ',\n'
  return out
Turn an array of values into a C source array data definition.

  Args:
    values: Array of input values.
    formatter: Formatting function, applied to each input value to get a
      C-source description of the value.
    margin: Left-side margin / indentation level.
    width: Maximum line width.
  Returns:
    A string containing the data definition as a C source fragment.
  
Turn an array of values into a C source array data definition.
Turn an array of values into a C source array data definition .
def CSourceForArrayData(values, formatter, margin=4, width=80):
  read_pos = 0
  read_len = len(values)
  write_pos = margin
  line_start = ' ' * margin
  max_width = width - margin - 1
  out = ''
  while read_pos < read_len:
    out += line_start
    write_pos = 0
    comma = ''
    while read_pos < read_len:
      item = comma + formatter(values[read_pos])
      if write_pos + len(item) > max_width:
        break  
      out += item
      read_pos += 1
      write_pos += len(item)
      comma = ','
    if read_pos == read_len:
      break
    out += ',\n'
  return out
def CSourceForArrayData ( values , formatter , margin = 4 , width = 80 ) : read_pos = 0 read_len = len ( values ) write_pos = margin line_start = ' ' * margin max_width = width - margin - 1 out = '' while read_pos < read_len : out += line_start write_pos = 0 comma = '' while read_pos < read_len : item = comma + formatter ( values [ read_pos ] ) if write_pos + len ( item ) > max_width : break out += item read_pos += 1 write_pos += len ( item ) comma = ',' if read_pos == read_len : break out += ',\n' return out
Turn an array of values into a C source array data definition.
Turn an array of values into a C source array data definition .
"""Turn an array of values into a C source array data definition.

  Args:
    values: Array of input values.
    formatter: Formatting function, applied to each input value to get a
      C-source description of the value.
    margin: Left-side margin / indentation level.
    width: Maximum line width.
  Returns:
    A string containing the data definition as a C source fragment.
  """ # Account for the margin + one final comma. # Too long, break line before this item.
A string containing the data definition as a C source fragment.
A string containing the data definition as a C source fragment .
values
Array of input values.
Array of input values .
formatter
Formatting function, applied to each input value to get a
C-source description of the value.
Formatting function applied to each input value to get a C - source description of the value .
margin
Left-side margin / indentation level.
Left - side margin / indentation level .
width
Maximum line width.
Maximum line width .