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
527 def get_parameter_index(self, name):
528 for i, parameter in enumerate(self.parameters):
529 if parameter.argname == name:
531 raise ValueError("Unknown argument %s" % (name, ))
533 def get_parameter(self, name):
534 for parameter in self.parameters:
535 if parameter.argname == name:
537 raise ValueError("Unknown argument %s" % (name, ))
540 class Function(Callable):
542 def __init__(self, name, retval, parameters, throws, symbol):
543 Callable.__init__(self, name, retval, parameters, throws)
545 self.is_method = False
546 self.is_constructor = False
547 self.shadowed_by = None # C symbol string
548 self.shadows = None # C symbol string
551 class VFunction(Callable):
553 def __init__(self, name, retval, parameters, throws):
554 Callable.__init__(self, name, retval, parameters, throws)
558 def from_callback(cls, cb):
559 obj = cls(cb.name, cb.retval, cb.parameters[1:],
568 Type.__init__(self, '<varargs>', target_fundamental='<varargs>')
573 GLIB_ARRAY = 'GLib.Array'
574 GLIB_BYTEARRAY = 'GLib.ByteArray'
575 GLIB_PTRARRAY = 'GLib.PtrArray'
577 def __init__(self, array_type, element_type, **kwargs):
578 Type.__init__(self, target_fundamental='<array>',
580 if (array_type is None or array_type == self.C):
581 self.array_type = self.C
583 assert array_type in (self.GLIB_ARRAY,
585 self.GLIB_PTRARRAY), array_type
586 self.array_type = array_type
587 assert isinstance(element_type, Type)
588 self.element_type = element_type
589 self.zeroterminated = True
590 self.length_param_name = None
594 arr = Array(self.array_type, self.element_type)
595 arr.element_type = self.element_type
596 arr.zeroterminated = self.zeroterminated
597 arr.length_param_name = self.length_param_name
603 def __init__(self, name, element_type, **kwargs):
604 Type.__init__(self, target_fundamental='<list>',
607 assert isinstance(element_type, Type)
608 self.element_type = element_type
611 l = List(self.name, self.element_type)
612 l.element_type = self.element_type
613 l.zeroterminated = self.zeroterminated
614 l.length_param_name = self.length_param_name
620 def __init__(self, key_type, value_type, **kwargs):
621 Type.__init__(self, target_fundamental='<map>', **kwargs)
622 assert isinstance(key_type, Type)
623 self.key_type = key_type
624 assert isinstance(value_type, Type)
625 self.value_type = value_type
628 m = Map(self.key_type, self.value_type)
633 def __init__(self, name, target, ctype=None):
634 Node.__init__(self, name)
639 class TypeContainer(Annotated):
640 """A fundamental base class for Return and Parameter."""
642 def __init__(self, typenode, transfer):
643 Annotated.__init__(self)
645 if transfer is not None:
646 self.transfer = transfer
647 elif typenode.is_const:
648 self.transfer = PARAM_TRANSFER_NONE
653 class Parameter(TypeContainer):
654 """An argument to a function."""
656 def __init__(self, argname, typenode, direction=None,
657 transfer=None, allow_none=False, scope=None,
658 caller_allocates=False):
659 TypeContainer.__init__(self, typenode, transfer)
660 self.argname = argname
661 self.direction = direction
662 self.allow_none = allow_none
664 self.caller_allocates = caller_allocates
665 self.closure_name = None
666 self.destroy_name = None
669 class Return(TypeContainer):
670 """A return value from a function."""
672 def __init__(self, rtype, transfer=None):
673 TypeContainer.__init__(self, rtype, transfer)
674 self.direction = PARAM_DIRECTION_OUT
677 class Enum(Node, Registered):
679 def __init__(self, name, ctype,
682 c_symbol_prefix=None,
684 Node.__init__(self, name)
685 Registered.__init__(self, gtype_name, get_type)
686 self.c_symbol_prefix = c_symbol_prefix
688 self.members = members
689 # Associated error quark
690 self.error_quark = None
693 class Bitfield(Node, Registered):
695 def __init__(self, name, ctype,
697 c_symbol_prefix=None,
700 Node.__init__(self, name)
701 Registered.__init__(self, gtype_name, get_type)
703 self.c_symbol_prefix = c_symbol_prefix
704 self.members = members
707 class Member(Annotated):
709 def __init__(self, name, value, symbol, nick):
710 Annotated.__init__(self)
716 def __cmp__(self, other):
717 return cmp(self.name, other.name)
721 class Compound(Node, Registered):
722 def __init__(self, name,
726 c_symbol_prefix=None,
728 Node.__init__(self, name)
729 Registered.__init__(self, gtype_name, get_type)
732 self.static_methods = []
734 self.constructors = []
735 self.disguised = disguised
736 self.gtype_name = gtype_name
737 self.get_type = get_type
738 self.c_symbol_prefix = c_symbol_prefix
740 def add_gtype(self, gtype_name, get_type):
741 self.gtype_name = gtype_name
742 self.get_type = get_type
744 def _walk(self, callback, chain):
745 for ctor in self.constructors:
746 ctor.walk(callback, chain)
747 for func in self.methods:
748 func.walk(callback, chain)
749 for func in self.static_methods:
750 func.walk(callback, chain)
751 for field in self.fields:
752 if field.anonymous_node is not None:
753 field.anonymous_node.walk(callback, chain)
755 class Field(Annotated):
757 def __init__(self, name, typenode, readable, writable, bits=None,
758 anonymous_node=None):
759 Annotated.__init__(self)
760 assert (typenode or anonymous_node)
763 self.readable = readable
764 self.writable = writable
766 self.anonymous_node = anonymous_node
768 def __cmp__(self, other):
769 return cmp(self.name, other.name)
772 class Record(Compound):
774 def __init__(self, name,
778 c_symbol_prefix=None,
780 Compound.__init__(self, name,
782 gtype_name=gtype_name,
784 c_symbol_prefix=c_symbol_prefix,
786 # If non-None, this record defines the FooClass C structure
787 # for some Foo GObject (or similar for GInterface)
788 self.is_gtype_struct_for = None
791 class Union(Compound):
793 def __init__(self, name,
797 c_symbol_prefix=None,
799 Compound.__init__(self, name,
801 gtype_name=gtype_name,
803 c_symbol_prefix=c_symbol_prefix,
807 class Boxed(Node, Registered):
808 """A boxed type with no known associated structure/union."""
809 def __init__(self, name,
812 c_symbol_prefix=None):
813 assert gtype_name is not None
814 assert get_type is not None
815 Node.__init__(self, name)
816 Registered.__init__(self, gtype_name, get_type)
817 if get_type is not None:
818 assert c_symbol_prefix is not None
819 self.c_symbol_prefix = c_symbol_prefix
820 self.constructors = []
822 self.static_methods = []
824 def _walk(self, callback, chain):
825 for ctor in self.constructors:
826 ctor.walk(callback, chain)
827 for meth in self.methods:
828 meth.walk(callback, chain)
829 for meth in self.static_methods:
830 meth.walk(callback, chain)
833 class Signal(Callable):
835 def __init__(self, name, retval, parameters):
836 Callable.__init__(self, name, retval, parameters, False)
839 class Class(Node, Registered):
841 def __init__(self, name, parent,
845 c_symbol_prefix=None,
847 Node.__init__(self, name)
848 Registered.__init__(self, gtype_name, get_type)
850 self.c_symbol_prefix = c_symbol_prefix
852 self.fundamental = False
853 self.unref_func = None
855 self.set_value_func = None
856 self.get_value_func = None
857 # When we're in the scanner, we keep around a list
858 # of parents so that we can transparently fall back
859 # if there are 'hidden' parents
860 self.parent_chain = []
861 self.glib_type_struct = None
862 self.is_abstract = is_abstract
864 self.virtual_methods = []
865 self.static_methods = []
867 self.constructors = []
872 def _walk(self, callback, chain):
873 for meth in self.methods:
874 meth.walk(callback, chain)
875 for meth in self.virtual_methods:
876 meth.walk(callback, chain)
877 for meth in self.static_methods:
878 meth.walk(callback, chain)
879 for ctor in self.constructors:
880 ctor.walk(callback, chain)
881 for field in self.fields:
882 if field.anonymous_node:
883 field.anonymous_node.walk(callback, chain)
884 for sig in self.signals:
885 sig.walk(callback, chain)
888 class Interface(Node, Registered):
890 def __init__(self, name, parent,
894 c_symbol_prefix=None):
895 Node.__init__(self, name)
896 Registered.__init__(self, gtype_name, get_type)
898 self.c_symbol_prefix = c_symbol_prefix
900 self.parent_chain = []
903 self.static_methods = []
904 self.virtual_methods = []
905 self.glib_type_struct = None
908 self.prerequisites = []
910 def _walk(self, callback, chain):
911 for meth in self.methods:
912 meth.walk(callback, chain)
913 for meth in self.static_methods:
914 meth.walk(callback, chain)
915 for meth in self.virtual_methods:
916 meth.walk(callback, chain)
917 for field in self.fields:
918 if field.anonymous_node:
919 field.anonymous_node.walk(callback, chain)
920 for sig in self.signals:
921 sig.walk(callback, chain)
924 class Constant(Node):
926 def __init__(self, name, value_type, value):
927 Node.__init__(self, name)
928 self.value_type = value_type
932 class Property(Node):
934 def __init__(self, name, typeobj, readable, writable,
935 construct, construct_only, transfer=None):
936 Node.__init__(self, name)
938 self.readable = readable
939 self.writable = writable
940 self.construct = construct
941 self.construct_only = construct_only
942 self.transfer = PARAM_TRANSFER_NONE
945 class Callback(Callable):
947 def __init__(self, name, retval, parameters, throws, ctype=None):
948 Callable.__init__(self, name, retval, parameters, throws)