py_cast.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "py_ptr.h"
  3. #include "py_ctx.h"
  4. #include <util/generic/typetraits.h>
  5. namespace NPython {
  6. template <typename T>
  7. TPyObjectPtr PyCast(typename TTypeTraits<T>::TFuncParam value);
  8. template <typename T>
  9. T PyCast(PyObject* value);
  10. template <typename T>
  11. bool TryPyCast(PyObject* value, T& result);
  12. template <typename T>
  13. TPyObjectPtr ToPyUnicode(const T& value);
  14. TPyObjectPtr ToPyObject(
  15. const TPyCastContext::TPtr& ctx,
  16. const NKikimr::NUdf::TType* type,
  17. const NKikimr::NUdf::TUnboxedValuePod& value);
  18. NKikimr::NUdf::TUnboxedValue FromPyObject(
  19. const TPyCastContext::TPtr& ctx,
  20. const NKikimr::NUdf::TType* type,
  21. PyObject* value);
  22. TPyObjectPtr ToPyArgs(
  23. const TPyCastContext::TPtr& ctx,
  24. const NKikimr::NUdf::TType* type,
  25. const NKikimr::NUdf::TUnboxedValuePod* args,
  26. const NKikimr::NUdf::TCallableTypeInspector& inspector);
  27. void FromPyArgs(
  28. const TPyCastContext::TPtr& ctx,
  29. const NKikimr::NUdf::TType* type,
  30. PyObject* pyArgs,
  31. NKikimr::NUdf::TUnboxedValue* cArgs,
  32. const NKikimr::NUdf::TCallableTypeInspector& inspector);
  33. } // namspace NPython