2 # GObject-Introspection - a framework for introspecting GObject libraries
3 # Copyright (C) 2008 Johan Dahlin
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the
17 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 # Boston, MA 02111-1307, USA.
21 from .ast import (Bitfield, Class, Enum, Interface, Member, Node,
22 Property, Struct, Union)
24 type_names, default_array_types,
25 TYPE_STRING, TYPE_INT8, TYPE_UINT8, TYPE_INT16, TYPE_UINT16,
26 TYPE_INT, TYPE_UINT, TYPE_UINT32, TYPE_INT32, TYPE_LONG,
27 TYPE_ULONG, TYPE_INT64, TYPE_UINT64, TYPE_FLOAT,
28 TYPE_DOUBLE, TYPE_BOOLEAN, TYPE_ANY, TYPE_SSIZET,
33 type_names['gchararray'] = TYPE_STRING
34 type_names['gint8'] = TYPE_INT8
35 type_names['guint8'] = TYPE_UINT8
36 type_names['gint16'] = TYPE_INT16
37 type_names['guint16'] = TYPE_UINT16
38 type_names['gint'] = TYPE_INT
39 type_names['guint'] = TYPE_UINT
40 type_names['gint32'] = TYPE_INT32
41 type_names['guint32'] = TYPE_UINT32
42 type_names['glong'] = TYPE_LONG
43 type_names['gulong'] = TYPE_ULONG
44 type_names['gint64'] = TYPE_INT64
45 type_names['guint64'] = TYPE_UINT64
46 type_names['gfloat'] = TYPE_FLOAT
47 type_names['gdouble'] = TYPE_DOUBLE
48 type_names['gchar*'] = TYPE_STRING
49 type_names['gboolean'] = TYPE_BOOLEAN
50 type_names['gpointer'] = TYPE_ANY
51 type_names['gconstpointer'] = TYPE_ANY
52 type_names['gsize'] = TYPE_SIZET
53 type_names['gssize'] = TYPE_SSIZET
54 type_names['gchar'] = TYPE_INT8
55 type_names['guchar'] = TYPE_UINT8
56 type_names['gshort'] = TYPE_INT16
57 type_names['gushort'] = TYPE_UINT16
59 # It's not very nice to duplicate the array types from ast.py,
60 # but a clean fix is hard without essentially hardcoding
61 # char * again inside transformer.py
62 default_array_types['guint8*'] = TYPE_UINT8
63 default_array_types['gchar**'] = TYPE_STRING
68 def __init__(self, name, type_name, members, get_type):
69 Enum.__init__(self, name, type_name, members)
70 self.ctype = type_name
71 self.type_name = type_name
72 self.get_type = get_type
75 return 'GlibEnum(%r, %r, %r)' % (self.name, self.members,
79 class GLibFlags(Bitfield):
81 def __init__(self, name, type_name, members, get_type):
82 Bitfield.__init__(self, name, type_name, members)
83 self.ctype = type_name
84 self.type_name = type_name
85 self.get_type = get_type
88 return 'GlibFlags(%r, %r, %r)' % (self.name, self.members,
92 class GLibEnumMember(Member):
94 def __init__(self, name, value, symbol, nick):
95 Member.__init__(self, name, value, symbol)
99 class GLibObject(Class):
101 def __init__(self, name, parent, type_name, get_type,
102 is_abstract, ctype=None):
103 Class.__init__(self, name, parent, is_abstract)
104 self.type_name = type_name
105 self.get_type = get_type
107 self.ctype = ctype or type_name
112 def __init__(self, type_name, get_type):
113 self.constructors = []
115 self.type_name = type_name
116 self.get_type = get_type
119 class GLibBoxedStruct(Struct, GLibBoxed):
121 def __init__(self, name, type_name, get_type, ctype=None):
122 Struct.__init__(self, name, ctype or type_name)
123 GLibBoxed.__init__(self, type_name, get_type)
126 class GLibBoxedUnion(Union, GLibBoxed):
128 def __init__(self, name, type_name, get_type, ctype=None):
129 Union.__init__(self, name, ctype or type_name)
130 GLibBoxed.__init__(self, type_name, get_type)
133 class GLibBoxedOther(Node, GLibBoxed):
135 def __init__(self, name, type_name, get_type):
136 Node.__init__(self, name)
137 GLibBoxed.__init__(self, type_name, get_type)
138 self.ctype = type_name
141 class GLibInterface(Interface):
143 def __init__(self, name, parent, type_name, get_type,
145 Interface.__init__(self, name, parent)
146 self.type_name = type_name
147 self.get_type = get_type
149 self.ctype = ctype or type_name
152 class GLibProperty(Property):
156 class GLibSignal(Node):
158 def __init__(self, name, retval):
159 Node.__init__(self, name)