summaryrefslogtreecommitdiff
path: root/src/map/magic-stmt.py
blob: 65f44a7f0b173e675842a8982c97926900285d22 (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
class op_t(object):
    __slots__ = ('_value')

    name = 'tmwa::magic::op_t'
    depth = 1
    enabled = True

    def __init__(self, value):
        if not value:
            value = None
        self._value = value

    def to_string(self):
        value = self._value
        if value is None:
            return '(op_t *) nullptr'
        return '(op_t *)'

    def children(self):
        value = self._value
        if value is None:
            return
        value = value.dereference()
        yield '->name', value['name']
        yield '->signature', value['signature']
        yield '->op', value['op']

    test_extra = '''
    using tmwa::operator "" _s;
    '''

    tests = [
            ('static_cast<tmwa::magic::op_t *>(nullptr)',
                '(op_t *) nullptr'),
            ('new tmwa::magic::op_t{"name"_s, "sig"_s, nullptr}',
                '(op_t *) = {->name = "name", ->signature = "sig", ->op = nullptr}'),
    ]