|
27 | 27 | import textwrap
|
28 | 28 | import warnings
|
29 | 29 |
|
30 |
| -from ctypes import c_void_p as void_p |
31 |
| -from ctypes import c_char_p as char_p |
32 |
| -from ctypes import py_object, c_int, c_char_p, POINTER, pointer |
| 30 | +from ctypes import py_object, c_char_p, c_int, c_void_p, POINTER, pointer |
33 | 31 |
|
34 | 32 | try:
|
35 | 33 | from shutil import which
|
@@ -510,40 +508,40 @@ def is_compatible_exe(jl_libpython):
|
510 | 508 |
|
511 | 509 | def setup_libjulia(libjulia):
|
512 | 510 | # Store the running interpreter reference so we can start using it via self.call
|
513 |
| - libjulia.jl_.argtypes = [void_p] |
| 511 | + libjulia.jl_.argtypes = [c_void_p] |
514 | 512 | libjulia.jl_.restype = None
|
515 | 513 |
|
516 | 514 | # Set the return types of some of the bridge functions in ctypes terminology
|
517 |
| - libjulia.jl_eval_string.argtypes = [char_p] |
518 |
| - libjulia.jl_eval_string.restype = void_p |
519 |
| - |
520 |
| - libjulia.jl_exception_occurred.restype = void_p |
521 |
| - libjulia.jl_typeof_str.argtypes = [void_p] |
522 |
| - libjulia.jl_typeof_str.restype = char_p |
523 |
| - libjulia.jl_call2.argtypes = [void_p, void_p, void_p] |
524 |
| - libjulia.jl_call2.restype = void_p |
525 |
| - libjulia.jl_get_field.argtypes = [void_p, char_p] |
526 |
| - libjulia.jl_get_field.restype = void_p |
527 |
| - libjulia.jl_typename_str.restype = char_p |
528 |
| - libjulia.jl_unbox_voidpointer.argtypes = [void_p] |
| 515 | + libjulia.jl_eval_string.argtypes = [c_char_p] |
| 516 | + libjulia.jl_eval_string.restype = c_void_p |
| 517 | + |
| 518 | + libjulia.jl_exception_occurred.restype = c_void_p |
| 519 | + libjulia.jl_typeof_str.argtypes = [c_void_p] |
| 520 | + libjulia.jl_typeof_str.restype = c_char_p |
| 521 | + libjulia.jl_call2.argtypes = [c_void_p, c_void_p, c_void_p] |
| 522 | + libjulia.jl_call2.restype = c_void_p |
| 523 | + libjulia.jl_get_field.argtypes = [c_void_p, c_char_p] |
| 524 | + libjulia.jl_get_field.restype = c_void_p |
| 525 | + libjulia.jl_typename_str.restype = c_char_p |
| 526 | + libjulia.jl_unbox_voidpointer.argtypes = [c_void_p] |
529 | 527 | libjulia.jl_unbox_voidpointer.restype = py_object
|
530 | 528 |
|
531 | 529 | for c_type in UNBOXABLE_TYPES:
|
532 | 530 | jl_unbox = getattr(libjulia, "jl_unbox_{}".format(c_type))
|
533 |
| - jl_unbox.argtypes = [void_p] |
| 531 | + jl_unbox.argtypes = [c_void_p] |
534 | 532 | jl_unbox.restype = getattr(ctypes, "c_{}".format({
|
535 | 533 | "float32": "float",
|
536 | 534 | "float64": "double",
|
537 | 535 | }.get(c_type, c_type)))
|
538 | 536 |
|
539 |
| - libjulia.jl_typeof.argtypes = [void_p] |
540 |
| - libjulia.jl_typeof.restype = void_p |
| 537 | + libjulia.jl_typeof.argtypes = [c_void_p] |
| 538 | + libjulia.jl_typeof.restype = c_void_p |
541 | 539 |
|
542 | 540 | libjulia.jl_exception_clear.restype = None
|
543 | 541 | libjulia.jl_stderr_obj.argtypes = []
|
544 |
| - libjulia.jl_stderr_obj.restype = void_p |
| 542 | + libjulia.jl_stderr_obj.restype = c_void_p |
545 | 543 | libjulia.jl_stderr_stream.argtypes = []
|
546 |
| - libjulia.jl_stderr_stream.restype = void_p |
| 544 | + libjulia.jl_stderr_stream.restype = c_void_p |
547 | 545 | libjulia.jl_printf.restype = ctypes.c_int
|
548 | 546 |
|
549 | 547 | libjulia.jl_parse_opts.argtypes = [POINTER(c_int),
|
@@ -759,7 +757,7 @@ def init_julia(self, options=None):
|
759 | 757 | argv_list = [s.encode('utf-8') for s in argv_list]
|
760 | 758 |
|
761 | 759 | argc = c_int(len(argv_list))
|
762 |
| - argv = POINTER(char_p)((char_p * len(argv_list))(*argv_list)) |
| 760 | + argv = POINTER(c_char_p)((c_char_p * len(argv_list))(*argv_list)) |
763 | 761 |
|
764 | 762 | logger.debug("argv_list = %r", argv_list)
|
765 | 763 | logger.debug("argc = %r", argc)
|
@@ -1139,9 +1137,9 @@ def check_exception(self, src="<unknown code>"):
|
1139 | 1137 | .format(exception, src))
|
1140 | 1138 |
|
1141 | 1139 | def _typeof_julia_exception_in_transit(self):
|
1142 |
| - exception = void_p.in_dll(self.api, 'jl_exception_in_transit') |
| 1140 | + exception = c_void_p.in_dll(self.api, 'jl_exception_in_transit') |
1143 | 1141 | msg = self.api.jl_typeof_str(exception)
|
1144 |
| - return char_p(msg).value |
| 1142 | + return c_char_p(msg).value |
1145 | 1143 |
|
1146 | 1144 | def help(self, name):
|
1147 | 1145 | """ Return help string for function by name. """
|
|
0 commit comments