tools/generate_stubs/generate_stubs.py
def ParseSignatures(infile):
  """Parses function signatures in the input file.

  This function parses a file of signatures into a list of dictionaries that
  represent the function signatures in the input file.  Each dictionary has
  the following keys:
    return_type: A string with the return type.
    name: A string with the name of the function.
    params: A list of each function parameter declaration (type + name)

  The format of the input file is one C-style function signature per line, no
  trailing semicolon.  Empty lines are allowed.  An empty line is a line that
  consists purely of whitespace.  Lines that begin with a # or // are considered
  comment lines and are ignored.

  We assume that "int foo(void)" is the same as "int foo()", which is not
  true in C where "int foo()" is equivalent to "int foo(...)".  Our generated
  code is C++, and we do not handle varargs, so this is a case that can be
  ignored for now.

  Args:
    infile: File object holding a text file of function signatures.

  Returns:
    A list of dictionaries, where each dictionary represents one function
    signature.

  Raises:
    BadSignatureError: A line could not be parsed as a signature.
  """
  signatures = []
  for line in infile:
    line = line.strip()
    if line and line[0] != '#' and line[0:2] != '//':
      m = SIGNATURE_REGEX.match(line)
      if m is None:
        raise BadSignatureError('Unparsable line: %s' % line)
      signatures.append({
          'return_type':
          m.group('return_type').strip(),
          'name':
          m.group('name').strip(),
          'params': [arg.strip() for arg in m.group('params').split(',')]
      })
  return signatures
Parses function signatures in the input file.

  This function parses a file of signatures into a list of dictionaries that
  represent the function signatures in the input file.  Each dictionary has
  the following keys:
    return_type: A string with the return type.
    name: A string with the name of the function.
    params: A list of each function parameter declaration (type + name)

  The format of the input file is one C-style function signature per line, no
  trailing semicolon.  Empty lines are allowed.  An empty line is a line that
  consists purely of whitespace.  Lines that begin with a # or // are considered
  comment lines and are ignored.

  We assume that "int foo(void)" is the same as "int foo()", which is not
  true in C where "int foo()" is equivalent to "int foo(...)".  Our generated
  code is C++, and we do not handle varargs, so this is a case that can be
  ignored for now.

  Args:
    infile: File object holding a text file of function signatures.

  Returns:
    A list of dictionaries, where each dictionary represents one function
    signature.

  Raises:
    BadSignatureError: A line could not be parsed as a signature.
  
Parses function signatures in the input file.
This function parses a file of signatures into a list of dictionaries that
represent the function signatures in the input file.  Each dictionary has
the following keys:
return_type: A string with the return type.
name: A string with the name of the function.
params: A list of each function parameter declaration (type + name)

The format of the input file is one C-style function signature per line, no
trailing semicolon.  Empty lines are allowed.  An empty line is a line that
consists purely of whitespace.  Lines that begin with a # or // are considered
comment lines and are ignored.


Parses function signatures in the input file . This function parses a file of signatures into a list of dictionaries that represent the function signatures in the input file . Each dictionary has the following keys : return_type : A string with the return type . name : A string with the name of the function . params : A list of each function parameter declaration ( type + name ) The format of the input file is one C - style function signature per line no trailing semicolon . Empty lines are allowed . An empty line is a line that consists purely of whitespace . Lines that begin with a # or // are considered comment lines and are ignored .
def ParseSignatures(infile):
  signatures = []
  for line in infile:
    line = line.strip()
    if line and line[0] != '#' and line[0:2] != '//':
      m = SIGNATURE_REGEX.match(line)
      if m is None:
        raise BadSignatureError('Unparsable line: %s' % line)
      signatures.append({
          'return_type':
          m.group('return_type').strip(),
          'name':
          m.group('name').strip(),
          'params': [arg.strip() for arg in m.group('params').split(',')]
      })
  return signatures
def ParseSignatures ( infile ) : signatures = [ ] for line in infile : line = line . strip ( ) if line and line [ 0 ] != '#' and line [ 0 : 2 ] != '//' : m = SIGNATURE_REGEX . match ( line ) if m is None : raise BadSignatureError ( 'Unparsable line: %s' % line ) signatures . append ( { 'return_type' : m . group ( 'return_type' ) . strip ( ) , 'name' : m . group ( 'name' ) . strip ( ) , 'params' : [ arg . strip ( ) for arg in m . group ( 'params' ) . split ( ',' ) ] } ) return signatures
Parses function signatures in the input file.
Parses function signatures in the input file .
"""Parses function signatures in the input file.

  This function parses a file of signatures into a list of dictionaries that
  represent the function signatures in the input file.  Each dictionary has
  the following keys:
    return_type: A string with the return type.
    name: A string with the name of the function.
    params: A list of each function parameter declaration (type + name)

  The format of the input file is one C-style function signature per line, no
  trailing semicolon.  Empty lines are allowed.  An empty line is a line that
  consists purely of whitespace.  Lines that begin with a # or // are considered
  comment lines and are ignored.

  We assume that "int foo(void)" is the same as "int foo()", which is not
  true in C where "int foo()" is equivalent to "int foo(...)".  Our generated
  code is C++, and we do not handle varargs, so this is a case that can be
  ignored for now.

  Args:
    infile: File object holding a text file of function signatures.

  Returns:
    A list of dictionaries, where each dictionary represents one function
    signature.

  Raises:
    BadSignatureError: A line could not be parsed as a signature.
  """
A list of dictionaries, where each dictionary represents one function
signature.
A list of dictionaries where each dictionary represents one function signature .
A line could not be parsed as a signature.
A line could not be parsed as a signature .
BadSignatureError
infile
File object holding a text file of function signatures.
File object holding a text file of function signatures .