Wrap an object in a Dispatch instance, exposing methods and properties via fully dynamic dispatch.
(obj)
| 19 | |
| 20 | |
| 21 | def Dispatch(obj): |
| 22 | """Wrap an object in a Dispatch instance, exposing methods and properties |
| 23 | via fully dynamic dispatch. |
| 24 | """ |
| 25 | if isinstance(obj, _Dispatch): |
| 26 | return obj |
| 27 | if isinstance(obj, ctypes.POINTER(automation.IDispatch)): |
| 28 | try: |
| 29 | tinfo = obj.GetTypeInfo(0) |
| 30 | except (OSError, COMError): |
| 31 | return _Dispatch(obj) |
| 32 | return lazybind.Dispatch(obj, tinfo) |
| 33 | return obj |
| 34 | |
| 35 | |
| 36 | class MethodCaller: |
searching dependent graphs…