cython

Форк
0
/
cpp_namespaces.pyx 
49 строк · 882.0 Байт
1
# mode: run
2
# tag: cpp, werror
3

4
cdef extern from "cpp_namespaces_helper.h" namespace "A":
5
    ctypedef int A_t
6
    cdef struct S:
7
        double x
8
        A_t k
9
    A_t A_func(A_t first, A_t)
10
    cdef void f(A_t)
11

12
cdef extern from "cpp_namespaces_helper.h" namespace "outer":
13
    int outer_value
14

15
cdef extern from "cpp_namespaces_helper.h" namespace "outer::inner":
16
    int inner_value
17

18
def test_function(x, y):
19
    """
20
    >>> test_function(1, 2)
21
    3
22
    >>> test_function(9, 16)
23
    25
24
    """
25
    return A_func(x, y)
26

27
def test_nested():
28
    """
29
    >>> test_nested()
30
    10
31
    100
32
    """
33
    print outer_value
34
    print inner_value
35

36
def test_typedef(A_t a):
37
    """
38
    >>> test_typedef(3)
39
    3
40
    """
41
    return a
42

43
def test_convert_struct(S s):
44
    """
45
    >>> py_value = {'x': 3.5, 'k': 10}
46
    >>> test_convert_struct(py_value) == py_value
47
    True
48
    """
49
    return s
50

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.