Scan exported impl members and collect same-name methods/properties for proxying.
(py_cls: type, impl_cls: type)
| 92 | |
| 93 | |
| 94 | def _scan_proxy_members(py_cls: type, impl_cls: type): |
| 95 | '''Scan exported impl members and collect same-name methods/properties for proxying.''' |
| 96 | proxy_methods = [] |
| 97 | proxy_attrs = [] |
| 98 | |
| 99 | for name, member in impl_cls.__dict__.items(): |
| 100 | if name.startswith('__'): |
| 101 | continue |
| 102 | |
| 103 | if isinstance(member, property): |
| 104 | proxy_attrs.append(name) |
| 105 | continue |
| 106 | |
| 107 | if not callable(member): |
| 108 | continue |
| 109 | if name not in py_cls.__dict__: |
| 110 | continue |
| 111 | |
| 112 | py_member = py_cls.__dict__[name] |
| 113 | if not callable(py_member): |
| 114 | continue |
| 115 | |
| 116 | # Dynamic validation: if both signatures are available, require identical |
| 117 | # parameter names; otherwise skip signature validation. |
| 118 | try: |
| 119 | py_sig = _normalize_param_names(py_member) |
| 120 | except (TypeError, ValueError): |
| 121 | py_sig = None |
| 122 | try: |
| 123 | impl_sig = _normalize_param_names(member) |
| 124 | except (TypeError, ValueError): |
| 125 | impl_sig = None |
| 126 | if py_sig is not None and impl_sig is not None and py_sig != impl_sig: |
| 127 | raise TypeError( |
| 128 | f'Signature mismatch for {py_cls.__name__}.{name}: ' |
| 129 | f'python params={py_sig}, cpp params={impl_sig}' |
| 130 | ) |
| 131 | |
| 132 | proxy_methods.append(name) |
| 133 | |
| 134 | return tuple(proxy_methods), tuple(proxy_attrs) |
| 135 | |
| 136 | |
| 137 | def cpp_class(py_class: Optional[_C] = None, *, cpp_class_name: Optional[str] = None): |
no test coverage detected