()
| 401 | |
| 402 | |
| 403 | async def main(): |
| 404 | params = await _gen_ct_bindings() |
| 405 | while True: |
| 406 | yn = input("regen api_bindings.py (y/n)? ").lower() |
| 407 | |
| 408 | if yn not in {"y", "n"}: |
| 409 | continue |
| 410 | |
| 411 | if yn == "n": |
| 412 | return |
| 413 | break |
| 414 | |
| 415 | out: str = "" |
| 416 | from src.pointers._pyapi import API_FUNCS |
| 417 | |
| 418 | funcs: dict[str, list[str]] = {} |
| 419 | |
| 420 | for k, v in API_FUNCS.items(): |
| 421 | func = v[0] |
| 422 | |
| 423 | if not func: |
| 424 | continue |
| 425 | |
| 426 | zip_params = (params[k], func.argtypes) |
| 427 | |
| 428 | if func.argtypes is None: |
| 429 | print("No argtypes...", func.__name__) |
| 430 | continue |
| 431 | |
| 432 | fparams = [f"{param}: {map_type(typ)}" for param, typ in zip(*zip_params)] |
| 433 | restype: type["ctypes._CData"] = func.restype # type: ignore |
| 434 | |
| 435 | name_split = k.split("_") |
| 436 | section = name_split[0] |
| 437 | |
| 438 | if not section: |
| 439 | name_split.pop(0) |
| 440 | section = "_" + name_split[0] |
| 441 | |
| 442 | if section not in funcs: |
| 443 | funcs[section] = [] |
| 444 | |
| 445 | origin_name = "_".join(name_split[1:]) |
| 446 | name = HARDCODED_NAMES.get(origin_name) or "" |
| 447 | |
| 448 | if not name: |
| 449 | for i in NAME_GROUPS: |
| 450 | if i in origin_name: |
| 451 | index = origin_name.index(i) |
| 452 | origin_name = origin_name.replace( |
| 453 | i, |
| 454 | f"{'_' if index else ''}{i.lower()}{'_' if (index + len(i)) != len(origin_name) else ''}", |
| 455 | ) |
| 456 | |
| 457 | for index, i in enumerate(origin_name): |
| 458 | lower: str = i.lower() |
| 459 | |
| 460 | if i.isupper(): |
no test coverage detected