(func, cfunctype)
return new_func_ptr, wrapped_pyfunc
Casts a native function pointer or a Python callable into `c_void_p`.

  Args:
    func: A callable, or a `c_void_p` pointing to a native function, or `None`.
    cfunctype: A `CFUNCTYPE` prototype that is used to wrap `func` if it is
      a Python callable.

  Returns:
    A tuple `(func_ptr, wrapped_pyfunc)`, where `func_ptr` is a `c_void_p`
    object, and `wrapped_pyfunc` is a `CFUNCTYPE` object that wraps `func` if
    it is a Python callable. (If `func` is not a Python callable then
    `wrapped_pyfunc` is `None`.)
Casts a native function pointer or a Python callable into `c_void_p`.
Casts a native function pointer or a Python callable into c_void_p .
def cast_func_to_c_void_p(func, cfunctype):
  """Casts a native function pointer or a Python callable into `c_void_p`.

  Args:
    func: A callable, or a `c_void_p` pointing to a native function, or `None`.
    cfunctype: A `CFUNCTYPE` prototype that is used to wrap `func` if it is
      a Python callable.

  Returns:
    A tuple `(func_ptr, wrapped_pyfunc)`, where `func_ptr` is a `c_void_p`
    object, and `wrapped_pyfunc` is a `CFUNCTYPE` object that wraps `func` if
    it is a Python callable. (If `func` is not a Python callable then
    `wrapped_pyfunc` is `None`.)
  """
  if not (callable(func) or isinstance(func, ctypes.c_void_p) or func is None):
    raise TypeError(_INVALID_CALLBACK_TYPE.format(func))
  try:
    new_func_ptr = ctypes.cast(func, ctypes.c_void_p)
    wrapped_pyfunc = None
  except ctypes.ArgumentError:
    wrapped_pyfunc = cfunctype(func)
    new_func_ptr = ctypes.cast(wrapped_pyfunc, ctypes.c_void_p)
  return new_func_ptr, wrapped_pyfunc
def cast_func_to_c_void_p ( func , cfunctype ) : if not ( callable ( func ) or isinstance ( func , ctypes . c_void_p ) or func is None ) : raise TypeError ( _INVALID_CALLBACK_TYPE . format ( func ) ) try : new_func_ptr = ctypes . cast ( func , ctypes . c_void_p ) wrapped_pyfunc = None except ctypes . ArgumentError : wrapped_pyfunc = cfunctype ( func ) new_func_ptr = ctypes . cast ( wrapped_pyfunc , ctypes . c_void_p ) return new_func_ptr , wrapped_pyfunc