File: cpp_enums.pyx

package info (click to toggle)
cython 3.1.6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,932 kB
  • sloc: python: 92,172; ansic: 19,275; cpp: 1,407; xml: 1,031; javascript: 511; makefile: 373; sh: 223; sed: 11
file content (58 lines) | stat: -rw-r--r-- 810 bytes parent folder | download | duplicates (2)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
# tag: cpp
# mode: run, no-cpp-locals

cdef extern from *:
    """
    enum Enum1 {
        Item1,
        Item2
    };

    """
    cdef enum Enum1:
        Item1
        Item2

a = Item1
b = Item2

cdef Enum1 x, y
x = Item1
y = Item2


def compare_enums():
    """
    >>> compare_enums()
    (True, True, True, True)
    """
    return x == a, a == Item1, b == y, y == Item2


cdef extern from * namespace "Namespace1":
    """
    namespace Namespace1 {
        enum Enum2 {
            Item3,
            Item4
        };
    }
    """
    cdef enum Enum2:
        Item3
        Item4

c = Item3
d = Item4

cdef Enum2 z, w
z = Item3
w = Item4


def compare_namespace_enums():
    """
    >>> compare_namespace_enums()
    (True, True, True, True)
    """
    return z == c, c == Item3, d == w, d == Item4