pygmt.clib.Session.get_libgmt_func
-
Session.
get_libgmt_func
(name, argtypes=None, restype=None)[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) – List of ctypes types used to convert the Python input arguments for
the API function.
restype (ctypes type) – The ctypes type used to convert the input returned by the function
into a Python 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'>