summaryrefslogtreecommitdiff
path: root/giscanner/glibast.py
blob: 50d51c346bafa103a6e2f5e5dfed1026753282b8 (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# -*- Mode: Python -*-
# GObject-Introspection - a framework for introspecting GObject libraries
# Copyright (C) 2008  Johan Dahlin
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#

from .ast import Class, Enum, Interface, Member, Node, Property, Struct


class GLibEnum(Enum):
    def __init__(self, name, members, type_name, get_type):
        Enum.__init__(self, name, type_name, members)
        self.ctype = type_name
        self.type_name = type_name
        self.get_type = get_type

    def __repr__(self):
        return '%s(%r, %r, %r)' % (
            self.__class__.__name__,
            self.name,
            self.members,
            self.get_type)


class GLibFlags(GLibEnum):
    pass


class GLibEnumMember(Member):
    def __init__(self, name, value, symbol, nick):
        Member.__init__(self, name, value, symbol)
        self.nick = nick


class GLibObject(Class):
    def __init__(self, name, parent, type_name, get_type):
        Class.__init__(self, name, parent)
        self.ctype = type_name
        self.type_name = type_name
        self.get_type = get_type
        self.signals = []

class GLibBoxed(Struct):
    def __init__(self, name, type_name, get_type):
        Struct.__init__(self, name, get_type)
        self.ctype = name
        self.constructors = []
        self.methods = []
        self.type_name = type_name
        self.symbol = type_name
        self.get_type = get_type


class GLibInterface(Interface):
    def __init__(self, name, type_name, get_type):
        Interface.__init__(self, name)
        self.ctype = type_name
        self.type_name = type_name
        self.get_type = get_type
        self.signals = []


class GLibProperty(Property):
    pass


class GLibSignal(Node):
    def __init__(self, name, retval):
        Node.__init__(self, name)
        self.retval = retval
        self.parameters = []