2 # GObject-Introspection - a framework for introspecting GObject libraries
3 # Copyright (C) 2008 Johan Dahlin
4 # Copyright (C) 2008, 2009 Red Hat, Inc.
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2 of the License, or (at your option) any later version.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the
18 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 # Boston, MA 02111-1307, USA.
22 from .odict import odict
23 from .utils import to_underscores
26 """A Type can be either:
27 * A reference to a node (target_giname)
28 * A reference to a "fundamental" type like 'utf8'
29 * A "foreign" type - this can be any string."
30 If none are specified, then it's in an "unresolved" state. An
31 unresolved type can have two data sources; a "ctype" which comes
32 from a C type string, or a gtype_name (from g_type_name()).
38 target_fundamental=None,
41 _target_unknown=False,
45 self.gtype_name = gtype_name
46 self.origin_symbol = origin_symbol
48 assert isinstance(self, TypeUnknown)
49 elif target_fundamental:
50 assert target_giname is None
51 assert target_foreign is None
53 assert '.' in target_giname
54 assert target_fundamental is None
55 assert target_foreign is None
57 assert ctype is not None
58 assert target_giname is None
59 assert target_fundamental is None
61 assert (ctype is not None) or (gtype_name is not None)
62 self.target_fundamental = target_fundamental
63 self.target_giname = target_giname
64 self.target_foreign = target_foreign
65 self.is_const = is_const
69 return (self.target_fundamental or
74 def unresolved_string(self):
78 return self.gtype_name
83 def create_from_gtype_name(cls, gtype_name):
84 """Parse a GType name (as from g_type_name()), and return a
85 Type instance. Note that this function performs namespace lookup,
86 in contrast to the other create_type() functions."""
87 # First, is it a fundamental?
88 fundamental = type_names.get(gtype_name)
89 if fundamental is not None:
90 return cls(target_fundamental=fundamental.target_fundamental)
91 if gtype_name == 'GHashTable':
92 return Map(TYPE_ANY, TYPE_ANY, gtype_name=gtype_name)
93 elif gtype_name in ('GArray', 'GPtrArray', 'GByteArray'):
94 return Array('GLib.' + gtype_name[1:], TYPE_ANY,
95 gtype_name=gtype_name)
96 return cls(gtype_name=gtype_name)
99 assert self.target_giname is not None
100 return self.target_giname.split('.')[1]
102 def __cmp__(self, other):
103 if self.target_fundamental:
104 return cmp(self.target_fundamental, other.target_fundamental)
105 if self.target_giname:
106 return cmp(self.target_giname, other.target_giname)
107 if self.target_foreign:
108 return cmp(self.target_foreign, other.target_foreign)
109 return cmp(self.ctype, other.ctype)
111 def is_equiv(self, typeval):
112 """Return True if the specified types are compatible at
113 an introspection level, disregarding their C types.
114 A sequence may be given for typeval, in which case
115 this function returns True if the type is compatible with
117 if isinstance(typeval, (list, tuple)):
119 if self.is_equiv(val):
122 return self == typeval
125 return Type(target_fundamental=self.target_fundamental,
126 target_giname=self.target_giname,
127 target_foreign=self.target_foreign,
129 is_const=self.is_const)
132 if self.target_fundamental:
133 return self.target_fundamental
134 elif self.target_giname:
135 return self.target_giname
136 elif self.target_foreign:
137 return self.target_foreign
140 if self.target_fundamental:
141 data = 'target_fundamental=%s, ' % (self.target_fundamental, )
142 elif self.target_giname:
143 data = 'target_giname=%s, ' % (self.target_giname, )
144 elif self.target_foreign:
145 data = 'target_foreign=%s, ' % (self.target_foreign, )
148 return '%s(%sctype=%s)' % (self.__class__.__name__, data, self.ctype)
150 class TypeUnknown(Type):
152 Type.__init__(self, _target_unknown=True)
158 TYPE_NONE = Type(target_fundamental='none', ctype='void')
159 TYPE_ANY = Type(target_fundamental='gpointer', ctype='gpointer')
161 TYPE_BOOLEAN = Type(target_fundamental='gboolean', ctype='gboolean')
162 TYPE_INT8 = Type(target_fundamental='gint8', ctype='gint8')
163 TYPE_UINT8 = Type(target_fundamental='guint8', ctype='guint8')
164 TYPE_INT16 = Type(target_fundamental='gint16', ctype='gint16')
165 TYPE_UINT16 = Type(target_fundamental='guint16', ctype='guint16')
166 TYPE_INT32 = Type(target_fundamental='gint32', ctype='gint32')
167 TYPE_UINT32 = Type(target_fundamental='guint32', ctype='guint32')
168 TYPE_INT64 = Type(target_fundamental='gint64', ctype='gint64')
169 TYPE_UINT64 = Type(target_fundamental='guint64', ctype='guint64')
170 TYPE_CHAR = Type(target_fundamental='gchar', ctype='gchar')
171 TYPE_SHORT = Type(target_fundamental='gshort', ctype='gshort')
172 TYPE_USHORT = Type(target_fundamental='gushort', ctype='gushort')
173 TYPE_INT = Type(target_fundamental='gint', ctype='gint')
174 TYPE_UINT = Type(target_fundamental='guint', ctype='guint')
175 TYPE_LONG = Type(target_fundamental='glong', ctype='glong')
176 TYPE_ULONG = Type(target_fundamental='gulong', ctype='gulong')
178 TYPE_LONG_LONG = Type(target_fundamental='long long', ctype='long long')
179 TYPE_LONG_ULONG = Type(target_fundamental='unsigned long long',
180 ctype='unsigned long long')
181 TYPE_FLOAT = Type(target_fundamental='gfloat', ctype='gfloat')
182 TYPE_DOUBLE = Type(target_fundamental='gdouble', ctype='gdouble')
184 TYPE_LONG_DOUBLE = Type(target_fundamental='long double',
186 TYPE_UNICHAR = Type(target_fundamental='gunichar', ctype='gunichar')
188 # C types with semantics overlaid
189 TYPE_GTYPE = Type(target_fundamental='GType', ctype='GType')
190 TYPE_STRING = Type(target_fundamental='utf8', ctype='gchar*')
191 TYPE_FILENAME = Type(target_fundamental='filename', ctype='gchar*')
193 TYPE_VALIST = Type(target_fundamental='va_list', ctype='va_list')
195 BASIC_GIR_TYPES = [TYPE_BOOLEAN, TYPE_INT8, TYPE_UINT8, TYPE_INT16,
196 TYPE_UINT16, TYPE_INT32, TYPE_UINT32, TYPE_INT64,
197 TYPE_UINT64, TYPE_CHAR, TYPE_SHORT, TYPE_USHORT, TYPE_INT,
198 TYPE_UINT, TYPE_LONG, TYPE_ULONG, TYPE_LONG_LONG,
199 TYPE_LONG_ULONG, TYPE_FLOAT, TYPE_DOUBLE,
200 TYPE_LONG_DOUBLE, TYPE_UNICHAR, TYPE_GTYPE]
201 GIR_TYPES = [TYPE_NONE, TYPE_ANY]
202 GIR_TYPES.extend(BASIC_GIR_TYPES)
203 GIR_TYPES.extend([TYPE_STRING, TYPE_FILENAME, TYPE_VALIST])
205 INTROSPECTABLE_BASIC = list(GIR_TYPES)
206 for v in [TYPE_NONE, TYPE_ANY,
207 TYPE_LONG_LONG, TYPE_LONG_ULONG,
208 TYPE_LONG_DOUBLE, TYPE_VALIST]:
209 INTROSPECTABLE_BASIC.remove(v)
212 for typeval in GIR_TYPES:
213 type_names[typeval.target_fundamental] = typeval
214 basic_type_names = {}
215 for typeval in BASIC_GIR_TYPES:
216 basic_type_names[typeval.target_fundamental] = typeval
219 type_names['char'] = TYPE_CHAR
220 type_names['signed char'] = TYPE_INT8
221 type_names['unsigned char'] = TYPE_UINT8
222 type_names['short'] = TYPE_SHORT
223 type_names['signed short'] = TYPE_SHORT
224 type_names['unsigned short'] = TYPE_USHORT
225 type_names['int'] = TYPE_INT
226 type_names['signed int'] = TYPE_INT
227 type_names['unsigned short int'] = TYPE_USHORT
228 type_names['signed'] = TYPE_INT
229 type_names['unsigned int'] = TYPE_UINT
230 type_names['unsigned'] = TYPE_UINT
231 type_names['long'] = TYPE_LONG
232 type_names['signed long'] = TYPE_LONG
233 type_names['unsigned long'] = TYPE_ULONG
234 type_names['unsigned long int'] = TYPE_ULONG
235 type_names['float'] = TYPE_FLOAT
236 type_names['double'] = TYPE_DOUBLE
237 type_names['char*'] = TYPE_STRING
238 type_names['void*'] = TYPE_ANY
239 type_names['void'] = TYPE_NONE
240 # Also alias the signed one here
241 type_names['signed long long'] = TYPE_LONG_LONG
243 # A few additional GLib type aliases
244 type_names['guchar'] = TYPE_UINT8
245 type_names['gchararray'] = TYPE_STRING
246 type_names['gchar*'] = TYPE_STRING
247 type_names['goffset'] = TYPE_INT64
248 type_names['gunichar2'] = TYPE_UINT16
249 type_names['gsize'] = TYPE_ULONG
250 type_names['gssize'] = TYPE_LONG
251 type_names['gconstpointer'] = TYPE_ANY
253 # We used to support these; continue to do so
254 type_names['any'] = TYPE_ANY
255 type_names['boolean'] = TYPE_BOOLEAN
256 type_names['uint'] = TYPE_UINT
257 type_names['ulong'] = TYPE_ULONG
259 # C stdio, used in GLib public headers; squash this for now here
260 # until we move scanning into GLib and can (skip)
261 type_names['FILE*'] = TYPE_ANY
263 # One off C unix type definitions; note some of these may be GNU Libc
264 # specific. If someone is actually bitten by this, feel free to do
265 # the required configure goop to determine their size and replace
268 # We don't want to encourage people to use these in their APIs because
269 # they compromise the platform-independence that GLib gives you.
270 # These are here mostly to avoid blowing when random platform-specific
271 # methods are added under #ifdefs inside GLib itself. We could just (skip)
272 # the relevant methods, but on the other hand, since these types are just
273 # integers it's easy enough to expand them.
274 type_names['size_t'] = type_names['gsize']
275 type_names['time_t'] = TYPE_LONG
276 type_names['off_t'] = type_names['gsize']
277 type_names['pid_t'] = TYPE_INT
278 type_names['uid_t'] = TYPE_UINT
279 type_names['gid_t'] = TYPE_UINT
280 type_names['dev_t'] = TYPE_INT
281 type_names['socklen_t'] = TYPE_INT32
282 type_names['size_t'] = TYPE_ULONG
283 type_names['ssize_t'] = TYPE_LONG
286 type_names['id'] = TYPE_ANY
292 PARAM_DIRECTION_IN = 'in'
293 PARAM_DIRECTION_OUT = 'out'
294 PARAM_DIRECTION_INOUT = 'inout'
296 PARAM_SCOPE_CALL = 'call'
297 PARAM_SCOPE_ASYNC = 'async'
298 PARAM_SCOPE_NOTIFIED = 'notified'
300 PARAM_TRANSFER_NONE = 'none'
301 PARAM_TRANSFER_CONTAINER = 'container'
302 PARAM_TRANSFER_FULL = 'full'
304 class Namespace(object):
305 def __init__(self, name, version,
306 identifier_prefixes=None,
307 symbol_prefixes=None):
309 self.version = version
310 if identifier_prefixes is not None:
311 self.identifier_prefixes = identifier_prefixes
313 self.identifier_prefixes = [name]
314 if symbol_prefixes is not None:
315 self.symbol_prefixes = symbol_prefixes
317 ps = self.identifier_prefixes
318 self.symbol_prefixes = [to_underscores(p).lower() for p in ps]
319 # cache upper-cased versions
320 self._ucase_symbol_prefixes = [p.upper() for p in self.symbol_prefixes]
321 self._names = odict() # Maps from GIName -> node
322 self._aliases = {} # Maps from GIName -> GIName
323 self._type_names = {} # Maps from GTName -> node
324 self._ctypes = {} # Maps from CType -> node
325 self._symbols = {} # Maps from function symbols -> Function
336 def type_names(self):
337 return self._type_names
343 def type_from_name(self, name, ctype=None):
344 """Backwards compatibility method for older .gir files, which
345 only use the 'name' attribute. If name refers to a fundamental type,
346 create a Type object referncing it. If name is already a
347 fully-qualified GIName like 'Foo.Bar', returns a Type targeting it .
348 Otherwise a Type targeting name qualififed with the namespace name is
350 if name in type_names:
351 return Type(target_fundamental=name, ctype=ctype)
355 target = '%s.%s' % (self.name, name)
356 return Type(target_giname=target, ctype=ctype)
358 def append(self, node, replace=False):
359 previous = self._names.get(node.name)
360 if previous is not None:
362 raise ValueError("Namespace conflict: %r" % (node, ))
363 self.remove(previous)
364 # A layering violation...but oh well.
365 if isinstance(node, Alias):
366 self._aliases[node.name] = node
367 elif isinstance(node, Registered) and node.gtype_name is not None:
368 self._type_names[node.gtype_name] = node
369 elif isinstance(node, Function):
370 self._symbols[node.symbol] = node
371 assert isinstance(node, Node)
372 assert node.namespace is None
373 node.namespace = self
374 self._names[node.name] = node
375 if hasattr(node, 'ctype'):
376 self._ctypes[node.ctype] = node
377 if hasattr(node, 'symbol'):
378 self._ctypes[node.symbol] = node
380 def remove(self, node):
381 if isinstance(node, Alias):
382 del self._aliases[node.name]
383 elif isinstance(node, Registered) and node.gtype_name is not None:
384 del self._type_names[node.gtype_name]
385 del self._names[node.name]
386 node.namespace = None
387 if hasattr(node, 'ctype'):
388 del self._ctypes[node.ctype]
389 if isinstance(node, Function):
390 del self._symbols[node.symbol]
392 def float(self, node):
393 """Like remove(), but doesn't unset the node's namespace
394 back-reference, and it's still possible to look up
395 functions via get_by_symbol()."""
396 if isinstance(node, Function):
399 self._symbols[symbol] = node
400 node.namespace = self
403 return iter(self._names)
406 return self._names.iteritems()
408 def itervalues(self):
409 return self._names.itervalues()
412 return self._names.get(name)
414 def get_by_ctype(self, ctype):
415 return self._ctypes.get(ctype)
417 def get_by_symbol(self, symbol):
418 return self._symbols.get(symbol)
420 def walk(self, callback):
421 for node in self.itervalues():
422 node.walk(callback, [])
424 class Include(object):
426 def __init__(self, name, version):
428 self.version = version
431 def from_string(cls, string):
432 return cls(*string.split('-', 1))
434 def __cmp__(self, other):
435 namecmp = cmp(self.name, other.name)
438 return cmp(self.version, other.version)
441 return hash(str(self))
444 return '%s-%s' % (self.name, self.version)
446 class Annotated(object):
447 """An object which has a few generic metadata
452 self.introspectable = True
453 self.attributes = [] # (key, value)*
454 self.deprecated = None
455 self.deprecated_version = None
458 class Node(Annotated):
459 """A node is a type of object which is uniquely identified by its
460 (namespace, name) pair. When combined with a ., this is called a
461 GIName. It's possible for nodes to contain or point to other nodes."""
463 c_name = property(lambda self: self.namespace.name + self.name)
464 gi_name = property(lambda self: '%s.%s' % (self.namespace.name, self.name))
466 def __init__(self, name=None):
467 Annotated.__init__(self)
468 self.namespace = None # Should be set later by Namespace.append()
471 self.file_positions = set()
473 def create_type(self):
474 """Create a Type object referencing this node."""
475 assert self.namespace is not None
476 return Type(target_giname=('%s.%s' % (self.namespace.name, self.name)))
478 def __cmp__(self, other):
479 nscmp = cmp(self.namespace, other.namespace)
482 return cmp(self.name, other.name)
485 return '%s(%r)' % (self.__class__.__name__, self.name)
487 def inherit_file_positions(self, node):
488 self.file_positions.update(node.file_positions)
490 def add_file_position(self, filename, line, column):
491 self.file_positions.add((filename, line, column))
493 def add_symbol_reference(self, symbol):
494 if symbol.source_filename:
495 self.add_file_position(symbol.source_filename, symbol.line, -1)
497 def walk(self, callback, chain):
498 res = callback(self, chain)
499 assert res in (True, False), "Walk function must return boolean, not %r" % (res, )
503 self._walk(callback, chain)
506 def _walk(self, callback, chain):
511 """A node that (possibly) has gtype_name and get_type."""
512 def __init__(self, gtype_name, get_type):
513 assert (gtype_name is None and get_type is None) or \
514 (gtype_name is not None and get_type is not None)
515 self.gtype_name = gtype_name
516 self.get_type = get_type
519 class Callable(Node):
521 def __init__(self, name, retval, parameters, throws):
522 Node.__init__(self, name)
524 self.parameters = parameters
525 self.throws = not not throws
526 self.instance_parameter = None # Parameter
528 def get_parameter_index(self, name):
529 for i, parameter in enumerate(self.parameters):
530 if parameter.argname == name:
532 raise ValueError("Unknown argument %s" % (name, ))
534 def get_parameter(self, name):
535 for parameter in self.parameters:
536 if parameter.argname == name:
538 raise ValueError("Unknown argument %s" % (name, ))
541 class Function(Callable):
543 def __init__(self, name, retval, parameters, throws, symbol):
544 Callable.__init__(self, name, retval, parameters, throws)
546 self.is_method = False
547 self.is_constructor = False
548 self.shadowed_by = None # C symbol string
549 self.shadows = None # C symbol string
552 class VFunction(Callable):
554 def __init__(self, name, retval, parameters, throws):
555 Callable.__init__(self, name, retval, parameters, throws)
559 def from_callback(cls, cb):
560 obj = cls(cb.name, cb.retval, cb.parameters[1:],
569 Type.__init__(self, '<varargs>', target_fundamental='<varargs>')
574 GLIB_ARRAY = 'GLib.Array'
575 GLIB_BYTEARRAY = 'GLib.ByteArray'
576 GLIB_PTRARRAY = 'GLib.PtrArray'
578 def __init__(self, array_type, element_type, **kwargs):
579 Type.__init__(self, target_fundamental='<array>',
581 if (array_type is None or array_type == self.C):
582 self.array_type = self.C
584 assert array_type in (self.GLIB_ARRAY,
586 self.GLIB_PTRARRAY), array_type
587 self.array_type = array_type
588 assert isinstance(element_type, Type)
589 self.element_type = element_type
590 self.zeroterminated = True
591 self.length_param_name = None
595 arr = Array(self.array_type, self.element_type)
596 arr.element_type = self.element_type
597 arr.zeroterminated = self.zeroterminated
598 arr.length_param_name = self.length_param_name
604 def __init__(self, name, element_type, **kwargs):
605 Type.__init__(self, target_fundamental='<list>',
608 assert isinstance(element_type, Type)
609 self.element_type = element_type
612 l = List(self.name, self.element_type)
613 l.element_type = self.element_type
614 l.zeroterminated = self.zeroterminated
615 l.length_param_name = self.length_param_name
621 def __init__(self, key_type, value_type, **kwargs):
622 Type.__init__(self, target_fundamental='<map>', **kwargs)
623 assert isinstance(key_type, Type)
624 self.key_type = key_type
625 assert isinstance(value_type, Type)
626 self.value_type = value_type
629 m = Map(self.key_type, self.value_type)
634 def __init__(self, name, target, ctype=None):
635 Node.__init__(self, name)
640 class TypeContainer(Annotated):
641 """A fundamental base class for Return and Parameter."""
643 def __init__(self, typenode, transfer):
644 Annotated.__init__(self)
646 if transfer is not None:
647 self.transfer = transfer
648 elif typenode.is_const:
649 self.transfer = PARAM_TRANSFER_NONE
654 class Parameter(TypeContainer):
655 """An argument to a function."""
657 def __init__(self, argname, typenode, direction=None,
658 transfer=None, allow_none=False, scope=None,
659 caller_allocates=False):
660 TypeContainer.__init__(self, typenode, transfer)
661 self.argname = argname
662 self.direction = direction
663 self.allow_none = allow_none
665 self.caller_allocates = caller_allocates
666 self.closure_name = None
667 self.destroy_name = None
670 class Return(TypeContainer):
671 """A return value from a function."""
673 def __init__(self, rtype, transfer=None):
674 TypeContainer.__init__(self, rtype, transfer)
675 self.direction = PARAM_DIRECTION_OUT
678 class Enum(Node, Registered):
680 def __init__(self, name, ctype,
683 c_symbol_prefix=None,
685 Node.__init__(self, name)
686 Registered.__init__(self, gtype_name, get_type)
687 self.c_symbol_prefix = c_symbol_prefix
689 self.members = members
690 # Associated error quark
691 self.error_quark = None
694 class Bitfield(Node, Registered):
696 def __init__(self, name, ctype,
698 c_symbol_prefix=None,
701 Node.__init__(self, name)
702 Registered.__init__(self, gtype_name, get_type)
704 self.c_symbol_prefix = c_symbol_prefix
705 self.members = members
708 class Member(Annotated):
710 def __init__(self, name, value, symbol, nick):
711 Annotated.__init__(self)
717 def __cmp__(self, other):
718 return cmp(self.name, other.name)
722 class Compound(Node, Registered):
723 def __init__(self, name,
727 c_symbol_prefix=None,
729 Node.__init__(self, name)
730 Registered.__init__(self, gtype_name, get_type)
733 self.static_methods = []
735 self.constructors = []
736 self.disguised = disguised
737 self.gtype_name = gtype_name
738 self.get_type = get_type
739 self.c_symbol_prefix = c_symbol_prefix
741 def add_gtype(self, gtype_name, get_type):
742 self.gtype_name = gtype_name
743 self.get_type = get_type
745 def _walk(self, callback, chain):
746 for ctor in self.constructors:
747 ctor.walk(callback, chain)
748 for func in self.methods:
749 func.walk(callback, chain)
750 for func in self.static_methods:
751 func.walk(callback, chain)
752 for field in self.fields:
753 if field.anonymous_node is not None:
754 field.anonymous_node.walk(callback, chain)
756 class Field(Annotated):
758 def __init__(self, name, typenode, readable, writable, bits=None,
759 anonymous_node=None):
760 Annotated.__init__(self)
761 assert (typenode or anonymous_node)
764 self.readable = readable
765 self.writable = writable
767 self.anonymous_node = anonymous_node
769 def __cmp__(self, other):
770 return cmp(self.name, other.name)
773 class Record(Compound):
775 def __init__(self, name,
779 c_symbol_prefix=None,
781 Compound.__init__(self, name,
783 gtype_name=gtype_name,
785 c_symbol_prefix=c_symbol_prefix,
787 # If non-None, this record defines the FooClass C structure
788 # for some Foo GObject (or similar for GInterface)
789 self.is_gtype_struct_for = None
792 class Union(Compound):
794 def __init__(self, name,
798 c_symbol_prefix=None,
800 Compound.__init__(self, name,
802 gtype_name=gtype_name,
804 c_symbol_prefix=c_symbol_prefix,
808 class Boxed(Node, Registered):
809 """A boxed type with no known associated structure/union."""
810 def __init__(self, name,
813 c_symbol_prefix=None):
814 assert gtype_name is not None
815 assert get_type is not None
816 Node.__init__(self, name)
817 Registered.__init__(self, gtype_name, get_type)
818 if get_type is not None:
819 assert c_symbol_prefix is not None
820 self.c_symbol_prefix = c_symbol_prefix
821 self.constructors = []
823 self.static_methods = []
825 def _walk(self, callback, chain):
826 for ctor in self.constructors:
827 ctor.walk(callback, chain)
828 for meth in self.methods:
829 meth.walk(callback, chain)
830 for meth in self.static_methods:
831 meth.walk(callback, chain)
834 class Signal(Callable):
836 def __init__(self, name, retval, parameters):
837 Callable.__init__(self, name, retval, parameters, False)
840 class Class(Node, Registered):
842 def __init__(self, name, parent,
846 c_symbol_prefix=None,
848 Node.__init__(self, name)
849 Registered.__init__(self, gtype_name, get_type)
851 self.c_symbol_prefix = c_symbol_prefix
853 self.fundamental = False
854 self.unref_func = None
856 self.set_value_func = None
857 self.get_value_func = None
858 # When we're in the scanner, we keep around a list
859 # of parents so that we can transparently fall back
860 # if there are 'hidden' parents
861 self.parent_chain = []
862 self.glib_type_struct = None
863 self.is_abstract = is_abstract
865 self.virtual_methods = []
866 self.static_methods = []
868 self.constructors = []
873 def _walk(self, callback, chain):
874 for meth in self.methods:
875 meth.walk(callback, chain)
876 for meth in self.virtual_methods:
877 meth.walk(callback, chain)
878 for meth in self.static_methods:
879 meth.walk(callback, chain)
880 for ctor in self.constructors:
881 ctor.walk(callback, chain)
882 for field in self.fields:
883 if field.anonymous_node:
884 field.anonymous_node.walk(callback, chain)
885 for sig in self.signals:
886 sig.walk(callback, chain)
889 class Interface(Node, Registered):
891 def __init__(self, name, parent,
895 c_symbol_prefix=None):
896 Node.__init__(self, name)
897 Registered.__init__(self, gtype_name, get_type)
899 self.c_symbol_prefix = c_symbol_prefix
901 self.parent_chain = []
904 self.static_methods = []
905 self.virtual_methods = []
906 self.glib_type_struct = None
909 self.prerequisites = []
911 def _walk(self, callback, chain):
912 for meth in self.methods:
913 meth.walk(callback, chain)
914 for meth in self.static_methods:
915 meth.walk(callback, chain)
916 for meth in self.virtual_methods:
917 meth.walk(callback, chain)
918 for field in self.fields:
919 if field.anonymous_node:
920 field.anonymous_node.walk(callback, chain)
921 for sig in self.signals:
922 sig.walk(callback, chain)
925 class Constant(Node):
927 def __init__(self, name, value_type, value):
928 Node.__init__(self, name)
929 self.value_type = value_type
933 class Property(Node):
935 def __init__(self, name, typeobj, readable, writable,
936 construct, construct_only, transfer=None):
937 Node.__init__(self, name)
939 self.readable = readable
940 self.writable = writable
941 self.construct = construct
942 self.construct_only = construct_only
943 self.transfer = PARAM_TRANSFER_NONE
946 class Callback(Callable):
948 def __init__(self, name, retval, parameters, throws, ctype=None):
949 Callable.__init__(self, name, retval, parameters, throws)