(targets, sources)
| 129 | return targets |
| 130 | |
| 131 | def do_generate_api(targets, sources): |
| 132 | header_file = targets[0] |
| 133 | c_file = targets[1] |
| 134 | |
| 135 | ufunc_api_index = genapi.merge_api_dicts(( |
| 136 | numpy_api.ufunc_funcs_api, |
| 137 | numpy_api.ufunc_types_api)) |
| 138 | genapi.check_api_dict(ufunc_api_index) |
| 139 | |
| 140 | ufunc_api_list = genapi.get_api_functions('UFUNC_API', numpy_api.ufunc_funcs_api) |
| 141 | |
| 142 | # Create dict name -> *Api instance |
| 143 | ufunc_api_dict = {} |
| 144 | api_name = 'PyUFunc_API' |
| 145 | for f in ufunc_api_list: |
| 146 | name = f.name |
| 147 | index = ufunc_api_index[name][0] |
| 148 | annotations = ufunc_api_index[name][1:] |
| 149 | ufunc_api_dict[name] = FunctionApi(f.name, index, annotations, |
| 150 | f.return_type, f.args, api_name) |
| 151 | |
| 152 | for name, val in numpy_api.ufunc_types_api.items(): |
| 153 | index = val[0] |
| 154 | ufunc_api_dict[name] = TypeApi(name, index, 'PyTypeObject', api_name) |
| 155 | |
| 156 | # set up object API |
| 157 | module_list = [] |
| 158 | extension_list = [] |
| 159 | init_list = [] |
| 160 | |
| 161 | for name, index in genapi.order_dict(ufunc_api_index): |
| 162 | api_item = ufunc_api_dict[name] |
| 163 | extension_list.append(api_item.define_from_array_api_string()) |
| 164 | init_list.append(api_item.array_api_define()) |
| 165 | module_list.append(api_item.internal_define()) |
| 166 | |
| 167 | # Write to header |
| 168 | s = h_template % ('\n'.join(module_list), '\n'.join(extension_list)) |
| 169 | genapi.write_file(header_file, s) |
| 170 | |
| 171 | # Write to c-code |
| 172 | s = c_template % ',\n'.join(init_list) |
| 173 | genapi.write_file(c_file, s) |
| 174 | |
| 175 | return targets |
| 176 | |
| 177 | |
| 178 | def main(): |
no test coverage detected