Changeset 6cbf34b


Ignore:
Timestamp:
May 30, 2017, 12:28:40 AM (7 years ago)
Author:
Martin Hermant <martin.hermant@gmail.com>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
Children:
541ea280
Parents:
b1f93c4
Message:

gen_external :

add function get_all_func_names_from_lib

analyze_c_declarations -> generate_lib_from_c_declarations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/lib/gen_external.py

    rb1f93c4 r6cbf34b  
    136136    return cpp_objects
    137137
    138 def analyze_c_declarations(cpp_objects, c_declarations):
     138
     139def get_all_func_names_from_lib(lib, depth=0):
     140    ''' return flat string of all function used in lib
     141    '''
     142    res = []
     143    indent = " " * depth
     144    for k, v in lib.items():
     145        if isinstance(v, dict):
     146            res += get_all_func_names_from_lib(v, depth + 1)
     147        elif isinstance(v, list):
     148            for elem in v:
     149                e = elem.split('(')
     150                if len(e) < 2:
     151                    continue  # not a function
     152                fname_part = e[0].strip().split(' ')
     153                fname = fname_part[-1]
     154                if fname:
     155                    res += [fname]
     156                else:
     157                    raise NameError('gen_lib : weird function: ' + str(e))
     158
     159    return res
     160
     161
     162def generate_lib_from_c_declarations(cpp_objects, c_declarations):
     163    ''' returns a lib from given cpp_object names
     164
     165    a lib is a dict grouping functions by family (onset,pitch...)
     166        each eement is itself a dict of functions grouped by puposes as :
     167        struct, new, del, do, get, set and other
     168    '''
    139169    lib = {}
    140170
     
    206236    cpp_objects = get_cpp_objects_from_c_declarations(c_declarations)
    207237
    208     lib = analyze_c_declarations(cpp_objects, c_declarations)
     238    lib = generate_lib_from_c_declarations(cpp_objects, c_declarations)
    209239    # print_c_declarations_results(lib, c_declarations)
    210240
Note: See TracChangeset for help on using the changeset viewer.