cuda_cffi/_cffi_autogen_common.py
def build_python_func(cdef, build_func_body, variable_descriptions={},
                      func_descriptions={}):
    """ wrap a single python function corresponding to the given cdef C
    function string.

    Parameters
    ----------
    cdef : str
        single line string containing a C function definition
    build_func_body : callable
        function to build a string corresponding to the body of the python
        wrapper function
    variable_descriptions : dict
        dictionary of variable descriptions for the docstring
    func_descriptions : dict
        dictionary of function descriptions for the docstring

    Returns
    -------
    str corresponding to the python_wrapper
    """


    cdef_regex = "(\w*)\s*(\w*)\s*\((.*)\).*"
    p = re.compile(cdef_regex)
    match = p.search(cdef)
    (return_type, func_name, func_args) = match.group(1, 2, 3)
    func_args = func_args.split(', ')

    if '[]' in cdef:
        warnings.warn("[] within cdef not currently supported. "
                      "skipping function: {}".format(func_name))
        return ''

    from collections import OrderedDict
    arg_dict = OrderedDict()
    for arg in func_args:
        substr = arg.split()
        if len(substr) == 2:
            val = substr[0]
        else:
            val = substr[-2]
        key = substr[-1]
        # handle pointer
        if key[0] == '*':
            val += ' *'
            key = key[1:]
        # handle pointer to pointer
        if key[0] == '*':
            val += '*'
            key = key[1:]
        arg_dict[key] = val

    func_description = func_descriptions.get(func_name, '')
    return _func_str(func_name, arg_dict, return_type,
                     build_func_body=build_func_body,
                     variable_descriptions=variable_descriptions,
                     func_description=func_description)
 wrap a single python function corresponding to the given cdef C
    function string.

    Parameters
    ----------
    cdef : str
        single line string containing a C function definition
    build_func_body : callable
        function to build a string corresponding to the body of the python
        wrapper function
    variable_descriptions : dict
        dictionary of variable descriptions for the docstring
    func_descriptions : dict
        dictionary of function descriptions for the docstring

    Returns
    -------
    str corresponding to the python_wrapper
    
wrap a single python function corresponding to the given cdef C
function string.

Parameters

cdef : str
single line string containing a C function definition
build_func_body : callable
function to build a string corresponding to the body of the python
wrapper function
variable_descriptions : dict
dictionary of variable descriptions for the docstring
func_descriptions : dict
dictionary of function descriptions for the docstring

Returns

str corresponding to the python_wrapper
wrap a single python function corresponding to the given cdef C function string . Parameters cdef : str single line string containing a C function definition build_func_body : callable function to build a string corresponding to the body of the python wrapper function variable_descriptions : dict dictionary of variable descriptions for the docstring func_descriptions : dict dictionary of function descriptions for the docstring Returns str corresponding to the python_wrapper
def build_python_func(cdef, build_func_body, variable_descriptions={},
                      func_descriptions={}):
    cdef_regex = "(\w*)\s*(\w*)\s*\((.*)\).*"
    p = re.compile(cdef_regex)
    match = p.search(cdef)
    (return_type, func_name, func_args) = match.group(1, 2, 3)
    func_args = func_args.split(', ')
    if '[]' in cdef:
        warnings.warn("[] within cdef not currently supported. "
                      "skipping function: {}".format(func_name))
        return ''
    from collections import OrderedDict
    arg_dict = OrderedDict()
    for arg in func_args:
        substr = arg.split()
        if len(substr) == 2:
            val = substr[0]
        else:
            val = substr[-2]
        key = substr[-1]
        if key[0] == '*':
            val += ' *'
            key = key[1:]
         to pointer
        if key[0] == '*':
            val += '*'
            key = key[1:]
        arg_dict[key] = val
    func_description = func_descriptions.get(func_name, '')
    return _func_str(func_name, arg_dict, return_type,
                     build_func_body=build_func_body,
                     variable_descriptions=variable_descriptions,
                     func_description=func_description)
def build_python_func ( cdef , build_func_body , variable_descriptions = { } , func_descriptions = { } ) : cdef_regex = "(\w*)\s*(\w*)\s*\((.*)\).*" p = re . compile ( cdef_regex ) match = p . search ( cdef ) ( return_type , func_name , func_args ) = match . group ( 1 , 2 , 3 ) func_args = func_args . split ( ', ' ) if '[]' in cdef : warnings . warn ( "[] within cdef not currently supported. " "skipping function: {}" . format ( func_name ) ) return '' from collections import OrderedDict arg_dict = OrderedDict ( ) for arg in func_args : substr = arg . split ( ) if len ( substr ) == 2 : val = substr [ 0 ] else : val = substr [ - 2 ] key = substr [ - 1 ] if key [ 0 ] == '*' : val += ' *' key = key [ 1 : ] if key [ 0 ] == '*' : val += '*' key = key [ 1 : ] arg_dict [ key ] = val func_description = func_descriptions . get ( func_name , '' ) return _func_str ( func_name , arg_dict , return_type , build_func_body = build_func_body , variable_descriptions = variable_descriptions , func_description = func_description )
wrap a single python function corresponding to the given cdef C
function string.
wrap a single python function corresponding to the given cdef C function string .
""" wrap a single python function corresponding to the given cdef C
    function string.

    Parameters
    ----------
    cdef : str
        single line string containing a C function definition
    build_func_body : callable
        function to build a string corresponding to the body of the python
        wrapper function
    variable_descriptions : dict
        dictionary of variable descriptions for the docstring
    func_descriptions : dict
        dictionary of function descriptions for the docstring

    Returns
    -------
    str corresponding to the python_wrapper
    """ # handle pointer # handle pointer to pointer
cdef
build_func_body
variable_descriptions
func_descriptions