(self, method)
| 567 | cfunctype_table = {} |
| 568 | |
| 569 | def __init__(self, method): |
| 570 | self.selector = c_void_p(objc.method_getName(method)) |
| 571 | self.name = objc.sel_getName(self.selector) |
| 572 | self.pyname = self.name.replace(b':', b'_') |
| 573 | self.encoding = objc.method_getTypeEncoding(method) |
| 574 | self.return_type = objc.method_copyReturnType(method) |
| 575 | self.nargs = objc.method_getNumberOfArguments(method) |
| 576 | self.imp = c_void_p(objc.method_getImplementation(method)) |
| 577 | self.argument_types = [] |
| 578 | for i in range(self.nargs): |
| 579 | buffer = c_buffer(512) |
| 580 | objc.method_getArgumentType(method, i, buffer, len(buffer)) |
| 581 | self.argument_types.append(buffer.value) |
| 582 | try: |
| 583 | self.argtypes = [self.ctype_for_encoding(t) |
| 584 | for t in self.argument_types] |
| 585 | except ValueError: |
| 586 | self.argtypes = None |
| 587 | try: |
| 588 | if self.return_type == b'@': |
| 589 | self.restype = ObjCInstance |
| 590 | elif self.return_type == b'#': |
| 591 | self.restype = ObjCClass |
| 592 | else: |
| 593 | self.restype = self.ctype_for_encoding(self.return_type) |
| 594 | except ValueError: |
| 595 | self.restype = None |
| 596 | self.func = None |
| 597 | |
| 598 | def ctype_for_encoding(self, encoding): |
| 599 | """Return ctypes type for an encoded Objective-C type.""" |
nothing calls this directly
no test coverage detected