def make_automatic_returnVal(buffer, output_list):

    # put together the outputs
    t_list = []
    buildvalue_string = ''

    # Check_found is used to indicate whether a found variable was
    # passed along with other output variables.  check_found is set to
    # True if the found variable indicating that the additional
    # outputs are valid.  This way, if nothing was found, the function
    # returns None instead of the output variables requested.
    check_found = False

    for output in output_list:
        # if the length of the output list is only 1 and it's found,
        # return true or false, otherwise, if found is false return None.
        if output.name == "found":
            if len(output_list) == 1:
                buffer.write(
                    '\n  if(found) { Py_RETURN_TRUE; } ' +
                    'else { Py_RETURN_FALSE; }'
                )
            else:
                check_found = True
            continue

        # If the output is an array, expand out all the elements in order
        # to build a python tuple out of them (This seems sub-optimal, I
        # have to read some more python C documentation).
        if output.is_array:
            t_list += get_array_sizes(output.num_elements, output.name)
        elif(output.get_py_fn):
            t_list.append('%s(&%s)' % (output.get_py_fn, output.name))
        else:
            t_list.append(output.name)

        buildvalue_string += output.py_string

    output_list_string = ", ".join(t_list)

    if output_list_string:
        if check_found:
            buffer.write(
                '\n  if(!found) {\n    return Py_None;\n  } else {\n    ')
        else:
            buffer.write('\n  ')

        buffer.write(
            'PyObject *returnVal = Py_BuildValue(buildvalue_string, %s);' % \
            (output_list_string))

        for output in output_list:
            if output.allocate_memory:
                buffer.write('\n  free(%s);' % output.name)

        buffer.write('\n  return returnVal;');

        if check_found:
            buffer.write('\n  }\n')
The outputs parameters and their dimensions are defined so this function
dataset/ETHPy150Open rca/PySPICE/mkwrapper.py/make_automatic_returnVal