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 .message import Position
23 from .odict import odict
24 from .utils import to_underscores
27 """A Type can be either:
28 * A reference to a node (target_giname)
29 * A reference to a "fundamental" type like 'utf8'
30 * A "foreign" type - this can be any string."
31 If none are specified, then it's in an "unresolved" state. An
32 unresolved type can have two data sources; a "ctype" which comes
33 from a C type string, or a gtype_name (from g_type_name()).
39 target_fundamental=None,
42 _target_unknown=False,
46 self.gtype_name = gtype_name
47 self.origin_symbol = origin_symbol
49 assert isinstance(self, TypeUnknown)
50 elif target_fundamental:
51 assert target_giname is None
52 assert target_foreign is None
54 assert '.' in target_giname
55 assert target_fundamental is None
56 assert target_foreign is None
58 assert ctype is not None
59 assert target_giname is None
60 assert target_fundamental is None
62 assert (ctype is not None) or (gtype_name is not None)
63 self.target_fundamental = target_fundamental
64 self.target_giname = target_giname
65 self.target_foreign = target_foreign
66 self.is_const = is_const
70 return (self.target_fundamental or
75 def unresolved_string(self):
79 return self.gtype_name
84 def create_from_gtype_name(cls, gtype_name):
85 """Parse a GType name (as from g_type_name()), and return a
86 Type instance. Note that this function performs namespace lookup,
87 in contrast to the other create_type() functions."""
88 # First, is it a fundamental?
89 fundamental = type_names.get(gtype_name)
90 if fundamental is not None:
91 return cls(target_fundamental=fundamental.target_fundamental)
92 if gtype_name == 'GHashTable':
93 return Map(TYPE_ANY, TYPE_ANY, gtype_name=gtype_name)
94 elif gtype_name in ('GArray', 'GPtrArray', 'GByteArray'):
95 return Array('GLib.' + gtype_name[1:], TYPE_ANY,
96 gtype_name=gtype_name)
97 return cls(gtype_name=gtype_name)
100 assert self.target_giname is not None
101 return self.target_giname.split('.')[1]
103 def __cmp__(self, other):
104 if self.target_fundamental:
105 return cmp(self.target_fundamental, other.target_fundamental)
106 if self.target_giname:
107 return cmp(self.target_giname, other.target_giname)
108 if self.target_foreign:
109 return cmp(self.target_foreign, other.target_foreign)
110 return cmp(self.ctype, other.ctype)
112 def is_equiv(self, typeval):
113 """Return True if the specified types are compatible at
114 an introspection level, disregarding their C types.
115 A sequence may be given for typeval, in which case
116 this function returns True if the type is compatible with
118 if isinstance(typeval, (list, tuple)):
120 if self.is_equiv(val):
123 return self == typeval
126 return Type(target_fundamental=self.target_fundamental,
127 target_giname=self.target_giname,
128 target_foreign=self.target_foreign,
130 is_const=self.is_const)
133 if self.target_fundamental:
134 return self.target_fundamental
135 elif self.target_giname:
136 return self.target_giname
137 elif self.target_foreign:
138 return self.target_foreign
141 if self.target_fundamental:
142 data = 'target_fundamental=%s, ' % (self.target_fundamental, )
143 elif self.target_giname:
144 data = 'target_giname=%s, ' % (self.target_giname, )
145 elif self.target_foreign:
146 data = 'target_foreign=%s, ' % (self.target_foreign, )
149 return '%s(%sctype=%s)' % (self.__class__.__name__, data, self.ctype)
151 class TypeUnknown(Type):
153 Type.__init__(self, _target_unknown=True)
159 TYPE_NONE = Type(target_fundamental='none', ctype='void')
160 TYPE_ANY = Type(target_fundamental='gpointer', ctype='gpointer')
162 TYPE_BOOLEAN = Type(target_fundamental='gboolean', ctype='gboolean')
163 TYPE_INT8 = Type(target_fundamental='gint8', ctype='gint8')
164 TYPE_UINT8 = Type(target_fundamental='guint8', ctype='guint8')
165 TYPE_INT16 = Type(target_fundamental='gint16', ctype='gint16')
166 TYPE_UINT16 = Type(target_fundamental='guint16', ctype='guint16')
167 TYPE_INT32 = Type(target_fundamental='gint32', ctype='gint32')
168 TYPE_UINT32 = Type(target_fundamental='guint32', ctype='guint32')
169 TYPE_INT64 = Type(target_fundamental='gint64', ctype='gint64')
170 TYPE_UINT64 = Type(target_fundamental='guint64', ctype='guint64')
171 TYPE_CHAR = Type(target_fundamental='gchar', ctype='gchar')
172 TYPE_SHORT = Type(target_fundamental='gshort', ctype='gshort')
173 TYPE_USHORT = Type(target_fundamental='gushort', ctype='gushort')
174 TYPE_INT = Type(target_fundamental='gint', ctype='gint')
175 TYPE_UINT = Type(target_fundamental='guint', ctype='guint')
176 TYPE_LONG = Type(target_fundamental='glong', ctype='glong')
177 TYPE_ULONG = Type(target_fundamental='gulong', ctype='gulong')
179 TYPE_LONG_LONG = Type(target_fundamental='long long', ctype='long long')
180 TYPE_LONG_ULONG = Type(target_fundamental='unsigned long long',
181 ctype='unsigned long long')
182 TYPE_FLOAT = Type(target_fundamental='gfloat', ctype='gfloat')
183 TYPE_DOUBLE = Type(target_fundamental='gdouble', ctype='gdouble')
185 TYPE_LONG_DOUBLE = Type(target_fundamental='long double',
187 TYPE_UNICHAR = Type(target_fundamental='gunichar', ctype='gunichar')
189 # C types with semantics overlaid
190 TYPE_GTYPE = Type(target_fundamental='GType', ctype='GType')
191 TYPE_STRING = Type(target_fundamental='utf8', ctype='gchar*')
192 TYPE_FILENAME = Type(target_fundamental='filename', ctype='gchar*')
194 TYPE_VALIST = Type(target_fundamental='va_list', ctype='va_list')
196 BASIC_GIR_TYPES = [TYPE_BOOLEAN, TYPE_INT8, TYPE_UINT8, TYPE_INT16,
197 TYPE_UINT16, TYPE_INT32, TYPE_UINT32, TYPE_INT64,
198 TYPE_UINT64, TYPE_CHAR, TYPE_SHORT, TYPE_USHORT, TYPE_INT,
199 TYPE_UINT, TYPE_LONG, TYPE_ULONG, TYPE_LONG_LONG,
200 TYPE_LONG_ULONG, TYPE_FLOAT, TYPE_DOUBLE,
201 TYPE_LONG_DOUBLE, TYPE_UNICHAR, TYPE_GTYPE]
202 GIR_TYPES = [TYPE_NONE, TYPE_ANY]
203 GIR_TYPES.extend(BASIC_GIR_TYPES)
204 GIR_TYPES.extend([TYPE_STRING, TYPE_FILENAME, TYPE_VALIST])
206 INTROSPECTABLE_BASIC = list(GIR_TYPES)
207 for v in [TYPE_NONE, TYPE_ANY,
208 TYPE_LONG_LONG, TYPE_LONG_ULONG,
209 TYPE_LONG_DOUBLE, TYPE_VALIST]:
210 INTROSPECTABLE_BASIC.remove(v)
213 for typeval in GIR_TYPES:
214 type_names[typeval.target_fundamental] = typeval
215 basic_type_names = {}
216 for typeval in BASIC_GIR_TYPES:
217 basic_type_names[typeval.target_fundamental] = typeval
220 type_names['char'] = TYPE_CHAR
221 type_names['signed char'] = TYPE_INT8
222 type_names['unsigned char'] = TYPE_UINT8
223 type_names['short'] = TYPE_SHORT
224 type_names['signed short'] = TYPE_SHORT
225 type_names['unsigned short'] = TYPE_USHORT
226 type_names['int'] = TYPE_INT
227 type_names['signed int'] = TYPE_INT
228 type_names['unsigned short int'] = TYPE_USHORT
229 type_names['signed'] = TYPE_INT
230 type_names['unsigned int'] = TYPE_UINT
231 type_names['unsigned'] = TYPE_UINT
232 type_names['long'] = TYPE_LONG
233 type_names['signed long'] = TYPE_LONG
234 type_names['unsigned long'] = TYPE_ULONG
235 type_names['unsigned long int'] = TYPE_ULONG
236 type_names['float'] = TYPE_FLOAT
237 type_names['double'] = TYPE_DOUBLE
238 type_names['char*'] = TYPE_STRING
239 type_names['void*'] = TYPE_ANY
240 type_names['void'] = TYPE_NONE
241 # Also alias the signed one here
242 type_names['signed long long'] = TYPE_LONG_LONG
244 # A few additional GLib type aliases
245 type_names['guchar'] = TYPE_UINT8
246 type_names['gchararray'] = TYPE_STRING
247 type_names['gchar*'] = TYPE_STRING
248 type_names['goffset'] = TYPE_INT64
249 type_names['gunichar2'] = TYPE_UINT16
250 type_names['gsize'] = TYPE_ULONG
251 type_names['gssize'] = TYPE_LONG
252 type_names['gconstpointer'] = TYPE_ANY
254 # We used to support these; continue to do so
255 type_names['any'] = TYPE_ANY
256 type_names['boolean'] = TYPE_BOOLEAN
257 type_names['uint'] = TYPE_UINT
258 type_names['ulong'] = TYPE_ULONG
260 # C stdio, used in GLib public headers; squash this for now here
261 # until we move scanning into GLib and can (skip)
262 type_names['FILE*'] = TYPE_ANY
264 # One off C unix type definitions; note some of these may be GNU Libc
265 # specific. If someone is actually bitten by this, feel free to do
266 # the required configure goop to determine their size and replace
269 # We don't want to encourage people to use these in their APIs because
270 # they compromise the platform-independence that GLib gives you.
271 # These are here mostly to avoid blowing when random platform-specific
272 # methods are added under #ifdefs inside GLib itself. We could just (skip)
273 # the relevant methods, but on the other hand, since these types are just
274 # integers it's easy enough to expand them.
275 type_names['size_t'] = type_names['gsize']
276 type_names['time_t'] = TYPE_LONG
277 type_names['off_t'] = type_names['gsize']
278 type_names['pid_t'] = TYPE_INT
279 type_names['uid_t'] = TYPE_UINT
280 type_names['gid_t'] = TYPE_UINT
281 type_names['dev_t'] = TYPE_INT
282 type_names['socklen_t'] = TYPE_INT32
283 type_names['size_t'] = TYPE_ULONG
284 type_names['ssize_t'] = TYPE_LONG
287 type_names['id'] = TYPE_ANY
293 PARAM_DIRECTION_IN = 'in'
294 PARAM_DIRECTION_OUT = 'out'
295 PARAM_DIRECTION_INOUT = 'inout'
297 PARAM_SCOPE_CALL = 'call'
298 PARAM_SCOPE_ASYNC = 'async'
299 PARAM_SCOPE_NOTIFIED = 'notified'
301 PARAM_TRANSFER_NONE = 'none'
302 PARAM_TRANSFER_CONTAINER = 'container'
303 PARAM_TRANSFER_FULL = 'full'
305 class Namespace(object):
306 def __init__(self, name, version,
307 identifier_prefixes=None,
308 symbol_prefixes=None):
310 self.version = version
311 if identifier_prefixes is not None:
312 self.identifier_prefixes = identifier_prefixes
314 self.identifier_prefixes = [name]
315 if symbol_prefixes is not None:
316 self.symbol_prefixes = symbol_prefixes
318 ps = self.identifier_prefixes
319 self.symbol_prefixes = [to_underscores(p).lower() for p in ps]
320 # cache upper-cased versions
321 self._ucase_symbol_prefixes = [p.upper() for p in self.symbol_prefixes]
322 self._names = odict() # Maps from GIName -> node
323 self._aliases = {} # Maps from GIName -> GIName
324 self._type_names = {} # Maps from GTName -> node
325 self._ctypes = {} # Maps from CType -> node
326 self._symbols = {} # Maps from function symbols -> Function
337 def type_names(self):
338 return self._type_names
344 def type_from_name(self, name, ctype=None):
345 """Backwards compatibility method for older .gir files, which
346 only use the 'name' attribute. If name refers to a fundamental type,
347 create a Type object referncing it. If name is already a
348 fully-qualified GIName like 'Foo.Bar', returns a Type targeting it .
349 Otherwise a Type targeting name qualififed with the namespace name is
351 if name in type_names:
352 return Type(target_fundamental=name, ctype=ctype)
356 target = '%s.%s' % (self.name, name)
357 return Type(target_giname=target, ctype=ctype)
359 def append(self, node, replace=False):
360 previous = self._names.get(node.name)
361 if previous is not None:
363 raise ValueError("Namespace conflict: %r" % (node, ))
364 self.remove(previous)
365 # A layering violation...but oh well.
366 if isinstance(node, Alias):
367 self._aliases[node.name] = node
368 elif isinstance(node, Registered) and node.gtype_name is not None:
369 self._type_names[node.gtype_name] = node
370 elif isinstance(node, Function):
371 self._symbols[node.symbol] = node
372 assert isinstance(node, Node)
373 assert node.namespace is None
374 node.namespace = self
375 self._names[node.name] = node
376 if hasattr(node, 'ctype'):
377 self._ctypes[node.ctype] = node
378 if hasattr(node, 'symbol'):
379 self._ctypes[node.symbol] = node
381 def remove(self, node):
382 if isinstance(node, Alias):
383 del self._aliases[node.name]
384 elif isinstance(node, Registered) and node.gtype_name is not None:
385 del self._type_names[node.gtype_name]
386 del self._names[node.name]
387 node.namespace = None
388 if hasattr(node, 'ctype'):
389 del self._ctypes[node.ctype]
390 if isinstance(node, Function):
391 del self._symbols[node.symbol]
393 def float(self, node):
394 """Like remove(), but doesn't unset the node's namespace
395 back-reference, and it's still possible to look up
396 functions via get_by_symbol()."""
397 if isinstance(node, Function):
400 self._symbols[symbol] = node
401 node.namespace = self
404 return iter(self._names)
407 return self._names.iteritems()
409 def itervalues(self):
410 return self._names.itervalues()
413 return self._names.get(name)
415 def get_by_ctype(self, ctype):
416 return self._ctypes.get(ctype)
418 def get_by_symbol(self, symbol):
419 return self._symbols.get(symbol)
421 def walk(self, callback):
422 for node in self.itervalues():
423 node.walk(callback, [])
425 class Include(object):
427 def __init__(self, name, version):
429 self.version = version
432 def from_string(cls, string):
433 return cls(*string.split('-', 1))
435 def __cmp__(self, other):
436 namecmp = cmp(self.name, other.name)
439 return cmp(self.version, other.version)
442 return hash(str(self))
445 return '%s-%s' % (self.name, self.version)
447 class Annotated(object):
448 """An object which has a few generic metadata
453 self.introspectable = True
454 self.attributes = [] # (key, value)*
455 self.deprecated = None
456 self.deprecated_version = None
459 class Node(Annotated):
460 """A node is a type of object which is uniquely identified by its
461 (namespace, name) pair. When combined with a ., this is called a
462 GIName. It's possible for nodes to contain or point to other nodes."""
464 c_name = property(lambda self: self.namespace.name + self.name)
465 gi_name = property(lambda self: '%s.%s' % (self.namespace.name, self.name))
467 def __init__(self, name=None):
468 Annotated.__init__(self)
469 self.namespace = None # Should be set later by Namespace.append()
472 self.file_positions = set()
474 def create_type(self):
475 """Create a Type object referencing this node."""
476 assert self.namespace is not None
477 return Type(target_giname=('%s.%s' % (self.namespace.name, self.name)))
479 def __cmp__(self, other):
480 nscmp = cmp(self.namespace, other.namespace)
483 return cmp(self.name, other.name)
486 return '%s(%r)' % (self.__class__.__name__, self.name)
488 def inherit_file_positions(self, node):
489 self.file_positions.update(node.file_positions)
491 def add_file_position(self, position):
492 self.file_positions.add(position)
494 def add_symbol_reference(self, symbol):
495 if symbol.source_filename:
496 self.add_file_position(Position(symbol.source_filename, symbol.line))
498 def walk(self, callback, chain):
499 res = callback(self, chain)
500 assert res in (True, False), "Walk function must return boolean, not %r" % (res, )
504 self._walk(callback, chain)
507 def _walk(self, callback, chain):
512 """A node that (possibly) has gtype_name and get_type."""
513 def __init__(self, gtype_name, get_type):
514 assert (gtype_name is None and get_type is None) or \
515 (gtype_name is not None and get_type is not None)
516 self.gtype_name = gtype_name
517 self.get_type = get_type
520 class Callable(Node):
522 def __init__(self, name, retval, parameters, throws):
523 Node.__init__(self, name)
525 self.parameters = parameters
526 self.throws = not not throws
527 self.instance_parameter = None # Parameter
529 def get_parameter_index(self, name):
530 for i, parameter in enumerate(self.parameters):
531 if parameter.argname == name:
533 raise ValueError("Unknown argument %s" % (name, ))
535 def get_parameter(self, name):
536 for parameter in self.parameters:
537 if parameter.argname == name:
539 raise ValueError("Unknown argument %s" % (name, ))
542 class Function(Callable):
544 def __init__(self, name, retval, parameters, throws, symbol):
545 Callable.__init__(self, name, retval, parameters, throws)
547 self.is_method = False
548 self.is_constructor = False
549 self.shadowed_by = None # C symbol string
550 self.shadows = None # C symbol string
553 class VFunction(Callable):
555 def __init__(self, name, retval, parameters, throws):
556 Callable.__init__(self, name, retval, parameters, throws)
560 def from_callback(cls, cb):
561 obj = cls(cb.name, cb.retval, cb.parameters[1:],
570 Type.__init__(self, '<varargs>', target_fundamental='<varargs>')
575 GLIB_ARRAY = 'GLib.Array'
576 GLIB_BYTEARRAY = 'GLib.ByteArray'
577 GLIB_PTRARRAY = 'GLib.PtrArray'
579 def __init__(self, array_type, element_type, **kwargs):
580 Type.__init__(self, target_fundamental='<array>',
582 if (array_type is None or array_type == self.C):
583 self.array_type = self.C
585 assert array_type in (self.GLIB_ARRAY,
587 self.GLIB_PTRARRAY), array_type
588 self.array_type = array_type
589 assert isinstance(element_type, Type)
590 self.element_type = element_type
591 self.zeroterminated = True
592 self.length_param_name = None
596 arr = Array(self.array_type, self.element_type)
597 arr.element_type = self.element_type
598 arr.zeroterminated = self.zeroterminated
599 arr.length_param_name = self.length_param_name
605 def __init__(self, name, element_type, **kwargs):
606 Type.__init__(self, target_fundamental='<list>',
609 assert isinstance(element_type, Type)
610 self.element_type = element_type
613 l = List(self.name, self.element_type)
614 l.element_type = self.element_type
615 l.zeroterminated = self.zeroterminated
616 l.length_param_name = self.length_param_name
622 def __init__(self, key_type, value_type, **kwargs):
623 Type.__init__(self, target_fundamental='<map>', **kwargs)
624 assert isinstance(key_type, Type)
625 self.key_type = key_type
626 assert isinstance(value_type, Type)
627 self.value_type = value_type
630 m = Map(self.key_type, self.value_type)
635 def __init__(self, name, target, ctype=None):
636 Node.__init__(self, name)
641 class TypeContainer(Annotated):
642 """A fundamental base class for Return and Parameter."""
644 def __init__(self, typenode, transfer):
645 Annotated.__init__(self)
647 if transfer is not None:
648 self.transfer = transfer
649 elif typenode.is_const:
650 self.transfer = PARAM_TRANSFER_NONE
655 class Parameter(TypeContainer):
656 """An argument to a function."""
658 def __init__(self, argname, typenode, direction=None,
659 transfer=None, allow_none=False, scope=None,
660 caller_allocates=False):
661 TypeContainer.__init__(self, typenode, transfer)
662 self.argname = argname
663 self.direction = direction
664 self.allow_none = allow_none
666 self.caller_allocates = caller_allocates
667 self.closure_name = None
668 self.destroy_name = None
671 class Return(TypeContainer):
672 """A return value from a function."""
674 def __init__(self, rtype, transfer=None):
675 TypeContainer.__init__(self, rtype, transfer)
676 self.direction = PARAM_DIRECTION_OUT
679 class Enum(Node, Registered):
681 def __init__(self, name, ctype,
684 c_symbol_prefix=None,
686 Node.__init__(self, name)
687 Registered.__init__(self, gtype_name, get_type)
688 self.c_symbol_prefix = c_symbol_prefix
690 self.members = members
691 # Associated error quark
692 self.error_quark = None
695 class Bitfield(Node, Registered):
697 def __init__(self, name, ctype,
699 c_symbol_prefix=None,
702 Node.__init__(self, name)
703 Registered.__init__(self, gtype_name, get_type)
705 self.c_symbol_prefix = c_symbol_prefix
706 self.members = members
709 class Member(Annotated):
711 def __init__(self, name, value, symbol, nick):
712 Annotated.__init__(self)
718 def __cmp__(self, other):
719 return cmp(self.name, other.name)
723 class Compound(Node, Registered):
724 def __init__(self, name,
728 c_symbol_prefix=None,
730 Node.__init__(self, name)
731 Registered.__init__(self, gtype_name, get_type)
734 self.static_methods = []
736 self.constructors = []
737 self.disguised = disguised
738 self.gtype_name = gtype_name
739 self.get_type = get_type
740 self.c_symbol_prefix = c_symbol_prefix
742 def add_gtype(self, gtype_name, get_type):
743 self.gtype_name = gtype_name
744 self.get_type = get_type
746 def _walk(self, callback, chain):
747 for ctor in self.constructors:
748 ctor.walk(callback, chain)
749 for func in self.methods:
750 func.walk(callback, chain)
751 for func in self.static_methods:
752 func.walk(callback, chain)
753 for field in self.fields:
754 if field.anonymous_node is not None:
755 field.anonymous_node.walk(callback, chain)
757 class Field(Annotated):
759 def __init__(self, name, typenode, readable, writable, bits=None,
760 anonymous_node=None):
761 Annotated.__init__(self)
762 assert (typenode or anonymous_node)
765 self.readable = readable
766 self.writable = writable
768 self.anonymous_node = anonymous_node
771 def __cmp__(self, other):
772 return cmp(self.name, other.name)
775 class Record(Compound):
777 def __init__(self, name,
781 c_symbol_prefix=None,
783 Compound.__init__(self, name,
785 gtype_name=gtype_name,
787 c_symbol_prefix=c_symbol_prefix,
789 # If non-None, this record defines the FooClass C structure
790 # for some Foo GObject (or similar for GInterface)
791 self.is_gtype_struct_for = None
794 class Union(Compound):
796 def __init__(self, name,
800 c_symbol_prefix=None,
802 Compound.__init__(self, name,
804 gtype_name=gtype_name,
806 c_symbol_prefix=c_symbol_prefix,
810 class Boxed(Node, Registered):
811 """A boxed type with no known associated structure/union."""
812 def __init__(self, name,
815 c_symbol_prefix=None):
816 assert gtype_name is not None
817 assert get_type is not None
818 Node.__init__(self, name)
819 Registered.__init__(self, gtype_name, get_type)
820 if get_type is not None:
821 assert c_symbol_prefix is not None
822 self.c_symbol_prefix = c_symbol_prefix
823 self.constructors = []
825 self.static_methods = []
827 def _walk(self, callback, chain):
828 for ctor in self.constructors:
829 ctor.walk(callback, chain)
830 for meth in self.methods:
831 meth.walk(callback, chain)
832 for meth in self.static_methods:
833 meth.walk(callback, chain)
836 class Signal(Callable):
838 def __init__(self, name, retval, parameters):
839 Callable.__init__(self, name, retval, parameters, False)
842 class Class(Node, Registered):
844 def __init__(self, name, parent,
848 c_symbol_prefix=None,
850 Node.__init__(self, name)
851 Registered.__init__(self, gtype_name, get_type)
853 self.c_symbol_prefix = c_symbol_prefix
855 self.fundamental = False
856 self.unref_func = None
858 self.set_value_func = None
859 self.get_value_func = None
860 # When we're in the scanner, we keep around a list
861 # of parents so that we can transparently fall back
862 # if there are 'hidden' parents
863 self.parent_chain = []
864 self.glib_type_struct = None
865 self.is_abstract = is_abstract
867 self.virtual_methods = []
868 self.static_methods = []
870 self.constructors = []
875 def _walk(self, callback, chain):
876 for meth in self.methods:
877 meth.walk(callback, chain)
878 for meth in self.virtual_methods:
879 meth.walk(callback, chain)
880 for meth in self.static_methods:
881 meth.walk(callback, chain)
882 for ctor in self.constructors:
883 ctor.walk(callback, chain)
884 for field in self.fields:
885 if field.anonymous_node:
886 field.anonymous_node.walk(callback, chain)
887 for sig in self.signals:
888 sig.walk(callback, chain)
891 class Interface(Node, Registered):
893 def __init__(self, name, parent,
897 c_symbol_prefix=None):
898 Node.__init__(self, name)
899 Registered.__init__(self, gtype_name, get_type)
901 self.c_symbol_prefix = c_symbol_prefix
903 self.parent_chain = []
906 self.static_methods = []
907 self.virtual_methods = []
908 self.glib_type_struct = None
911 self.prerequisites = []
913 def _walk(self, callback, chain):
914 for meth in self.methods:
915 meth.walk(callback, chain)
916 for meth in self.static_methods:
917 meth.walk(callback, chain)
918 for meth in self.virtual_methods:
919 meth.walk(callback, chain)
920 for field in self.fields:
921 if field.anonymous_node:
922 field.anonymous_node.walk(callback, chain)
923 for sig in self.signals:
924 sig.walk(callback, chain)
927 class Constant(Node):
929 def __init__(self, name, value_type, value):
930 Node.__init__(self, name)
931 self.value_type = value_type
935 class Property(Node):
937 def __init__(self, name, typeobj, readable, writable,
938 construct, construct_only, transfer=None):
939 Node.__init__(self, name)
941 self.readable = readable
942 self.writable = writable
943 self.construct = construct
944 self.construct_only = construct_only
945 self.transfer = PARAM_TRANSFER_NONE
948 class Callback(Callable):
950 def __init__(self, name, retval, parameters, throws, ctype=None):
951 Callable.__init__(self, name, retval, parameters, throws)