summaryrefslogtreecommitdiffstats
path: root/yql/essentials/udfs/common/python/bindings/py_cast.h
blob: 5dc4182ae917d1fe06f7c196d4009df6e1feaa07 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include "py_ptr.h"
#include "py_ctx.h"

#include <util/generic/typetraits.h>

namespace NPython {

template <typename T>
TPyObjectPtr PyCast(typename TTypeTraits<T>::TFuncParam value);

template <typename T>
T PyCast(PyObject* value);

template <typename T>
bool TryPyCast(PyObject* value, T& result);

template <typename T>
TPyObjectPtr ToPyUnicode(const T& value);

TPyObjectPtr ToPyObject(
    const TPyCastContext::TPtr& ctx,
    const NKikimr::NUdf::TType* type,
    const NKikimr::NUdf::TUnboxedValuePod& value);

NKikimr::NUdf::TUnboxedValue FromPyObject(
    const TPyCastContext::TPtr& ctx,
    const NKikimr::NUdf::TType* type,
    PyObject* value);

TPyObjectPtr ToPyArgs(
    const TPyCastContext::TPtr& ctx,
    const NKikimr::NUdf::TType* type,
    const NKikimr::NUdf::TUnboxedValuePod* args,
    const NKikimr::NUdf::TCallableTypeInspector& inspector);

void FromPyArgs(
    const TPyCastContext::TPtr& ctx,
    const NKikimr::NUdf::TType* type,
    PyObject* pyArgs,
    NKikimr::NUdf::TUnboxedValue* cArgs,
    const NKikimr::NUdf::TCallableTypeInspector& inspector);

} // namespace NPython