def get_array_shapes()

in scripts/gen_wrappers.py [0:0]


def get_array_shapes(full_src_lines):
    #  ===== Parse array shape hints =====
    array_shapes = OrderedDict()
    curr_struct_name = None
    for line in full_src_lines:
        # Current struct name
        m = re.match(r'struct (\w+)', line)
        if m:
            curr_struct_name = m.group(1)
            continue
        # Pointer with a shape comment
        m = re.match(r'\s*\w+\s*\*\s+(\w+);\s*//.*\((.+) x (.+)\)$', line)
        if m:
            name = curr_struct_name[1:] + '.' + m.group(1)
            assert name not in array_shapes
            array_shapes[name] = (tryint(m.group(2)), tryint(m.group(3)))
    return array_shapes