summaryrefslogtreecommitdiff
path: root/src/sexpr/variant.py
blob: 3be402a9f7fdad63ce0334ca624ab23802480706 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Variant(object):
    __slots__ = ('_value')
    name = 'tmwa::sexpr::Variant'
    enabled = True

    def __init__(self, value):
        self._value = value

    def to_string(self):
        return None

    def children(self):
        value = self._value
        data = value['data']
        state = value['state']
        ty = value.type.template_argument(state)
        yield '(%s)' % ty, data.address.cast(ty.pointer()).dereference()

    tests = [
            ('tmwa::sexpr::Variant<int, const char *>(42)', '{(int) = 42}'),
            ('tmwa::sexpr::Variant<int, const char *>("Hello, World!")', '{(const char *) = "Hello, World!"}'),
    ]