pygmt.clib.Session.get_libgmt_func
- Session.get_libgmt_func(name, argtypes=None, restype=<class 'ctypes.c_int'>)[source]
Get a ctypes function from the libgmt shared library.
Assigns the argument and return type conversions for the function.
Use this method to access a C function from libgmt.
- Parameters:
name (
str) – The name of the GMT API function.argtypes (
list|None, default:None) – List of ctypes types used to convert the Python input arguments for the API function.restype (
Any, default:<class 'ctypes.c_int'>) – The ctypes type used to convert the value returned by the function into a Python type [Default isctypes.c_int]. UseNonefor functions that return void.
- Return type:
- Returns:
function – The GMT API function.
Examples
>>> from ctypes import c_void_p, c_int >>> with Session() as lib: ... func = lib.get_libgmt_func( ... "GMT_Destroy_Session", argtypes=[c_void_p], restype=c_int ... ) >>> type(func) <class 'ctypes.CDLL.__init__.<locals>._FuncPtr'>